works without strict but not with why ???? 
Author Message
 works without strict but not with why ????

use strict;


("January","February","March","April","May","June","July","August","Septembe
r","October","November","December");
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$dst) =
localtime(time()-1*3600);
$mon = $mon + 1;
if ($hour < 10)           {$hour = '0'.$hour;  }
if ($min  < 10)           {$min  = '0'.$min;   }
if ($sec  < 10)           {$sec  = '0'.$sec;   }
if ($mon  < 10)           {$mon  = '0'.$mon;   }
if ($mday < 10)           {$mday = '0'.$mday;  }
$year += 1900;
$date2 = "$year$mon$mday";
$timestamp = "$months[$mon] $mday, $year $hour:$min:$sec";
print "Content-type: text/html\n\n";
print "$timestamp <br><br>This Line is the date used by the rest of the CGI
script to test other dates...";
print "$date2";

errors with strict are
Global symbol "$date2" requires explicit package name at
C:\InetPub\cgi-bin\servertest.pl line 13.
Global symbol "$timestamp" requires explicit package name at
C:\InetPub\cgi-bin\servertest.pl line 14.
Execution of C:\InetPub\cgi-bin\servertest.pl aborted due to compilation
errors.



Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????


Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????
never mind had to use no strict "vars";


Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????


Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????


Quote:

> use strict;



> ("January","February","March","April","May","June","July","August","Septembe
> r","October","November","December");
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$dst) =
> localtime(time()-1*3600);
> $mon = $mon + 1;
> if ($hour < 10)           {$hour = '0'.$hour;  }
> if ($min  < 10)           {$min  = '0'.$min;   }
> if ($sec  < 10)           {$sec  = '0'.$sec;   }
> if ($mon  < 10)           {$mon  = '0'.$mon;   }
> if ($mday < 10)           {$mday = '0'.$mday;  }
> $year += 1900;
> $date2 = "$year$mon$mday";
> $timestamp = "$months[$mon] $mday, $year $hour:$min:$sec";
> print "Content-type: text/html\n\n";
> print "$timestamp <br><br>This Line is the date used by the rest of the CGI
> script to test other dates...";
> print "$date2";

> errors with strict are
> Global symbol "$date2" requires explicit package name at
> C:\InetPub\cgi-bin\servertest.pl line 13.
> Global symbol "$timestamp" requires explicit package name at
> C:\InetPub\cgi-bin\servertest.pl line 14.
> Execution of C:\InetPub\cgi-bin\servertest.pl aborted due to compilation
> errors.

perhaps it failed because you didnt declare $date2 or $timestamp in your my ()
statement? try reading your error messages, they tell you what to look at.

MC
--
---------------------------------------------------------------------
My email address(s) are my private property.  They are NOT to be used
or recorded for ANY reason without my explicit permission.  Disregard
of this statement is in violation of federal privacy & copyright law.
---------------------------------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????

Quote:
>$date2 = "$year$mon$mday";
>$timestamp = "$months[$mon] $mday, $year $hour:$min:$sec";

You never declared these variables. Put a "my" in front of each of these
statements, and it should work.

--
        Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????


Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????

Quote:
>never mind had to use no strict "vars";

But then there's no use in using strict at all.

--
        Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????

Quote:
>never mind had to use no strict "vars";

You are being bad.

You may have to pay for that some day.

Much safer to do it without symbolic refs, which is
easily possible in your situation.

If you use symbolic references, you deserve to have bad
stuff happen to you.

--
    Tad McClellan                          SGML Consulting

    Fort Worth, Texas



Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????


Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????
On Wed, 14 Jun 2000 09:00:54 GMT, "Daniel van den Oord"

Quote:

> use strict;



Delete $wday, $yday, $dst (you don't use them), and add $date2 and
$timestamp.

Quote:

> ("January","February","March","April","May","June","July","August","Septembe
> r","October","November","December");

I'd use qw for this:

             July August September October November December);

Quote:
> ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$dst) =
> localtime(time()-1*3600);

Not sure why you subtract 3600 from time() -- don't you want the current
local time? But OK.

($sec, $min, $hour, $mday, $mon, $year) = localtime(time() - 1*3600);

You can leave off variables at the end in list assignment.

Quote:
> $mon = $mon + 1;
> if ($hour < 10)           {$hour = '0'.$hour;  }
> if ($min  < 10)           {$min  = '0'.$min;   }
> if ($sec  < 10)           {$sec  = '0'.$sec;   }
> if ($mon  < 10)           {$mon  = '0'.$mon;   }
> if ($mday < 10)           {$mday = '0'.$mday;  }
> $year += 1900;

Replace this bit with:

$mon = $mon + 1; # or $mon++; or $mon += 1;
$year += 1900
for($hour, $min, $sec, $mon, $mday) {
    $_ = sprintf("%.2d", $_);

Quote:
}

The rest seems OK.

Quote:
> errors with strict are
> Global symbol "$date2" requires explicit package name at
> C:\InetPub\cgi-bin\servertest.pl line 13.

So either write $::date2 or $main::date2, or add $date2 to the my(...)
declaration to make it a lexical variable instead of a global one. The
latter is preferred.

Cheers,
Philip
--

If you're not part of the solution, you're part of the precipitate.



Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????


Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????
On Wed, 14 Jun 2000 09:13:35 GMT, "Daniel van den Oord"

Quote:

> never mind had to use no strict "vars";

That's not considered the best way to get around use strict complaining.
See my other post.
--

If you're not part of the solution, you're part of the precipitate.


Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????


Wed, 18 Jun 1902 08:00:00 GMT  
 works without strict but not with why ????
works just fine with me !!!!


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 17 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Why, why, why, -w and use strict?

2. why not use(strict)?

3. why does strict not warn about shaddowing declarations ?

4. Strict not working.

5. use strict not working?

6. use strict refs not so strict?

7. Why does print $line not work?

8. Why i install Win32:GD not working?

9. Newbie: Why does cpan not work?

10. Why does this not work

11. Pleas help, why does it not work??

12. Why is the system call not working?

 

 
Powered by phpBB® Forum Software