in reply to Re^2: Parsing a file line by line until a certain indice in array
in thread Parsing a file line by line until a certain indice in array

Thank you very much for the help guys. All my questions thus far have been answered and then some.

It completely works the way I want it to, but I am curious, what if some lines had, lets say a word in the beginning of the line. That I did not want to return with the rest of the line, for instance, I have one line with the word DISKUSED in the front.

The normal structure of the lines I am returning look like this:

DISKUSED OK - /vol/hello/ - total: 83886080 Kb - used 519800 Kb (1%) - + free: 83366280 Kb /vol/john/.snapshot - total: 0 Kb - used 30971856 Kb (0%) - free: 0 Kb /vol/bill/ - total: 20132660 Kb - used 7178128 Kb (36%) - free: 129545 +32 Kb /vol/ted/ - total: 52428800 Kb - used 4137924 Kb (8%) - free: 48290876 + Kb

There is only one instance where there will be something before the volume name in my file. I just want to be prepared for that, but at the same time I am curious as to how to get passed that if it occurred multiple times.

I guess what I am trying to ask is, as opposed to returning the entire line, how can I manipulate the STDOUT to be printing everything from $vol_to_parse to end of line?

And secondly, is that the right way I should be thinking for a situation like this in perl? Or is there some kind of reverse-chomp-type modifier.

Once again, any and all help is greatly appreciated.

Thank you,

Sluggo

Replies are listed 'Best First'.
Re^4: Parsing a file line by line until a certain indice in array
by AnomalousMonk (Archbishop) on Sep 06, 2009 at 21:10 UTC
    If I understand your question correctly, you might try something like:
    my $vol_to_parse = qr{ /what/ever }xms; my $line = get_a_line_somehow(); if ($line =~ m{ ($vol_to_parse .*) }xms) { print "$1 \n"; }