Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^3: error calling variables? Going insane...

by SuicideJunkie (Vicar)
on Jun 25, 2014 at 21:46 UTC ( #1091254=note: print w/replies, xml ) Need Help??


in reply to Re^2: error calling variables? Going insane...
in thread error calling variables? Going insane...

Since this is a question regarding why your if condition is unexpectedly true, collect some sample cases where it is not behaving as expected.

Since you are doing a simple regex test against a single value, your question likely boils down to "Why does this string get matched by this regex?"

if ($strands{$ID[$i]} =~ m/\+/) { That regex matches any string containing a '+' anywhere in it. In the case where you think it should NOT match but is matching, print out the string $strands{$ID[$i]} (not just $ID[$i] as your comment implies) and see what it contains.


Appended:

I notice at the top you are checking if '-', elsif '+', but at the bottom of your code, you are checking if '+' elsif '-'. If you have a string that contains both a + and a -, that may be causing some confusion.

Replies are listed 'Best First'.
Re^4: error calling variables? Going insane...
by lecb (Acolyte) on Jun 25, 2014 at 22:22 UTC

    Thank you for taking the time to have a look; I have only been learning for 2 weeks. My %strands is as follows:

    $key = some ID $value = + or -
    If I print out $strands{$ID[$i]}, all it does is print a string of pluses and minuses.

    I have however figured out the problem:
    my @ID; foreach my $line(@col_NM) { if ($line =~ m/(NM\_\d+)/) { push (@ID, $1); } }
    If $line did not match /(NM\_\d+)/, it would not be added to @ID . Since, I iterate through $ID[$i], I became out of sync with my positives and minuses.

    Thank you for pointing me in the right direction and your patience! :) El

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1091254]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2018-01-20 23:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How did you see in the new year?










    Results (227 votes). Check out past polls.

    Notices?