The content of the /usr/ports/y.lis file is as following:sub scan { $lb1->insert('end', "Scanning..."); my $counter = '0'; my $file = '/usr/ports/y.lis'; my $outf = '/usr/ports/yyy.lis'; open(ARGV,$file) or die $!; open(OUTF,">$outf") or die $!; BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = <ARGV>)) { chomp $_; use File::Glob (); foreach $_ (glob("$_/*")) { if (!/Makefile(.inc|)$/) { printf OUTF "$_\n"; } else { $counter++; } } close(ARGV); close(OUTF); print "processed $counter records."; $lb1->insert('end', "Done."); } }
The content of the /usr/ports/yyy.lis file (produced by the code above) is as following:accessibility arabic archivers astro audio ...and about 70 more.
Anybody has an idea why it hangs?accessibility/accerciser accessibility/at-poke accessibility/at-spi accessibility/at-spi-reference accessibility/atk accessibility/atk-reference accessibility/dasher accessibility/eflite accessibility/gail accessibility/gail-reference accessibility/gir-repository-atk accessibility/gnome-mag accessibility/gnome-speech accessibility/gnopernicus accessibility/gok accessibility/java-access-bridge accessibility/kdeaccessibility accessibility/kdeaccessibility4 accessibility/linux-atk accessibility/linux-f10-atk accessibility/linux-f8-atk accessibility/mousetweaks accessibility/orca accessibility/py-papi accessibility/qt4-accessible accessibility/ruby-atk accessibility/speech-dispatcher accessibility/yasr
I've tried to merge (not only append!) these two sub-routines all night long without success.sub scan { $lb1->insert('end', "Scanning..."); my $counter = '0'; my $file = '/usr/ports/y.lis'; my $outf = '/usr/ports/yy.lis'; open(ARGV,$file) or die $!; open(OUTF,">$outf") or die $!; BEGIN { $/ = "\n"; $\ = "\n"; } LINE: while (defined($_ = <ARGV>)) { chomp $_; use File::Glob (); foreach $_ (glob("$_/*")) { printf OUTF "$_\n"; $counter++; } } close(ARGV); close(OUTF); print "processed $counter records."; $lb1->insert('end', "Done."); clean(); } sub clean { $portscount = '0'; $ifile = '/usr/ports/yy.lis'; $ofile = '/usr/ports/yyy.lis'; open(IFILE, $ifile) or die $!; open(OFILE,">$ofile") or die $!; while (<IFILE>) { $_ =~ s/\s+//g; if (!/Makefile(.inc|)$/) { printf OFILE "$_\n"; } else { $portscount++; } } close(IFILE); close(OFILE); print "processed $portscount records."; }
In reply to Re^2: 2 questions about Perl/Tk and Perl
by unknown-monk
in thread 2 questions about Perl/Tk and Perl
by unknown-monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |