Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: alpha numeric comparision

by prad_intel (Monk)
on Jan 28, 2005 at 12:52 UTC ( [id://425933]=note: print w/replies, xml ) Need Help??


in reply to alpha numeric comparision

Hi, The temp_var string can start with either an alphabet or a number but the whole string is alpha numeric.

if($temp_var1 == $temp_var2 and $temp_var2 == $temp_var3) {printf LOG"1";} if($temp_var2 != $temp_var1 and $temp_var3 == $temp_var2) {printf LOG"2";} if($temp_var2 eq $null and $temp_var3 eq $null) + {printf LOG"3";} if($temp_var3 == $temp_var1 and $temp_var2 eq $null) {printf LOG"4";} if($temp_var1 != $temp_var2 and $temp_var3 eq $null) {printf LOG"6";} if($temp_var2 != $temp_var1 and $temp_var3 != $temp_var1) {printf LOG"5";} if($temp_var1 == $temp_var2 and $temp_var3 != $temp_var1) {printf LOG"5";} if($temp_var2 == $temp_var1 and $temp_var3 eq $null) {printf LOG"5";}

Prad

Replies are listed 'Best First'.
Re^2: alpha numeric comparision
by nobull (Friar) on Jan 28, 2005 at 13:02 UTC
    There is no clue there as to what you are trying to achieve.
      I have 3 variables,I want to compare those 3 based on a particular logic

      All i want now is the variables are alpha numeric, i tried regex but i am unable to achieve the above

      Hope i get a guiding light.

      Prad
        This doesn't help. Post some examples of values for the variables, and what the results of the 'comparison' would be.
        I have 3 variables,I want to compare those 3 based on a particular logic All i want now is the variables are alpha numeric, i tried regex but i am unable to achieve the above

        Your problem has nothing to do with Perl. You are trying to implement "a particular logic" in Perl but you are unable to describe that "particular logic" even in human language.

        You are making the common mistake of jumping ahead to how without first pausing at what.


        Hmm... I've just re-read what you said...
        All i want now is the variables are alpha numeric

        ...is that really all you are asking?

        To check that a string is alphanumeric with a regex

        !/[^[:alnum:]]/

        or if you don't want a negated regex

        /^[[:alnum:]]*\z/

        Note: only pedants use \z most of the time. Most people use $. Reading the manual to discover the subtle difference is left as an exercise for the reader.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found