Home > Archive > PERL Beginners > January 2006 > Need help to change to a perl script
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Need help to change to a perl script
|
|
| Herbert 2006-01-20, 6:59 pm |
| Hello,
I am trying to change a ksh script to a perl now practicing perl script
and need some help with it. Can anyone there help with ksh script
part?
#!//perl5/bin/perl5.8 -w
#
use strict;
# my $FILE_DIR = "/xxx/xxx/xxx";
#
my $FILE_DIR = "/yyy/yyy/yyy";
#
#
chdir "$FILE_DIR";
open (IN_FILES, "in_files") or die "Can't open Input file:$!\n";
while ($line = <IN_FILES> ) {
find ${$line} -mtime +90 -type f -print0 | xargs -0 rm -vf
==> system ("find ${$line} -mtime +90 -type f -print0 | xargs -0 rm
-vf");
for j in $(find ${i} -mtime +1 -type f) ==> foreach ??
do
SIZE="`ls -l $j | awk -F' ' '{print $5}'`" ==>
??
COMP_TOOL=gzip
# if [ "$SIZE" -gt 2000000000 ]
if [ $SIZE -gt 2000 ]
then
COMP_TOOL=compress
fi
$COMP_TOOL $j
done
}
in_files contains
aa_file_dd_*
bb_file_dd_*
cc_file_dd_*
dd_file_dd_*
ee_file_dd_*
ff_file_dd_*
Many thanks in advance.
| |
| Paul Lalli 2006-01-20, 6:59 pm |
| Herbert wrote:
> I am trying to change a ksh script to a perl now practicing perl script
> and need some help with it.
You're asking for "help", but you appear to be desiring someone to
write the script for you. That, while possible, is unlikely.
> Can anyone there help with ksh script part?
I will be happy to help you by pointing you to the correct places in
the Perl documentation to learn what you need to do.
> #!//perl5/bin/perl5.8 -w
> #
> use strict;
>
>
> # my $FILE_DIR = "/xxx/xxx/xxx";
> #
> my $FILE_DIR = "/yyy/yyy/yyy";
> #
> #
> chdir "$FILE_DIR";
>
> open (IN_FILES, "in_files") or die "Can't open Input file:$!\n";
> while ($line = <IN_FILES> ) {
>
> find ${$line} -mtime +90 -type f -print0 | xargs -0 rm -vf
> ==> system ("find ${$line} -mtime +90 -type f -print0 | xargs -0 rm
> -vf");
Yeah, you could just shell out to the actual command... but then, you
could just wrap your entire ksh script in a giant system command. I
thought you wanted to translate this to Perl?
perldoc File::Find
perldoc -f stat
perldoc -f -X
perldoc -f unlink
> for j in $(find ${i} -mtime +1 -type f) ==> foreach ??
Yup.
perldoc perlsyn
> do
> SIZE="`ls -l $j | awk -F' ' '{print $5}'`" ==>
> ??
perldoc -f -X
> COMP_TOOL=gzip
> # if [ "$SIZE" -gt 2000000000 ]
> if [ $SIZE -gt 2000 ]
perldoc perlsyn
perldoc perlop
> then
> COMP_TOOL=compress
> fi
>
> $COMP_TOOL $j
> done
> }
>
>
> in_files contains
> aa_file_dd_*
> bb_file_dd_*
> cc_file_dd_*
> dd_file_dd_*
> ee_file_dd_*
> ff_file_dd_*
perldoc -f glob
> Many thanks in advance.
You're welcome.
Paul Lalli
|
|
|
|
|