[EMAIL PROTECTED] am Dienstag, 2. August 2005 19.36:
> reg exp using \G
> Datum: 2.8.05 19:36:44
> Von: [EMAIL PROTECTED]
> An: [email protected]
>
> All,
>
> I think I am on the right track as far as what assertion to use. I need to
> print from one string to another using .. with \G
Your boss the reason that you *need* to? ;-)
> My goal is to capture from allsets down.
>
> thank you
>
>
>
> Here is my code:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> $ENV{PATH} = qq(/opt/SUNWsamfs/sbin:/usr/bin);
Nice to see :-)
> open (ARC, "archiver -lv |") or die $!;
>
> foreach (<ARC>)
> {
> ##-- Tape --##
> if (/allsets/ .. /fs_clinical.1/)
You are in your foreach loop. $_ contains *one* line. I've the impression that
here you somehow want to treat multiple lines with your if condition.
BTW, the "." in your regex stands for any char, not for a literal ".".
> {
> print $_;
> my $tape =$1;
You didn't capture in a regex, so $1 contains nothing.
> } else {
> / \G 'heartlab.1'/
\G is not usable here: It refers to the last match of the *same* string. But
a "last match" doesn't occur in the program flow: Per line in the foreach
loop, you visit either the if or the else part.
> }
> }
> close (ARC);
add a "or die" or at least "or warn" here.
>
> __END_CODE__
> __BEGIN_DATA__
Your problem, if I understand it, is to extract some adjacent lines, the first
line and the last line containing a keyword.
One approach (and not the best/shortest I suppose) could be:
- read in lines until the start line is found
- accumulate additional lines until end line is found.
[...snipped most of the big data]
> Archive sets:
> allsets
>
>
> back.1
> media: sf
> Volumes:
> STK000
> Total space available: 60.8G
>
> back.2
> media: sf
> Volumes:
> STK005
> Total space available: 60.9G
>
> clinical1.1
> media: sf
> Volumes:
> STK000
> Total space available: 60.8G
>
> darch.1
> media: sf
> Volumes:
> STK000
> Total space available: 60.8G
>
> fs_clinical.1
> Destination: disk1 (/darchive/data1)
[...]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>