Hi Errin, Try something like this:
#!/usr/bin/perl use strict; my $file = 'filename'; open FH "<$fh"; my $text = ""; while (my $line = <FH> and $line !~ /System Temperatures/) {} while (my $line = <FH> and $line !~ /==*/) { $text .= $line; } print $text; __END__ It may not be elegant, but it should work. -David On Fri, 13 Aug 2004 08:19:43 -0500, Errin Larsen <[EMAIL PROTECTED]> wrote: > Hey guys (and gals, I imagine!), > > I'm really new to perl. I've been working through some beginners > tutorials and now I need (want!) to use perl to overhaul something I > wrote in the past. I've got a script (in bash) that I use that has a > particular sed command in it. The command is as follows: > > sed -n '/System Temperatures/,/==*/p' FILENAME > > The file in question has text that looks like this: > > <<BEGIN FILE SAMPLE>> > No failures found in System > =========================== > > ========================= Environmental Status ========================= > > System Temperatures (Celsius): > ------------------------------- > Device Temperature Status > --------------------------------------- > CPU0 65 OK > CPU1 63 OK > CPU2 64 OK > CPU3 63 OK > MB 35 OK > IOB 30 OK > DBP0 32 OK > > ================================= > > Front Status Panel: > ------------------- > Keyswitch position: NORMAL > > <<END FILE SAMPLE>> > > (obviously, this is output from the Sun Solaris' prtdiag -v command!) > > I want to collect just the temperature data from this file, so I use > the above sed command to pull out only the lines: > > <<BEGIN SAMPLE>> > System Temperatures (Celsius): > ------------------------------- > Device Temperature Status > --------------------------------------- > CPU0 65 OK > CPU1 63 OK > CPU2 64 OK > CPU3 63 OK > MB 35 OK > IOB 30 OK > DBP0 32 OK > > ================================= > <<END SAMPLE>> > > What I'm looking for is a graceful way to do this in a perl script. > I'm kinda at a loss for where to begin. Can you help me out? > > Thanks, > > --Errin Larsen > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>