#!/usr/bin/perl
use strict;
use warnings;
my @array = ( 1..20 );
my @array2 = ( 1000..1005 );
print "\@array : @array\n\@array2 : @array2\n";
my @rmArray = splice ( @array, 5, scalar(@array2), @array2 );
print "After spliece\n";
print "\@array : @array\n\@rmArray : @rmArray\n";
Result :
$ perl splice.pl
@array : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
@array2 : 1000 1001...
Friday, December 2, 2011
Perl - [ $perl -e ' Command Line ' ] - [ Shift / Unshift / Pop / Push ]
Note: Open shell and type the code "command line" below!Syntax : $ perl -e ' command line '1) Profile example
$ perl -e '@array = (1..5); print "Result : @array \n";'
Result : 1 2 3 4 5
2) Removes the first element of the array
$ perl -e '@array = (1..5); shift (@array);print "Result : @array \n";'
Result : 2 3 4 5
3) Remove the last element of the array
$...