Hi,

Thanx for helpIt was a silly mistake, I put a '\n'  due to usual practice ,
The prob is resolved, by not using join.

Now
$middle=sprintf "%4d-%02d-%02d",$year+1900,$mon+1,$mday;

and

$file_name=$prefix."_".$middle.$suffix;

But still a bit curios about this
if I do
$middle=`date +%F`;
I get result ( the new line prob),

New File name : log_2009-07-07
.gz

It there any way to do it using this (Using date command).


2009/7/8 Alexander Koenig <alexander.koe...@mpi.nl>

> I wrote on 07/08/2009 09:50 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
> > ------
>
> I'm sorry. The actual output from the quoted script was
> ----
> My Date : 2009-07-08
>
> New File name : log2009-07-08
> .gz
> ----
>
> This is because join expects a list as its second parameter. That means
> it should be
> $file_name=join("_",($prefix,$middle,$suffix));
> instead of
> $file_name=join("_",$prefix.$middle.$suffix);
>
> bye
> Alex
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
Regards,
मेघानंद नं. आचरेकर
Meghanand N. Acharekar
" A proud Linux User "
Reg Linux User  #397975
------------------------------------------
I was born free! No Gates and Windows can restrict my Freedom !!!

Reply via email to