Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Perl Syntax

by SuicideJunkie (Vicar)
on Oct 30, 2013 at 20:59 UTC ( [id://1060448]=note: print w/replies, xml ) Need Help??


in reply to Perl Syntax

The best way to find out is to print the results as you go:

c:>  perl -e "my $new = [$a,$b];  print qq*new is: * .$new . qq*\n 0+new is:*. (0+$new). qq*\n*; which gives:
new is: ARRAY(0x2491b4) 0+new is:2396596

As for line three, note that there is a for in there which loops over ($a, $b).

Replies are listed 'Best First'.
Re^2: Perl Syntax
by kbfiles (Initiate) on Oct 30, 2013 at 21:04 UTC
    @Suicide - I'm not trying to find what the value is but what does it do? What does 0+ do to $new?

      Uggh ... that is one bad code smell ... basically in that context you're getting the memory address of the reference value and using it as the key for the hash.

      -derby

        Some call it code smell, others call it the basis for managing inside-out objects.

        Update: Example from Class::Std:

        sub import { my $caller = caller; no strict 'refs'; *{ $caller . '::ident' } = \&Scalar::Util::refaddr;

        Dave

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 07:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found