Wicker King (jtoomey) wrote,
Wicker King
jtoomey

  • Music:

I Got Bored Again...

...and I wrote the following pair of scripts. (It's quite possible to do this with one script on UNIX, but most folks use PCs, so I'll leave that adaptation to the reader. I realize that, since I'm using two files any way, I should just use one script and a data file, but, hey, it's my program, not yours. :) ) Here's the syntax:
randf.pl
 select a random user from my friends list
randf.pl -l
 list my friends
randf.pl -a 
[Error: Irreparable invalid markup ('<username[,>') in entry. Owner must fix manually. Raw contents below.]

...and I wrote the following pair of scripts. (It's quite possible to do this with one script on UNIX, but most folks use PCs, so I'll leave that adaptation to the reader. I realize that, since I'm using two files any way, I should just use one script and a data file, but, hey, it's my program, not yours. :) ) Here's the syntax:<BLOCKQUOTE><TABLE><TR><TD><PRE>randf.pl</PRE></TD><TD>&nbsp;</TD><TD>select a random user from my friends list</TD></TR>
<TR><TD><PRE>randf.pl -l</PRE></TD><TD>&nbsp;</TD><TD>list my friends</TD></TR>
<TR><TD><PRE>randf.pl -a <username[, username...]></PRE></TD><TD>&nbsp;</TD><TD>add one or more users to my friends list</TD></TR>
<TR><TD><PRE>randf.pl -r <username[, username...]></PRE></TD><TD>&nbsp;</TD><TD>remove one or more users from my friends list</TD></TR>
<TR><TD><PRE>randf.pl -reset</PRE></TD><TD>&nbsp;</TD><TD>reset my friends list so that everyone is unselected</TD></TR>
<TR><TD><PRE>randf.pl -clear</PRE></TD><TD>&nbsp;</TD><TD>clear my friends list</TD></TR></TABLE></BLOCKQUOTE>Note that the friends list in question here is a local list which has no link to your actual LJ friends list. You have to stock it using the <B>-a</B> option, but it does accept the list format shown in your LJ userinfo page (comma and space separated), so that's nice. Feel free to adapt it to use the LJ HTTP interface to stock your friends list automatically. :)

The selections made by <B>randf.pl</B> are marked off internally, so you won't get the same friend twice. When you run out of friends, you'll be told so, and you can add more, or use <B>-reset</B>.

<B>-clear</B> empties out your (local) friends list, if that wasn't clear. *rimshot*

Here's the code for <A HREF="http://www.yark.org/code/perl/randf.txt"><B>randf.pl</B></A> and the code for <A HREF="http://www.yark.org/code/perl/randfd.txt"><B>randfd.pl</B></A>, which you never actually call -- it's used internally by <I>randf.pl</I>. Man, you'd think I had too much free time or something. This is what I get for reading <lj user="creentmerveille">'s random friend bit. :)
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 3 comments