in reply to Re^2: Basic Coding Tips: Parsimonious Parameterization
in thread Basic Coding Tips: Parsimonious Parameterization

I have to admit - he couldn't do it much faster than that and still have a subroutine...

(Anyone else notice that @array2 will always be empty since @array1 will get all of @_? Thus, the foreach will always be skipped!)

  • Comment on Re^3: Basic Coding Tips: Parsimonious Parameterization

Replies are listed 'Best First'.
Re^4: Basic Coding Tips: Parsimonious Parameterization
by wazoox (Prior) on Jan 31, 2005 at 12:37 UTC
    Yes :) But it'd works this way:
    sub array_merge(\@\@){ my($array1, $array2) = @_; foreach my $element (@$array2){ @$array1 = (@$array1, $element); }#foreach return @$array1; }#array_merge my @t=array_merge(@liste1, @liste2);
      my @t = (@liste1, @liste2);
      works too. No need to reinvent what the core language already provides in a simple way.