develooper Front page | perl.beginners | Postings from April 2002

Re: Filehandles named with a variable

Thread Previous | Thread Next
From:
Mr Hash
Date:
April 2, 2002 15:20
Subject:
Re: Filehandles named with a variable
Message ID:
20020402232012.GA635@local.enodev.com
$1 is the resultant of a regex match. It don't need to be around very
long, because I build a hash of open filehandles (key = filehandle
string, value = file) at the time I open the file.

And no, I don't close 'em! exit() does just fine.

On 04/02, Timothy Johnson said something like:
> 
> You REALLY shouldn't use $1 for a variable name, though, since it has a
> special meaning.
> 
> -----Original Message-----
> From: David Gray [mailto:david_gray@3b2.com]
> Sent: Tuesday, April 02, 2002 2:33 PM
> To: core@enodev.com; beginners@perl.org
> Subject: RE: Filehandles named with a variable
> 
> 
> > So, I'm trying to 'open ($1,">>$file")', where $1 is a string 
> > like "cbQosCMPrePolicyPktOverflow".
> > 
> > Obviously, with use strict this does not work. How can I make 
> > it work? I need arbitrarily named filehandles. I know, it 
> > could get rended with gobbleworts if the data gets out of hand...
> 
> Have you tried using eval, like:
> 
> eval "open ($1 ">>$file");select $1";
--
Mr Hash
core@enodev.com

I filled out an application that said, "In Case Of Emergency
Notify".  I wrote "Doctor"...  What's my mother going to do?
						-- Stephen Wright

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About