in reply to printing needed info only

Not exactly sure what you want. To print only the blocks beginning 'Switch name complete'?. If so, let's parse the data and see what we can do...
my ($output,$match_flag); open (DATA, "/export/home/webadm/scripts/backup_scripts/backup_data/1s +tnodupe"); while (<DATA>) { if (/^Switch name complete/) { # match this $output .= $_; $match_flag=1; } elsif (/^\s/ && $match_flag) { # if correct, match this as well $output .= $_; } elsif (/^\S/) { # invalid, so don't match, or match following lines # beginning with whitespace $match_flag=0; } } close(DATA); print $output;

That strips out only the sections beginning with 'Switch name complete'. (Note, I didn't test, but I think syntax is OK).

cLive ;-)

Replies are listed 'Best First'.
Re: Re: printing needed info only
by Er1kW (Initiate) on May 03, 2001 at 22:51 UTC
    Thank you Guys for your assistnace

    I figured our a pattern and used it

    Line pattern as follows:
    /^\S/ # at least one followed by /^\s/ # and there are two lines of this


    The line I needed we just before the /^\s/ line.
    I was able to follow this pattern and print the desired
    info out to yet another file

    the following script is what I used:
    #!/usr/bin/perl -w use strict; my $previous_line = ""; my $line = ""; open (DATA, "/export/home/webadm/scripts/data/fourth_parse"); while (<DATA>) { chop; $line = $_; if ($line =~ /^\s/ && $previous_line =~ /^\S/) { print "$previous_line\n"; } else { if ($line =~ /^\sR*/ && $previous_line =~ /^\sR*/) { print "$previous_line\n"; print "$line\n"; } } $previous_line = $line; }
    Thank you again for your support
    Erik