in reply to System call to ssh stalling.
Update: Perhaps you wanted to loop until the first non-blank line was entered?#!/usr/bin/perl -w use strict; my $cmd; while ((print "enter cmd: "), $cmd=<STDIN> and $cmd !~/^\s*$/) { chomp $cmd; print "cmd was: $cmd\n"; } print "loop exited\n";
I guess I'm not so clear about exactly you want to do.my $cmd=""; until ($cmd !~ /^\s*$/){print "enter cmd: "; $cmd=<STDIN>;} chomp $cmd; print "cmd was: $cmd\n";
Basically, I try to construct these loops such that the "last;" statement if any, is not the main, "normal" way that the loop exits. I use that to mean, "oh, we are quitting abnormally early" for some reason - maybe finding the first match or something like that.
If you are wondering why I used a regex, normally leading/trailing blanks on user input are ignored and I would have some statement to trim these instead of just a simple chomp; Anyway 3 spaces and one tab should be counted as just a "whitespace" line.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: System call to ssh stalling.
by yoda54 (Monk) on Jan 21, 2012 at 04:03 UTC |