Net::Telnet retrieving temporary text problem
am 06.11.2006 09:32:30 von pauld
Im retrieving screens of information from a telnet server, going
(backwards) from one to the next by pressing '0'. When I get to the
first one a message 'No more previous attendances' flashes on the
screen .
thuis retrieves the screens
($names)=$t2->waitfor('/Main Index Details/');
print $names;print $q-> hr;
do
{$t2->print('0');
my ($names2)=$t2->waitfor('/Main Index Details/');
$names=$names.$names2;
print $names;print $q-> hr;
}
until ($names=~/No\s+more/);
'No more previous' appears in dump_file and input_string but not in
$names;
Version 2 generates an error
Can't "last" outside a loop block at /var/www/localhost/cgi-bin/pas2.pl
line 119.
my $last=0;
do
{$t2->print('0');
$text='';
do {$text=$t2->get;
#print $text;print $q-> hr;##debugging string
if ($text=~m/previous/){$last=1;last;}
$names.=$text;}
until ($text=~m/Delete/);
}
until ($last);
print $names;print $q-> hr;
so how do i exit the loops when it finds the text ?
Re: Net::Telnet retrieving temporary text problem
am 06.11.2006 10:45:26 von someone
pdc124 wrote:
> Im retrieving screens of information from a telnet server, going
> (backwards) from one to the next by pressing '0'. When I get to the
> first one a message 'No more previous attendances' flashes on the
> screen .
> thuis retrieves the screens
> ($names)=$t2->waitfor('/Main Index Details/');
> print $names;print $q-> hr;
> do
> {$t2->print('0');
>
> my ($names2)=$t2->waitfor('/Main Index Details/');
> $names=$names.$names2;
> print $names;print $q-> hr;
> }
>
> until ($names=~/No\s+more/);
>
> 'No more previous' appears in dump_file and input_string but not in
> $names;
>
> Version 2 generates an error
> Can't "last" outside a loop block at /var/www/localhost/cgi-bin/pas2.pl
> line 119.
>
> my $last=0;
> do
> {$t2->print('0');
> $text='';
> do {$text=$t2->get;
> #print $text;print $q-> hr;##debugging string
> if ($text=~m/previous/){$last=1;last;}
> $names.=$text;}
> until ($text=~m/Delete/);
> }
> until ($last);
> print $names;print $q-> hr;
>
> so how do i exit the loops when it finds the text ?
See the end of the "Statement Modifiers" section of perlsyn for a solution:
perldoc perlsyn
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
Re: Net::Telnet retrieving temporary text problem
am 06.11.2006 11:17:54 von pauld
thanks .
its breaking out of 2 do loops that im not getting correct
my $last=0;
LOOP: do
{$t2->print('0');
$text='';
do {$text=$t2->get;# print $text;print $q-> hr;
last if ($text=~m/previous/);# if
($text=~m/previous/){$last=1;last;}
$names.=$text;
}
until ($text=~m/Delete/); #until ($last);#print $names;print $q->
hr;print $q-> hr;
}
#until ($last);
print $names;print $q-> hr; ##this is line 122
Software error:
syntax error at /var/www/localhost/cgi-bin/pas2.pl line 122, near
"print"
ie I assume it needs an 'until' to go with the do
but then removing the do and just leaving the curly braces doesnt
execute the loop
LOOP:
# do
{$t2->print('0');
$text='';
do
{$text=$t2->get; print $text;print $q-> hr;
last if ($text=~m/previous/);#
$names.=$text;
}
until ($text=~m/Delete/);
}
#until ($last);
print $names;print $q-> hr;
sends no '0's and doesnt grab any other screens of information