in reply to Evaluate variable while using
I'm not sure how to achieve this.
The How depends mostly on the Why - and you have not explained that. This is probably an XY Problem.
One solution is a closure.
#!/usr/bin/env perl use strict; use warnings; my $x; sub greeting { my $str = 'Hello ' . $x; print $str . "\n"; } $x = 'Kevin'; greeting (); $x = 'chickenman'; greeting ();
🦛
|
|---|