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

Hi Experts,

I have written the simple script,which will print the value of the variable.

The Script is as:
#!/usr/bin/env ksh #!/usr/bin/perl $iputlne = 34; print $iputlne;
The error message is :
$ 3.pl 3.pl[3]: =: not found [No such file or directory]

Please help me...since I am new to perl scripting...

Thanks in Advance!!

Replies are listed 'Best First'.
Re: Not able to run the perl script
by cdarke (Prior) on Oct 12, 2009 at 08:31 UTC
    Welcome to Perl! You should be aware that the korn shell you invoked with #!/usr/bin/env ksh is a different language to Perl, use one or the other. The second #! line does not invoke perl, it is merely seen as a comment. The error is probably because korn shell does not allow spaces around the '=' in an assignment, but more flexible languages, like Perl, do.

    I noticed that you are invoking ksh using env(1), and wonder if you should be doing the same for perl. You are not using strict and warnings. I known this is only a simple basic script, but scripts never get any smaller! It is worth always using them, no matter how trivial the program.

    Here is my version:
    #!/usr/bin/perl use warnings; use strict; my $inputline = 34; print "$inputline\n";
    Have fun!
    Update: corrected typo (thanks Anomalous Monk)
Re: Not able to run the perl script
by Anonymous Monk on Oct 12, 2009 at 06:45 UTC
    remove the #!/usr/bin/env ksh as the script is not able to find the perl interpretor. First decide if its a ksh script or a perl script and use the appropriate shebang line
Re: Not able to run the perl script
by ikegami (Patriarch) on Oct 12, 2009 at 05:41 UTC

    Your post is unreadable. Go back and read the line right under the "Preview" and "Create" buttons.

    ksh is treating your Perl script as ksh commands. Perhaps you shouldn't pass your Perl script to ksh.