If you had read my previous post. You would've written (which was mostly written for you) a simple test program.
use strict; use warnings; my @lines = ( '012345 NA13333 C C', '012345 NA13334 F F', '012345 NA13335 E F', '012346 NA13333 U U', '012346 NA13334 I I', '012346 NA13335 Y O'); foreach my $line (@lines) { next unless $line =~ m{^(\S+) NA(\d+) (.*)}; my ($site, $userID, $data) = ($1, $2, $3); print "SITE: $site USER: $userID DATA: $data\n"; }
Then you would've seen output like this:
SITE: 012345 USER: 13333 DATA: C C SITE: 012345 USER: 13334 DATA: F F SITE: 012345 USER: 13335 DATA: E F SITE: 012346 USER: 13333 DATA: U U SITE: 012346 USER: 13334 DATA: I I SITE: 012346 USER: 13335 DATA: Y O
This would've shown you the regex is no longer the problem and you could've started looking for the real problem and posted pertenent information, instead of posting the code you already posted.

Some problems you have not addressed from my original post:

next unless $line =~ m{^(\S+) (\d+) (.*)}; my ($site, $userID, $data, $data2) = ($1, $2, $3, $4); # you have 3 capturing paran's but you try to call $4 # your 2 data columns get folded together in $3 because of your gree +dy .* $user{$userID}{$site} = $data, $data2; # $data2 is useless and I think you are trying to use an array ref # but that is not what you are doing [ ] signifies an array ref
The rest of your code has several problems. Print out the %user hash with Data::Dumper and then fix your code.
print Dumper \%user;


grep
One dead unjugged rabbit fish later

In reply to Re^5: Modifying a regex by grep
in thread Modifying a regex by seni

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.