[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Self Aware Data routines?



		       On Fri, 25 Jun 1999 13:36:34 EDT,
			      "Bill Jones" wrote:

:> Here's a nice trivia question:
:>
:> Why does your program still work if "\m/^(.+)$/io" is replaced by
:> "m/^(.+)$/io"?  (The backslash is removed.)
:
:Not sure what you mean?  I used a \ (reference), hence
:the &$$var mainly because in my bigger project,
:$_ is getting nuked with each interation...
:
:???

Your original loop looked like this:

  while (<DATA>) {
    no strict q/refs/;
    $vSub = \m/^(.+)$/io;                  # <=== backslash here
    &$$vSub if defined &$$vSub;
    print "Sorry, I don't see a Subroutine
           $$vSub\n" unless defined &$$vSub;
  }


but this loop will actually do the same thing:

  while (<DATA>) {
    no strict q/refs/;
    $vSub = m/^(.+)$/io;                  # <=== no backslash here
    &$$vSub if defined &$$vSub;
    print "Sorry, I don't see a Subroutine
           $$vSub\n" unless defined &$$vSub;
  }

My question is why it still works (in 5.004 and 5.005_03, at least).

Michael

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org