Ok sorry for my habit i include strict and warning when i wrote here! This is my code and now isn't running!

use strict; use warnings; use Data::Dumper; my $mio2; my $mio; my $line; my $line2; my $words; my $words2; my $i=0; my %go_accession_hash=(); open (FILE, "/Users/Pabli/Desktop/gene_association.goa_human"); open (FILE2, "/Users/Pabli/Desktop/go3.obo"); while(<FILE>) { my @array_with_all_fields=split(/\t/); if ($array_with_all_fields[2] eq "TP53"){ $mio=$array_with_all_fields[4]; open my $out_file, '>>', 'myoutputfilename.txt' or die "$!"; #print "".$mio."\n"; print $out_file $mio; # print to file } #print "".$mio."\n"; #} #%go_accession_hash=($mio,''); #my @test2= keys %go_accession_hash; #print "".$test2[0]."\n"; #print "".$mio."\n"; } open (FILE3, "/Users/Pabli/Documents/workspace/PerlProva/myoutputfilen +ame.txt"); while($line=<FILE2>){ $words2 = split(" ",$line); print "$words2[1]\n"; $i=2; while($line2=<FILE3>){ $i = $i - 1; if ($i >= 0) { $words = split(" ",$line2); #print $words[0]."\n"; } $mio2=$words[0]; #print "$words2[1]\n"; #print $words[0]."\n"; } #print "$words2[1]\n"; #print $words[0]."\n"; #$line= split(/\s+/); #if ($words2[0] eq "id:") { #$mio4=$words2[1]; #print $mio4."\n"; # } #elsif ($words2[0] eq "name:"){ #if ($mio4 == $mio2){ #print "name: ".$words2[1]."\n"; #} #} #} } close FILE; close FILE2; close FILE3;

The error is about "words" and "words2". The program needs global declaration i think so (i did it at first row) but i don't know the way to do it. Thanks

In reply to Re^4: While problem by pabla23
in thread While problem by pabla23

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.