<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<blockquote cite="mid:471E932A.703@perltraining.com.au" type="cite">
  <blockquote type="cite">
    <pre wrap="">#&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; CUT HERE &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
#!/usr/bin/perl -w
#
use strict;
use warnings;

sub get_name_1
{
    my ( $n, $backfill ) = @_;

    my $job_name = "backfill_" if $backfill;
    </pre>
  </blockquote>
  <pre wrap=""><!---->
This line above is like writing:

        my $a if $b;

So the lexical variable $a only springs into existence if $b is true.  Therefore
(since $backfill isn't true)
  </pre>
</blockquote>
why is it the same?<br>
<br>
The "my $job_name" should be an isolated statement due to the "="
operator, ie: an lvalue is being created.<br>
Thus "my $a if $b" doesn't have a lvalue until the "if" is true.<br>
<br>
<blockquote cite="mid:471E932A.703@perltraining.com.au" type="cite">
  <blockquote type="cite">
    <pre wrap="">    $job_name .= "migrate_$n";
    </pre>
  </blockquote>
  <pre wrap="">
this must be the global $job_name; hence the behaviour you see.  There is a
(lame) excuse for why you don't get strict errors and warnings, but I don't
remember what it is, and personally I think it's a bug.
  </pre>
</blockquote>
In any case $job_name would be undef on the first iteration, whether it
was global or local scoped.&nbsp; I'd be interested to know why a warning
isn't produced?<br>
<br>
cheers,<br>
Mathew<br>
<br>
</body>
</html>