On Sun, 2008-10-26 at 14:10 -0700, AndrewMcHorney wrote:
> Hello
> 
> I have some perl code that was working and for the life of me I 
> cannot determine why it is is failing now. All I am trying to do is 
> to create and open a new file using a date time stamp in the 
> filename. Below is the code snippet for the open, It is returning an 
> invalid argument error.
> 
> 
> ($Seconds,$Minutes,$Hours,$Day,$Month,$Year) = (localtime)[0,1,2,3,4,5];
> $Year = $Year + 1900;
> 
> $Date = $Month."-".$Day."-".$Year.".".$Hours.":".$Minutes.":".$Seconds;
> 
> $DuplicateFileName = ">Duplicate_File_List_".$Date;
> print $DuplicateFileName."\n";
> 
> $OpenStatus = 1;
> 
> open DUPLICATE_FILE_NAME, $DuplicateFileName or $OpenStatus = 0;
> if ($OpenStatus == 0)
> {
>     print "$!";
>     print " ";
>     die "Unable to open duplicate file name file\n";
> }
> 
> Thanks
> Andrew
> 
> 

Linux or Windows?

In Windows, some characters are not allowed in file names.  I do believe
':' is one of them (it is use to separate the volume from the path as in
C:\TEMP).

BTW, you may want to investigate strftime() in POSIX.  It formats dates:

use POSIX;
my @tm = localtime;
$Date = strftime( '%m_%d_%Y_%H_%M_%S', @tm );


-- 
Just my 0.00000002 million dollars worth,
  Shawn

Linux is obsolete.
-- Andrew Tanenbaum


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to