On Tue, Jan 16, 2001 at 11:24:25AM -0500, Ricardo Cumberbatch L. wrote:
> Hi Every one,
>
>
> I have a single cuestion how i do using the funtion split to separate a
> date, example:
>
> $date = 2001/01/16;
>
> I whant do this give to $year = 2001;
> $month = 01;
> $day = 16;
>
> I do somthing like this
>
> ($year, $month, $day) = split (/ /, $date);
>
> And in doesnt work.
>
> Note: sorry for my bad english
>
> Thanks a lot for the help
>
> Ricardo Cumberbatch L.
>
>
>
>
>
> _______________________________________________
> Perl-Unix-Users mailing list. To unsubscribe go to
>http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users
Ricardo,
The way you currently have $date defined causes perl to perform division on
the right hand side of the expression before assigning the value to $date.
You need to make sure that perl knows it is a string so that split will
work correctly. You will need to do something like this:
$date = "2001/01/16";
($year, $month, $day) = split (/\//, $date);
print "year is: $year\n";
print "month is $month\n";
print "day is $day\n";
Be sure to "escape" the slash in split.
--
regards,
Michael Branson
Programmer -- Application Development
----------------------------------------------------------------------------
Walking on water and developing software from a specification are easy...
...if both are frozen.
----------------------------------------------------------------------------
_______________________________________________
Perl-Unix-Users mailing list. To unsubscribe go to
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users