For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Re: Opening .dat file in perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Opening .dat file in perl
Paul Lalli

2006-10-30, 7:03 pm

Paul Lalli wrote:
> Goksie wrote:
>
>
> This is the one and only downside of using lexical filehandles I've
> ever found. You can't use the default that print() prints $_ if not
> given an argument. You have to state it explicitly:
>
> while (<$fh> ) {
> print $fh $_;
> }
>
> Those extra two characters of typing are well worth the benefits,
> however.



Ignore everything I just said - I read your code too quickly and didn't
parse it correctly in my head. And my answer is nonsensical. So my
apologies.

What exactly are you *trying* to do? You've opened a file for reading,
and then you're printing the value of that filehandle. Are you trying
to print the line read from the filehandle?
while (<$fh> ){
print;
}

or are you trying to print some other content *to* the filehandle? In
that case, you'd need to open the file for *writing* and find some
other source for the content.

Paul Lalli

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com