Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: How do I...Conditional hash value

by myocom (Deacon)
on Jul 26, 2002 at 22:20 UTC ( #185685=note: print w/replies, xml ) Need Help??

in reply to How do I...Conditional hash value

First off, beware the "= vs. eq vs. ==" bug. Remember that = does an assignment, == compares numeric values, and eq compares string values. Having said that, what you're probably looking for is the ternary ?: operator (documented in perlop). I'd write what you're looking for like this:

my %required; $required{path} = ($ENV{HTTP_HOST} eq '') ? 'g:/websites/' : 'd:/users/http/html/';

Then again, if you have several keys to set, you're probably better off doing:

my %required; if ($ENV{HTTP_HOST} eq '') { # We now know which # platform we're on... $required{path} = 'g:/websites/'; $required{someotherkey} = 'some other string'; } else { $required{path} = 'd:/users/http/html/'; $required{someotherkey} = 'some different string'; }
"One word of warning: if you meet a bunch of Perl programmers on the bus or something, don't look them in the eye. They've been known to try to convert the young into Perl monks." - Frank Willison

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://185685]
[choroba]: You can also try DBD::MariaDB instead of MySQL
[choroba]: it's not on CPAN yet, unfortunately, so you have to install manually from github
[Spenser]: Thanks. I tried DBD::MariaDB just now. It can't find that module.
[Spenser]: oh, I'll check github

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2018-03-17 12:56 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (224 votes). Check out past polls.