Re: using a hash for lots of replacements

2003-08-17 Thread Jeff 'japhy' Pinyan
On Aug 17, David T-G said: >Hmmm... Well, it wasn't happy. I got the assignment right, it seems, >but then I can't use it: > > 43 while ( my @row = $result->fetchrow_array ) > 44 { [snip] > 52 my (%template,%userdata) ;# we must predefine > if we're to

Re: using a hash for lots of replacements

2003-08-17 Thread David T-G
Jeff, et al -- ...and then Jeff 'japhy' Pinyan said... % % On Aug 17, David T-G said: % % >% Yes. I'm using s{}{} instead of s///. I prefer the use of {} delimiters % >% when I'm doing a s///e, because it better represents the "code" aspect of % >% the replacement. % > % >Ohhh... Slick.

Re: using a hash for lots of replacements

2003-08-17 Thread Jeff 'japhy' Pinyan
On Aug 17, David T-G said: >% Yes. I'm using s{}{} instead of s///. I prefer the use of {} delimiters >% when I'm doing a s///e, because it better represents the "code" aspect of >% the replacement. > >Ohhh... Slick. Can I use () or perhaps even [] as well? Indeed, and <> too. Those are

Re: using a hash for lots of replacements

2003-08-17 Thread David T-G
Jeff, et al -- ...and then Jeff 'japhy' Pinyan said... % % On Aug 17, David T-G said: % % >% That's good of you to show how you'd do it in another language (yes, even % >% if that language is PHP ;) ), because it clears up what you want to do. % > % >Indeed. It was the most succinct way to expl

Re: using a hash for lots of replacements

2003-08-17 Thread Jeff 'japhy' Pinyan
On Aug 17, David T-G said: >% That's good of you to show how you'd do it in another language (yes, even >% if that language is PHP ;) ), because it clears up what you want to do. > >Indeed. It was the most succinct way to explain it :-) This list (and many others) often receives questions about

Re: using a hash for lots of replacements

2003-08-17 Thread David T-G
Jeff, et al -- ...and then Jeff 'japhy' Pinyan said... % % On Aug 17, David T-G said: % % > my $string = "Hello, #NAME_FIRST# #NAME_LAST# from #STATE#!" ; ... % > my %xlate = ... % >instance, in php, I would write something like % > % > $fields = array('#NAME_FIRST#','#NAME_LAST#','#STATE#')

Re: using a hash for lots of replacements

2003-08-17 Thread Jeff 'japhy' Pinyan
On Aug 17, David T-G said: > my $string = "Hello, #NAME_FIRST# #NAME_LAST# from #STATE#!" ; > >and I want to replace those chunks each with another string, what is a >good way to approach that? I'd love to use something like > > my %xlate = > ( >NAME_FIRST => "David", >NAME_LAST => "T-