Thanks to all... I was not knowing such a basic thing... :)
Cheers, Parag On Sat, Dec 5, 2009 at 5:19 PM, Paul Johnson <p...@pjcj.net> wrote: > On Sat, Dec 05, 2009 at 04:46:38PM +0530, Parag Kalra wrote: > > 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. > > perldoc -f print > > and in perticular, the last few lines. > > -- > Paul Johnson - p...@pjcj.net > http://www.pjcj.net >