I just discovered something in MakeMaker and I'm trying to figure out
if its a bug or its a feature.  The best way to explain it is probably
just to dump the IRC log of me explaining it to Ken Williams (here
playing the part of DrMath).


**** BEGIN LOGGING AT Tue Feb  5 02:43:23 2002

--> Schwern (~[EMAIL PROTECTED]) has joined #MM
--- london.rhizomatic.net sets mode +n #MM
--- london.rhizomatic.net sets mode +t #MM
--> crab ([EMAIL PROTECTED]) has joined #MM
--> DrMath ([EMAIL PROTECTED]) has joined #MM
<crab> yow!
<DrMath> yow you!
<Schwern> Ok, I went to install Ogg::Vorbis with 5.49_01 and was getting:
<Schwern> /usr/local/bin/perl -MExtUtils::MY -we "MY->fixin(shift)" blib/script/pogg
<Schwern> Can't use string ("MY") as a HASH ref while "strict refs" in use at 
/usr/share/perl/5.6.1/ExtUtils/MM_Unix.pm line 3091.
<DrMath> uh....
<Schwern> This is what it was choking on:
<Schwern> sub perm_rwx {
<Schwern>     shift->{PERM_RWX} || "755";
<Schwern> }
<Schwern> Obviously
<DrMath> ah, it's not designed to be a class method.
<Schwern> That's what I thought.
<Schwern> Then I noticed that fixin() (which calls perm_rwx) hadn't been touched since 
5.6.1
<DrMath> hm?
<Schwern> ie. in 5.6.1 MY->fixin() worked
<Schwern> in bleadperl MY->fixin() works
<Schwern> With MakeMaker 5.49_01 (derived from bleadperl) it doesn't work.
<DrMath> What were you running it under?
<Schwern> and fixin() hasn't changed.
<Schwern> 5.6.1
<DrMath> Hm, but the class hierarchy has.
<Schwern> Not significantly
<Schwern> Here's a hint:  MM_Unix is SelfLoaded
<DrMath> Shit, I don't know much about SelfLoading.
<Schwern> But I'd turned it off because it makes things hard to debug.
<DrMath> right.
<Schwern> s/SelfLoading/AutoLoaded/ for all intents and purposes
<DrMath> okay.
<Schwern> Certain things don't propogate to Self/Autoloaded subs, like lexicals and 
strict....
<Schwern> What does "MM"->{PERM_RWX} do without strict?
<DrMath> blows up, yes?
<Schwern> Nope, symbolic reference
<Schwern> $MM{PERM_RWX}
<DrMath> no way!
<Schwern> merlyn spotted it
<Schwern> $ perl -wle '"MM"->{FOO} = 42;  print $MM{FOO}'
<Schwern> 42
<DrMath> Jesus.  I guess that's why we use strict.
<Schwern> So now what I really, really, really, really, really, really hope is that 
this is a bug and not a feature.
<DrMath> Yeah, no kidding.
<DrMath> But I wouldn't hold your breath.
<DrMath> Actually, why should you be able to access hash elements without a sigil?
<DrMath> I'd vote bug, I think.
<crab> it looks like a nice feature.
<Schwern> Oh, the sym ref is definately a feature.
<Schwern> Its just:  $foo = "MM";  $foo->{BAR}
<Schwern> I'm hoping that MakeMaker isn't actually using %MY to store object data.
<DrMath> Which is just ${$foo}{BAR}.
<Schwern> This concludes tonites Horror
<Schwern> Oh, I have another horror
<DrMath> Right.  Thanks for the freakshow.
<DrMath> okay
<Schwern>     push @m,
<Schwern> qq[POD2HTML_EXE = $pod2html_exe\n],
<Schwern> qq[POD2HTML = \$(PERL) -we 'use File::Basename; use File::Path qw(mkpath); 
%m=\@ARGV;for (keys %m){' \\\n],
<Schwern> q[-e 'next if -e $$m{$$_} && -M $$m{$$_} < -M $$_ && -M $$m{$$_} < -M "],
<Schwern>  $self->{MAKEFILE}, q[";' \\
<Schwern> -e 'print "Htmlifying $$m{$$_}\n";' \\
<Schwern> -e '$$dir = dirname($$m{$$_}); mkpath($$dir) unless -d $$dir;' \\
<Schwern> -e 'system(q[$(PERLRUN) $(POD2HTML_EXE) ].qq[$$_>$$m{$$_}])==0 or warn 
"Couldn\\047t install $$m{$$_}\n";' \\
<Schwern> -e 'chmod(oct($(PERM_RW))), $$m{$$_} or warn "chmod $(PERM_RW) $$m{$$_}: 
$$!\n";}'
<Schwern> ];
<Schwern> And I can't think of how to clean that up.
<DrMath> argh.
<DrMath> I hate using arrays instead of strings in the first place.
<Schwern> Oh yeah, it just joins them all together at the end anyway
<DrMath> right, but I still always hate it.
<Schwern> I guess I'll just turn it into a here-doc
<Schwern> And toss the array
<DrMath> But with which quotes? =)
<DrMath> It alternates, I guess that's the reason it's so ugly.
<Schwern> Yeah, that's a lot of escaping.
<DrMath> You need the perl6 quotes.
<Schwern> Ahh, I know!  I'll use my $m = sprintf <<'FOO';
<DrMath> hm, that's a good idea.
<Schwern> I think there's only one real variable in that mess
<Schwern> two
<DrMath> Yeah, $pod2html_exe?
<Schwern> And $self->{MAKEFILE}
<Schwern> What other horrors did I dig up tonite...
<DrMath> I like the "Couldn\\047t".
<DrMath>  
<Schwern> perl -e "system qq[pl2bat.bat ].shift" some_file
<DrMath> heh
<Schwern> That hung on Activestate's perl
<Schwern> Out of protest, probably
<DrMath> =)
<Schwern> Pure cargo cult.  here it is in context:
<crab> hm? hm?
<crab> perl6 quotes?
<Schwern>  ($Is_Win32
<Schwern>   ? q{FIXIN = $(PERLRUN) \
<Schwern>     -e "system qq[pl2bat.bat ].shift"
<Schwern> } : q{FIXIN = $(PERLRUN) -MExtUtils::MakeMaker \
<Schwern>     -e "MY->fixin(shift)"
<Schwern> })
<DrMath> crab: single-quoting rules in parts of double-quoted strings, and vice versa.
<Schwern> Basically, whoever hacked in the Win32 version just cargo-culted the Unix 
version.
<DrMath> I see, so it's one branch of a truth table.
<crab> "'foo', he said." ?
<crab> s/foo/$foo/
<DrMath> I forget the exact syntax, but something like "he said q{$foo}.\n", or 
something.
<DrMath> What's teh FIXIN thingy?
<Schwern> What does it do?
<crab> but! but! what if he said 'q{$foo}'?
<Schwern> It changes #!/usr/bin/perl to #!/path/to/the/perl/you/have/installed
<DrMath> I see.
<Schwern> It does it in a really, really complicated way
<DrMath> You can't just use $CONFIG{whatever}?
<crab> why does it need to be complicated?
<Schwern> The basic idea is so that when you have bin/foo.plx in your module 
distribution, MakeMaker adjusts its #! to the local machine.
<DrMath> Oh, it actually fixes them in script files.
<Schwern> crab:  Because its MakeMaker.
<Schwern> DrMath:  Yeah.
<Schwern> sub fixin { # stolen from the pink Camel book, more or less
<Schwern> I think half of it is trying to find the local perl executable, for which 
there already a method in MakeMaker
<Schwern> The othe half is emulating -I
<Schwern> err, -i
<DrMath> ...and an entry in %CONFIG
<Schwern> s/CONFIG/Config/ ?
<DrMath> oops, yes.
<Schwern> It uses onfig, but doesn't seem to trust it
<DrMath> factionism!
<Schwern> It really doesn't make any sense the way its written *shrug*
<Schwern> And then there's that wacky "running under some shell" exec thing
<Schwern> Its archeology I tells ya
<DrMath> I've never understood the "running under some shell" thing.  Or rather, the 
need for it.
<DrMath> Or both.
<Schwern> I think its for weird, crippled shells
<Schwern> Say hi to Andreas
* Schwern waves to Andreas
<Schwern> I'm going to send him a log of this to see if he can figure out what's up 
with %MY.  Wave
* DrMath waves to Andreas


So is the %MY thing a bug or feature?  Please, please, please tell me
its a bug.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
If you'll mount me, I'll let you bomb Canada until they swoon.

Reply via email to