Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Weird Happening when i print into a file

by kprasanna_79 (Hermit)
on Oct 27, 2008 at 20:10 UTC ( [id://719825]=perlquestion: print w/replies, xml ) Need Help??

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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://719825]
Approved by mr_mischief
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-04-24 06:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found