On Thu, 3 Jan 2002, Pam Derks wrote:

> I've been trying to understand program 6.21 in the Perl Cookbook, which changes URLs 
>to html links
>  here's a snippet:
>
>  #!/usr/bin/perl
>
>  $urls = '{http|telnet|gopher|file|wais|ftp');
>  $ltrs = '\w';
>  $gunk = '/#~:.?+=&%!\-';
>  $punc = '.:?@\-';
>  $any = "${ltrs}${gunk}${punc}";
>
>  I understand what $any is, but
>  what exactly is ${ltrs}  or ${gunk}  ??
>  is this an anonymous hash
>

It's a "not too common", but sometimes necessary, way to write a
variable.

${gunk} is the same as $gunk

${ltrs} is the same as $ltrs.

imagine this scenario:

let's say I have variable $file_name which has a filename in it
(useful_commands.txt).

And I want to rename it to include my username or something:

chris_useful_commands.txt

I could say:

my $new_filename = "${user_name}_${file_name}";

I could also say:

my $new_filename = $user_name . "_" $file_name;

what's the difference?  TMTOWTDI..


hope that helps,

Chris


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to