Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: regex issue

by davido (Cardinal)
on Mar 24, 2004 at 16:47 UTC ( #339466=note: print w/replies, xml ) Need Help??

in reply to regex issue

You really should hold off on using symbolic references. <update>For one thing, symbolic refs can't be used to create lexical variables (which is what it appears you're trying to do).</update> Perl is one of a very few languages that even allow them, and yet look at how much work is getting accomplished with all those languages that don't implicitly allow symrefs.

In the case of Perl, the best alternative to symbolic references, in many cases, is to use a hash. After all, the global symbol table itself is just a special kind of hash. If it's good enough for the goose, it's good enough for the gander.

use strict; # Always, for now. use warnings; # Always, while developing code. my %symbols; open INFILE, "<mydata.txt" or die "Can't open infile.\n$!"; while ( my $key = <INFILE> ) { my $value; unless ( $value = <INFILE> ) { die "Uneven key/value pairs!"; } $value =~ s/^\s+|\s+$//g; $symbols{$key} = $value; } print "$_: $symbols{$_}\n" for keys %symbols;

Also, please don't keep asking the same question with different titles. If you don't get good answers to your initial question, it's probably because it was unclear. In that case, you can follow-up in the same thread with refined details as to what you're looking for.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://339466]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2022-01-24 13:27 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (64 votes). Check out past polls.