in reply to recognizing OS
Although $^O is the literal answer to your question the answer for portability is to use perls internal functions only rather than system calls. That way the port of Perl takes care of the port of you script for you. This could be a lot more terse if desired:
use Cwd; opendir my $dir, cwd() or die "Can't read ".cwd().": $!\n"; my @contents = readdir $dir; closedir $dir; my @dirs = grep{ -d and $_ ne '.' and $_ ne '..' } @contents; print "DIR $_\n" for @dirs; #my @files= grep{ -f } @contents; #print "FILE $_\n" for @files;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: recognizing OS
by ikegami (Patriarch) on May 03, 2008 at 06:18 UTC | |
by Anonymous Monk on May 03, 2008 at 08:38 UTC |