I want to do something along the lines of
#! perl -w scipt use strict; use warnings; # open a file for reading in the current directory open(FILEHANDLE,"< input_file.txt"); open(OUTFILE,"+> outfile_file.txt"); my $record_count = 0; while (<FILEHANDLE>){ if ($_ =~ /^(\d{1,5})\s+ (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} (?:([A-Z0-9()-]{2,15})\s+([A-Z0-9()-]{7})){0,1} $/gx){ $record_count++; my $1st = $1; my $2st = $2; my $3st = $3; my $4st = $4; my $5st = $5; my $6st = $6; my $7st = $7; my $8st = $8; my $9st = $9; my $10st = $10; my $11st = $11; my $12st = $12; my $13st = $13; my $14st = $14; my $15st = $15; my $16st = $16; my $17st = $17; my $18st = $18; my $19st = $19; my $20st = $20; my $21st = $21; my $22st = $22; my $23st = $23; my $24st = $24; my $25st = $25; my $26st = $26; my $27st = $27; my $28st = $28; my $29st = $29; my $30st = $30; my $31st = $31; my $32st = $32; my $33st = $33; my $34st = $34; my $35st = $35; my $36st = $36; my $37st = $37; my $38st = $38; my $39st = $39; my $40st = $40; my $41st = $41; my $42st = $42; my $43st = $43; my $44st = $44; my $45st = $45; my $46st = $46; my $47st = $47; my $48st = $48; my $49st = $49; my $50st = $50; my $51st = $51; my @array_of_gene_records = ($2st, $3st, $4st, $5st, $6st, $7st, + $8st, $9st, $10st, $11st, $12st, $13st, $14st, $15st, $15, $16st, $1 +7st, $18st, $19st, $20st, $21st, $22st, $23st, $24st, $25st, $26st, $ +27st, $28st, $29st, $30st, $31st , $32st , $33st, $34st, $35st, $36st +, $37st, $38st, $39st, $40st, $41st, $42st, $43st, $44st, $45st, $46s +t, $47st, $48st, $49st, $50st, $51st); my $subrecord_id = 1; foreach (@array_of_gene_records){ print OUTFILE "$record_count\t$1st\t$subrecord_id\t$_\n"; $subrecord_id++; } } }

In reply to Re^2: Perl Regex by Anonymous Monk
in thread Perl Regex by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.