I want to know how can I encapsulate the result(substr($text, 12)) of the variable $opt into itself(put the result replacing the expression substr($text, 12)), but how I can do this?
If needed. Here is my code:
my $text;
my $opt = substr($text, 12);
if ($command =~ /^Hello World Application/i) {
print "$opt\n";
}
# More code....
print # Here I want to print the result of 'substr($text, 12)' in the if
I think you want to create an anonymous subroutine that captures the behaviour and references that you want but you don’t run until you need it: