python ( and some other languages ) can do some crazy stuff where a simple string variable is a class other than a string. ie, $email is an Email class object, when set it can only hold an email or toss an error. when you call print, or do any sort of string operation to it, it behaves like a string because of a representation function
i kind of really need something like that in perl - in one webapp, I'm regexing a single variable to see if it's a url/email 15x , tossing it through various functions that are different from one another. i'd love to replace the tests with a simple class check, and just change the instantiation to use a class instead of a string.
I've been through all my perl books , the pod, and perlmonks, but I can't seem to find anyone doing behavior like this. does anyone have a clue? can this even be done?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.