Hello friends,
I have a simple program I've written that is going through and parsing some data for me....sort of. The way I've coded it, I'm pulling out a unique part of each line by which to classify a group of lines and therefore separate them (this will make a bit more sense as you check the code I hope). This unique portion-in this case the target name (ATH1121501:244901 in the input as you'll see)of 244901-is what I am pattern matching each of the next lines against. If a line comes up that does not match this, then I want the new target name to be extracted and become the value of $target_name. All the next lines of the input file will be matched against this, etc, until the end of the file. However, this isn't occuring; $target_name does not change in the program, even though the target name in the input data does. Help??
#! C:\Perl\bin\perl ######################################################### # probe.pl- converts affy probe set files to excel files# # by D. Newkirk on 9/9/03 # ######################################################### use strict; use warnings; print STDOUT 'Please state the file containing the probes: '; chomp(my $input=<STDIN>); open (INPUT, "$input")or die "Cannot open file: $!"; print STDOUT 'Please name the output file: '; chomp(my $output=<STDIN>); open (OUTPUT, ">$output")or die "Cannot open file: $!"; $_=<INPUT>; my ($target_name, %probes); $target_name=$1 if m[:(\d{6})_]x; #print "$target_name\n"; do { if ($_=~ m/$target_name/) { chomp(my $probe=<INPUT>); if ($probe=~ /^(\w{20})/) {print "$probe\n"; push @{$probes{$target_name}}, $probe; } } if ($_ !=~ [$target_name]) { $_= m[:(\d{6})_]x; $target_name=$_; print "$target_name\n"; } }until eof INPUT; for $target_name(sort{@{probes{$b}}<=>@{probes{a}}}keys %probes) { print OUTPUT "$target_name, ", join(", ", sort @{$probes{$target_n +ame}}), "\n"; } close (INPUT); close (OUTPUT); exit; _input_ >probe:ATH1-121501:244901_at:594:703;Interrogation_Position=56;Antisen +se;TTGCTGCTATTCTATCTATTTGTGC Times 11 >probe:ATH1121501:244902_at:522:511;Interrogation_Position=153;Antisen +se; GGTATTTTCCGTTTCTTCGGATGAT Times 11 _output_ 244901, AACACTTACAAATGCCACTTCTTCC, AGCAATTTGCCTACTCTTGTATCTC, AGCTGTGA +ATTCGAACTTTTTGGTA, ATATTCCTATTATGTCAATGCCAAT, CCAACGGTGGCAGCTGCGGAATC +CG, GAAGAATCGCAGCAATTCCCCAATC, GAAGTAGTTCCTCCGGAATCCAATG, GACTTTCAAAG +TGACTCTCGACGGG, GAGCCTCCAGGCTATTCAGGAAGAA, GAGTCCGAGGTACTATTGCTGTAGA, + GATGGGTCAAGTATTTGCTTCATTG, GCAAGCTTTGTTATGCCGAAACCTA, GCGGAATCCGCTAT +TGGGTTAGCCA, GGTATTTTCCGTTTCTTCGGATGAT, GTATTCGGGGAATCCTCCTTAATAG, GT +CGCATCCGTTTTCAGGACGATCT, TAACTTTCCGAGTCCGAGGTACTAT, TAGCCATTTTCGTTATA +ACTTTCCG, TCAGCTTGCGAATTTGTGGCACCGT, TGCTTCATTGGTTCCAACGGTGGCA, TTACC +AATGGCACGCTGTGCGCCTA, TTGCTGCTATTCTATCTATTTGTGC
Everything else about the output is fine.
Thanks!!!!!!!

Bioinformatics

In reply to Why is it matching?? by bioinformatics

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.