#!/usr/bin/perl -w
use warnings;
use strict;
main();
exit(0);
sub main {
my @aAry = ( 1, 2, 3 );
print( "Before calling subroutine1...\n" );
print( "Array in main:" );
foreach my $iPiece ( @aAry ) {
print( "\t$iPiece" );
}
print( "\n" );
&_subroutine1( \@aAry );
print( "After calling subroutine1 and Before calling subroutine2...\n" );
print( "Array in main:" );
foreach my $iPiece ( @aAry ) {
print( "\t$iPiece" );
}
print( "\n" );
&_subroutine2( \@aAry );
print( "After calling subroutine2...\n" );
print( "Array in main:" );
foreach my $iPiece ( @aAry ) {
print( "\t$iPiece" );
}
print( "\n" );
}
sub _subroutine1 {
my @aAry = @{shift @_};
@aAry = reverse @aAry;
print( "Array in subroutine1:" );
foreach my $iPiece ( @aAry ) {
print( "\t$iPiece" );
}
print( "\n" );
}
sub _subroutine2 {
my $raAry = shift;
@{$raAry} = reverse @{$raAry};
print( "Array in subroutine2:" );
foreach my $iPiece ( @{$raAry} ) {
print( "\t$iPiece" );
}
print( "\n" );
}
留言列表