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

Re: [FWP] Self Aware Data routines?



		       On Thu, 24 Jun 1999 22:54:29 EDT,
			      "Bill Jones" wrote:

...

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

...

:Comments?


I would have written

  while (<DATA>) {
    no strict 'refs';  # save one keystroke :-)
    chomp;
    defined &$_ ? &$_ : print "Sorry, I don't see a Subroutine\n\t$_\n";
  }

Your "m/^(.+)$/io" amounts to a "chomp" (and doesn't need the "io" options).
Also, there's no need to test the definedness of &$$vSub twice.

Here's a nice trivia question:

Why does your program still work if "\m/^(.+)$/io" is replaced by
"m/^(.+)$/io"?  (The backslash is removed.)

Michael
-- 
*^=*SIG;@$=($_,%^)=('Jerk hot rats, leprechaun','INT',sub{$\=chop($;=<DATA>)});
sub _{unpack(shift,shift)}kill $#$,$$;print +(split //)[_("C*",_(u,$;))]
__END__
9`!<,"P0*&`8'%0$""!$0$@\.!184`Q,)#0``

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