-
Basic Perl Compile Question?
Jeez...this should be so easy, but I am having problems.
I have RH 8.0, the following perl rpms installed
Code:
cmmiller@phoenix Perl]$ rpm -qa | grep perl
perl-XML-Encoding-1.01-20
perl-libxml-enno-1.02-25
perl-libxml-perl-0.07-25
mod_perl-1.99_05-3
perl-XML-Dumper-0.4-22
perl-libwww-perl-5.65-2
perl-DBD-MySQL-2.1017-3
perl-XML-Parser-2.31-12
perl-DB_File-1.804-55
perl-Parse-Yapp-1.05-26
perl-XML-Grove-0.46alpha-21
perl-DBD-Pg-1.13-5
perl-CGI-2.81-55
perl-URI-1.21-3
perl-XML-Twig-3.05-3
perl-CPAN-1.61-55
perl-HTML-Tagset-3.03-25
perl-DBI-1.30-1
perl-HTML-Parser-3.26-14
perl-Filter-1.28-9
perl-5.8.0-55
perl-DateManip-5.40-27
And perl in my path
Code:
[cmmiller@phoenix Perl]$ whereis perl
perl: /usr/bin/perl /usr/share/man/man1/perl.1.gz
[cmmiller@phoenix Perl]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/jdk/bin:/home/cmmiller/bin
When I try to compile a simple perl script
Code:
[cmmiller@phoenix Perl]$ cat basicperl.p
#!/usr/bin/perl
# Program name: example1.p
print"This is a simple\n";
print"Perl Program.\n";
I get this error:
Code:
[cmmiller@phoenix Perl]$ ./basicperl.p
./basicperl.p: line 6: printThis is a simple\n: command not found
./basicperl.p: line 7: printPerl Program.\n: command not found
Perl experts, I need your help on this one.
"I am the EPITOME of FRUGALITY, the KING OF CHEAPNESS, the TIGHTEST of the TIGHTWADS, the MASTER-BLASTER of PENNY PINCHING, the BISHOP of UNDER-BUDGETING, the CARDINAL of COST-CUTTING, I AM THE MASTER MISER!!!."
-Jim Sears
GAIM ID: cmmiller1973
-
maybe put a space after print?
Welcome to Der Weinerschnitzel May I take your order please?
Yeah, I want: Two large Cokes, Two large fries Chili-cheese dog, large Doctor Pepper Super deluxe, with cheese and tomato.
You want Bill sperm with that?
NO!
-- The Descendents
-
This book I have is ****ed up.
This code worked:
Code:
#!/usr/bin/perl
printf "This is a simple\n";
printf "Perl Program.\n";
Need printf instead of print.
No ( ) around the quotes.
thanks for your help and I knew it was too easy...
Last edited by JockVSJock; 05-29-2003 at 10:39 PM.
"I am the EPITOME of FRUGALITY, the KING OF CHEAPNESS, the TIGHTEST of the TIGHTWADS, the MASTER-BLASTER of PENNY PINCHING, the BISHOP of UNDER-BUDGETING, the CARDINAL of COST-CUTTING, I AM THE MASTER MISER!!!."
-Jim Sears
GAIM ID: cmmiller1973
-
try nameing the file with a .pl extension
-
#!/usr/bin/perl
needs to be on the first line of the file.
Your script is being interprited as a shell script.
-
1) There is no space needed after "print".
2) You don't HAVE to name perl programs with .pl. However, depending on your system, you may need to run your program with a "./" before the name.
3) You can see the example below. If you don't use the .pl, and just type "test", nothing happens. Define the path, and it works.
Code:
yaknow:~$ cat test
#!/usr/local/bin/perl -w
# Program name: example1.p
print"This is a simple\n";
print"Perl Program.\n";
yaknow:~$ test
yaknow:~$ ./test
This is a simple
Perl Program.
yaknow:~$
-
Ok, now I'm having this problem, every perl script that I try to run keeps getting this error:
Code:
syntax error near unexpected token `;'
I've googled this, but didn't find anything that was helpful.
Here is the basic script
Code:
#!/usr/bin/perl
$inputline = <STDIN> ;
printf $inputline ;
"I am the EPITOME of FRUGALITY, the KING OF CHEAPNESS, the TIGHTEST of the TIGHTWADS, the MASTER-BLASTER of PENNY PINCHING, the BISHOP of UNDER-BUDGETING, the CARDINAL of COST-CUTTING, I AM THE MASTER MISER!!!."
-Jim Sears
GAIM ID: cmmiller1973
-
I did a straight copy/past and it worked for me.
Make sure the exec your running is current. (make sure you saved the file before you ran it...)
-
I reread your post...Every perl script you do outputs that error?
Post a log of that. How do you run the script?
-
I have no idea why it won't run, I've even tried it on a different box.
I can get this one to run
Code:
#!/usr/bin/perl
# Program name: example1.p
printf "This is a simple\n";
printf "Perl Program.\n";
All I do is chmod +x example.p
and then type
./example.p
and it runs
"I am the EPITOME of FRUGALITY, the KING OF CHEAPNESS, the TIGHTEST of the TIGHTWADS, the MASTER-BLASTER of PENNY PINCHING, the BISHOP of UNDER-BUDGETING, the CARDINAL of COST-CUTTING, I AM THE MASTER MISER!!!."
-Jim Sears
GAIM ID: cmmiller1973
-
Beats me.
Take out the last two lines and try to run it. If it runs (doing nothing), add back those two lines, one at a time. That way you can tell a bit more about what line is causing you problems.
-
For example, here is one I coded to see if it would work, called example2.pl
Code:
#!/usr/bin/perl
$name = "Charlie";
printf "Greetings $name\n";
Pretty basic, right?
When running, I get the following errors:
Code:
./example2.pl: line 5: =: command not found
Greetings
But, if I comment out line 5, it runs fine, but only outputs "Greetings"
?
"I am the EPITOME of FRUGALITY, the KING OF CHEAPNESS, the TIGHTEST of the TIGHTWADS, the MASTER-BLASTER of PENNY PINCHING, the BISHOP of UNDER-BUDGETING, the CARDINAL of COST-CUTTING, I AM THE MASTER MISER!!!."
-Jim Sears
GAIM ID: cmmiller1973
-
here is another one that I have coded straight from an example:
Code:
[cmmiller@phoenix Perl]$ cat example4.pl
#!/usr/bin/perl
printf "Enter a number: ";
$number = <STDIN>;
if ($number == 10)
{
printf "That is the number I was thinking of. \n"
}
else
{
printf "You entered $number\n";
}
Here are the error messages:
Code:
[cmmiller@phoenix Perl]$ ./example4.pl
Enter a number: ./example4.pl: line 6: syntax error near unexpected token `;'
./example4.pl: line 6: `$number = <STDIN>; '
???
"I am the EPITOME of FRUGALITY, the KING OF CHEAPNESS, the TIGHTEST of the TIGHTWADS, the MASTER-BLASTER of PENNY PINCHING, the BISHOP of UNDER-BUDGETING, the CARDINAL of COST-CUTTING, I AM THE MASTER MISER!!!."
-Jim Sears
GAIM ID: cmmiller1973
-
There is nothing wrong with those scripts. Check and make sure you have a stable version of perl. Perhaps reinstall it.
-
Originally posted by JockVSJock
{
printf "That is the number I was thinking of. \n"
}
Jock, your missing a semi colon at the end of that line
The Difference being, Hackers build things, Crackers break them
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|