use
5.008_005;
our
$VERSION
=
'0.12'
;
before
'write_process'
=>
sub
{
my
$self
=
shift
;
print
"# In before write process!\n"
;
my
$process
=
$self
->process;
chomp
(
$process
);
my
@input
=
$self
->local_attr->get_values(
'INPUT'
)
if
$self
->local_attr->
exists
(
'INPUT'
);
my
@output
=
$self
->local_attr->get_values(
'OUTPUT'
)
if
$self
->local_attr->
exists
(
'OUTPUT'
);
my
(
$input
,
$output
) = (
$input
[0],
$output
[0]);
my
$tprocess
=
""
;
if
(
$input
){
$tprocess
.=
<<EOF;
[ -f "$input" ] || \\{ >&2 echo "INPUT: $input not found" ; exit 256; \\} && \\
[ -s "$input" ] || \\{ >&2 echo "INPUT: $input is empty"; \\} && \\
touch $input || \\{>&2 echo "INPUT: $input could not be touched. Please check your file permissions!"; exit 1; \\} && \\
EOF
if
(
$output
){
$tprocess
.=
<<EOF;
touch $output || \\{>&2 echo "OUTPUT: $output could not be touched. Please check your file permissions!"; exit 1;\\} && \\
EOF
}
$tprocess
.=
$process
;
$process
=
$tprocess
;
}
if
(
$output
){
$process
=
$process
.
" && \\\n"
;
$tprocess
=
<<EOF;
[ -f "$output" ] || \\{>&2 echo "OUTPUT $output not found" ; \\} && \\
[ -s "$output" ] || \\{>&2 echo "OUTPUT $output is empty"; \\}
EOF
$process
.=
$tprocess
;
}
$self
->process(
$process
);
};
1;