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: $!";
In reply to Re: Error executing
by toolic
in thread Error executing
by Nathan_84
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |