On Sep 8, Christopher Spears said:

I want to catch the various parts of the output of the
date command.  Here is my script:

my $date = system("date");

1. system() does not RETURN the output of a command.
2. backticks -- that is, `...` -- return the output of a command.
3. Perl provides a date function, localtime

You really just want to do this:

  my @days = qw( Sun Mon Tue Wed Thu Fri Sat Sun );
  my $d = (localtime)[3];
  print "Today is $days[$d].\n";

See 'perldoc -f localtime'.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to