> -----Original Message-----
> From: Manav Mathur [mailto:[EMAIL PROTECTED]
> Sent: Saturday, March 26, 2005 5:33 AM
> To: Brett Williams; [email protected]
> Subject: RE: very new - need help with regular expressions
>
>
>
>
> |-----Original Message-----
> |From: Brett Williams [mailto:[EMAIL PROTECTED]
> |Sent: Saturday, March 26, 2005 3:01 PM
> |To: [email protected]
> |Subject: re: very new - need help with regular expressions
> |
> |
> |Thank you Manav :)
> |
> |That was a big help. I now have another problem however. I
> had assumed
> |that adding a line number preceding the prices would be a trivial
> |matter, however what i thought would work is not doing so.
> Here is the
> |code ive tried.
> |
> |(open(INPUT, "record.txt")) or die("Error, can't find file\n"); my
> |$line; my $lnum = 1;
> |while(<INPUT>)
> |{
> |chomp;
> |print "$lnum: $line" . $1 ."\n" if (/^\?.*?<(.+?)>/); } close(INPUT);
> |
> |What i would like is for the output to look like
> |
> |1: 1002.00
> |2: 125.00
> |3: 61864.35
> |4: 890876.99
> |5: 9.99
> |
> |but perl doesn't like my code. My apologies for not including this
> |originally, i wanted to make my original question as short
> as possible.
> |
> |Thanks
> |brettaw
> |
> |--
> |To unsubscribe, e-mail: [EMAIL PROTECTED] For
> additional
> |commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
> |<http://learn.perl.org/first-response>
> |
> |
>
> Try this,
>
> (open(INPUT, "record.txt")) or die("Error, can't find
> file\n"); my $line = 1; my $lnum = 1;
> while(<INPUT>)
> {
> print $line++.": "."$lnum: $line" . $1 ."\n" if
> (/^\?.*?<(.+?)>/); } close(INPUT);
>
> *********************************************************
> Disclaimer:
>
> The contents of this E-mail (including the contents of the
> enclosure(s) or attachment(s) if any) are privileged and
> confidential material of MBT and should not be disclosed to,
> used by or copied in any manner by anyone other than the
> intended addressee(s). In case you are not the desired
> addressee, you should delete this message and/or re-direct it
> to the sender. The views expressed in this E-mail message
> (including the enclosure(s) or attachment(s) if any) are
> those of the individual sender, except where the sender
> expressly, and with authority, states them to be the views of MBT.
>
> This e-mail message including attachment/(s), if any, is
> believed to be free of any virus. However, it is the
> responsibility of the recipient to ensure that it is virus
> free and MBT is not responsible for any loss or damage
> arising in any way from its use
>
> *********************************************************
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED] For
> additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
And my $0.02:
#!/usr/bin/perl
use warnings;
use strict;
open (INPUT, "record.txt") or die "Error, can't find file: ($!)\n";
my $x = '1';
while (<INPUT>) {
print "$x $1\n" and $x++ if /^\?<(.*)>/;
}
close (INPUT);
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>