Vladimir Lemberg wrote:
I have this file:
foobar-45whatever-37hello16goodbye9#!!!
snafu23skidoo---+30-50
I need to store all digits into list. As you can see there is no
any obvious delimiter, so I'm using global matching
open (INFILE, "$ARGV[0]") || die "cannot open $ARGV[0].\n";
@digits
> open (INFILE, "$ARGV[0]") || die "cannot open $ARGV[0].\n";
> @digits = =~ /-*?\d+/g;
> print "@digits";
>
> The problem is that @digits took only first line of my file.
You read only 1 line... for more, you may need,
my $lines = join "", ;
@digits = $lines =~ /-*?\d+/g;
or
my @digit
Vladimir Lemberg wrote:
> Hi,
>
> Could you help me to solve this problem?
>
>
>
> I have this file:
>
> foobar-45whatever-37hello16goodbye9#!!!
>
> snafu23skidoo---+30-50
>
>
>
> I need to store all digits into list. As you can see there is no any
> obvious delimiter, so I'm usin
On Dec 19, Bram Heyns said:
>For example if I have a string like "" and I want to match every
>"aa" in there, how should I do this?
Use a look-ahead:
while ($str =~ /(?=pattern)/g) { ... }
so you'd use /(?=aa)/g there.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox
Bram Heyns wrote:
>
> I have a rather simple question, but I can't figure it out!
> For example if I have a string like "" and I want to match
> every "aa" in there, how should I do this?
> So I want a match on position 0-1,1-2,2-3.
> If I use if(/aa/g){} statement, it only finds one, and if
Try using a positive lookahead assertion:
while ( /a(?=a)/g){}
Let me know if it works. ;-)
- Original Message -
From: "Bram Heyns" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 19, 2001 2:37 PM
Subject: global matching
I have a rather simple question, but I c