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 imbibing at the Monastery: (16)
As of 2015-07-01 17:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (12 votes), past polls