Hi,
I have this file like this:
$cat a
hdisk1 active
hdisk2 active
I use this shell script to check:
$cat a.sh
#!/usr/bin/ksh
for d in 1 2
do
grep -q "hdisk$d" a && echo "$d : ok"
done
Trying to convert this to Perl like this:
$cat b.sh
#!/usr/bin/ksh
export d
for d in 1 2
do
cat a | perl -lane 'BEGIN{$d=$ENV{'d'};} print "$d: OK" if /hdisk$d\s+/'
done
I export the variable d
in the shell script and get the value using %ENV
in perl. Is there a better way of passing this value to the Perl one-liner?
Thanks.