in reply to Indirect Referencing

Can I just say that you code just screams for a rewrite?

my $cfg = {}; open my $INFILE,"<","testfile.txt" or die "Could not open file:$!"; $cfg->{infile} = $INFILE; my $infh = $cfg->{infile}; while(<$infh>){ print "$_\n"; }

Sorry, but if i ever worked on your code before i did anything else i would make conversions like that $$hash{key} is an evil meme that is confusing (it doesnt scale up) easy to misunderstand (what the hell is $$hash {key}, a dereferenced ref followed by a block containing a sub call, a syntax error or a hashref dereference and lookup?) $hash->{key} is hard to mistake for anything but what it is.


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi


Replies are listed 'Best First'.
Re^2: Indirect Referencing
by periapt (Hermit) on Jun 21, 2004 at 12:59 UTC
    Hmmm, I like the open my $INFILE ... construct. I'll have to remember it since I use the
    open INFILE,"<","testfile.txt" or die "Could not open file:$!"; $fh = \*INFILE;
    code a lot.

    On a personal note, I have never felt comfortable with the arrow op. It may just be lack of use although I have been using it more lately. I do agree with you about scalability. I generally end up using the arrow op on more complex structures - although I do have a $$$cfg{infile} line in this same program ;o) - Still, it does look cleaner here...

    Thanks for the suggestions.

    PJ
    unspoken but ever present -- use strict; use warnings; use diagnostics; (if needed)