davidov0009 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; my $dir = '/home/music'; my @mp3 = getSongs($dir); foreach my $song (@mp3) { print "$song\n"; } sub getSongs { my $dir = @_; use Carp; my @files; if (-d $dir) { opendir(MP3, $dir) || croak("Cannot open directory: $d +ir"); @files = readdir(MP3); closedir(MP3); } return @files; }
use strict; use CGI;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: subroutine array empty
by merlyn (Sage) on Dec 08, 2007 at 22:40 UTC | |
|
Re: subroutine array empty
by graff (Chancellor) on Dec 09, 2007 at 01:02 UTC | |
by davidov0009 (Scribe) on Dec 09, 2007 at 04:47 UTC | |
|
Re: subroutine array empty
by mwah (Hermit) on Dec 08, 2007 at 22:50 UTC | |
|
Re: subroutine array empty
by Anonymous Monk on Dec 08, 2007 at 22:41 UTC |