-----Original Message----- From: joseph [mailto:[EMAIL PROTECTED] Sent: Thursday, July 20, 2006 6:45 PM To: beginners@perl.org Subject: Re: check existence of element in a list
> > s/\s+$// foreach @pclist; > s/\s+$// foreach @smsclient; > > instead of using chomp(). If this also fails, then try removing leading > whitespace as well with > > s/^\s+// foreach @pclist; > s/^\s+// foreach @smsclient; > > and if it's still not working, print out the invisible contents of the > string > to see where they differ. An easy way is: > > use URI::Escape; > print uri_escape($_), "\n" foreach @pclist; > > if you have that module installed. If it gets this far and you don't have > the > module then come back here for alternatives. I have known Windows > utilities > output their reports in UTF16 but I don't think net does this. > > Rob Hi Rob, Thanks for your invaluable help. Your first option work without any glitch, now for my learning may is ask a pointer for resources where could i learn the trailing of a particular line in a file? e.g for windows <CTRL><LF>/linux \n? I also tried to search by ppm the module you mention but it wasn't listed there. ************************************************************************ ***** >From Perl Best Practices on page 71 and 72 it recommends using the function any() from the module List::MoreUtils. "The function any returns true value as soon as any of the values causes its test block to succeed. This is an efficient general solution for testing list membership b/c you can put any kind of equivalence test in the block" ## Is the index already taken? my @allocated_slots = (); my $requested_slot = 0; if ( any {$requested_slot == $_} @allocated_slots ) { print "Slot already taken:", $requested_alot; } _________________________________________________ This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited. Dansk - Deutsch - Espanol - Francais - Italiano - Japanese - Nederlands - Norsk - Portuguese - Svenska: www.cardinalhealth.com/legal/email -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>