kprasanna_79 has asked for the wisdom of the Perl Monks concerning the following question:

Revered Monks, Below is my code
($_jobcard_basename = basename($_job_card)) =~ s/^sub\.//i; $_jobcard_basename =~ s/\.xml//; use Data::Dumper; chomp($_jobcard_basename); print FOUT $_jobcard_basename; local $Data::Dumper::Useqq = 1; print STDERR Dumper "The Dumper value is $_jobcard_basename";
In the above code, i dont see any values printed in the file, but i do see some values when i use Dumper to print to STDERR.
The output using dumper is $VAR1 = "The Dumper value is topline.chs ";
Is there something weird going on.
Any body any idea???
-Prasanna.K

Replies are listed 'Best First'.
Re: Weird Happening when i print into a file
by ikegami (Patriarch) on Oct 27, 2008 at 20:13 UTC

    Change

    print FOUT $_jobcard_basename;

    to

    print FOUT $_jobcard_basename or die ("Can't write to FOUT: $!\n");

    to see what's wrong.

    Update: If the print doesn't given an error, add

    close(FOUT) or die ("Can't write to FOUT: $!\n");

    when you're done with the file.

      In the CB, the OP reported the above gives him "Bad file number" indicating that FOUT is not open.

        Hear that? That's the sound of everyone who read this post banging his or her head against a wall.

Re: Weird Happening when i print into a file
by JavaFan (Canon) on Oct 27, 2008 at 20:33 UTC
    Are you sure your open succeeded?
Re: Weird Happening when i print into a file
by ikegami (Patriarch) on Oct 27, 2008 at 20:18 UTC
    What's printing "The output using dumper is"? The code you showed doesn't produce that.
Re: Weird Happening when i print into a file
by ccn (Vicar) on Oct 28, 2008 at 06:10 UTC
    Where is your
    open FOUT, ">filename" or die $!;
    line?