I'm trying to do the simplest thing with splice() but not seeing the
results I expect.  It seems to go weird when I passed an array of
arguments rather than a direct list.

  my (@list, @result, @args);

  # first, the working example
  @list   = qw( a b c d e );
  @result = splice(@list, 3, 1);

  print "splice remains: @list\n";      # a, b, c, e
  print "splice result: @result\n";     # d

  # now the not-so-working example
  @list   = qw( a b c d e );
  @args   = (3, 1);
  @result = splice(@list, @args);

  print "splice remains: @list\n";      # a, b
  print "splice result: @result\n";     # c, d, e

The summary: splice() seems to get confused if you call it as
splice(@list, @args).

Am I missing something obvious?


A


Reply via email to