GertMT has asked for the wisdom of the Perl Monks concerning the following question:
hi,
The file I'm working on is just one big line. There are multiple occurrences of the pattern I'm looking for in this single line. The regex I currently have only shows the last occurrence 80 times? I'm not seeing what I should change.
The file I'm working on is just one big line. There are multiple occurrences of the pattern I'm looking for in this single line. The regex I currently have only shows the last occurrence 80 times? I'm not seeing what I should change.
Patter is a few letters [a-zA-Z] after "photo/" followed by a dot and three [a-z].
#!/usr/bin/perl use strict; use warnings; my $count = 1; open( FILE, $ARGV[0] ); while ( my $w = <FILE> ) { foreach ( $w =~ m/photo\/([a-zA-Z]+\.[a-zA-Z]{3})/g ) { print "Photo: $count $1\n"; $count++; } } $count = $count - 1; print "\nI counted $count image-files\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Regex shows only last match multiple times?
by zeltus (Beadle) on Feb 13, 2014 at 10:17 UTC | |
by GertMT (Hermit) on Feb 13, 2014 at 10:47 UTC | |
by Anonymous Monk on Aug 08, 2014 at 13:41 UTC | |
by Athanasius (Archbishop) on Aug 08, 2014 at 15:51 UTC | |
Re: Regex shows only last match multiple times?
by Eily (Monsignor) on Feb 13, 2014 at 10:43 UTC | |
Re: Regex shows only last match multiple times?
by GertMT (Hermit) on Feb 13, 2014 at 10:26 UTC |
Back to
Seekers of Perl Wisdom