入职已经489天了,新鲜事很多,不过更多应该是无趣、枯燥的日常:装很多的数据库、反复的测试、写很多的脚本…… 不过,在这繁忙工作中,还是希望自己能够保持一份趣味。
下面这个perl函数就是帮你保持脚本有趣的一个办法。
在你的Perl脚本中下面的函数,并在脚本的第一行调用之。函数会在你的输出前随机的输出一条“名言”,让你在枯燥的调试程序时,仍然保持一份清醒:
use MIME::Base64; ####################################################### # This is a interesting function by orczhou@gmail.com # It outputs a random quote ####################################################### sub randomQuote{ my @quote; push(@quote,"S2VlcCBpdCBzaW1wbGUsIFN0dXBpZA=="); push(@quote,"VG9tb3Jyb3cgaXMgYW5vdGhlciBkYXk="); push(@quote,"TGlmZSBpcyBsaWtlIGEgYm94IG9mY2hvY29sYXRlcw=="); push(@quote,"VGhlIGFuZ3J5IGlzIHRoYXQgdGFraW5nIHRoZSBvdGhlcidzIG1pc3Rha2UgdG8gcHVuaXNoIG9uZXNlbGY="); push(@quote,"VGhlIGhvcGUgb2YgdG9tb3Jyb3cgbGV0cyB1cyBmb3JnZXQgdG9kYXkncyBwYWlu"); push(@quote,"VGhlIHBsYWNlIHdoaWNoIHRoZSBpZGVhbCBpcyBpbiwgdGhlIGhlbGwgbWF5YmUgYSBoZWF2ZW4="); push(@quote,"Rm9yIGhpcyBsb25nIGFuZCBub24tdmlvbGVudCBzdHJ1Z2dsZSBmb3IgZnVuZGFtZW50YWwgaHVtYW4gcmlnaHRzIGluIENoaW5h"); push(@quote,"V2hhdCBpcyBkb25lIGJ5IG5pZ2h0IGFwcGVhcnMgYnkgZGF5"); push(@quote,"SWYgeW91IHdhbnQgdG8gaGF2ZSB0aGUgcGVyZmVjdCBmcmllbmRzaGlwLCBwb3NzaWJseSB5b3UgbWF5IGZpbmQgbm8gZnJpZW5kIGZvciBhbGw gbGlmZXRpbWU="); push(@quote,"VGhlIGV4cGVyaWVuY2UgdGFrZXMgb3V0IGJ5IHRoZSBlc3NlbmNlIG9mIHBhaW4="); push(@quote,"VGhlIGJpZ2dlc3QgbWlzdGFrZSBpbiBsaWZlIGlzIHRoZSB1bmNlYXNpbmdseSB3b3JyaWVkIGFib3V0IG1ha2luZyBtaXN0YWtl"); push(@quote,"TGF6aW5lc3Mgd2lsbCBjYXVzZSB5b3UgcGFpbg=="); push(@quote,"S2VlcCB0aGUgcGFzc2lvbiBmb3IgeW91ciBqb2I="); push(@quote,"VGhlcmUgaXMgb2Z0ZW4gbGVzcyBkYW5nZXIgaW4gdGhlIHRoaW5ncyB3ZSBmZWFyIHRoYW4gaW4gdGhlIHRoaW5ncyB3ZSBkZXNpcmU="); push(@quote,"WW91IGNhbiB1c2Ugc2NyaXB0IGRvIG1vcmUgd29yayxidXQgc2FkZGx5IGl0IG1ha2UgbW9yZSBqb2JzIGNvbWUgdG8gdQ=="); push(@quote,"TXkgbmFtZSBpcyBteXNxbGRhdXRvLkkgd2FzIGNyZWF0ZWQgYnkgb3JjemhvdQ=="); #push(@quote,""); my $count = scalar(@quote); my $rand_num = int(rand($count)); print decode_base64($quote[$rand_num])."\n"; } randomQuote();
如果觉得上面的代码,破坏了脚本的输出,可以使用参数控制其是否输出。