Kevin Reynolds wrote:
> 
> I am just writing a basic form where the user enters the time of an event.
> It is entered in 24 hour format (HHMM) with no seconds.  What I want to do
> is perform some error checking on the entry by confirming that the first two
> numbers are between 00 and 23 and the second two are between 00 and 59.
> 
> Normally I would separate them into two varialbes, $hour and $minute and
> then perform the error checking with a couple of if statements.  But since
> there is no delimiter, how do you separate the two?  I know it can be done,
> I just forget how (or never really understood how).

my ( $hour, $minute ) = unpack 'a2 a2', $time;

my ( $hour, $minute ) = $time =~ /(\d\d)(\d\d)/;

my $hour   = substr $time, 0, 2;
my $minute = substr $time, 2, 2;



John
-- 
use Perl;
program
fulfillment

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

Reply via email to