Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
It sounds like you're trying to do something in C, not Perl. If the string you're passing is an integer, then it's an integer, not a string!
I'm not trying to be dense, but that's the way Perl looks at things. If you want to pass integers in, but treat them as strings, the easiest way I can think of it to pass a second variable in that would tell you if this scalar is to be viewed as an integer or string. Of course, I would personally write two functions, one for integers and one for strings. Then, you decide outside the function which to do. Right now, you've got a function doing two different things. Make each do one thing and one thing well. You can tell this really easily if your function has the form:
------ Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement. In reply to Re: 1 vs "1"
by dragonchild
|
|