Hi im trying to use regular expression to capture the digits on my data stored on a file that contains alphanumeric data and store the output to a different file. I am not getting any errors and the size of my output file has increased after execution but do not see any data.
#!/usr/bin/perl
open (FILE, 'name.tsv');
open (OFILE, '>probe_dist.tsv');
while (<FILE>) {
my $name = (FILE=~ m/:(\d+)/);
print OFILE "$name\n";
}
close (FILE);
exit;
my input data contains rows like this below
chr1:4775792-4775851
chr1:4775842-4775901
chr1:4775852-4775911
chr1:4775902-4775961
chr1:4775952-4776011
chr1:4776002-4776061
chr1:4776052-4776111
chr1:4776102-4776161
chr1:4776212-4776271
chr1:4776252-4776311
chr1:4776302-4776361
chr1:4776352-4776411
chr1:4776402-4776461
chr1:4776452-4776511
chr1:4776502-4776561
chr1:4777032-4777091
chr1:4777082-4777141
My idea is to print the first occurrence of all the continuous digits in my file.
pls help
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.