Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Small perl code help!!!

Status
Not open for further replies.

rgoud

IS-IT--Management
May 9, 2002
21
US
Hi list,
When I execute this piece of code, it is always putting 1 at the end, anyone know
how to get rid of this?

#/usr/bin/perl -w
use Date::Manip;
$time = &DateCalc("today","+ 30 days");
$time1 = print (&UnixDate($time,"%m/%d/%Y"));
chomp $time1;
print "$time1\n";


bash-2.03$ perl delart.pl
05/01/20041 <------ here


Thanks in advance
 
For your print statement, try
Code:
print $time1, "\n";
That way you at least know it's printing the $time1 variable and not $time followed by a '1'.

 
Nevermind my last post... it's not the variable name. Don't know what I was thinking. It's this line causing the problem:
Code:
$time1 = print (&UnixDate($time,"%m/%d/%Y"));
I think the print statement is printing the time and then returning a '1' which is getting stored in $time1. Then you print the '1' when you print $time1. Sooo, you should probably not assign the return value from your print statement to $time1.

 
Try using gmtime(), time(), and localtime()
See perlfunc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top