http://www.perlmonks.org?node_id=1020413

Balaton has asked for the wisdom of the Perl Monks concerning the following question:

Could anybody please help me why I got this error message? Use of uninitialized value $_[0] in pattern match (m//) at ModuleMatching.pm line 11, <> line And this is the line I am matching LOCUS AB007147 460 bp DNA linear PRI 08-FEB-2002 it worked without the subroutine. Thanks a lot! Here is the code: ##########################################
use lib "/d/user2/aszend01/BCII/240213"; use ModuleMatching; my $locus_acc_no; while (my $line = <>) { # locus_acc_no if ($line =~ ModuleMatching::MatchLAC($locus_acc_no)) { unless (ModuleMatching::MatchLAC($locus_acc_no)){ print "something is wrong with the matching", "\n"; next; } } print $locus_acc_no, "\n"; } # This module will be called from the myparserM.pl. It will pull out t +he locus_acc_no. package ModuleMatching; use strict; # Here are the matchig code for the locus_acc_no (LAC) sub MatchLAC($) { return $_[0] =~ /^LOCUS\s{7}(\w+)\s+\w+/; } 1;
######################################################### And here is the file I want to do the matching: ####################################################### LOCUS AB007147 460 bp DNA linear PRI 08-FEB-2002 DEFINITION Homo sapiens gene for ribosomal protein S2, partial cds. ACCESSION AB007147 VERSION AB007147.1 GI:3077742 KEYWORDS ribosomal protein S2. SOURCE Homo sapiens (human) ORGANISM Homo sapiens Eukaryota; Metazoa; Chordata; Craniata; Vertebrata; Euteleostomi; Mammalia; Eutheria; Euarchontoglires; Primates; Haplorrhini; Catarrhini; Hominidae; Homo. REFERENCE 1 AUTHORS Kenmochi,N., Kawaguchi,T., Rozen,S., Davis,E., Goodman,N., Hudson,T.J., Tanaka,T. and Page,D.C. TITLE A map of 75 human ribosomal protein genes JOURNAL Genome Res. 8 (5), 509-523 (1998) PUBMED 9582194 REFERENCE 2 (bases 1 to 460) AUTHORS Kenmochi,N. TITLE Direct Submission JOURNAL Submitted (10-SEP-1997) Naoya Kenmochi, Miyazaki Medical College, Central Research Laboratories; 5200 Kihara, Kiyotake, Miyazaki 889-1692, Japan (E-mail:kenmochi@post.miyazaki-med.ac.jp, Tel:81-985-85-9665, Fax:81-985-85-1514) FEATURES Location/Qualifiers source 1..460 /organism="Homo sapiens" /mol_type="genomic DNA" /db_xref="taxon:9606" /chromosome="16" /map="16p13.3" CDS join(<1..73,300..>460) /codon_start=1 /product="ribosomal protein S2" /protein_id="BAA25813.1" /db_xref="GI:3088335" /translation="LLMMAGIDDCYTSARGCTATLGNFAKATFDAISKTYSYLTPDLW KETVFTKSPYQEFTDHLVKTHTRVSVQRTQAPAV" exon <1..73 /product="ribosomal protein S2" intron 74..299 exon 300..>460 /product="ribosomal protein S2" ORIGIN 1 ctgctcatga tggctggtat cgatgactgc tacacctcag cccggggctg cactgccacc 61 ctgggcaact tcggtaggtg gtccacacat ggggcatagc catggtctct cagctccgct 121 taaccacacg ggtccagtgt gtgcttggcg tgttttcagg gaggcagaga aaggctctcc 181 taatgnacga cagacccgcc cagaatggcc tctctgttcc taggagtgcg acaatttttg 241 ggttggggga cttgcctcaa gcacaccact gaccctcctg gggttctttt gttttgcagc 301 caaggccacc tttgatgcca tttctaagac ctacagctac ctgacccccg acctctggaa 361 ggagactgta ttcaccaagt ctccctatca ggagttcact gaccacctcg tcaagaccca 421 caccagagtc tccgtgcagc ggactcaggc tccagctgtg //