Hi Agnello, On Monday 18 October 2010 15:01:56 Agnello George wrote: > I know the problem is solved but Could the script be done like this ?? >
OK, I'll answer it. > #!/usr/bin/perl > > use strict; > use warnings; > > > while (my $line =<DATA> ) { Why are you using *DATA and __DATA__ for the data? The data is found in a different file and you should open an explicit filehandle to the filename. > chomp($line); > > my ($out_file) = $line =~ m/^(\d+_\d+_\d+);/; You should check the return value of =~ inside a conditional. > > open (WRT,">>$out_file.log" ) or die " cannot opne file: > $!"; > print WRT "$line\n"; > close(WRT); 1. Please don't use bareword filehandles, and two-args open: http://perl-begin.org/tutorials/bad-elements/#open-function-style 2. Use a more meaningful variable name than "WRT" (did you mean "write"?). 3. The worst problem here is that you're opening an append filehandle, writing a single line to it, and closing it, for each and every line. This is very wasteful and may slow down your program considerably. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ My Favourite FOSS - http://www.shlomifish.org/open-source/favourite/ <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/