Other ways to assign a filehandle to a variable?
After reading Randal's March 2000 LM column and learning that you can assign a filehandle to a scalar by doing something like: open(FILE, $filename) or die whatever; $value = *FILE{IO}; I am wondering if there are other, perhaps better, ways of doing this? FYI, I googled for assigning filehandle to variable perl and a couple other searches, but only came up with pages directing how to read from a filehandle into a scalar. Regards, Roman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Other ways to assign a filehandle to a variable?
Roman Daszczyszak schreef: After reading Randal's March 2000 LM column and learning that you can assign a filehandle to a scalar by doing something like: open(FILE, $filename) or die whatever; $value = *FILE{IO}; I am wondering if there are other, perhaps better, ways of doing this? FYI, I googled for assigning filehandle to variable perl and a couple other searches, but only came up with pages directing how to read from a filehandle into a scalar. Use lexical ones in the first place. open my $fh, '', $filename or die open $filename, stopped ; -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Other ways to assign a filehandle to a variable?
Use lexical ones in the first place. open my $fh, '', $filename or die open $filename, stopped ; And if you're gogint to die you might as well say why :) ... or die open $filename failed: $! ; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Other ways to assign a filehandle to a variable?
JupiterHost.Net schreef: Use lexical ones in the first place. open my $fh, '', $filename or die open $filename, stopped ; And if you're gogint to die you might as well say why :) ... or die open $filename failed: $! ; Yes, I meant: open my $fh, '', $filename or die open $filename, stopped $! ; The $! begins with at bla -bla, so the stopped glues nicely. I don't remember where I copied it from, maybe a perldoc. -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Other ways to assign a filehandle to a variable?
For posterity: http://perl.plover.com/local.html#3_The_First_Class_Filehandle_Tr -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response