in reply to Re: Please help - problem with script on Win2K
in thread Please help - problem with script on Win2K

when I tried running the script I get the following error message below. Is there something I'm missing (i.e. module..)? thanks again! D:\Perl\bin>perl -w x.pl Undefined subroutine &main::strftime called at x.pl line 6.
  • Comment on Re: Re: Please help - problem with script on Win2K

Replies are listed 'Best First'.
Re: Re: Re: Please help - problem with script on Win2K
by BrowserUk (Patriarch) on Sep 18, 2002 at 20:02 UTC

    Yes, you need use POSIX;. It's part of the standard distribution, so there's not installation to be done.

    Sorry! I should have mentioned it or added the line to the code.


    Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!
      Thanks for your help! I put in use posix; and it did something. When the script finished running I don't know where it created and took the logs file??? Is there a way I can create the time stamped folder in the current directory? I.E, (my $filedir = "\\\\10.1.1.5\\Weblogiclogs";)

        You need to use the absolute path in both the mkdir call and the rename call. the following two lines will make the the script current working directory (cwd) the directory you specify. You'll also not that I have used forward slashes rather than doubled backslashes. The result is the same, but this is rather more readable I think. This will work for all pathnames within Perl, even on Win32 (and other DOS-like systems as the pod would have it:).

        use Cwd 'chdir'; chdir '//10.1.1.5/Weblogiclogs';

        Alternatively, simply prepend the directory name to the filename as in

        my $createdir = '//10.1.1.5/Weblogiclogs' . strftime( '%y%d%e%H%M%S', +localtime);

        As for where the directory you created was created and the files moved to, that will depend what the cwd was at the time. If you had run the script from the command line, it would have been the same as the directory you were in when you ran it? At least under any circumstances I can think of.

        As for where the directory/files that you created/moved are - probably the easiest way to find them would be to use the Start->Find...->Files or Folders... option and enter the name of the directory you created.


        Cor! Like yer ring! ... HALO dammit! ... 'Ave it yer way! Hal-lo, Mister la-de-da. ... Like yer ring!