CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [johnny241088] Problems at searching and counting: Edit Log



7stud
Enthusiast

Jan 15, 2013, 11:19 PM


Views: 1001
Re: [johnny241088] Problems at searching and counting

Your code should look like this:


Code
use strict;  
use warnings;
use 5.012;

open my $INFILE, "<", 'data.txt'
or die "Couldn't open data.txt: $!";

my %results;

while (my $line = <$INFILE>) {
if ($line =~ /exon \s* (\d{4}) /xms) {
push @{$results{$1}}, $line;
}
}

while ( my($key, $array_ref) = each %results) {
my @arr = @{$array_ref};

if (@arr > 1) {
for (@arr) {
print;
}
}
}

However, that program is way too complicated for you at this point. You have not learned the basics of modern perl programming yet. You need to read a beginning perl book before proceeding any further. There are no short cuts when learning computer programming. Whatever you are currently using to learn perl, you should abandon.


(This post was edited by 7stud on Jan 15, 2013, 11:31 PM)


Edit Log:
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:20 PM
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:21 PM
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:22 PM
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:23 PM
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:26 PM
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:28 PM
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:29 PM
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:30 PM
Post edited by 7stud (Enthusiast) on Jan 15, 2013, 11:31 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives