[TriLUG] YAPQ (yet another perl question)..

Scott Lambdin lopaki at gmail.com
Thu Jun 11 15:07:05 EDT 2009


What are the angle brackets for in this line?

foreach $beforeLine (<@before>) {
Should they be there?
On Thu, Jun 11, 2009 at 2:53 PM, Steve Litt <slitt at troubleshooters.com>wrote:

>  On Thursday 11 June 2009 02:20:52 pm Greg Brown wrote:
> > Ok, I've got a really simple script that is confounding me.  I have a
> > source list of a bunch of routers, all the same make and model.  I ssh
> into
> > the routers and, at this point, just running a simple command: show
> flash.
> > The command 'show flash' returns output much like this:
> >
> > routername#show flash
> >
> > Directory of flash:/
> >
> >     2  -rwx        2072   Jun 2 2009 17:29:17 +00:00  multiple-fs
> >     3  -rwx     7713393   Mar 1 1993 01:11:46 +00:00
> > c3560-advipservicesk9-mz.122-25.SED.bin
> >     4  -rwx         616   Mar 1 1993 00:00:55 +00:00  vlan.dat
> >     5  drwx         192   Mar 1 1993 00:08:10 +00:00
> > c3560-ipservices-mz.122-25.SEB2
> >   358  -rwx        3916   Jun 2 2009 17:29:17 +00:00  private-config.text
> >   359  -rwx        8248   Jun 2 2009 17:29:17 +00:00  config.text
> >
> > 15998976 bytes total (358912 bytes free)
> >
> > Nothing terrible exciting.  I'm capturing this using Perl::Expect and I'm
> > doing so using this small block of code:
> >
> >         # now we should be at the "#" prompt
> >         $ssh->expect(30,'#');
> >
> >         # now see how many free bytes we have
> >         print $ssh "show flash\r";
> >
> >         my( $which, $why, $match, $before, $after ) =
> $ssh->expect(30,'#');
> >
> > The variable "$before" captures the output of 'show flash'
> >
> > The only line I'm interested in at this point is the last line that shows
> > the total size of flash and the bytes free.
>
> I can't understand everything you say, but the way to get just the last
> element of a Perl array is:
>
> my $lastline = $myarray[$#myarray];
>
> because $#myarray gives you the highest used subscript, which of course is
> 1
> less than the array's length.
>
> HTH
>
> SteveT
>
> Steve Litt
> Recession Relief Package
> http://www.recession-relief.US <http://www.recession-relief.us/>
> Twitter: http://www.twitter.com/stevelitt
>
> --
> TriLUG mailing list        : http://www.trilug.org/mailman/listinfo/trilug
> TriLUG FAQ  : http://www.trilug.org/wiki/Frequently_Asked_Questions
>



-- 
There's a box?



More information about the TriLUG mailing list