View Full Version : beginning perl in ubuntu
manish411
September 16th, 2011, 03:54 PM
#!/usr/bin/perl
$inputline = <STDIN>;
print ($inputline );
while running the simple programming
in file pr1
I am getting the following problem
./pr1: line 2: syntax error near unexpected token `;'
./pr1: line 2: ` $inputline = <STDIN>;'
nvteighen
September 16th, 2011, 04:19 PM
This works for me:
#!/usr/bin/env perl
use strict;
use warnings;
my $input = <STDIN>;
print $input;
EDIT: How are you executing your code?
cgroza
September 16th, 2011, 06:31 PM
I don't think you are using the perl interpreter to execute that code.
I typed the same thing in bash, and got the exact same error message.
Arndt
September 16th, 2011, 06:34 PM
#!/usr/bin/perl
$inputline = <STDIN>;
print ($inputline );
while running the simple programming
in file pr1
I am getting the following problem
./pr1: line 2: syntax error near unexpected token `;'
./pr1: line 2: ` $inputline = <STDIN>;'
You have blanks at the start of all lines. This doesn't matter for the perl code, but it disables the #! line, so when seeing ./pr1, bash will treat it as a bash script. Remove the blank.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.