in reply to dynamic socket communication
#!/usr/bin/perl use warnings; use strict; # The DATA filehandle is just a an open handle on the current # file. The current file is just the $0 variable (so long as # you haven't changed it) # main part of script ... my $count; while(<DATA>){ $count = $_ ; print "$count\n";} $count++; # then redo the count update: rewrite_count($count); sub rewrite_count { my $count = shift; open(SELF,"+<$0")||die $!; while(<SELF>){last if /^__END__/} truncate(SELF,tell SELF); print SELF $count; close SELF; } __END__ 1232
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: dynamic socket communication
by MidLifeXis (Monsignor) on Aug 05, 2010 at 17:46 UTC |