#! /usr/bin/perl use strict; use warnings; use Data::Dumper qw( Dumper ); sub splitlist(@) { [@_[0 .. int((($#_ % 2 ) ? $#_ : $#_ - 1) / 2)]], [@_[int(($#_ + 1) / 2) .. $#_]] } my @empty; my @oneelement = qw( 1 ); my @odd = qw( 1 2 3 4 5 ); my @even = qw( 1 2 3 4 5 6 ); print "empty:\n"; my ($f,$s) = splitlist(@empty); print "first: " . Dumper($f) . "\n"; print "second: " . Dumper($s) . "\n"; print "oneelement:\n"; ($f,$s) = splitlist(@oneelement); print "first: " . Dumper($f) . "\n"; print "second: " . Dumper($s) . "\n"; print "odd:\n"; ($f,$s) = splitlist(@odd); print "first: " . Dumper($f) . "\n"; print "second: " . Dumper($s) . "\n"; print "even:\n"; ($f,$s) = splitlist(@even); print "first: " . Dumper($f) . "\n"; print "second: " . Dumper($s) . "\n"; ~