in reply to Error executing
or die "Can't open $filename!";Get more information on why the open failed by printing $!
Perhaps the file doesn't exist or you don't have permissions to open it.or die "Can't open $filename $!";
I much rather have the user enter the path at the terminal. How would I do this?You could prompt the user like this:
use strict; use warnings; use File::stat; # Declare variables my $filename; my $FILE_HANDLE; my $file_stat; my $current_time; my $diff_seconds; print "enter a file:\n"; $filename = <STDIN>; chomp $filename; # Open the file open ($FILE_HANDLE, $filename) or die "Can't open $filename: $!";
Or, pass it in on the command line, then use shift:
use strict; use warnings; use File::stat; # Declare variables my $filename; my $FILE_HANDLE; my $file_stat; my $current_time; my $diff_seconds; $filename = shift; # Open the file open ($FILE_HANDLE, $filename) or die "Can't open $filename: $!";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Error executing
by Nathan_84 (Acolyte) on May 15, 2010 at 00:58 UTC | |
by almut (Canon) on May 15, 2010 at 09:12 UTC | |
by Nathan_84 (Acolyte) on May 15, 2010 at 22:15 UTC |