1827894 Members
1769 Online
109969 Solutions
New Discussion

Re: help on perl command

 
Pando
Regular Advisor

help on perl command

dear gurus,

I have the following line in my scripts which works fine

export Var=$(awk -F "," '/DIFFLOTID/ {print $2}' $FILE)
$perl/perl -e '$PerlVar=$ENV{Var};
$PerlVar=~ m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/g;
if (pos($PerlVar)) {system("echo 'NUMBER'")} else {system("'$ExePath'/mv -f '$FILE' '$temp'")}'
$scrptpath/parset2xml -t $FILE
$ExePath/rm $FILE

However, i would like to ask how can i improve the conditions:

if (pos($PerlVar)) {system("echo 'NUMBER'")} else {system("'$ExePath'/mv -f '$FILE' '$temp'")}'

that instead of echoing 'NUMBER', it would call the folloing line below.

$scrptpath/parset2xml -t $FILE
$ExePath/rm $FILE

I have tried to insert the lines to replace the echo 'NUMBER' but it fails.

Maximum points for all correct answers!
2 REPLIES 2
H.Merijn Brand (procura
Honored Contributor

Re: help on perl command

# perl -le '$file=$ENV{FILE};@ARGV=($file);$var=(split/,/,(grep/DIFFLOTID/,<>)[0],3)[1];$var=~m/^[0-9][0-9]*[\.[0-9][0-9]*]{0,1}$/?`scrptpath/parset2xml -t $file;unlink$file:`ExePath/mv -f "$file" "$temp"`'

untested

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Muthukumar_5
Honored Contributor

Re: help on perl command

I hope you are posting this again. :). Check your prev. thread also for one liner.

You can use as,

if (pos($PerlVar)) {
qx ' $scrptpath/parset2xml -t $FILE;$ExePath/rm $FILE'
} else {
qx '$ExePath'/mv -f '$FILE' '$temp'"
}

You can use quote's as `command1;command2;...;commandn` like qx.

hth.
Easy to suggest when don't know about the problem!