[EMAIL PROTECTED] wrote:
I have this value, from the date format solution emails, in a subroutine
and I want to pass it to a if clause, how would I go about this?
Can I assign a literal such as
sub datemanip {
my ( $month, $day, $year) = (localtime)[4,3,5];
my $foodate = printf ("%02d/%02d/%02d\n", $month + 1, $day, ($year %100));
Use sprintf for that.
I use sprintf in one of my programs like this:
my $d8_dato = sprintf( "%4d%02d%02d", ( substr( $dato, 4, 4 ),
substr( $dato, 2, 2 ),
substr( $dato, 0, 2 ) ) );
}
while (<D>)
if ( $_ =~ $foodate) {
It would work, if you use sprintf as shown above. But I would write:
if ( $_ =~ m/$foodate/ )
instead to eliminate confusesing when maintaining the code later.
.....
}
--
Flemming Greve Skovengaard FAITH, n.
a.k.a Greven, TuxPower Belief without evidence in what is told
<[EMAIL PROTECTED]> by one who speaks without knowledge,
4112.38 BogoMIPS of things without parallel.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>