Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: why does sort with uniq not work together

by tobyink (Abbot)
on Nov 27, 2013 at 12:51 UTC ( #1064604=note: print w/replies, xml ) Need Help??


in reply to why does sort with uniq not work together

The + is the unary plus operator. It does nothing, but can be used to disambiguate a first argument. For example:

print (1 + 2) . "\n";

You might expect that to be roughly the same as print "3\n", but it's actually more like my $tmp = print 3; $tmp . "\n". The line break doesn't get printed; it gets concatenated to the return value of the print function. That is, it's parsed like:

(print(1+1)) . "\n";

The unary plus helps Perl notice that something is an argument to the preceding function:

print +(1 + 2) . "\n";

Unary plus can also be useful in disambiguating +{} (a hashref) from { } (an empty block of code).

See Symbolic Unary Operators in perlop.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1064604]
help
Chatterbox?
[GotToBTru]: I think I have that inside out .. but you get the point
[choroba]: $array[0]{key1}[1] {key2}
[thepkd]: ??
[GotToBTru]: I would think temporary variables would help in making the real life meaning of your structure clear
[choroba]: the problems start when you want to "skip a level", i.e. the arrays for all the keys
[LanX]: what are temps?
[moritz]: oh, the question was about creation, not indexing
[thepkd]: temporary variables
[moritz]: [ { a => [ { b => 1 } ] } ]
[choroba]: dereference ne creation

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2016-12-06 13:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (104 votes). Check out past polls.