Randy_j53 has asked for the wisdom of the Perl Monks concerning the following question:
The above works, but I need to print the variable later in my code. When I try to print the variable $public_key_type outside the block the variable becomes empty. Does anyone have a suggestion on how I can keep the data in the variable once it leaves the block?====================================================== if ( $line =~ /^Public Key Type:/ ) { $public_key_type = scalar <DATA> for 1; $public_key_type =~ s/^\s+//; $public_key_type =~ s/\s+$//; $public_key_type = "$public_key_type"; $public_key_type =~ s/\R//g; print "$public_key_type\n"; } ======================================================
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: variable has value but then become empty
by stevieb (Canon) on Sep 09, 2015 at 14:04 UTC | |
by AnomalousMonk (Archbishop) on Sep 09, 2015 at 16:19 UTC | |
|
Re: variable has value but then become empty
by 1nickt (Canon) on Sep 09, 2015 at 14:09 UTC | |
| |
|
Re: variable has value but then become empty
by locked_user sundialsvc4 (Abbot) on Sep 09, 2015 at 14:44 UTC |