close

#!/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" );
}

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 wenching520 的頭像
    wenching520

    牧羊人

    wenching520 發表在 痞客邦 留言(0) 人氣()