Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Add value from one array element into another of same ID

by pryrt (Abbot)
on May 27, 2021 at 15:32 UTC ( [id://11133143]=note: print w/replies, xml ) Need Help??


in reply to Add value from one array element into another of same ID

You have ... if $data->{ Name } = '';. This will always end up assigning $data->{Name} to the empty string (because = is an assignment operator not an equality operator); and since the empty string is false, the expression evaluates to false, so the if sees false, so the push will never happen.

String comparison is done with the eq operator, so you probably want ... if $data->{ Name } eq '';


edit: rereading your question, that might not be all of what you need; I'm not sure I understand it fully. However, the assignment operator does need to be changed to the string equality operator to make that if clause make sense.

Replies are listed 'Best First'.
Re^2: Add value from one array element into another of same ID
by Anonymous Monk on May 27, 2021 at 15:50 UTC
    It was a typo, it should've been if $data->{ Name } eq ''; to show the example. But I am still in doubt in how I could do to have the data the way I posted in my question.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found