<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"><div><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">It's the ternary logic you're after, I think.   ;-)  <br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">Tried to comment but I'm a programmer not a tech writer.  <br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px;
 font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span><br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>#!/usr/bin/perl<br><br>my $MAC="10.0.0.1";<br>my $NewUsage=150;<br>my %Usage=();<br><br>#$Usage{$MAC}=0 if ( ! $Usage{$MAC} );<br>#$Usage{$MAC}=$Usage{$MAC}+$NewUsage;<br></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><br></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;">#  
 Assgin                   condition                      0 if T else F assign new usage<br><span></span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: HelveticaNeue,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; background-color: transparent; font-style: normal;"><span>$Usage{$MAC}= (!exists($Usage{$MAC}) ? 0:$Usage{$MAC}+$NewUsage);<br><br>print "This should be 0\n";<br>foreach $key(keys %Usage){ print "$key -> $Usage{$key}\n"; }<br><br><br>$Usage{$MAC}= (!exists($Usage{$MAC}) ? 0:$Usage{$MAC}+$NewUsage);<br><br>print "This should be 150\n";<br>foreach $key(keys %Usage){ print "$key -> $Usage{$key}\n"; }<br><br class=""></span></div><div style="display: block;" class="yahoo_quoted"> <br> <br> <div style="font-family:
 HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> On Friday, February 14, 2014 1:00 PM, "boulder-pm-request@pm.org" <boulder-pm-request@pm.org> wrote:<br> </font> </div>  <div class="y_msg_container">Send Boulder-pm mailing list submissions to<br>    <a ymailto="mailto:boulder-pm@pm.org" href="mailto:boulder-pm@pm.org">boulder-pm@pm.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br>    <a href="http://mail.pm.org/mailman/listinfo/boulder-pm" target="_blank">http://mail.pm.org/mailman/listinfo/boulder-pm</a><br>or, via email, send a message with subject or body 'help' to<br>    <a ymailto="mailto:boulder-pm-request@pm.org"
 href="mailto:boulder-pm-request@pm.org">boulder-pm-request@pm.org</a><br><br>You can reach the person managing the list at<br>    <a ymailto="mailto:boulder-pm-owner@pm.org" href="mailto:boulder-pm-owner@pm.org">boulder-pm-owner@pm.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of Boulder-pm digest..."<br><br><br>Today's Topics:<br><br>   1. Adding undefined variables? (Robert L. Harris)<br>   2. Re: Adding undefined variables? (DeAndre)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Fri, 14 Feb 2014 12:11:47 -0700<br>From: "Robert L. Harris" <<a ymailto="mailto:robert.l.harris@gmail.com" href="mailto:robert.l.harris@gmail.com">robert.l.harris@gmail.com</a>><br>To: boulder-pm <<a ymailto="mailto:boulder-pm@pm.org" href="mailto:boulder-pm@pm.org">boulder-pm@pm.org</a>><br>Subject: [Boulder.pm] Adding
 undefined variables?<br>Message-ID:<br>    <<a ymailto="mailto:CAOXayVvTzCpzaD6gjJvWOfcV_KxshdxSVGZSBj07NKSPJehArg@mail.gmail.com" href="mailto:CAOXayVvTzCpzaD6gjJvWOfcV_KxshdxSVGZSBj07NKSPJehArg@mail.gmail.com">CAOXayVvTzCpzaD6gjJvWOfcV_KxshdxSVGZSBj07NKSPJehArg@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"<br><br>Quicky here.  I'm processing logs do not necessarily know the MAC's of IP's<br>I'm looking to find usage for.  Right now I'm doing this:<br><br><br><br>$Usage{$MAC}=0 if ( ! $Usage{$MAC} );<br>$Usage{$MAC}=$Usage{$MAC}+$NewUsage;<br><br><br>I could have swore there was a way to say something along the line of just<br>set $Usage{$MAC} to Zero if it's not defined.  Without turning off warnings<br>is my goal.<br><br><br>Anyone know a better or cleaner way to do this?<br><br>Robert<br><br><br>--
 <br>:wq!<br>---------------------------------------------------------------------------<br>Robert L. Harris<br><br>DISCLAIMER:<br>      These are MY OPINIONS             With Dreams To Be A King,<br>       ALONE.  I speak for                      First One Should Be A Man<br>       no-one else.                                     - Manowar<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="http://mail.pm.org/pipermail/boulder-pm/attachments/20140214/9057d25f/attachment-0001.html" target="_blank">http://mail.pm.org/pipermail/boulder-pm/attachments/20140214/9057d25f/attachment-0001.html</a>><br><br>------------------------------<br><br>Message: 2<br>Date: Fri, 14 Feb 2014 12:22:46
 -0700<br>From: DeAndre <<a ymailto="mailto:deandre@deandrecarroll.com" href="mailto:deandre@deandrecarroll.com">deandre@deandrecarroll.com</a>><br>To: <a ymailto="mailto:boulder-pm@pm.org" href="mailto:boulder-pm@pm.org">boulder-pm@pm.org</a><br>Subject: Re: [Boulder.pm] Adding undefined variables?<br>Message-ID: <<a ymailto="mailto:49w1qexw9fo75jjk8c5lx55t.1392405766096@email.android.com" href="mailto:49w1qexw9fo75jjk8c5lx55t.1392405766096@email.android.com">49w1qexw9fo75jjk8c5lx55t.1392405766096@email.android.com</a>><br>Content-Type: text/plain; charset="utf-8"<br><br>Use 'exists' on hashes to check whether there is an entry for a key.<br><br>For example:<br><br>$Usage{$MAC}=0 if ( ! exists $Usage{$MAC} );<br><br>This should alleviate your warnings problem.<br><br><br>Sent from my Galaxy S?III<br><br>-------- Original message --------<br>From: "Robert L. Harris" <<a ymailto="mailto:robert.l.harris@gmail.com"
 href="mailto:robert.l.harris@gmail.com">robert.l.harris@gmail.com</a>> <br>Date:02/14/2014  12:11 PM  (GMT-07:00) <br>To: boulder-pm <<a ymailto="mailto:boulder-pm@pm.org" href="mailto:boulder-pm@pm.org">boulder-pm@pm.org</a>> <br>Subject: [Boulder.pm] Adding undefined variables? <br><br><br>Quicky here. ?I'm processing logs do not necessarily know the MAC's of IP's I'm looking to find usage for. ?Right now I'm doing this:<br><br><br><br>$Usage{$MAC}=0 if ( ! $Usage{$MAC} );<br>$Usage{$MAC}=$Usage{$MAC}+$NewUsage;<br><br><br>I could have swore there was a way to say something along the line of just set $Usage{$MAC} to Zero if it's not defined. ?Without turning off warnings is my goal.<br><br><br>Anyone know a better or cleaner way to do this?<br><br>Robert<br><br><br>-- <br>:wq!<br>---------------------------------------------------------------------------<br>Robert L. Harris<br><br>DISCLAIMER:<br>? ? ? These are MY OPINIONS? ? ? ? ?
 ?? With Dreams To Be A King,<br>? ? ?? ALONE.? I speak for? ? ? ? ? ? ? ? ? ? ? First One Should Be A Man<br>? ? ?? no-one else.? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? - Manowar<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <<a href="http://mail.pm.org/pipermail/boulder-pm/attachments/20140214/188a839e/attachment-0001.html" target="_blank">http://mail.pm.org/pipermail/boulder-pm/attachments/20140214/188a839e/attachment-0001.html</a>><br><br>------------------------------<br><br>Subject: Digest Footer<br><br>_______________________________________________<br>Boulder-pm mailing list<br><a ymailto="mailto:Boulder-pm@pm.org" href="mailto:Boulder-pm@pm.org">Boulder-pm@pm.org</a><br><a href="http://mail.pm.org/mailman/listinfo/boulder-pm" target="_blank">http://mail.pm.org/mailman/listinfo/boulder-pm</a><br><br>------------------------------<br><br>End of Boulder-pm Digest, Vol 41, Issue
 1<br>*****************************************<br><br><br></div>  </div> </div>  </div> </div></body></html>