garny has asked for the wisdom of the Perl Monks concerning the following question:
I have to open all the files in a directory, the name of which will be given in the command line arguement .My code is
; #!usr/bin/perl -w use strict; use warnings; my $handle=$ARGV[0]; opendir(D,$handle) or die "cannot open"; my @files=readdir(D); foreach my $file(@files) {open (MYFILE,"$file") or die"oops"; } closedir(D)
The directory in command line has 5 files. It gives output as oops .I am a noob to perl so it will be helpful if you provide a basic explanation and the code i need to use . thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cant open files from a directory
by parv (Parson) on Jan 31, 2014 at 06:39 UTC | |
|
Re: cant open files from a directory
by vinoth.ree (Monsignor) on Jan 31, 2014 at 07:20 UTC | |
by x-lours (Sexton) on Jan 31, 2014 at 15:15 UTC | |
by Anonymous Monk on Feb 01, 2014 at 05:31 UTC | |
|
Re: cant open files from a directory
by parv (Parson) on Jan 31, 2014 at 08:24 UTC | |
|
Re: cant open files from a directory
by kcott (Archbishop) on Feb 01, 2014 at 04:53 UTC | |
by Anonymous Monk on Feb 01, 2014 at 05:38 UTC | |
by kcott (Archbishop) on Feb 01, 2014 at 05:53 UTC | |
by Anonymous Monk on Feb 01, 2014 at 07:56 UTC | |
|
Re: cant open files from a directory (Path::Tiny)
by Anonymous Monk on Jan 31, 2014 at 08:15 UTC |