Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Can't get rid of: Useless use of private variable in void context

by Anonymous Monk
on Feb 25, 2013 at 10:08 UTC ( #1020484=note: print w/ replies, xml ) Need Help??


in reply to Can't get rid of: Useless use of private variable in void context

#Process Zero sized (uninitialized) memory $PlaceToPutInformation->{'Maps'}{'HIGHTEC'}{$5} = { 'Start' => $1, 'End' => $2, 'Size' => $3, 'Symbol' => $4, 'Memory' => $6, 'OutputSection' => $7, 'InputSection' => $8, 'InputObject' => $9, }; local *HTEC = $PlaceToPutInformation->{'Memory'}{'HIGHTEC'}; $HTEC{'OverallSize'} ||= 0; $HTEC{'OverallSize'} = $HTEC{'OverallSize'} + $3; $HTEC{'Memory'}{$6} ||= 0; $HTEC{'Memory'}{$6} = $HTEC{'Memory'}{$6} + $3; $HTEC{'OutputSection'}{$7} ||= 0; $HTEC{'OutputSection'}{$7} = $HTEC{'OutputSection'}{$7} + $3;


Comment on Re: Can't get rid of: Useless use of private variable in void context
Download Code
Re^2: Can't get rid of: Useless use of private variable in void context
by Anonymous Monk on Feb 25, 2013 at 10:10 UTC
    Bah, start short too :)
    $HTEC{$5} = { 'Start' => $1, 'End' => $2, 'Size' => $3, 'Symbol' => $4, 'Memory' => $6, 'OutputSection' => $7, 'InputSection' => $8, 'InputObject' => $9, };
      and while you're at it, drop the single quotes for barewords :)

      $HTEC{perl}{is}{Perl}

Re^2: Can't get rid of: Useless use of private variable in void context
by tobias_hofer (Friar) on Feb 25, 2013 at 10:18 UTC

    Yes, much more beautiful!
    sadly I still got to use perl 5.10 so local *HTEC... is not working

    However, the  ||= 0 version makes the code much more better and makes me get rid of all the if statements!
    I will use it that way!
    Thanks a lot!

    Cheers!

    Tobias

      sadly I still got to use perl 5.10 so local *HTEC... is not working

      Sure it is, it worked since the very first perl5, at least

      perl -MData::Dump -e" dd $f={2,{4,{6,8}}}; local *H=$$f{2}{4}; dd\%H" { 2 => { 4 => { 6 => 8 } } } { 6 => 8 }
        Hey, you are right! :-)
        Perfect!

        But there is one thing, I have to remove the  use strict;
        else I get a:
        Global symbol "%HTEC" requires explicit package name at...

        Thanks a lot!
        Tobias

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2015-07-07 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (85 votes), past polls