Hi Lynx, I'm CCing my reply to the list. Next time, please use the GMail "reply to all" feature.
On Tuesday 09 November 2010 15:59:25 Lynx RO wrote: > Hello Shlomu Fish > It's "Shlomi" - not "Shlomu". > thanks for your comment I did changes , about chomp I think that is first > step is taking by default, about the rest I change @F and $f with @val and > $val[] but I still have error about some package > my @val = split (/;/, $line); > and > Global symbol "@val" requires explicit package name at test.pl . Can you > explain me were I am doing some mistake I find in the link about @ here > http://perldoc.perl.org/perlvar.ht...@- but I can not see were is my > mistake in the script :( can you help me? > You have not applied all of my commentary. Here are some notes: > > [code] > use strict; > use warnings; > > > # GET a value for accout.txt and outaccount > my $OUTPUTFILE ="acounts.txt"; > my $ACC_FILE = "inaccount.txt"; Be consistent - use «my $OUTPUT_FILE» instead of «my $OUTPUTFILE» > > #open input file > open my $ACC_IN ,"<", $ACC_FILE > or die "Cannot open '$ACC_FILE' for reading - $!; > > #split by line > while (my $line = <ACC_IN>) > > { > chomp ($line); > > my @val = split (/;/, $line); > > > #open output file > open my $out_fh, ">" , $OUTPUTFILE > or die "Cannot open '$OUTPUTFILE' for reading - $!; > 1. Here you are opening the file for writing and over-writing it in the process for each line in the loop. The opening should be done before the loop and the closing afterwards to prevent the file from being over-written each time. 2. You're missing the ending double-quotes («"»). > #print value what is interested for me in the file and then go to the next > line I gave you a fixed comment as it is not phrased well. > > print {$out_fh} "$val[0]$val[1]$val[2]$val[0]_mytext$val[3]\n"; > > > #close outfile > close $out_fh; Move this close out of the loop. > } > [/code] > Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ What Makes Software Apps High Quality - http://shlom.in/sw-quality <rindolf> She's a hot chick. But she smokes. <go|dfish> She can smoke as long as she's smokin'. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/