Hello All,
This code is working:
#!/usr/bin/perl
> 2 my @column_names=(A..ZZ);
> 3 for(my $i=0; $i<26; $i=$i+1) {
> 4 my $tmp_file = "$column_names[$i]".".out";
> 5 open $i, ">column_names/$tmp_file" or die "Could not create the
> file - $tmp_file \n";
> 6 print $i "This is working\n";
> 7 close $i or die "Could not close the file - $i\n";
> 8 }
>
But this code is not working:
#!/usr/bin/perl
> my @column_names=(A..ZZ);
> for(my $i=0; $i<26; $i=$i+1) {
> my $tmp_file = "$column_names[$i]".".out";
> open $column_names[$i], ">column_names/$tmp_file" or die "Could not
> create the file - $tmp_file \n";
> print $column_names[$i] "This is not working\n";
> close $column_names[$i] or die "Could not close the file -
> $tmp_file\n";
> }
>
I am getting following error:
(Missing operator before "This is not working\n"?)
> syntax error at test1.pl line 6, near "] "This is not working\n""
> Execution of test1.pl aborted due to compilation errors.
>
Although its not recommended to use bare-words for file handlers but they at
least work, so why are they not working in second code.
Cheers,
Parag