Hi,

You wrote on 07/08/2009 09:35 AM:

> #!/usr/bin/perl -w
> # Prog for demostrating file name concatenations.
> $prefix="log";
> $suffix=".gz";
> 
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
> # Time
> $middle=sprintf "%4d-%02d-%02d \n",$year+1900,$mon+1,$mday;
> print "My Date : $middle \n";
> $file_name=join("_",$prefix.$middle.$suffix);
> print "New File name : $file_name \n";
> 
> I am getting value of $file_name as
> 
> New File name : 1250_RDE_2009-07-07
> .gz

The script above has a different output for me, i.e.:

-----
My Date : 2009-07-08

New File name : log_2009-07-08
_.gz
------

Why do you put a whitespace and a linebreak into $middle?

I would change this line
> $middle=sprintf "%4d-%02d-%02d \n",$year+1900,$mon+1,$mday;
to this
$middle=sprintf "%4d-%02d-%02d",$year+1900,$mon+1,$mday;

Why are you using join to put the filename together?

I would change this line
> $file_name=join("_",$prefix.$middle.$suffix);
to this
$file_name= $prefix."_".$middle.$suffix;

hth
Alex

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to