in reply to Strings with undefined variables?

What you need is a "template". For a simple one, you can use String::Interpolate, but there are many more, some even implementing loops and template inheritance.
#! /usr/bin/perl use warnings; use strict; use String::Interpolate; my $template = 'String::Interpolate'->new; $template->('http://something.com/api_stuff/$GUID'); make_call( '1234' ); sub make_call { my $GUID = shift; $template->{GUID} = $GUID; POST("$template"); } use Test::More; sub POST { is shift, 'http://something.com/api_stuff/1234', 'intepolates'; } done_testing();

The same using Template:

#! /usr/bin/perl use warnings; use strict; use Template; my $template = 'http://something.com/api_stuff/[%GUID%]'; make_call( '1234' ); sub make_call { my $GUID = shift; my $template_object = 'Template'->new; $template_object->process(\$template, {GUID => $GUID}, \ my $outpu +t); POST($output); } use Test::More; sub POST { is shift, 'http://something.com/api_stuff/1234', 'intepolates'; } done_testing();
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Strings with undefined variables?
by 23skiddoo (Beadle) on Jan 04, 2019 at 13:00 UTC
    Thanks! I'll check it out, but it may prove to be more overhead than I want for this application. Good to know in general, though.
    fnord