Perl/Useful hacks

Quote for s23 wiki

 * 1) !/usr/bin/perl
 * 2) Will put pre-existing text in wiki markup for presentation
 * 3) example:
 * 4)     '''Lyrics
 * 5)     '''Lyrics
 * 6)     
 * 1)     '''Lyrics
 * 2)     

$prefix =" '''";   # to prefix each sentence in file

$file = "$ARGV[0]"; open(TEMP, $file) || die "Needs file name\n"; @raw=(TEMP); close(TEMP);

foreach $line (@raw) {   $wholeline = "$prefix". "$line"; }

Rename the contents of directory
foreach my $file (glob "*.old") { my $newfile = $file; $newfile =~ s/\.old$/.new/; if (-e $newfile) { warn "can't rename $file to $newfile: $newfile exists\n"; } elsif (rename $file, $newfile) { ## success, do nothing } else { warn "rename $file to $newfile failed: $!\n"; } } Thought there is much faster way to do this in bash i bet (link from here if you know of one)
 * How to rename everything that ends with ".old " to the same name with ".new". Here's how to do it in Perl nicely: