Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: The day of today

by Erez (Curate)
on Mar 07, 2008 at 12:25 UTC ( #672751=note: print w/ replies, xml ) Need Help??


in reply to The day of today

I know if I got rid of "use strict" it could be much shorter, but at work all scripts must have this.

and for a very good reason. As for your code:

#!/usr/local/bin/perl use strict; use warnings; my @localtime = localtime(); print "Today is day $localtime[3].";

UPDATE: changed @localtime to $localtime, ++haoess

Software speaks in tongues of man.
Stop saying 'script'. Stop saying 'line-noise'.
We have nothing to lose but our metaphores.


Comment on Re: The day of today
Download Code
Re^2: The day of today
by haoess (Curate) on Mar 07, 2008 at 12:31 UTC
    print "Today is day @localtime[3].";

    Doesn't your perl warn like

    Scalar value @localtime[3] better written as $localtime[3]

    ? You should do it ;-)

    -- Frank

      See? That's why you need to use strict and warnings :P

      Software speaks in tongues of man.
      Stop saying 'script'. Stop saying 'line-noise'.
      We have nothing to lose but our metaphores.

Re^2: The day of today
by johngg (Abbot) on Mar 07, 2008 at 13:57 UTC
    If you are happy to dispense with the array you can do this.

    use strict; use warnings; print "today is day @{ [ ( localtime )[3] ] }.";

    Cheers,

    JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://672751]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-12-26 01:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls