http://www.perlmonks.org?node_id=938568


in reply to My script is working fine on linux but it's not working on the Windows

Welcome to the Monastery, please read How do I post a question effectively?. You've posted unformated code (post formatting advice is displayed) and not mentioned what happens when you run it, or provided any input data.

No use strict; use warnings;? See Use strict and warnings and Use strict warnings and diagnostics.

  • Comment on Re: My script is working fine on linux but it's not working on the Windows
  • Download Code

Replies are listed 'Best First'.
Re^2: My script is working fine on linux but it's not working on the Windows
by galacticos (Initiate) on Nov 17, 2011 at 10:01 UTC

    Actuall in windows this programme is working fine But at the same time When I am trying this programme in windows it's not working and one more thing when i exectue my perl script in windows it's got stuck in cmd but after that when i prees enetr two or three time it will throw thius error " the system cannot" only these three word please check this if it's possible ... Thanks and regards Galacticos

    #!/usr/bin/perl use strict; use warnings; $y_date= `date --date="yesterday"`; $y_date =~ s/IST//g; $y_date =~ m/(\d+)$/; $year= $1; print $year; $y_date =~ m/^(\w+\s\w+\s\w+)/; #print $y_date; $day=$1; print $day; open(FH,"C:\\arerror.log") or die "Unable to open logfile:$!\n"; open(OUT,">C:\\output.log") or die "Unable to open output file:$!\n"; @fileco=<FH>; @grepLogs = grep(/$day(.*)$year/,@fileco ); print OUT @grepLogs;

      Instead of relying on an external date program, consider looking at localtime.

      "Actuall in windows this programme is working fine But at the same time When I am trying this programme in windows it's not working and one more thing when i exectue my perl script in windows it's got stuck in cmd but after that when i prees enetr two or three time it will throw thius error " the system cannot" only these three word please check this if it's possible ..."

      So it's working fine, apart from the fact that it doesn't work?

      $y_date= `date --date="yesterday"`;

      had you actually run this from the command prompt you'd notice that you're being prompted for user input, hence pressing enter multiple times provides the (invalid) input. The error you get isn't from your perl code, its because you don't understand what date does. As Corion suggested, don't reply on an external program (albeit the wrong program, which you don't seem to understand how to use) to get yesterdays date.

      A reply falls below the community's threshold of quality. You may see it by logging in.

      I noticed you've added use strict; use warnings now your code won't even get to the line which causes the problem. Did you even try running this?

A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.