in reply to I get these errors when I perform the script

It's a little easier to see now that you've edited your post. But you still don't show the relevant part of your code. See PerlMonks FAQ#Posting-on-PerlMonks.

All that can be seen from what you posted is that you twice try to use a variable $out that has not been initialized. In other words, it doesn't contain what you think it does. You should print() it out to see what's in it. Maybe you read it from a file and forgot to chomp() the newline character off the end?

Of course since $out is uninitialized at line 20, your open() fails, but you don't know because you don't check, like this:

open my $OUT, '>', "$out.out" or die "open failed: $!\n";

You're also trying to read from a filehandle that hasn't been opened at line 26; put the same error check on that open() and see why the filehandle isn't open.

The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: I get these errors when I perform the script
by Discipulus (Canon) on Sep 17, 2015 at 07:02 UTC
    yes, in fact in the docs for open is stated clearly:
    When opening a file, it's seldom a good idea to continue if the requ +est failed, so open is frequently used with die. Even if die won't do what you want (say, in a CGI script, where you +want to format a suitable error message (but there are modules that can help with that problem)) always check the retur +n value from opening a file.

    L*
    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.