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

Re: Not understanding 2 sentences in perldoc

by ikegami (Pope)
on Jul 30, 2020 at 21:28 UTC ( #11120088=note: print w/replies, xml ) Need Help??


in reply to Not understanding 2 sentences in perldoc

It means this

my $x = f(); my $y = $x;
can be written as
my $y = my $x = f();
and
my $copy = $str; $copy =~ s/\\/\\\\/g;
can be written as
( my $copy = $str ) =~ s/\\/\\\\/g;

Update: Added second example.

Replies are listed 'Best First'.
Re^2: Not understanding 2 sentences in perldoc
by LanX (Cardinal) on Jul 30, 2020 at 22:30 UTC
    Very concise! ++

    But he asked for lists, so

    my @x = f(); my @y = @x;

    can be written as

    my @y = my @x = f();

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

    update
    DB<39> sub f { 1..3} DB<40> my @y = my @x = f(); print"@x,@y" 1 2 3,1 2 3 DB<41>

      Well, the second passage was about scalar assignment. That's what I focused on. Your example completes the answer by addressing the first passage. Thanks.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2021-01-16 23:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?