in reply to Re: Re: about scope and s///eeg
in thread about scope and s///eeg
As coded above I get the output#!/usr/bin/perl -w use strict; use warnings; my $var_one; $var_one = 'now defined'; sub copy_file { while( my $x = <DATA>) { $x =~ s|(\$\w+)|$1|eeg; print $x; }; } copy_file(); __DATA__ The variable is $var_one.
The variable is now defined.If I comment out the $var_one = I see
Use of uninitialized value in substitution iterator at anon02.pl line 12, <DATA> line 1. The variable is .Any chance the variable name is misspelled in the text file? When I tried the following data:
__DATA__ The variable is $var_one. The variable is $var_one2. The variable is $Var_one.I got error messages:
The variable is now defined. Use of uninitialized value in substitution iterator at anon02.pl line 14, <DATA> line 2. The variable is . Use of uninitialized value in substitution iterator at anon02.pl line 14, <DATA> line 3. The variable is .
|
|---|