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. > >Ohhhhhhh... Slick. Can I use () or perhaps even [] as well?
Indeed, and <> too. Those are the four pairs of, err, pairing delimiters. The others (like / and % and !) match themselves. And you'll notice that I didn't have to \ the {'s and }'s inside the code. That's because when using paired delimiters, you can nest them (properly) without distress. Any of them that WOULD disrupt the nesting DO need to be backslashed. > 63 sub parseit > 64 { > 65 my ($t,$u) = @_ ; > 66 my %template = %$t ; > 67 my %userdata = %$u ; > 68 my $body = > 69 $userdata{flag} ? > 70 $template{HTML} : $template{ASCII} ; > 71 my $keys = join('|',map(quotemeta,keys(%userdata))) ; > 72 $body =~ s/#($keys)#/$userdata{$1}/g ; > 73 return $body ; > 74 } Nicely done. >and works dandily :-) I could probably clean up the two hashes I send to >parseit. Hey, I wonder if > > my ($template{ASCII},$template{HTML}, > $userdata{flag},$userdata{EMAIL},$userdata{NAME_FIRST}, > $userdata{NAME_LAST}) = @row > >because each of those is a single value... Sadly, no, but you're close. You can't use my() on a PART of a hash or array. You'd have to declare the hashes first, and then populate them. my (%tmplate, %userdata); ( @template{qw(ASCII, HTML)}, @userdata{qw(flag EMAIL NAME_FIRST NAME_LAST)}, ) = @row; That's perfectly fine; use it if you feel it cuts down on clutter and is still comprehensible. I'd like to say that it's a pleasure helping you. You know what you want to do, you know how to explain it, you show your code, you're receptive to advice and pointers to documentation, and you have a very good attitude. Thank you for making my Perl day more bearable. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]