Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: handling files using regular expression

by sundialsvc4 (Abbot)
on Jun 28, 2013 at 15:37 UTC ( #1041274=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    perl -e 'my $str = "chr1:4777082-4777141"; \
      my ($foo) = $str =~ /([0-9]+)/; print "foo is $foo\n";'
    ...
    foo is 4777082
    
    ... correct.
    
  2. or download this
    while (my $str = <INFILE>) {
      my ($foo) = $str =~ /[:]([0-9]+)/;  # WE TESTED THIS
    ...
        unless ($foo);   # NEVER ASSUME, NEVER ASSUME
      print OUTFILE "FILE=$foo\n";  # NOTICE DOUBLE-QUOTES
    }
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-12-20 02:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls