[EMAIL PROTECTED] wrote:

On Jul 12, 12:59 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:

for my $path ( <*P4/[0-9][0-9][0-9]> ) {
     open my $fh, '>', "$path/PREVUE2.CFG"
         or die "Cannot open '$path/PREVUE2.CFG' $!";
     print $fh $path;
     }

Hey John,
Thanks for the reply.  I'm getting this error when I execute that
code:
./perl.pl: line 1: syntax error near unexpected token `$path'
./perl.pl: line 1: `for my $path ( <*P4/[0-9][0-9][0-9]> ) {'

Any suggestions?

$ bash -c '
for my $path ( <*P4/[0-9][0-9][0-9]> ) {
open my $fh, ">", "$path/PREVUE2.CFG" or die "Cannot open $path/PREVUE2.CFG $!";
    print $fh $path;
    }
'
bash: -c: line 1: syntax error near unexpected token `$path'
bash: -c: line 1: `for my $path ( <*P4/[0-9][0-9][0-9]> ) {'


You are trying to get the shell to run your Perl script. You need to use perl instead!

The first three lines of 'perl.pl' *should* be:

#!/usr/bin/perl
use warnings;
use strict;


Assuming of course that your perl interpreter is located at /usr/bin/perl.




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to