Lets take it from the begining.
You said
I'm trying to use the die function to throw an error when an inputted path is wrong, however it's not throwing anything.
now if you want to print an error message (by the time your script tries to open it), in case the file does not exist.......remember using this way your program will stop running
Code:
open FILE, "$file" or die "Can't open: $! \n";
if you want to print an error message later on on your script......
Code:
eval{
open FILE, "$file" or die $!;
do whatever
close FILE:
};
if $! eq "No such file or directory"){
print "Dude There is $!\n";
}
We put the if in case the $! holds something else that you didn't notice (usually something like [red]Inappropriate ioctl for device[/red]). So we check if it holds [red]No such file or directory[/red] which is the error message you get when the file does not exists. And you print whatever and whenever you want.
If your open function contains any '>' and the file does not exists, it will create it so there is no error as before.
If none of these ways are working for you then your perl is not the way she should be.
And something else, stop using [red]print STDOUT[/red] use just print and your message, it will print it to STDOUT, don't use in your code useless stuff
``The wise man doesn't give the right answers,
he poses the right questions.''
TIMTOWTDI