This may not be a new use, but many (like me) may not have tried it until now. Microperl is worth your attention, especially if you are like me and have 2 left feet when it comes to shell scripts, awk and sed. Have you heard of microperl, but never tried it? Here is a success story. It definitely is worth using.

I've developed my own system for making full backups to cdr, and use perl of course. A problem arises when restoring to a blank system, in that there is no perl available to run the restore script. Well I was thinking about using a shell script (kind of clunky with strings), or a C program(since it's a pretty simple operation). Then I came across a node which pointed me to microperl, which comes with 5.8. It fills the bill! It is only 908k on my system, which easily fits on a cdrom. So with microperl and my 2 small scripts, I get a bootstrap perl restore system. The backup system relies on multi-volume tar archives, which are made for each second level sub-directory, then gunzipped and written to a ext2 image mounted via loop. When the image gets filled, it gets written to cdr, and the next iso is started. I delve 2 layers into /usr since it's so big. So I end up with a bunch of files named:

_etc-1.tar.gz
_root-1.tar.gz
_root-2.tar.gz
_root-3.tar.gz
_lib-1.tar.gz
_lib-2.tar.gz
_usr_lib-1.tar.gz
_usr_lib-2.tar.gz
etc..
etc..
Now I just throw a copy of microperl, and my 2 scripts on to each cd, and I can boot with any floppy, mount my cd's and restore. Microperl dosn't do it all, and seems to have some small peculiarities compared to full perl. Notably, I needed to use `ls` and grep to simulate a glob or readdir.

First you make microperl, by "make -f Makefile.micro" in the perl58 distribution. The first thing I noticed was it didn't include alot of standard functions like opendir, so you need to use backticks and system alot. BUT you do get grep,arrays,hashes, and regexes; so it eliminates the need for awk,sed,expr, and the other apps usually needed by shell scripts. So it's actually a space saver at 908k. Also the system calls seemed to like double quotes, to pass parameters.


#!microperl #to substitute for a readdir or glob #I needed to ls then grep my @files = `ls`; @files = grep($_ =~ /.tar.gz$/,@files); foreach(@files){print "\ngunzipping->$_\n"; system("gunzip $_")} my @files = `ls`; @files = grep($_ =~ /.tar$/,@files); (@bases) = map{$_ =~ m/^(.*)-\d+.tar$/ }@files; print "@bases\n"; my %hash; $hash{$_}++ foreach (@bases); print "$_: $hash{$_}\n " foreach (sort {$hash{$a} <=> $hash{$b}} keys +%hash); foreach $basename (keys %hash){ #initialize first file if (-e "$basename-1.tar"){ $old= "$basename-1.tar"; $new= "$basename.tar"; rename $old,$new or warn $!; } #the restore-rotate.pl script just swaps files like they were tapes system ('tar','-x','-M',"-F ./restore-rotate.pl $basename","-f$basenam +e.tar"); unlink "$basename.tar"; #cleanup print "----------------------------------\n"; } system("mkdir proc"); system("mkdir tmp"); system("mkdir home"); exit;

update (broquaint): s{^#+$}(<hr/>)


In reply to bootstrapping with microperl by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.