On Sep 14, siren jones said:

>$date = `/bin/date + %y%m%d`;

There's really no need to be calling an external system command to get the
date.  Perl has its own function, localtime(), and you can use the
POSIX::strftime() function to use date-like formatting instructions (the
%y and %m stuff).

>$a = chomp($date);
>print "$a";

First, chomp() does not "get rid of the newline".  chomp() removes the
input record separator from the end of a string, if it's there.  What is
the input record separator?  Well, most people call it a "line
ending".  And what is the default line endning?  Newline.

Technically, chomp() removes the value of $/ (the input rec. sep., whose
default value is "\n") from the end of the strings you pass it.

However, chomp() does not return the modified string.  chomp() modifies
the arguments you pass it IN-PLACE.

  $date = `date`;
  chomp $date;
  print $date;  # no newline here

Read the documentation for chomp():

  perldoc -f chomp

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to