On Sep 25, Kevin der Kinderen said:
> tty 81 bcain Async 01:18:35 00:02:55
> tty 83 dnguyen Async 00:20:27 00:01:13
> tty 85 cmandeville \
> Async 03:26:22 00:00:58
> tty 88 twooten Async 02:00:36 00:00:30
> tty 89 jwaters Async 00:13:37 00:00:32
> tty 95 epastoriza Async 00:45:29 00:00:00
I'd suggest the following:
>my @cmd_output = $session->cmd( 'show caller' );
my @condensed;
for (my $i = 0; $i < @cmd_output; $i++) {
my $line = $cmd_output[$i];
$line .= $cmd_output[++$i] while $line =~ s/\\$//;
push @condensed, $line;
}
Or, if you don't like C-style for-loops:
my @condensed;
while (@cmd_output) {
my $line = shift @cmd_output;
$line .= shift @cmd_output while $line =~ s/\\$//;
push @condensed, $line;
}
Here's how the approach works:
1. put the next element in $line
2. if $line ends in a slash (and we remove the slash):
2a. append the next element to $line
2b. go to 2
3. append $line to the @condensed array
4. go to 4
The loop stops when it has exhausted the array.
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]