sgregoratto.me

source files for www.sgregoratto.me
git clone git://git.sgregoratto.me/sgregoratto.me
Log | Files | Refs

commit 9fb0f810e71722c0d79dcc2956e24f69ee6c1704
parent b001cd5a19d0dcbbb9ab77e254bcb85f44d8c9a8
Author: Stephen Gregoratto <dev@sgregoratto.me>
Date:   Thu, 14 Nov 2019 19:57:38 +1100

new: code golf the error handling

Diffstat:
Mnew | 7++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/new b/new @@ -15,9 +15,7 @@ my $fmtTime = "%B %e, %Y"; my $postFile; my $xml; -if (! @ARGV) { - die "usage: new title\n"; -} +die "usage: new title\n" if not @ARGV or $ARGV[0] eq "-h"; $title = $fname = join(" ", @ARGV); $title = titlecase($title); @@ -26,8 +24,7 @@ $fname =~ tr/A-Za-z0-9/-/cs; $fname =~ tr/A-Z/a-z/; $fname .= ".xml"; -open($postFile, '>', $fname) - or die "could not open $fname for reading\n"; +open($postFile, '>', $fname) or die "could not open $fname\n"; $xml = XML::Writer->new(OUTPUT => $postFile, DATA_MODE => 1,