"Gabriel Genellina" <gagsl-...@yahoo.com.ar> writes: > En Mon, 05 Jan 2009 02:03:26 -0200, Roy Smith <r...@panix.com> escribió: > > >> The other day, I came upon this gem. It's a bit of perl embedded in a >> Makefile; this makes it even more gnarly because all the $'s get >> doubled to >> hide them from make: >> >> define absmondir >> $(shell perl -e ' \ >> sub absmon { my $$a = $$_[0]; \ >> if ( $$^O =~ m/cygwin|MSWin32/i ) { >> $$prefix = `/bin/mount -p|awk "NR==2{print >> \\\$$1}"`; >> chomp($$prefix); \ >> $$a = ($$_[1]||"$(PWD)") . "/$$a" \ >> unless ( $$a =~ m !^(:?$$prefix|/|[A-Za-z]:)! ); \ >> } else { $$a = ($$_[1]||"$(PWD)") . "/$$a" unless ( $$a =~ m !^/! >> ); } \ >> return unslash(undot(undotdot($$a))); }; \ >> sub unslash ($$) { $$_[0] =~ s://+:/:g; $$_[0] =~ s:/$$::; >> return($$_[0]); >> }; \ >> sub undot ($$) { $$_[0]=~s:/\./:/:g; return ($$_[0]); }; \ >> sub undotdot ($$) { my $$in = $$_[0]; \ >> return ( $$in =~ s:/[^/.][^/]*/\.\.::g )?undotdot($$in):$$in; }; \ >> print absmon("$(1)","$(2)"); \ >> ' ) >> endef >> >> Barf-o-rama. I know what it's supposed to do, and I still can't >> figure it out. > > Ouch! Me too, when I come to some piece of Perl code I've written some > years ago, I invariably think "what's all this noise?". Never happens > with other languages I've used in the past.
I still occassion upon the chance to write some Perl, and even as a full-time developer who works with Python for a living, I relish every opportunity. The funny thing is that I've never had the problem of writing code like this in Perl. The example is a very poor use-case and doesn't reflect on the useful/useless-ness of the language itself but more on the choices of the implementor. Perl is a very useful language overall and when used properly, very powerful. -- http://mail.python.org/mailman/listinfo/python-list