Nov 26, 2009 #1 DIEBEL Programmer Joined Oct 16, 2009 Messages 1 Location CA I wish to pipe the output of the previous commond in a pipeline into my perl script. How is this generally best done? Thanx
I wish to pipe the output of the previous commond in a pipeline into my perl script. How is this generally best done? Thanx
Nov 26, 2009 #2 TrojanWarBlade Programmer Joined Apr 13, 2005 Messages 1,783 Location GB command | perl script Trojan. Upvote 0 Downvote
Nov 26, 2009 1 #3 Annihilannic MIS Joined Jun 22, 2000 Messages 6,317 Location AU And to read the piped input, you can use the "diamond operator", i.e. <>, for example, the following code will simply print it out. Code: while (<>) { print; } Annihilannic. Upvote 0 Downvote
And to read the piped input, you can use the "diamond operator", i.e. <>, for example, the following code will simply print it out. Code: while (<>) { print; } Annihilannic.
Dec 2, 2009 1 #4 bichonfrise74 Programmer Joined Oct 18, 2007 Messages 4 Location US Another way... Code: #!/usr/bin/perl use strict; open( my $ls_output, '-|', 'ls' ) or die "Cannot execute ls - $!"; print "$_\n" while (<$ls_output>); close( $ls_output ); Upvote 0 Downvote
Another way... Code: #!/usr/bin/perl use strict; open( my $ls_output, '-|', 'ls' ) or die "Cannot execute ls - $!"; print "$_\n" while (<$ls_output>); close( $ls_output );