in reply to &process or die

process() is returning a boolean false value so the part after 'or' is executed. Your code means: "process all elements but die at the first failing element". That's maybe not what you want.

Also your function doesn't use a 'return' statement so it returns the return value of the last statement which is 'close()' in this case. Close seems to return false which might be caused be a failing open() in the first place. You can't close a file which you couldn't open.

Do you use use strict; use warnings; ?? If not put it in and look for correlated warnings.

Replies are listed 'Best First'.
Re^2: &process or die
by steph_bow (Pilgrim) on Apr 18, 2008 at 15:42 UTC

    Dear mscharrer Thanks a lot for your help

    I have taken into consideration what you have said. In fact the last line of my subroutine is:

    chdir("$path_to_the_script_directory") or die;

    And I do not have any errors (when I do not use "or die" for process() )

    But in my operations of process(), I have used :

    while (my $line = <$INFILE>){

    And when I want to print $_ after the loop, I have :

    Use of uninitialized value in concatenation (.) or string at
      And when I want to print $_ after the loop, I have

      $_ and $line are different variables. The contents of one may or may not reflect the contents of the other.