slow_leaner wrote:
Hello all,
Hello,
what am i missing!!!!!!!
#!/usr/bin/perl -w
@array_number =<STDIN>;
@new_array = half( @array_number );
print "@new_array\n";
sub half {
@numbers = @_;
while (<@numbers>){
That is short for:
while ( defined( $_ = glob join $", @numbers ) ) {
@n = $_ / 2;
That could also be written as:
$n[ 0 ] = $_ / 2;
@new_a = pop(@n);
That could also be written as:
$new_a[ 0 ] = pop(@n);
}
return @new_a;
Since you are only dealing with scalar values that could also be written as:
return $new_a[ 0 ];
}
#I am calling a sub function "half".
#but it return only the last element in to @new_array.
#here what i am exception.
#input return
#1 --------> 0.5
#2 --------> 1
#3 --------> 1.5
#!/usr/bin/perl
use warnings;
use strict
chomp( my @array_number = <STDIN> );
$_ /= 2 for my @new_array = @array_number;
print "$_\n" for @new_array;
__END__
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/