Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

use strict;

by snowrider (Pilgrim)
on Feb 01, 2001 at 22:29 UTC ( [id://55770]=perlquestion: print w/replies, xml ) Need Help??

snowrider has asked for the wisdom of the Perl Monks concerning the following question:

monks, I am a very new perl programmer and i do not understand why i am getting errors when i use strict; i am tring to run a very simple program just by typing the program name on the command line and i get
"use" may clash with future reserved word at line 3. syntax error in file at line 3, next 2 tokens "use stri +ct" "my" may clash with future reserved word at line 7. "my" may clash with future reserved word at line 8.
if i type perl program_name on the command line the program works just fine is this normal behavior? any help would be appreciated thanks, snowrider

Edit: 2001-03-03 by neshura

Replies are listed 'Best First'.
Re: use strict;
by chipmunk (Parson) on Feb 01, 2001 at 22:43 UTC
    If 'use' and 'my' are not recognized, then you're using perl4. The #! line in your script is pointing to a very old version of perl.

    Type which perl at the command line, since your script works with that one, and change your #! line accordingly.

Re: use strict;
by azatoth (Curate) on Feb 01, 2001 at 22:34 UTC
    First, post the code and i'll know for sure.

    Second, it sounds like you've missed a " somewhere, or something.

    As I said, post up your code using the code tags and I'll help you.

    Also, don't make a new node, just update the one above with the code...

Re: use strict;
by stefan k (Curate) on Feb 01, 2001 at 22:32 UTC
    It would help a lot if you'd post the program code here as well. How should The Monks be able to help you otherwise?
    Another thing is that you may consider not using the strong-tag in your post, but that's just a minor topic.

    Stefan K

    $dom = ""; ## May The Open Source Be With You! $Mail = "mail@$dom; $Url = "http://www.$dom";
Re (tilly) 1: use strict;
by tilly (Archbishop) on Feb 01, 2001 at 22:33 UTC
    I suspect you are not using semi-colons at the end of your lines.
(tye)Re: use strict;
by tye (Sage) on Feb 01, 2001 at 22:41 UTC

    Sounds like Perl4 to me. What does "perl -v" report?

            - tye (but my friends call me "Tye")
Re: use strict;
by snowrider (Pilgrim) on Feb 01, 2001 at 22:53 UTC
    when i type perl -v i get
    This is perl, v5.6.0 built for 9000/777-hpux Copyright 1987-2000, Larry Wall Perl may be copied only under the terms of either the Artistic License + or the GNU General Public License, which may be found in the Perl 5.0 source +kit. Complete documentation for Perl, including FAQ lists, should be found +on this system using `man perl' or `perldoc perl'. If you have access to + the Internet, point your browser at, the Perl Home Pa +ge.
    when i type which perl i get
    i replaced #!/usr/contrib/bin/perl -w with #!/opt/perl5/bin/perl -w and it seems to work fine thanks alot fellow monks you saved me alot of hair pulling snowrider
Re: use strict;
by mikfire (Deacon) on Feb 01, 2001 at 22:50 UTC
    I would be willing to bet if you did a perl -v you would discover that you are not using perl 5. This warning is what is generated when you attempt perl5isms on perl4.

    Make sure the #! line is pointing at the correct perl. I hope you have perl5 installed somewhere else. If not, you need to scream very loudly and get it installed.


Re: use strict;
by arturo (Vicar) on Feb 01, 2001 at 22:35 UTC

    We can't tell you what's happening unless you post your code (be sure to put it in between <code> and </code> tags when you do!). One possibility is that you have simply misplaced or forgotten a quote.

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: use strict;
by snowrider (Pilgrim) on Feb 01, 2001 at 22:36 UTC
    monks, sorry about not attaching my code here it is.
    #!/usr/contrib/bin/perl -w use strict; my $a="5.0"; my $b="5"; print "Are these variables equal as numbers? ",$a==$b,"\n"; print "Are the variables equal as strings? ",$a eq $b,"\n"; print "These variables are equal as strings\n" if($a eq $b); print "These variables are equal numerically\n" if($a==$b);

      When you're running perl you are using the version of Perl from your path. This seems to be fine.

      When running ./ you're using the version in /usr/contrib/bin/perl. Looks like that's Perl version 4. to confirm this type
      /usr/contrib/bin/perl -v at your command line.

      To fix it, find out which version of Perl is on your path by typing which perl and replace the /usr/contrib/bin/perl in your script with the results of that command.


      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

      Looks ok to me ... are you sure there's a perl interpreter at the location specified in your '#!' line? Try issuing the following on the command line and see what you get: which perl

      Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: use strict;
by Gloom (Monk) on Feb 01, 2001 at 22:35 UTC
    some code can be helpfull to try to debug this :)

Re: use strict;
by curtisb (Monk) on Feb 02, 2001 at 02:00 UTC
    If you post your code then we (the Perl Monks) can help in a more perlish way. But, from what the error messages you have posted say; you may not be using semi-colons on lines 3, 7, and 8.

    In my experience with Perl, from the command line you have to type "c:\perl program_name" to make it execute (this in in windows). In UNIX you can execute it if the path to Perl is in you liberary search path. Then you can execute it by using "./program_name", if you are in that directory.

    What OS are you writing this perl script in? And please post your code as well.

    curtisb -- "trying to help"

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://55770]
Approved by root
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-24 03:15 GMT
Find Nodes?
    Voting Booth?

    No recent polls found