From joel at fentin.com Sun Mar 9 00:31:57 2003 From: joel at fentin.com (Joel Fentin) Date: Thu Aug 5 00:20:45 2004 Subject: dereference question Message-ID: <000401c2e605$e2314560$b1843f42@6540q01> ~sdpm~ open(INFILE, ") { $_ =~ s/\$D/${\$D}/g; #line 1 $_ =~ s/\$D/$D/g; #line 2 print; } close(INFILE); In my application, both line 1 and line 2 seem to do the same job, thus revealing the value contained within. But they won't work for $E or $F. Is there a line of code which will apply to all referenced scalars that are read in from the file? -- Joel Fentin tel: 760-749-8863 FAX: 760-749-8864 email: joel@fentin.com Biz: http://fentin.com Personal: http://fentin.com/me/ ~sdpm~ The posting address is: san-diego-pm-list@hfb.pm.org List requests should be sent to: majordomo@hfb.pm.org If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe san-diego-pm-list If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human. From merlyn at stonehenge.com Sun Mar 9 09:05:51 2003 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Thu Aug 5 00:20:45 2004 Subject: dereference question In-Reply-To: <000401c2e605$e2314560$b1843f42@6540q01> References: <000401c2e605$e2314560$b1843f42@6540q01> Message-ID: <867kb8fuls.fsf@red.stonehenge.com> ~sdpm~ >>>>> "Joel" == Joel Fentin writes: Joel> In my application, both line 1 and line 2 seem to do the same job, thus Joel> revealing the value contained within. But they won't work for $E or $F. Is Joel> there a line of code which will apply to all referenced scalars that are Joel> read in from the file? Hmm. Sounds like a FAQ to me. Did you check the FAQs first? -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! ~sdpm~ The posting address is: san-diego-pm-list@hfb.pm.org List requests should be sent to: majordomo@hfb.pm.org If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe san-diego-pm-list If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human. From rkleeman at energoncube.net Sun Mar 9 09:13:26 2003 From: rkleeman at energoncube.net (Bob Kleemann) Date: Thu Aug 5 00:20:45 2004 Subject: dereference question In-Reply-To: <000401c2e605$e2314560$b1843f42@6540q01> References: <000401c2e605$e2314560$b1843f42@6540q01> Message-ID: <20030309151326.GA4565@energoncube.net> ~sdpm~ s/\$(\w+)/${$1}/; Keep in mind though that this can be abused. Make sure you know you can really trust what's in INFILE. Also, it appears that you are working on a simplistic templating system. Have you considered using one of the pre-built systems already available? On Sat, Mar 08, 2003 at 10:31:57PM -0800, Joel Fentin wrote: > ~sdpm~ > open(INFILE, " while() > { > $_ =~ s/\$D/${\$D}/g; #line 1 > $_ =~ s/\$D/$D/g; #line 2 > print; > } > close(INFILE); > > In my application, both line 1 and line 2 seem to do the same job, thus > revealing the value contained within. But they won't work for $E or $F. Is > there a line of code which will apply to all referenced scalars that are > read in from the file? > -- > Joel Fentin tel: 760-749-8863 FAX: 760-749-8864 > email: joel@fentin.com > Biz: http://fentin.com > Personal: http://fentin.com/me/ > > > ~sdpm~ > > The posting address is: san-diego-pm-list@hfb.pm.org > > List requests should be sent to: majordomo@hfb.pm.org > > If you ever want to remove yourself from this mailing list, > you can send mail to with the following > command in the body of your email message: > > unsubscribe san-diego-pm-list > > If you ever need to get in contact with the owner of the list, > (if you have trouble unsubscribing, or have questions about the > list itself) send email to . > This is the general rule for most mailing lists when you need > to contact a human. ~sdpm~ The posting address is: san-diego-pm-list@hfb.pm.org List requests should be sent to: majordomo@hfb.pm.org If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe san-diego-pm-list If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human. From joel at fentin.com Sun Mar 9 10:51:16 2003 From: joel at fentin.com (Joel Fentin) Date: Thu Aug 5 00:20:45 2004 Subject: dereference question References: <000401c2e605$e2314560$b1843f42@6540q01> <867kb8fuls.fsf@red.stonehenge.com> Message-ID: <002b01c2e65c$1aa50fc0$c4843f42@6540q01> ~sdpm~ > Joel> In my application, both line 1 and line 2 seem to do the same job, thus > Joel> revealing the value contained within. But they won't work for $E or $F. Is > Joel> there a line of code which will apply to all referenced scalars that are > Joel> read in from the file? > > Hmm. Sounds like a FAQ to me. Did you check the FAQs first? I tried everything I could think of. I read everything I could think of. Which specific FAQ do you have in mind? -- Joel Fentin tel: 760-749-8863 FAX: 760-749-8864 email: joel@fentin.com Biz: http://fentin.com Personal: http://fentin.com/me/ ~sdpm~ The posting address is: san-diego-pm-list@hfb.pm.org List requests should be sent to: majordomo@hfb.pm.org If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe san-diego-pm-list If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human. From merlyn at stonehenge.com Sun Mar 9 10:56:27 2003 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: Thu Aug 5 00:20:45 2004 Subject: dereference question In-Reply-To: <002b01c2e65c$1aa50fc0$c4843f42@6540q01> References: <000401c2e605$e2314560$b1843f42@6540q01> <867kb8fuls.fsf@red.stonehenge.com> <002b01c2e65c$1aa50fc0$c4843f42@6540q01> Message-ID: <86bs0keax0.fsf@red.stonehenge.com> ~sdpm~ >>>>> "Joel" == Joel Fentin writes: Joel> In my application, both line 1 and line 2 seem to do the same job, Joel> thus Joel> revealing the value contained within. But they won't work for $E or Joel> $F. Is Joel> there a line of code which will apply to all referenced scalars that Joel> are Joel> read in from the file? >> >> Hmm. Sounds like a FAQ to me. Did you check the FAQs first? Joel> I tried everything I could think of. I read everything I could think of. Joel> Which specific FAQ do you have in mind? $ perldoc -tq variables Found in /usr/libdata/perl5/pod/perlfaq4.pod How can I expand variables in text strings? Let's assume that you have a string like: $text = 'this has a $foo in it and a $bar'; If those were both global variables, then this would suffice: $text =~ s/\$(\w+)/${$1}/g; # no /e needed But since they are probably lexicals, or at least, they could be, you'd have to do this: $text =~ s/(\$\w+)/$1/eeg; die if $@; # needed /ee, not /e It's probably better in the general case to treat those variables as entries in some special hash. For example: %user_defs = ( foo => 23, bar => 19, ); $text =~ s/\$(\w+)/$user_defs{$1}/g; See also ``How do I expand function calls in a string?'' in this section of the FAQ. Found in /usr/libdata/perl5/pod/perlfaq7.pod How can I catch accesses to undefined variables/functions/methods? The AUTOLOAD method, discussed in "Autoloading" in perlsub and "AUTOLOAD: Proxy Methods" in perltoot, lets you capture calls to undefined functions and methods. When it comes to undefined variables that would trigger a warning under "-w", you can use a handler to trap the pseudo-signal "__WARN__" like this: $SIG{__WARN__} = sub { for ( $_[0] ) { # voici un switch statement /Use of uninitialized value/ && do { # promote warning to a fatal die $_; }; # other warning cases to catch could go here; warn $_; } }; -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! ~sdpm~ The posting address is: san-diego-pm-list@hfb.pm.org List requests should be sent to: majordomo@hfb.pm.org If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe san-diego-pm-list If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human. From joel at fentin.com Mon Mar 10 11:56:30 2003 From: joel at fentin.com (Joel Fentin) Date: Thu Aug 5 00:20:45 2004 Subject: dereference question References: <000401c2e605$e2314560$b1843f42@6540q01><867kb8fuls.fsf@red.stonehenge.com><002b01c2e65c$1aa50fc0$c4843f42@6540q01> <86bs0keax0.fsf@red.stonehenge.com> Message-ID: <000001c2e734$555143e0$11813f42@6540q01> ~sdpm~ > Joel> I tried everything I could think of. I read everything I could think of. > Joel> Which specific FAQ do you have in mind? > > $ perldoc -tq variables... > $text =~ s/(\$\w+)/$1/eeg; Thank you. That did the trick. I looked in 4 perl books and spent perhaps 2 hours trying to come to my own solution to the problem. A semi-constant affliction is that when I encounter a problem, I don't know the proper buzzword to use to get help. ================== Bob: Thank you for your email. I didn't know that what I was attempting is called templating. I'll start reading about templating. -- Joel Fentin tel: 760-749-8863 FAX: 760-749-8864 email: joel@fentin.com Biz: http://fentin.com Personal: http://fentin.com/me/ ~sdpm~ The posting address is: san-diego-pm-list@hfb.pm.org List requests should be sent to: majordomo@hfb.pm.org If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe san-diego-pm-list If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human. From rkleeman at energoncube.net Mon Mar 17 12:24:42 2003 From: rkleeman at energoncube.net (Bob Kleemann) Date: Thu Aug 5 00:20:45 2004 Subject: Mongers Meeting Tommorow Message-ID: <20030317182442.GA14075@energoncube.net> ~sdpm~ Fellow Perl Mongers, There is a meeting tommorow evening. Same time and the same place as last month: Tuesday March 18, 7PM at the Barnes & Noble at Mira Mesa Blvd and the 15. If you need directions or other assistance finding the location, let me know and I'll try and help. Topics for this weeks meeting: More discussion on future (more permanent) locations for the meetings, future discussions/seminars, more Perl questions from our faithfully devoted, and perhaps a few other things. Come along and help in the discussion. ~sdpm~ The posting address is: san-diego-pm-list@hfb.pm.org List requests should be sent to: majordomo@hfb.pm.org If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe san-diego-pm-list If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human. From rkleeman at energoncube.net Tue Mar 18 17:13:12 2003 From: rkleeman at energoncube.net (Bob Kleemann) Date: Thu Aug 5 00:20:45 2004 Subject: Meeting Tonight! Message-ID: <20030318231312.GB4564@energoncube.net> ~sdpm~ Just a friendly reminder. There is a meeting tonight, 7PM at the Barnes & Noble on Mira Mesa Blvd by the 15. Let me know if you need directions, otherwise I hope to see you there! ~sdpm~ The posting address is: san-diego-pm-list@hfb.pm.org List requests should be sent to: majordomo@hfb.pm.org If you ever want to remove yourself from this mailing list, you can send mail to with the following command in the body of your email message: unsubscribe san-diego-pm-list If you ever need to get in contact with the owner of the list, (if you have trouble unsubscribing, or have questions about the list itself) send email to . This is the general rule for most mailing lists when you need to contact a human.