Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Using a subroutine as a module

by bradcathey (Prior)
on Nov 03, 2003 at 02:11 UTC ( [id://303984]=note: print w/replies, xml ) Need Help??


in reply to Using a subroutine as a module

Wow, all great answers and a big help. I can hardly wait to get started. Thanks responsive monks!

Update:
It worked as shown below. Good stuff and sorely missing from the literature. Maybe this would make a good Q&A (now an unapproved question, under subroutines).
#!/usr/bin/perl print "Content-type: text/plain\n\n"; use strict; use CGI::Carp qw(fatalsToBrowser); use Validate; my $the_time = "12:23 pm"; Validate::val_time($the_time); $the_time = $Validate::val; if ($the_time) { print "$the_time\n" } else { print "error\n" }
And the module:
package Validate; # use package to declare a module our $val; sub val_time { $val = shift; $val = ($val =~ /^(\d{2}):(\d{2}) (am|pm)$/) ? "$1:$2 $3" : 1; return $val; #worked with and without this line } 1;
Thanks!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-03-29 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found