Hi jet speed,
On Friday 26 Mar 2010 19:17:46 jet speed wrote:
> Hi,
> I have a simple code below,
>
> ###################################
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @list =( '/usr/data/logs' , '/usr/data1/logs');
> foreach (@list)
> {
> print "$_ \n";
>
> system "(/usr/bin/find "$_" -mtime 3 -print -exec ls '{}' \;)";
This is invalid Perl code. You need to write it as:
{{
system("/usr/bin/find \"$_\" -mtime 3 -print -exec ls '{}' \;");
}}
Which is better written using the list form:
{{
system("find", $_, qw(-mtime 3 -print -exec ls {} ;));
}}
That put aside, to traverse the file-system you should use File::Find or one
of its alternatives:
* http://www.shlomifish.org/open-source/projects/File-Find-Object/
* http://www.perlfoundation.org/perl5/index.cgi?alternatives_to_file_find
Regards,
Shlomi Fish
> }
> ################################################
>
> I am not sure how to get the $_ value inside the system command, any tips
> would be most helpful.
>
> Kind Regards
> Sj
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Parody on "The Fountainhead" - http://shlom.in/towtf
Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/