CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
need help


New User

May 14, 2018, 10:16 AM

Post #1 of 3 (454 views)
need help Can't Post

I am new to perl and learning please help me what does this mean

i have a condition that mention as

&& !(exists $orra_dta->{$nm_id}->{'XY_IP_ID'})

also below one

$orra_dta->{$nm_id}->{'XY_IP_ID'} = $orra_dta->{$nm_id}->{'ID_NM'}

Chris Charley

May 14, 2018, 3:20 PM

Post #2 of 3 (451 views)
Re: [karuperl] need help [In reply to] Can't Post

The '&&' is anding the (unseen) condition preceding the statement '!(exists $orra_dta->{$nm_id}->{'XY_IP_ID'}) '.

'!(exists $orra_dta->{$nm_id}->{'XY_IP_ID'}) ' is saying if not exists the key 'XY_IP_ID' in the hash ' $orra_dta->{$nm_id}'.

Your statement in question is most likely followed by an action like:

if (black && blue) { 
apply ointment

The line '$orra_dta->{$nm_id}->{'XY_IP_ID'} = $orra_dta->{$nm_id}->{'ID_NM'}' is assigning the value associated with hash key ''ID_NM' to the the hash element keyed by 'XY_IP_ID'.

Chris Charley

May 17, 2018, 4:33 PM

Post #3 of 3 (436 views)
Re: [karuperl] need help [In reply to] Can't Post


I realize that my previous reply may not have been so helpful, so I'll try again.

Making a wild guess, perhaps your code looks like this.

if (exists $orra_dta->{$nm_id} && !(exists $orra_dta->{$nm_id}->{'XY_IP_ID'}) { 
$orra_dta->{$nm_id}->{'XY_IP_ID'} = $orra_dta->{$nm_id}->{'ID_NM'};

The first condition exists $orra_dta->{$nm_id} checks to see if '$nm_id' exists as a key in the hash. If it does, then a check is made !(exists $orra_dta->{$nm_id}->{'XY_IP_ID'}) to see if 'XY_IP_ID' doesn't exist in the hash. It checks the first condition before the second condition to avoid auto vivifying the 'first' key before trying the second condition.

If both conditions are true, then an assignment is made, i.e., $orra_dta->{$nm_id}->{'XY_IP_ID'} = $orra_dta->{$nm_id}->{'ID_NM'}

As I said, this is just a guess at what code you are using.

(This post was edited by Chris Charley on May 17, 2018, 4:36 PM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives