Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Cookbook Recipe Bot

by epoptai (Curate)
on Dec 11, 2000 at 11:32 UTC ( #46045=sourcecode: print w/replies, xml ) Need Help??
Category: Web Stuff
Author/Contact Info epoptai
Description: There are two scripts here, and a sample crontab. gets & stores daily cookbook recipes from Written to run as a cronjob (no output except the file) & includes a sample daily crontab to automate the process. lists the saved recipes in alphabetical order. The viewer requires two images to work properly, 1. a small transparent gif named blank.gif, and 2. a Perl Cookbook cover image such as these at fatbrain and amazon, both stored in the same dir as the scripts & saved files.

Update: fixed url to point to the new recipe location at

# - get and store daily cookbook recipes from
# files are saved as title_of_the_recipe.html

use strict;
use LWP::Simple 'get';

my $path = "/full/path/to/cookbook"; # CHANGE
my $cook = "";
my $cooked = get $cook or die;
$cooked =~ s|<link href="/perl_a\.css" type="text/css" rel="stylesheet
$cooked =~ s|language="JavaScript"|language="foo"|gi;
$cooked =~ s| src="(.*?)"| src="blank.gif"|gi;
$cooked =~ s| href="/| href="http://www\.perl\.com/|gi;
$cooked =~ m/<h2><center>.*[^<]/oi;
my $title = $&;
chomp title;
$title =~ s|<h2><center>||oi;
$title =~ s|\W|_|g;
$title =~ s|^_||o;
my $save = "$title.html";
open(FILE,">$path/$save") or die;
print FILE $cooked; 
close (FILE) or die;

# - list saved recipes

use CGI qw(:standard);

opendir DIR, "." or die "error reading dir: $!";
@files = readdir DIR;
closedir DIR;
foreach $file(@files){ if($file=~/.*\.html/){ if($file=~/^[A-Z]/){ pus
+h @recs,$file}}}
print header;
print start_html(-title=>'Recipes of the Day',-bgcolor=>'ffffff',-text
<table border="0" cellpadding="3" cellspacing="0" width="100%" align="
+center"><tr><td bgcolor="#0098C0">
<font color="#FFFFFF" size="+3" face="Times New Roman">&nbsp;$uhh Perl
+ Cookbook Recipes<br></font></td>
<td bgcolor="#0098C0" align="right"><a href="
<img src="cookbook.gif" border=0 alt="Perl Cookbook cover image"></a>
foreach $pe(@recs){
        ($fp=$pe)=~s/_|\.html$/ /g;
        print qq~<li><a href="$pe">$fp</a><br>~;
if($uhh==0){ print qq~Your recipes will be listed here, sorted alphabe
<tr bgcolor="#0098C0"><td><font size="-1" color="#ffffff">
Solutions and Examples for Perl Programmers</td>
<td align="right"><font size="-2" color="#ffffff">
by Tom Christiansen and Nathan Torkington</font></td></tr></table>

# sample crontab
1 11 * * * /full/path/to/cookbook/
Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://46045]
[tye]: probably something in the init subsystem that does the mounting that you could disable and reboot.
davido needs to close laptop to board flight home from yapc.
[davido]: I'll look into it in a few hours probably.
[davido]: when i do get to that point I think I'll do it in a vm snapshot just in case. :)
[oiskuu]: tye, you were right: loginuid/sessionid are part of task struct if compiled with AUDITSYSCALL. I have some doubts if you should actually depend on that feature.
[Corion]: oiskuu: Depends on what you want to do with that information
[tye]: I'm not depending on that feature. But I could in this environment. I'm using getlogin(). shrug
[Corion]: For benign logging (which user started this DB instance), it's OK
[tye]: We use auditd for security monitoring. So we can rely on auditing being enabled. I'm not sure who would want to not be able to audit. Maybe some VM inside another system with audit?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-06-23 20:12 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (555 votes). Check out past polls.