elfs: (Default)
[personal profile] elfs
Have you signed up for Tor.com's "Free ebook of the week?" Do you own a Palm Pilot? Do you Pluck? If so, then this incantation is for you!

ls *.html | perl -ne 'chomp; $p = $_; $t = $p; $t =~ s/.html//; $f = $t; $f =~s/\W//g; print qq{plucker-build --stayonhost -f $f.pdb -N "$t" -P . "$p"\n}' | bash

Where do we sign up?

Date: 2008-07-23 05:32 am (UTC)
From: [identity profile] ideaphile.livejournal.com
I can't find anything there to sign up for.

I found this most awesome page, though:

http://tor.com/index.php?option=com_content&view=blog&id=577

I already owned a couple of those books, and I'm looking forward to reading the others.

. png

Re: Where do we sign up?

Date: 2008-07-23 05:55 am (UTC)
From: [identity profile] elfs.livejournal.com
I honestly don't recall. It was almost four months ago. There's a "forward this email" link on the email they send me, but I suspect it's one of those "sign this and you've establish a relationship with Macmillan and then we can send you all kinds of crap because we've got an agreed-upon relationship!" kind of thing. Want it?

Re: Where do we sign up?

Date: 2008-07-23 06:30 am (UTC)
From: [identity profile] ideaphile.livejournal.com
Sure, thanks. I'll post back here when I find out what happens. :-)

. png

Date: 2008-07-23 05:38 am (UTC)
From: (Anonymous)
Please learn how to write proper perl and shell. You're still in Chapter 1 of the Beginner's Sysadmin book with that code.

Date: 2008-07-23 05:50 am (UTC)
From: [identity profile] elfs.livejournal.com
So... how would you write it? Please ensure that your code is maintainable. Others may read it someday.

Date: 2008-07-23 10:47 am (UTC)
From: [identity profile] en-ki.livejournal.com
I'm not Anonymous, but:

* "ls *.html | ..." is generally better done with "find . -name '*.html' -print0 | ... -0 ..."; that way the shell doesn't choke if there are lots of .html files in the directory, and downstream code doesn't choke on weird characters in the name.

* Piping to shells is scary; "system" (with the full path to the command, and the arguments in a list) is generally considered safer. I realize that you're probably not reading "The Story of Little Bobby Tables", but as written you'll get burned by (at a minimum) ", $, and \ characters in the filenames.

Date: 2008-07-23 08:21 pm (UTC)
From: [identity profile] elfs.livejournal.com
Hah, I'd forgotten about Bobby Tables. I avoided find because I didn't want to recurse down the directory, and find -maxdepth 1 is a little too twee.

Yeah, this string is special-purpose: I don't intend to run it just anywhere. My assumption was that it would be used for the Tor ebook collection, which so far has the very regular format of Lastname, Firstname - Title of Book.html, and unless someone's doing something very weird I'm not likely to get Bobbytabled.

Date: 2008-07-23 08:41 pm (UTC)
From: [identity profile] en-ki.livejournal.com
Sure, it's fine as far as it goes. I twitch when I read stuff like that, though, because in my universe every one-off script is a DNA insertion in a germ line cell. (Some of these are just weird: there's a group of developers here that uses "more foo |" instead of "< foo". I just let them be.)

Profile

elfs: (Default)
Elf Sternberg

December 2025

S M T W T F S
 12345 6
78910111213
14151617181920
21222324252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 30th, 2025 12:00 pm
Powered by Dreamwidth Studios