Brett Williams wrote:
Hi :)
Hello,
I am still very new to perl (and programming) and am getting stuck with
regular expressions. I have a text file in which I want to find, then
print to screen all lines beginning with "?" and then print the text
between the "<" and ">" characters. The code I have tried (amongst many
variations) is below
(open(INPUT, "record.txt")) || die("Error, can't find file\n");
$line = readline(INPUT);
while($line =~ /^\?/)
{
chomp($line);
print($line =~ /(.+)<\/a>\]/);
$line = readline(INPUT);
}
close(INPUT);
open INPUT, '<', 'record.txt' or die "Error, can't open 'record.txt' $!";
while ( <INPUT> ) {
next unless /^\?/;
print "$1\n" if /<([^>]+)>/;
}
close INPUT;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>