CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Perl One-Liners: Multiple line task exection



Sep 10, 2012, 12:26 PM

Post #1 of 2 (1577 views)
Perl One-Liners: Multiple line task exection Can't Post

Hello, Perl Kings and Queens!

I found Walter C. Mankowski's Essential One-Liners guide online and have found it to be great! I am move beyond the guides examples and need to know how to develop multiple task execution in a one liner:

For example:

perl -lane ' `ping -n 3 $F[0]` ' pinglist.txt

Simple enough. But now I want to add a "For Loop," to the operation for $i 1 . . 5, and then sleep for 10 and continue.

How do you create that in a one-liner?

Okay I determined the following:

# perl -lane ' for($i=0;$i<3;$i++){`ping -n 3 $F[1]`}' nodelistB.txt

But I want the code to advance one line unitil it gets to the <3 limit, pause, and then continue forward in the file.

hmm . . .

(This post was edited by preston3271 on Sep 10, 2012, 12:40 PM)

Veteran / Moderator

Sep 10, 2012, 1:18 PM

Post #2 of 2 (1574 views)
Re: [preston3271] Perl One-Liners: Multiple line task exection [In reply to] Can't Post

To start with, I would rewrite


as something like:

foreach my $i (0..2)

Which is much more "perlish", clearer, and, BTW, faster.

Having said that, I don't really understand what you want to accomplish, I don't understand your question.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives