>> if ($buffer =~ /MARKER/)
> {
> $buffer = $&
> }
> Not that I'm an RE guru or anything but my code could look like
> something like this:
# consider the marker to be '#'
$buffer = $1 if ($buffer =~ /(.*)#/);
You might also look at using /g and, say, a while loop:
while ( $buffer =~ /(.+)MARKER/msg ) {
my $current_buf = $1;
# do what you like w/ the data
}
this'll step throught the $buffer one marker full at a time. That is data
like [1]
dlfkjaslf # lkasdfjdlks #
sdfslkjl
asldfkjd #
sfaslfdjdlk # asdfldsfas
Note, markers can be tricky, as is the ".+" ".*" etc. and if it's possibly
multi-line (handled above by the 's' switch) data, If it were a '#'
marker, I'd use a negative char class for the match:
while ( $buffer =~ /([^#]+)#/msg ) {
just to be safe.
a
[1]
m.pl:
#!/usr/bin/perl
use strict;
use warnings;
local $/ = undef;
my $buffer = <>;
print "Buf: $buffer|\n";
while ( $buffer =~ /(.+?)#/smg ) {
my $current_buf = $1;
print "CB: $current_buf|\n";
# do what you like w/ the data
}
m.dat:
dlfkjaslf # lkasdfjdlks #
sdfslkjl
asldfkjd #
sfaslfdjdlk # asdfldsfas
# perl /tmp/m.pl /tmp/m.dat
Buf: dlfkjaslf # lkasdfjdlks #
sdfslkjl
asldfkjd #
sfaslfdjdlk # asdfldsfas
|
CB: dlfkjaslf |
CB: lkasdfjdlks |
CB:
sdfslkjl
asldfkjd |
CB:
sfaslfdjdlk |
Andy Bach
Systems Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738 FAX 264-5932
"The Microsoft Exchange Information Store service depends on
the Microsoft Exchange Directory service which failed to
start because of the following error:
The operation completed successfully."
(actual MSE error msg)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs