Kevin Pfeiffer wrote:
> 
> In article <[EMAIL PROTECTED]>, John W. Krahn wrote:
> 
> [orig. question clipped]
> 
> >
> > The simplest way I could think of doing that would be:
> >
> > use warnings;
> > use strict;
> > use Tie::File;
> > use Fcntl ':flock';
> >
> > my $source_file = 'searchandreplace.txt';
> >
> > my $t = tie my @data, 'Tie::File', $source_file or die "Cannot open
> > $source_file: $!"; $t->flock( LOCK_EX );
> >
> > s/\s+\w+// for @data;
> >
> > untie @data;
> >
> > __END__
> 
> When I tried this I got an "untie attempted while one inner reference..."
> warning. Adding "undef $t" before the untie cured it.
> 
> Seems to be a useful module.

You can also avoid that warning by doing it like this:

use warnings;
use strict;
use Tie::File;
use Fcntl ':flock';

my $source_file = 'searchandreplace.txt';

( tie my @data, 'Tie::File', $source_file or die "Cannot open $source_file: $!" 
)->flock( LOCK_EX );

s/\s+\w+// for @data;

untie @data;

__END__


;-)

John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to