Open perl

From Teknologisk videncenter
Revision as of 04:28, 21 November 2009 by Heth (talk | contribs) (Getting STDOUT from commands)
Jump to: navigation, search

Piping from Perl to system commands

Getting STDOUT from commands

Metode 1

#!/usr/bin/env perl

print "Jeg er et perl program\n";

open FH,"ls -l|";

foreach my $i (<FH>) {
 print "Har modtaget linien: $i";
}

Metode 2

#!/usr/bin/perl

my @files = `ls -l`;

for my $i (@files) {
 print "Der er $i\n";
}