very new - need help with regular expressions
From: Brett Williams (brettaw_at_gmail.com)
Date: 03/26/05
- Next message: Edward Wijaya: "How can I get Inline::C to deal with big number?"
- Previous message: Offer Kaye: "Re: Question on configuring Help"
- Next in thread: Brett Williams: "re: very new - need help with regular expressions"
- Maybe reply: Brett Williams: "re: very new - need help with regular expressions"
- Maybe reply: Steven Schubiger: "Re: very new - need help with regular expressions"
- Maybe reply: Chris Heiland: "RE: very new - need help with regular expressions"
- Reply: John W. Krahn: "Re: very new - need help with regular expressions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 26 Mar 2005 19:33:50 +1100 To: beginners@perl.org
Hi :)
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);
record.txt contains
___
#Retail price items
?<1002.00>
?<125.00>
?<61864.35>
?<890876.99>
?<9.99>
#Transaction code
S,M,L
#Sales commission
5:7:10
___
This code returns nothing. I am at a loss as to what im doing wrong &
have been playing with this since yesterday. Big thanks to anyone who
can help :)
brettaw
- Next message: Edward Wijaya: "How can I get Inline::C to deal with big number?"
- Previous message: Offer Kaye: "Re: Question on configuring Help"
- Next in thread: Brett Williams: "re: very new - need help with regular expressions"
- Maybe reply: Brett Williams: "re: very new - need help with regular expressions"
- Maybe reply: Steven Schubiger: "Re: very new - need help with regular expressions"
- Maybe reply: Chris Heiland: "RE: very new - need help with regular expressions"
- Reply: John W. Krahn: "Re: very new - need help with regular expressions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]