Re: AUTOLOAD speed
Simon Wistow sent the following bits through the ether: And thought ... would it be big performance hit if I did this through AUTOLOAD. Right, that does it. The next two talks I'm gonna do will be "Introduction to Benchmarking with Perl and the Bechmark module" and "Introduction to Testing with Perl and the Test module". Leon -- Leon Brocard.http://www.astray.com/ yapc::Europehttp://yapc.org/Europe/ ... All new improved Brocard, now with Template Toolkit!
Re: AUTOLOAD speed
At Fri, 19 Jan 2001 16:02:23 +, Simon Wistow [EMAIL PROTECTED] wrote: I was just typing this ... # Unsigned int 8bit sub ui8() { my $self; = shift; $self-UI8()} # Unsigned int 16bit sub ui16() { my $self; = shift; $self-UI16() } sub Word() { my $self; = shift; $self-UI16() } sub word() { my $self; = shift; $self-UI16() } ... And thought ... would it be big performance hit if I did this through AUTOLOAD. How about something like this (at the file level of your package): *ui8 = \U18; *ui16 = \UI16; *Word = \UI16; *word = \UI16; Typeglobs are your friend. Dave... [who doesn't like to encourage people to use AUTOLOAD as it has potential to break Symbol::Approx::Sub]
Re: AUTOLOAD speed
Dave Cross wrote: *ui8 = \U18; *ui16 = \UI16; *Word = \UI16; *word = \UI16; That's the ticket. Brain still fried today.
Re: AUTOLOAD speed
Robin Houston wrote: Although the best solution would (obviously) be to use Symbol::Approx::Sub with an appropriate matcher :-) [simon@ns0 simon]$ cat globtest #!/usr/bin/perl *foo = \UI; UI16(); UI32(); SI402(); foo12(); sub UI () { print $_[0],"\n"; } sub SI() { print $_[0],"\n"; } sub AUTOLOAD { my ($name) = $AUTOLOAD; $name =~ /^[^:]+::([^\d]+)(\d+)/ $1($2); } [simon@ns0 simon]$ perl globtest 16 32 402 12 [simon@ns0 simon]$