Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: non numeric data

by blue_cowdawg (Prior)
on Jun 24, 2013 at 12:53 UTC ( #1040428=note: print w/ replies, xml ) Need Help??


in reply to non numeric data

      but somehow if loop block is visited even if data is numeric

First off you are not doing an apples to apples comparison in your conditional. Secondly you are trying to do pattern matching in a dubious fashion. Check out the following:

$ cat torres09.pl #!/usr/bin/perl -w use strict; while(my $line=<DATA>){ chomp $line; if ( $line =~ m/^\d+$/){ printf "%s\n",$line; } } exit(0); __END__ 0123 0444 A123 $ perl torres09.pl 0123 0444


Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg


Comment on Re: non numeric data
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-07-29 10:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (213 votes), past polls