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

Jacinta Richardson jarich at perltraining.com.au
Sun Sep 12 19:11:57 CDT 2004


Steve Wray wrote:
> 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.

"4750
"

When taken in a list context, backticks return one line per list item. 
Thus you may be able to take merely the first list position to get what 
you want:

  # Only want the first line of output returned.
  my $mode = ( `svn propget file:mode "$filename"` )[0];

I'm not sure why chomp isn't working.

I hope this helps.

       Jacinta

-- 
    ("`-''-/").___..--''"`-._          |  Jacinta Richardson         |
     `6_ 6  )   `-.  (     ).`-.__.`)  |  Perl Training Australia    |
     (_Y_.)'  ._   )  `._ `. ``-..-'   |      +61 3 9354 6001        |
   _..`--'_..-_/  /--'_.' ,'           | contact at perltraining.com.au |
(il),-''  (li),'  ((!.-'              |   www.perltraining.com.au   |




More information about the Wellington-pm mailing list