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;
In reply to Re: recognizing OS
by Anonymous Monk
in thread recognizing OS
by PerlZealot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |