Pyrl: polyglossia WTF
-
One of my job's regular tasks involves fixing bugs in a tool implemented as a few dozen programs/modules in various scripting languages, tied together with bash/make. The scripts are piped together, execute each other (Perl backticks galore, see snippet below) and do all sorts of other weird I/O shit, so it is best to watch your step around there.
[code]representative snippet of code:cat $somefile | somecode.sh
;[/code]
Today I was supposed to make a fix in one of the Perl modules. I started by grepping the entire source against the Perl module's name. I see it mentioned in a Python script I'm not familiar with, so I look inside to check what the dependency is about:- The author (let's call him Dave) opens up the Perl module file for reading - ok.
- Then Dave runs every line of the Perl source file through a regex match - right, makes sense.
- Then he ... Wait, what?!
Apparently, while writing a Python program, Dave needed configuration data hardcoded in a hash inside the Perl module. He thought:
- Why not write a mini regex Perl parser and just fetch it directly from the source?
- The required data is conveniently kept in an inline hash definition, one key/value pair per line, so this will be super-easy!
The best part is that the Python code doesn't check where that particular hash definition starts and ends. It just accepts any line matching /\s*(\w+)\s*=>\s*'(\w+)',/, so it will happily slurp any other inline-defined hashes from the Perl module.
Cthulhu help me.
Also: good evening, everyone.
-
Exquisite WTF!
Filed under: Welcome
-
The WTF factor is off the chart! Luckily I have a bigger chart- Some thieving bastard's nicked my bigger chart!
-
-
Good morning
We had code like this but it was perl parsing perl. I finally exorcised it in the latest release!
-
beautiful WTF
-
Turn the configuration data into a S-expression (or JSON or whatever) as quickly as possible. Have both programs parse the thing.
-
-
JSON was my first thought. Sadly, this particular wtf is not connected with the problems I'm fixing, so it has to wait. I'll have to verify that nothing else depends on this particular instance (yay!) of this data. I just started to dig into this pile of crap, so there's definitely more fun to come.
-
It's the explosive, not the smelly kind of things to avoid stepping on.
-
It looks to me like even if you avoid the explosive things, there are lots of smelly things you don't want to step on either.
-
-
We use those:
Hmm, looks like someone mistyped a subroutine name in a call. But it gives no errors - how so? Oh, right, it's mistyped in the definition and all other calls as well.
-
Hmm, looks like someone mistyped a subroutine name in a call. But it gives no errors - how so? Oh, right, it's mistyped in the definition and all other calls as well.
I resemble that remark!
-
Hmm, looks like someone mistyped a subroutine name in a call. But it gives no errors - how so? Oh, right, it's mistyped in the definition and all other calls as well.
It's why, besides autocomplete, your IDE should have a spellchecker.(fixes typo in bluetothAdapter. Thanks, IDEA!)
-
@eskel said:
JSON was my first thought.
Needs moar XML!http://what.thedailywtf.com/t/jsonx-is-sexy-liesx/5317?u=boomzilla
-
indeed, why not @zoidberg?
-
I took the liberty of fertilizing your caviar.
-
not the one i was hoping you would say....
-
So no caviar fertilization for you then?
-
what caviar?
foxes don't eat caviar.
-
foxes don't eat caviar.
Sure? It smells like fish. Doubt a fox wouldn't at least try it.
-
true, but how many have access to it? and wouldn't we much prefer a rabbit or the actual fish?
-
and wouldn't we much prefer a rabbit or the actual fish?
So you think he will go hunting instead of eating something that is offered on a plate?
-
wait. you're offering caviar?
that changes EVERYTHING
-
-
Once again, the conservative, sandwich-heavy portfolio pays off for the hungry investor.
-
Also: once again someone thought $#array gives the length of an array in Perl, so we have a lot of false-positive test results.
-
If you are going to post that each time a thread gets derailed here...
-
Yeah, I get the picture. I didn't want to do it, but when I saw that poster ...
The things you do, when your're at work dreaming about caviar and vodka (not necessarily in that order).
-
I like how your avatar appears to approve of the comment immediately preceding it. I also like that it's Vault Boy, but that's not important right now...
-
It's certainly more tasteful than when I hat Winter Amy Rose and @Luhmann has that pissing infant; if I replied to him, it looked like Amy was catching the urine stream
-
I'msorrywhatnow?
-
I was going to find the post where it was preserved… but Discosearch.
-
-
Did a post(s) get Jeffed from this topic?
-
Doesn't look like it. Post count matches post ID.
-
Well, somebody introduced urine streams, and I am perplexed as to why...
-
somebody introduced urine streams
Talking about one of @Luhmann previous avatars, I believe:
@Luhmann has that pissing infant
-
-
-
Thankyou! I knew someone had posted it!
-
8/10 would pee again
-
8/10 would pee again
#DO NOT WANT!!!
Edit: Context added, since some people seem to be confused by this.
-
-
I... OK... Erm...