in reply to Can't use string (">> /$1/$2/figs/Com/dis") as a symbol ref while "strict refs" in use

Use 3 parameter form of open, and watch your parenthesis.

my $file = "/$1/$2/figs/Com/dis/result.xml"; open RESULT, '>>', $file or die "Can't open $file: $!"; select(RESULT);

Also note that you should include your select statement within your if, as there's not point in selecting a file handle if you don't actually open it.

  • Comment on Re: Can't use string (">> /$1/$2/figs/Com/dis") as a symbol ref while "strict refs" in use
  • Download Code

Replies are listed 'Best First'.
Re^2: Can't use string (">> /$1/$2/figs/Com/dis") as a symbol ref while "strict refs" in use
by tchrist (Pilgrim) on May 03, 2011 at 05:41 UTC
    Because the reported error message cannot result from the code that was shown, it does no good telling them to use 3 arguments to open instead of only 2. That is not where the problem lies. Somehow the code shown is not what is really happening. You cannot fix this just by adding another argument. You have to stop using a string in the first argument: there is no other issue here.
      it does no good telling them to use 3 arguments to open instead of only 2

      Yes, the error message received was not immediately diagnosable given the code shown. Therefore, the only action I could see was to lead the OP toward fixing the 4 things obviously wrong with his code, hopefully leading him toward receiving a more meaningful error message.

      There's certainly some good from that, *fingers crossed*