Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: problem unless I use ".="

by chargrill (Parson)
on May 13, 2007 at 14:30 UTC ( [id://615170]=note: print w/replies, xml ) Need Help??


in reply to problem unless I use ".="

Pretty sure you'll get the warning regardless if you use $a = $a . $b vs. $a .= $b, especially given the above code.*

In your above code, $baseball{yankees} hasn't been initialized, hence the warning that you're trying to use an uninitialized value in a concatenation.

You can get more detail if you use diagnostics; at the top of your program, which yeilds:

Use of uninitialized value in concatenation (.) or string at -e line 1 (#2) (W uninitialized) An undefined value was used as if it were already defined. It was interpreted as a "" or a 0, but maybe it was a mistake. To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl tells you what operation you used the undefined value in. Note, however, that perl optimizes your program and the operation displayed in the warning may not necessarily appear literally in your program. For example, "that $foo" is usually optimized into "that " . $foo, and the warning will refer to the concatenation (.) operator, even though there is no . in your program.

What are you trying to do, exactly?

If you just want to add a new key/value pair to your hash,

$baseball{yankees} = 'new york'; # OR $baseball{yankees} = $baseball{mets};

... will suffice.

* Update: Incorrect



--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-25 03:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found