annie06 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl $infile = shift @ARGV; open (FILE, $infile) or die "Unable to open $infile: $!"; while (<FILE>) { foreach (@ARGV) { $pattern = $_; if ($pattern eq "Info I want") { if (/^Info I want/../^Start of/) { print unless ( /^Start of Info/ ); } } } } close (FILE);
But that prints an extra line that I don't want:#!/usr/bin/perl $infile = "my_file"; open (FILE, $infile); @text = <FILE>; close(FILE); foreach $line (@text) { $_ = $line; if (/^Info I want/../^Start of Info/) { print; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parse a block of text
by dragonchild (Archbishop) on Jul 07, 2008 at 19:22 UTC | |
by annie06 (Acolyte) on Jul 07, 2008 at 19:31 UTC | |
by dragonchild (Archbishop) on Jul 08, 2008 at 00:42 UTC | |
|
Re: Parse a block of text
by talexb (Chancellor) on Jul 07, 2008 at 19:44 UTC | |
by annie06 (Acolyte) on Jul 07, 2008 at 20:40 UTC | |
by talexb (Chancellor) on Jul 07, 2008 at 21:14 UTC | |
by runrig (Abbot) on Jul 07, 2008 at 22:52 UTC | |
|
Re: Parse a block of text
by Lawliet (Curate) on Jul 07, 2008 at 19:24 UTC | |
by JadeNB (Chaplain) on Jul 07, 2008 at 21:04 UTC | |
by Lawliet (Curate) on Jul 07, 2008 at 21:15 UTC | |
|
Re: Parse a block of text
by Cristoforo (Curate) on Jul 07, 2008 at 22:35 UTC | |
|
Re: Parse a block of text
by hilitai (Monk) on Jul 07, 2008 at 19:26 UTC | |
|
Re: Parse a block of text
by Anonymous Monk on Jul 07, 2008 at 19:49 UTC | |
by Anonymous Monk on Jul 07, 2008 at 20:46 UTC | |
by Anonymous Monk on Jul 07, 2008 at 20:17 UTC |