title: how to pass a variable to different if statement
body: <p>I'm really confused about how to pass a variable into different statement. My code is:</p>
  
  <pre><code>use warnings;
  use strict;
  use feature qw(say);
  
  say "Please enter the first sequence:";
  my $sequence1 = &lt;STDIN&gt;;
  $sequence1 = chomp $sequence1;
  say "Please enter the second sequence:";
  my $sequence2 = &lt;STDIN&gt;;
  $sequence2 = chomp $sequence2;
  
  if (length $sequence1 &lt; length $sequence2){
          my $sequence2_new = substr $sequence2, length $sequence1;
  }
  
  my @sequence1 = split(',', $sequence1);
  my @sequence2 = split(',', $sequence2_new);
  my $element = scalar @sequence1;
  
  my $num = 0;
  for ($a = 0; $a &lt; $element; $a++){
          if ($sequence1[$a] = $sequence2[$a]){
                  $num++;
          }
  }
  
  my $score = $num % length $sequence2;
  say "The alignment score is: $score";
  </code></pre>
  
  <p>In this case, this program will return a <code>Global symbol "$sequence2_new" requires explicit package name at alignment_sequence.pl line 19.</code>mistake. If I move the "my" declaration in front of if statement in line 14 like <code>my $sequence2_new;</code> it will give me <code>Use of uninitialized value $sequence2_new in split at alignment_sequence.pl line 20, &lt;STDIN&gt; line 2.</code> warning.</p>