Front page | perl.beginners |
Postings from December 2002
Passing array to a function
Thread Next
From:
Satya_Devarakonda
Date:
December 19, 2002 07:33
Subject:
Passing array to a function
Message ID:
OF44AE82F7.E967977C-ON85256C93.007F8B7F@tufts-health.com
Hi,
How can I pass an array to a function and get values back in it??? Here
are excerpts from my code.
########################################################
sub getTimeInfo
{
my $sec = 0;
my $min = 0;
my $hour = 0;
my $day = 0;
my $mon = 0;
my $year = 0;
my $IsDST = 0;
my $week_day = 0;
my @time_info = "\n";
my $day_of_year = 0;
($sec,$min,$hour,$day,$mon,$year,$week_day,$day_of_year,$IsDST) =
localtime(time);
my @monName =
("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" );
my @dayName =
("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
$mon += 1;
$year += 1900;
$results[0] = "$monName[${mon}-1]${day}";
if ( $day < 10 )
{
$day = "0${day}";
}
$results[1] = "$year$mon$day";
$results[2] = "\"$mon\/$day\/$year\",\"${dayName[$week_day]}\", \n";
print "Satya - @results";
return "@results";
} #End of getTimeInfo ()
#########################################################
use strict;
use Net::FTP;
use Time::Local;
#Get Time Information to be used to call different functions
my @results;
@results = split (/ /, getTimeInfo(), 3);
my $MonthDay = $results[0];
my $ccyymmdd = $results[1];
my $FormattedDate = $results[2];
print "Satya1 - $MonthDay : $ccyymmdd : $FormattedDate \n";
######################################################
Satya1 - Dec18 : 20021218 :
"12/18/2002","Wednesday",27480969643208615188651398403761002
And why am I getting junk(I believe it is pointer information) at the the
end like ==== > 27480969643208615188651398403761002
Thanks for your help.
Satya
Thread Next
-
Passing array to a function
by Satya_Devarakonda