Since I generally prefer using Perl rather than handfuls of commands such as sed, awk, tr, cut, when I see a post like this I feel the strange need to post a Perl one-liner version.
perl -pi -e ‘undef $/;s/I(\s+)hope/we$1expect/g’ file.txt
Before you run this, beware that I’m using in-place editing (-i) so it will overwrite the [...]
Thomas: My solution to the the differences in Unix tools across platforms is often to use Perl. In your example,
echo “kaka pipi” | perl -p -e ’s/\S/./g’
produces the correct output, and in my experience, Perl works the same whether I’m running it on Solaris, various Linux distributions, or OS X. After months [...]
I wrote a little script to make it convenient to send cluepackets to dashboard. Read on to see the source.
# Authors: Jamin P. Gray <firstname.lastname@example.org>
# Purpose: Convenience script to send a cluepacket to Dashboard from
# the command line
my @clues = ();
GetOptions(”frontend|f=s” => [...]
At work we’ve had the need to view diagrams showing the data flow from one “thread” to another within a Cloverleaf Site. For quite some time we’ve used Visio diagrams, however there are a number of issues with this approach. Philosophically and practically I have an issue with the file formats being a [...]
I’m working on an integration interface at work where I’m going to be converting an XML file into ultimately, HL7. However, first I need to build a formatted report with fields filled in from the XML file. Later on I’m going to use the Cloverleaf engine to mutilate the report and end up [...]
A few years ago, my friend Adam wrote an awk script to parse UNIX mbox mail files and report new mail. The script has been very helpful to me and I’ve been using it for ages, particularly at work where I have it running automatically every 90 seconds to show me in which folders [...]
I was asked to write a Perl quick-reference guide, that mostly covers the basics of regular expressions. I figured it might be useful to others so here it is in first rough draft form.
A couple weeks ago I wrote a paper on the advantages of using Perl. The article was for my coworkers and was presented at a retreat. Now I present it to you.
A coworker and I wanted to mirror a website of a friend of his. However wget -r insists on honouring the robots.txt file, which is probably a good thing. It seemed like a good opportunity to write a perl script.
$url = shift || die “no url given”;
print “Base URL: $url
I’ve been meaning to write a JAPH signature for a while, but just got around to a first cut yesterday. Here ’tis:
$_ = q&))r 22756 o 636168602 p 627560502275686
47 s 6 r 6160247375 7n4(jd,”" avbw,”46U” (xpnc
gavec&;y/A-Za-z/N-ZA-Mn-za-m/;$_ = reverse $_;