Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Given When Syntax

by Marshall (Canon)
on Mar 16, 2014 at 15:03 UTC ( [id://1078519]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Given When Syntax
in thread Given When Syntax

Try this:
sub test2 { my ($var2) = shift; # Perl can implement the if/else idea very code efficiently. return ("One") if ($var2 =~ /^1\./ ); return ("Two") if ($var2 =~ /^2\./ ); return ("Three") if ($var2 =~ /^3\./ ); return ("UNKOWN"); } print test2 ("1.00.000"), "\n"; print test2 ("11.00.000"), "\n"; print test2 ("3.abc"), "\n"; __END__ prints: One UNKOWN Three
Update:
Well I think we both know that this is a simple example.
The regex'es aren't complicated. Just to demo the idea.

Replies are listed 'Best First'.
Re^4: Given When Syntax
by Deep_Plaid (Acolyte) on Mar 16, 2014 at 16:19 UTC

    Thanks, Marshal. That did the trick. I was an idiot for not seeing the subroutine was not identified in your code snippet as it was in my example. Thanks again for your time and patience.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found