Ok. There are these things called regular expressions. I'm not sure what that means outside of perl. This is what it means inside perl:
You have a file and you want to know what is in it. Maybe your friend is trying to quit porn cold turkey and you think he's been squeezin the hog when no ones looking. Perhaps you have an old hard drive, really old, like super duper old, and you don't know where you put that REALLY IMPORTANT STUFF. Maybe you stalk young women online and you just grepped a bunch of stuff and you want to find her diary..er.. or whatever.
In come regular expressions!
We have quantifiers like:
*
and
+
So let's use them in a regular expression.
we want to find if a file contains the word sabrina so in perl we say
if (/sabrina/) {
print "We found it!.";
}
But how do we know that we're really looking for sabrina? Maybe we should look for Sabrina capitalized.We don't know. So let's just look for both.
Using the OR function which looks like this:
|
our new code to find either or is:
if(/sabrina|Sabrina) {
print "We found a match!";
}
ok but what if want to find sabrina's secrets? If you don't know most people hide things in folders named secret. It makes them feel like james bond or computer haxors or something. So let's fix that regular expression up to represent the new search.
if(/sabrina|secrets|Sabrina/) {
print "Elementary my dear watson...elementary.";
}
Look at that shit! All we had to do was add the word secrets and another OR function! Good stuff!
Ok well now you get into sabrinas secret file and it's empty except for one line!!!
It reads: computer haxors are stupid l33t xxx.
Well this must be some sort of code you reason, so you try to search for that.
you type
if(/l33t|xxx/) {
print "Gotcha bitch!";
<>;
print "I'm rick james bitch!";
And your console dutifully tells you that it has, of course, 'got u bitch'. It also adds that it is Rick James, in case anyone was in doubt.
You go to the files named l33t and xxx and they are also empty. You tell rick james to fuck off. Afterwards you get an idea.
You decide it's been really retarded what you've been doing. You just need to search for dated files. Those would be the juicy ones. Of course. For posterity..er..whatever.
So you use character classes.
Bust out that fuckin script:
if ...
and around this time you realize that you hardly know perl and regex (regular expressions) have made you want to drown a kitten. Your puppy starts to look dehydrated and you think how he would feel so much better submerged in the bathtub so you skip ahead a chapter in the llama book and do the problems, fail, skip to the answers in the back, do them again, fail, skip again to the answers in the back, memorize the answers and then move on to the next. And promise to not touch another regex until you know what the hell you're doing.
No comments:
Post a Comment