💾 Archived View for sdf.org › blippy › webstuff.pm captured on 2023-07-10 at 14:27:45.
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
package webstuff; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(slurp spit insertio); sub slurp { my $file = shift; open my $fh, '<', $file or die; local $/ = undef; my $cont = <$fh>; close $fh; return $cont; } sub spit { my ($fname, $contents) = @_; open my $fh, '>', $fname or die; print $fh $contents; close $fh; } sub insertio { my ($line, $fname) = @_; my $contents = slurp($fname); my ($before, $after) = split(/---/, $contents, 2); $contents = "$before---\n$line$after"; spit $fname, $contents; } 1;