Ktb wrote: > > I have a file "test2" with the format of: > > [Kent] > Address: 3473278 jones > omaha, ne 65465 > Phone: Home 8943, Work 83485, Cell 84853 > Email: Home @jdddd.cor, Work > Birthdate: 88484 > > [Pat] > Address: 747474 street > where, CA 848484 > Phone: Home 555-5555, Work 333-3333, Cell 222-22222 > Email: Home [EMAIL PROTECTED], Work > Birthdate: 8-4-4 > > I'm trying to delete in place a paragraph, if a name match is found. > The following code does not work but I think it should:) What am I > doing wrong? > > #!/usr/bin/perl > use strict; > use warnings; > > open FILE, '+<test2' || die $!; > chomp (my $name = <@ARGV>);
You are using the <> operator improperly here. It can be used as either readline() or glob() and in this context it is doing a file glob. > $^I; > $/ = ""; > while (<FILE>) { > if (/^\[$name/i) { > s/.//g; > } > } You have to have the file name in @ARGV and you have to set $^I to SOME value for perl's in-place editing to work. #!/usr/bin/perl use strict; use warnings; my $name = shift; @ARGV = 'test2'; $^I = ''; $/ = ''; while ( <> ) { next if /^\[$name/i; print; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]