On 10/02/2012 17:52, Harry Putnam wrote:
This script:

------- 8<  snip ---------- 8<  snip ---------- 8<snip -------
#!/usr/local/bin/perl

use strict;
use warnings;

my ($seven, $nine) = (stat('./SweetwatterPk-016.jpg'))[7, 9];
print "$seven and $nine\n";
------- 8<  snip ---------- 8<  snip ---------- 8<snip -------

Prints the desired fields of the stat array.  Now, how to reduce that
to the command line?

But these command line attempts fail:

(all on one line)
  perl  -e 'my ($seven, $nine) =
     (stat('./SweetwatterPk-016.jpg'))[7, 9];
         print "$seven and $nine"'

output:
   syntax error at -e line 1, near "stat(."
   Search pattern not terminated at -e line 1.

-------        ---------       ---=---       ---------      --------

(all on one line)
  perl  -e 'my ($seven, $nine); if (($seven, $nine) =
    (stat('./SweetwaterPk-016.jpg'))[7, 9]){ print
      "$seven and  $nine\n"}'

output:
   syntax error at -e line 1, near "stat(."
   Search pattern not terminated at -e line 1.

-------        ---------       ---=---       ---------      --------

What is the necessary syntax?

Something like this perhaps?

  perl -e "print join ' and ', (stat shift)[7,9]" ./SweetwaterPk-016.jpg

But I would think the modification time (stat 9) wouldn't be of much
use without formatting it.

HTH,

Rob

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to