I cobbled together a “yell” program for linux. It’s a perl script that takes advantage of “write” to send a giant message to another user. You type something like “yell ethan you rule!” and ethan gets a giant message telling him he rules. Rather than post the entire thing here, you can check out the source code here.
Archive for the 'Perl' Category
Perl is frustrating. There is an exists() function that works for hashes, put push() only works for arrays. So I wrote a function to tell me if a string exists in an array.
sub in_array { $needle = shift(@_); @haystack = @_; $found = 0; foreach $hs (@haystack) { if ($hs eq $needle) { $found = 1; } } return $found; } @moo = ("one", "two", "three"); if (in_array("two", @moo)) { print "two!n"; }