in reply to Re: Can we do without auxiliary variable here?
in thread Can we do without auxiliary variable here?

Why not write that without the auxiliary array manipulation there?

  • Comment on Re^2: Can we do without auxiliary variable here?

Replies are listed 'Best First'.
Re^3: Can we do without auxiliary variable here?
by roboticus (Chancellor) on Feb 28, 2011 at 23:07 UTC

    chromatic:

    Ha, ha! It never occurred to me!

    #!/usr/bin/perl use strict; use warnings; my $prefix="Prefix: "; sub print_prefix { print $prefix, @_; } print_prefix "alpha ", "beta ", "gamma\n";

    Sigh. When I read your reply, I thought, "Hmm, does unshift return a reference to the array?", so a first I thought you were prompting me to do something like:

    print unshift @_, $prefix;

    But when I checked the docs, I could see that it wouldn't fly. Then I understood what you meant. Ah, well! I'm always amused at how my mind works: it seems I frequently complicate simple things. ;^)

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.