Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Array of variables

by dbuckhal (Pilgrim)
on May 28, 2013 at 20:49 UTC ( #1035723=note: print w/replies, xml ) Need Help??


in reply to Re: Array of variables
in thread Array of variables

Ok, I'm confused....
perl -le '($x, $y, $z) = (1, 2, 3); @a = ($x, $y, $z); print join ( " +", map { $_++, $_ } @a )' __output__ 1 2 2 3 3 4
...or more (which I believe) is more similar to the OP's example:
perl -le 'my @a; my ($x, $y, $z) = (1, 2, 3); @a = ($x, $y, $z); print + $a[1]; $a[1]++, print $a[1];' __output__ 2 3
Am I not breaking it correctly? :)

Replies are listed 'Best First'.
Re^3: Array of variables
by frozenwithjoy (Priest) on May 28, 2013 at 20:54 UTC
    What part of what you wrote are you confused about?

      I thought I replicated the OP's code, but did not have a problem with the post-increment of the array element. So, I am confused that my code seems to work, whereas the OP's does not.

      Note how my output does increment the elements. Did I present code that replicates the OP's scenario, or am I off target here?

      Thanks!
        The difference is that you are actually printing the thing you are incrementing rather than incrementing one item and printing another completely distinct item. What the OP did is more like the final print statement here:
        perl -E ' my ( $x, $y, $z ) = ( 1, 2, 3 ); my @a = ( $x, $y, $z ); say join " ", map { $_++, $_ } @a; say "@a"; say "$x $y $z"; ' 1 2 2 3 3 4 2 3 4 1 2 3

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1035723]
help
Chatterbox?
[Corion]: Hi James!
[james28909]: I looked through the docs, and see that PerlApp::exe() is suppose to return this information but whenever i try to use this, i get the error "Undefined subroutine &PerlApp::exe called"
[james28909]: i just want to verify the integrity of the executables name each time it is run.
[Corion]: Weird. this documentation says what you say.
[Corion]: I assume you are experiencing this with your packaged program. Maybe also include PerlApp.pm in the packaging list?
[james28909]: has anyone else run into this problem? i have tried searching but have not returned many results
[james28909]: ah, good idea.
[Corion]: What does print $PerlApp::VERSION output?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2017-07-28 13:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (429 votes). Check out past polls.