Many Thanks Simon, John and everyone else for pointing me to the correct
direction. Cheeers !!
Js

On Fri, Mar 26, 2010 at 7:03 PM, Shlomi Fish <shlo...@iglu.org.il> wrote:

> On Friday 26 Mar 2010 20:51:17 John W. Krahn wrote:
> > jet speed wrote:
> > > Hi,
> >
> > Hello,
> >
> > > 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 '{}' \;)";
> > > }
> > > ################################################
> > >
> > > I am not sure how to get the $_ value inside the system command, any
> tips
> > > would be most helpful.
> >
> > The escape \ in front of the semicolon is being interpolated away by
> > perl before the shell sees it so you need to escape it:
> >
> > system "(/usr/bin/find "$_" -mtime 3 -print -exec ls '{}' \\\;)";
> >
>
> 1. This is invalid Perl code - you cannot do "String"$_"OtherString".
>
> 2. \\\; has one redundant \ - you can use "\\;" inside a double quoted
> string
> instead.
>
> > Or you need to bypass the shell altogether:
> >
> > system '/usr/bin/find', $_, '-mtime', 3, '-print', '-exec', 'ls', '{}',
> > ';';
> >
> >
> > (You do realize that "-print" and "exec ls {} \;" do the same thing?)
> >
> >
> >
> > John
>
> --
> -----------------------------------------------------------------
> Shlomi Fish       http://www.shlomifish.org/
> "Humanity" - Parody of Modern Life - http://shlom.in/humanity
>
> 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: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to