Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Head to numb to see it.....

by danger (Priest)
on Mar 08, 2001 at 22:26 UTC ( [id://63050]=note: print w/replies, xml ) Need Help??


in reply to Head to numb to see it.....

Well, assuming you have fixed length data so that you know YES occurs at index 25 in the string given, I'll use my PSI::ESP module and guess that you've read in lines of data into an array (@arr), and that the YES string is supposed to occur at the end of that line and you haven't chomped the newline off the end of the line -- thus you are trying to compare "YES\n" eq "YES". If this guess sounds right, try doing a chomp $contact_me; prior to your inner conditional test as in:

#!/usr/bin/perl -w use strict; my @arr = <DATA>; my $contact_me_count = 0; for my $lcv (0 .. $#arr){ if($arr[$lcv] =~ /^CONTACT_ME:/){ my $contact_me = substr("$arr[$lcv]", 25); chomp $contact_me; if($contact_me eq 'YES'){ $contact_me_count ++; } } } print $contact_me_count; __DATA__ CONTACT_ME: YES CONTACT_ME: NO

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-04-19 16:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found