Re: Maybe-useful subroutine (BETTER!)

2002-07-02 Thread Steffen Mueller
Keith C. Ivey [EMAIL PROTECTED] schrieb im Newsbeitrag 3D20DD6E.24532.1A2D7FCB@localhost">news:3D20DD6E.24532.1A2D7FCB@localhost... Steffen Mueller [EMAIL PROTECTED] wrote: I hope I'm not drifting into the unfun territory, but how come YAPC::Europe can afford to take 89EUR whereas American

Re: Maybe-useful subroutine (BETTER!)

2002-07-02 Thread Abigail
On Mon, Jul 01, 2002 at 05:43:52PM +, sara starre wrote: 1) I don't think my code was obfuscated. It certainly wasn't intended to. 2) I will never ever be at a Perl conference where they charge over $1000 entrance fee and hundreds more for tutorials. I'd be

Re: Maybe-useful subroutine (BETTER!)

2002-07-02 Thread Bernard El-Hagin
On Tue, 2 Jul 2002, Abigail wrote: As for beer, well, I don't drink alcohol anyway. Unless you do drugs there goes the only thing I could think of to explain some of your JAPHs. ;-) Cheers, Bernard -- echo 42|perl -pe '$#=Just another Perl hacker,'

Re: Maybe-useful subroutine (BETTER!)

2002-07-02 Thread sara starre
From: Abigail [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: Maybe-useful subroutine (BETTER!) Date: Tue, 2 Jul 2002 05:06:04 -0700 .. .. .. There isn't much going on here. '$#' followed by a name of an array gives you the index of the last element. '@' followed

Re: Maybe-useful subroutine (BETTER!)

2002-07-01 Thread Abigail
Unfortunally, I left out a '-1'. Here's the right version: #!/usr/bin/perl -w use strict; use warnings 'all'; sub rotate { return () unless $_ [1]; die Not an array ref unless ARRAY eq ref $_ [1]; return [] unless {$_ [1]}; my $l = $_ [0] % {$_ [1]}; [@{$_ [1]} [$l ..

Re: Maybe-useful subroutine (BETTER!)

2002-07-01 Thread sara starre
From: Abigail [EMAIL PROTECTED] To: [EMAIL PROTECTED], [EMAIL PROTECTED] Subject: Re: Maybe-useful subroutine (BETTER!) Date: Mon, 1 Jul 2002 08:37:42 -0700 Unfortunally, I left out a '-1'. Here's the right version: #!/usr/bin/perl -w use strict; use warnings 'all'; . . . Well

Re: Maybe-useful subroutine (BETTER!)

2002-07-01 Thread Yitzchak Scott-Thoennes
Yet Another *::Util Plug: Scalar::Util::reftype finds the underlying type even for objects. (Unfortunately for non-refs it returns undef instead of '' as the builtin ref does.) In article [EMAIL PROTECTED], Abigail [EMAIL PROTECTED] wrote: #!/usr/bin/perl -w use strict; use warnings 'all';

Re: Maybe-useful subroutine (BETTER!)

2002-07-01 Thread sara starre
[EMAIL PROTECTED] (Yitzchak Scott-Thoennes) wrote: I didn't think that was obfuscated. How about this: sub rotate {[$#{$_[!$||$|]}*@{$_[!!$_^!$_]}?@{$_[!$..!!$.]}[$_[@--@+]%@ {$_[$==~/(?=)//!$`]}..$#{$_[$??!!$?:!$?]},($)?!$):!!$))..$_[$--$-]%@{$_ [$]/$]]}-(!!$++!$+)]:@{$_[!!$^^^!$^^]}]}

Re: Maybe-useful subroutine (BETTER!)

2002-07-01 Thread Yitzchak Scott-Thoennes
In article [EMAIL PROTECTED], sara starre [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Yitzchak Scott-Thoennes) wrote: I didn't think that was obfuscated. How about this: sub rotate {[$#{$_[!$||$|]}*@{$_[!!$_^!$_]}?@{$_[!$..!!$.]}[$_[@--@+]%@

Re: A better way ?

2002-04-18 Thread Michael G Schwern
On Thu, Apr 18, 2002 at 06:21:52AM +0200, Paul Johnson wrote: On Wed, Apr 17, 2002 at 07:59:22PM -0400, Michael G Schwern wrote: Just because the safety is on doesn't mean you should juggle handguns. Never know whose foot it'll blow off. Awww. You're no fun. *bang* -- Michael G.

AW: A better way ?

2002-04-18 Thread Pense, Joachim
Michael G Schwern [mailto:[EMAIL PROTECTED]] wrote: On Thu, Apr 18, 2002 at 06:21:52AM +0200, Paul Johnson wrote: On Wed, Apr 17, 2002 at 07:59:22PM -0400, Michael G Schwern wrote: Just because the safety is on doesn't mean you should juggle handguns. Never know whose foot it'll blow

Re: A better way ?

2002-04-18 Thread Steffen Mueller
Michael G Schwern [EMAIL PROTECTED] schrieb im Newsbeitrag 20020417205231.GV851@blackrider">news:20020417205231.GV851@blackrider... | On Wed, Apr 17, 2002 at 12:28:37PM -0700, Rick Klement wrote: | There's already a %dispatch set up for you by perl... | | I'd have used it but it just fell into

Re: A better way ?

2002-04-18 Thread abigail
On Wed, Apr 17, 2002 at 02:02:02PM -0400, Bill -Sx- Jones wrote: I have the habit of doing: last if (substr($vFlag, 1, 3) eq 'END'); $vSub = \Sneex if (substr($vFlag, 1, 5) eq 'SNEEX'); $vSub = \Admin if (substr($vFlag, 1, 5) eq 'ADMIN'); $vSub = \Reports if (substr($vFlag, 1,

Re: A better way ?

2002-04-18 Thread Steve Lane
[EMAIL PROTECTED] wrote: On Wed, Apr 17, 2002 at 02:02:02PM -0400, Bill -Sx- Jones wrote: I have the habit of doing: last if (substr($vFlag, 1, 3) eq 'END'); $vSub = \Sneex if (substr($vFlag, 1, 5) eq 'SNEEX'); $vSub = \Admin if (substr($vFlag, 1, 5) eq 'ADMIN'); $vSub

A better way ?

2002-04-17 Thread Bill -Sx- Jones
'); $vSub = \Targets if (substr($vFlag, 1, 7) eq 'TARGETS'); $vSub = \Usenet if (substr($vFlag, 1, 6) eq 'USENET'); (substr($_, 0, 1) eq '[') ? next : $vSub; (NOTE: Obviously NOT all of the 668 lines of program code is here, so this doesn't stand on it's own two feet...) Q: Is there a better

Re: A better way ?

2002-04-17 Thread Steven Lembark
on it's own two feet...) Q: Is there a better way? Use a hash as a jump table, with the keys being what you extract and the values being subs. If the string is regex-able then something like: my %jumpz = ( SNEEX = \sneez, ... ); ... my ($name) = $vflag

Re: A better way ?

2002-04-17 Thread Michael G Schwern
is here, so this doesn't stand on it's own two feet...) Q: Is there a better way? The above implies the format is something like: SNEEXADMINEND in which case, suicide is an honorable option. Adding in some sort of delimiter: SNEEX|ADMIN|END and then you can just split

Re: A better way ?

2002-04-17 Thread Steven Lembark
suicide is an honorable option. croak $$: The uers are idiots! unless $api eq makes sense; Adding in some sort of delimiter: SNEEX|ADMIN|END my %jumpz = ( SNEEX = \foo, ADMIN = \bar, ... ); my $regex = join '|', keys %jumpz; if( my ($name) = $vflag =~

Re: A better way ?

2002-04-17 Thread Bill -Sx- Jones
On 4/17/02 2:22 PM, Michael G Schwern [EMAIL PROTECTED] wrote: The above implies the format is something like: SNEEXADMINEND in which case, suicide is an honorable option. :) Actually, the input data looks more like [SNEEX] [ADMIN] [END] Sorry for the mass hysteria;

Re: A better way ?

2002-04-17 Thread Steven Lembark
Actually, the input data looks more like [SNEEX] [ADMIN] [END] my $regex = '\b(' . join('|', keys %jumpz) . ')\b'; if( my ($name) = $foo =~ /$regex/o ) { my $sub = $jumpz{$name}; ... } Sorry for the mass hysteria; What hysteria? Hysteria? Oh, no...

Re: A better way ?

2002-04-17 Thread Michael G Schwern
On Wed, Apr 17, 2002 at 02:34:20PM -0400, Bill -Sx- Jones wrote: On 4/17/02 2:22 PM, Michael G Schwern [EMAIL PROTECTED] wrote: The above implies the format is something like: SNEEXADMINEND in which case, suicide is an honorable option. :) Actually, the input data looks

Re: A better way ?

2002-04-17 Thread Bart Lateur
On Wed, 17 Apr 2002 15:01:50 -0400, Michael G Schwern wrote: On Wed, Apr 17, 2002 at 02:34:20PM -0400, Bill -Sx- Jones wrote: Actually, the input data looks more like [SNEEX] [ADMIN] [END] # setup %Dispatch as before, then... while( $vData =~ /\[([A-Z])\]/g ) {

Re: A better way ?

2002-04-17 Thread Steven Lembark
-- Michael G Schwern [EMAIL PROTECTED] On Wed, Apr 17, 2002 at 12:28:37PM -0700, Rick Klement wrote: There's already a %dispatch set up for you by perl... I'd have used it but it just fell into the gaping security hole. A recent Phrack article pointed out that one of the SOAP/RPC/XML

Re: A better way ?

2002-04-17 Thread Michael G Schwern
On Wed, Apr 17, 2002 at 04:38:50PM -0500, Steven Lembark wrote: A recent Phrack article pointed out that one of the SOAP/RPC/XML modules was doing this: $soap-$tainted_method_name(@args); Use -T and untaint by extracting the subname: my $flag = ::$input =~ /\w+$/;

Re: A better way ?

2002-04-17 Thread Rick Klement
Michael G Schwern wrote: On Wed, Apr 17, 2002 at 12:28:37PM -0700, Rick Klement wrote: There's already a %dispatch set up for you by perl... I'd have used it but it just fell into the gaping security hole. A recent Phrack article pointed out that one of the SOAP/RPC/XML modules was

Re: A better way ?

2002-04-17 Thread Michael G Schwern
On Wed, Apr 17, 2002 at 04:16:08PM -0700, Rick Klement wrote: Notice that the regex match (which should have been /\[([A-Z]+)\]/ ) effectively untaints and closes the security hole by disallowing anything through that is not [A-Z]+ This is still too lenient, you've just narrowed the possible

Re: A better way ?

2002-04-17 Thread Aaron D. Marasco
'); $vSub = \Targets if (substr($vFlag, 1, 7) eq 'TARGETS'); $vSub = \Usenet if (substr($vFlag, 1, 6) eq 'USENET'); (substr($_, 0, 1) eq '[') ? next : $vSub; (NOTE: Obviously NOT all of the 668 lines of program code is here, so this doesn't stand on it's own two feet...) Q: Is there a better way

Re: A better way ?

2002-04-17 Thread Michael G Schwern
On Wed, Apr 17, 2002 at 09:01:37PM -0400, Aaron D. Marasco wrote: I like something like this, where the sub name is is sub_KEYWORD (from a CGI, hopefully you can extract usefulness): eval sub_.param('page') if (param defined param('page') defined sub_.param('page')); The last clause

Re: A better way ?

2002-04-17 Thread Paul Johnson
On Wed, Apr 17, 2002 at 07:59:22PM -0400, Michael G Schwern wrote: Just because the safety is on doesn't mean you should juggle handguns. Never know whose foot it'll blow off. Awww. You're no fun. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net

Re: Better ?

2002-01-28 Thread abigail
On Fri, Jan 25, 2002 at 11:31:37AM -0600, [EMAIL PROTECTED] wrote: Greetings, On Friday, January 25, 2002, at 10:56 AM, [EMAIL PROTECTED] wrote: /[fF][oO][oO]/ better than /foo/i That'd be Mr. RE Jeffrey Freidl in the Mastering RE/Owl book. The parser has to do less backtracking

Re: Better ?

2002-01-25 Thread Bill -OSX- Jones
Greetings, On Friday, January 25, 2002, at 10:56 AM, [EMAIL PROTECTED] wrote: /[fF][oO][oO]/ better than /foo/i That'd be Mr. RE Jeffrey Freidl in the Mastering RE/Owl book. The parser has to do less backtracking or something. I have to disagree; while I have read the RE/Owl (I hear

Re: Better ?

2002-01-25 Thread Rick Klement
Bill -OSX- Jones wrote: Greetings, On Friday, January 25, 2002, at 10:56 AM, [EMAIL PROTECTED] wrote: /[fF][oO][oO]/ better than /foo/i That'd be Mr. RE Jeffrey Freidl in the Mastering RE/Owl book. The parser has to do less backtracking or something. I have to disagree; while

Re: Better ?

2002-01-25 Thread Jeff 'japhy' Pinyan
On Jan 25, Bill -OSX- Jones said: Greetings, On Friday, January 25, 2002, at 10:56 AM, [EMAIL PROTECTED] wrote: /[fF][oO][oO]/ better than /foo/i That'd be Mr. RE Jeffrey Freidl in the Mastering RE/Owl book. The parser has to do less backtracking or something. I have to disagree

Re: Better ?

2002-01-25 Thread Jeff 'japhy' Pinyan
On Jan 25, Bill -OSX- Jones said: $_ = a planet of Perl Fun; for $y(qw/a e f l n o p r t u/){$x||=y/$y//%2; print $y $x \n} What is $x being set to and why ? $x is going to be zero for all of them, because $_ does not contain any _'s or y's. -- Jeff japhy Pinyan [EMAIL PROTECTED]

Re: Better ?

2002-01-25 Thread Bill -OSX- Jones
* should know better. (Besides, I realize I am not good enough to win on my own efforts, I just had a fever in that I *felt* s close but could not get past even sets of vowels, IE merlyn. And besides, posting did confuse or dismay some potential beginners postings - plus what I posted was WRONG

Re: Better ?

2002-01-25 Thread Yanick
On Fri, Jan 25, 2002 at 12:50:54PM -0500, Bill -OSX- Jones wrote: So, to come back, allow me to ask: $_ = a planet of Perl Fun; for $y(qw/a e f l n o p r t u/){$x||=y/$y//%2; print $y $x \n} What is $x being set to and why ? Nothing interesting, as y/// doesn't extrapolate. Try

Re: Better ?

2002-01-25 Thread Bill -OSX- Jones
You guys are waayyy to fast :) Nothing interesting, as y/// doesn't extrapolate. Where does a knuckle draggin' neanderthal go to evolve around here? :) _Sx ('-Sx- IUDICIUM //\ Have Computer - v_/_Will Hack...

Re: Better ?

2002-01-25 Thread Rick Klement
Bill -OSX- Jones wrote: You guys are waayyy to fast :) Nothing interesting, as y/// doesn't extrapolate. Where does a knuckle draggin' neanderthal go to evolve around here? :) _Sx ('-Sx- IUDICIUM //\ Have Computer - v_/_Will Hack...

Re: Better ?

2002-01-25 Thread Big D
: Bill -OSX- Jones [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: Better ? You guys are waayyy to fast :) Nothing interesting, as y/// doesn't extrapolate. Where does a knuckle draggin' neanderthal go to evolve around here? :) _Sx ('-Sx- IUDICIUM

Re: Better REs

2002-01-25 Thread Andy_Bach
- | /[fF][oO][oO]/ better than /foo/i The /i penalty had nothing to do with backtracking, but with making an extra copy of the target string. If the target string was short, it wasn't really much of an issue. It's described on p278. Once the book came out, it (and many other bugs) were fixed

Better ?

2002-01-24 Thread Bill -OSX- Jones
$c = grep {/[osx]/i} @_; Is there a better way? _Sx ('-Sx- IUDICIUM //\ Have Computer - v_/_Will Hack...

Re: Better ?

2002-01-24 Thread Craig S. Cottingham
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Thursday, January 24, 2002, at 10:14 , Bill -OSX- Jones wrote: $c = grep {/[osx]/i} @_; Is there a better way? To do... what? - -- Craig S. Cottingham [EMAIL PROTECTED] PGP key available from: http://pgp.ai.mit.edu:11371/pks/lookup?op

Re: Better ?

2002-01-24 Thread Michael G Schwern
On Thu, Jan 24, 2002 at 11:24:47AM -0500, Bill -OSX- Jones wrote: $c = grep {/[osx]/i} @_; Is there a better way? To do... what? Sorry - Given: $_ = Mac OS X; split //; $c = grep {/[osx]/i} @_; Regardless, the {} there is redundant and actually slows you down a bit (Perl has

Re: Better ?

2002-01-24 Thread Philip Newton
element which isn't cheap and its not smart enough to optimize it out. But you can't just take them off since you'd need to put a comma in then: $c = grep /[osx]/i, @_; or perhaps even $c = grep /[osxOSX]/, @_; ISTR someone saying that matching /[fF][oO][oO]/ was better than /foo/i