aturtle has asked for the wisdom of the Perl Monks concerning the following question:

Hi I am trying to get ExtUtils::Command to create a empty file if one does not exist. However I cant seem to get any results from these: perl -MExtUtils::Command -e 'ExtUtils::Command->touch('test');' perl -MExtUtils::Command -e 'touch test.txt ;' perl -MExtUtils::Command -e "touch('test');" any ideas ? Thanks

Replies are listed 'Best First'.
Re: ExtUtils::Command touch
by choroba (Cardinal) on Jan 13, 2014 at 21:16 UTC
    As the documentation of ExtUtils::Command says:
    In all cases the functions work from @ARGV rather than taking arguments.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Thanks I have no Idea what that means :) could you give me an example?
        OH I see like this: perl -MExtUtils::Command -e touch test.txt ; Thanks I must need more coffee today!
Re: ExtUtils::Command touch (Path::Tiny , Shell::Command )
by Anonymous Monk on Jan 13, 2014 at 21:51 UTC
      AHH thanks I was hoping not to add any dependencies for this and ExtUtils::Command is installed. I did get path::tiny to work:
      #!/usr/bin/perl package Debug; use strict ; use warnings ; &test_pt; sub test_ex { use ExtUtils::Command; my ( $path ) = @_ ; my ($file, $count); my @files = ('test.txt','test-1.txt'); foreach $file (@files) { if ($path) {$file = "$path/$file"} $count++; print "$file\n"; ExtUtils::Command::touch $file || ($count--, print "$file not update +d\n") ; } print "$count files updated\n"; } sub test_pt { use Path::Tiny qw/ path /; my ( $path ) = @_ ; my ($file, $count); my @files = ('test.txt','test-1.txt'); foreach $file (@files) { if ($path) {$file = "$path/$file"} $count++; print "$file\n"; path( $file )->touchpath || ($count--, print "$file not updated\n") + ; } print "$count files updated\n"; } 1;
      Oh well not going to be a big deal to add it Thanks!