[Wellington-pm] tidying up output from naughty backticked commands?

Steve Wray stevew at catalyst.net.nz
Sun Sep 12 16:01:17 CDT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi there,

This may seem really obvious but its bothering me.

I've found that one of the programs I'm using in backticked expressions 
in perl scripts returns a bothersome and non obvious format.

I've enclosed it in angle brackets so that you can see what it looks 
like. The number is purely an example;

<4750

>

So, the command outputs an extra line.

chomp doesn't seem to get rid of it, and nor do multiple invocations of 
chomp (that was my first reaction; get rid of two newlines with two 
chomps).

Currently I have this;
my $messy_mode = `svn propget file:mode "$filename"`;
my ($tidy_mode) = $messy_mode =~ m/^(\d+)\D+$/;

so that I get the digits and nothing but the digits.

I was thinking that this is a bit of a shotgun approach.

Can anyone offer some perl insights as to a more, uh, surgical approach?
:)

Thanks!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFBRLkqmVx2hyhuTucRAvVjAJ9uMhLn9gWdI5K48+m1USsm6GJ3/QCcC6yb
5N+hP0DGuvSxWGRhN69ZQP4=
=XRlm
-----END PGP SIGNATURE-----



More information about the Wellington-pm mailing list