Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: if && condition not working

by rakheek (Sexton)
on Mar 24, 2010 at 19:06 UTC ( [id://830642]=note: print w/replies, xml ) Need Help??


in reply to Re: if && condition not working
in thread if && condition not working

Thanks for replying Anonymous Monk. Yes, my data is right. I printed it out. Also, if I use if condition without the &&, it works. I am totally confused. Here is what worked:
sub validate_date { my $start_date = $_[0]; my $end_date = $_[1]; my $today_date = $_[2]; my @start_date_array = split(/\//, $start_date); my @end_date_array = split(/\//, $end_date); my @today_date_array = split(/\//, $today_date); my $error_msg = ""; if (!$start_date || !$end_date){ $error_msg = "Blank Field in Date field. Please Use Browser Ba +ck button and Enter Date Field"}; # if ( (@start_date_array[0] > @today_date_array[0]) && (@start_ +date_array[1] > @today_date_array[1]) && (@start_date_array[2] > @tod +ay_date_array[2])) { if (@start_date_array[0] > @today_date_array[0]) { $error_msg = "Start Date can not be a Future Date. Please Use +Browser Back button and Enter Start Date"}; if ( (@end_date_array[0] > @today_date_array[0]) && (@end_date +_array[1] > @today_date_array[1]) && (@end_date_array[2] > @today_dat +e_array[2])) { $error_msg = "End Date can not be a Future Date. Please Use Br +owser Back button and Enter End Date"}; return $error_msg; }

Replies are listed 'Best First'.
Re^3: if && condition not working
by kennethk (Abbot) on Mar 24, 2010 at 19:19 UTC
    The request was not if your data is properly formatted. The request was to show us examples, so we know what to feed into the subroutine to test it. How are your dates formatted? Is it month/day/year, day/month/year, year/month/day? Is January represented by "1" or "01"? This information is very significant for showing you how your code is incorrect.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://830642]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-03-28 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found