###	SPAR <http://www.cpan.org/scripts/>
###	67	644	1067451878	1217599890	Makeppfile
#
# This file tests the perl(_begin) statement, the sub statement,
# the perl function and perl actions.
#
$(phony all): statements function oneline multiline rule-script.out


perl_begin

*{'f_xyz._'} = sub { "xyz" }

perl_end

perl { sub f_foo { return "foo"; } } # A one-line Perl statement.

sub f_abc { return "abc"; }	# A one-line sub statement.

statements:
	&echo $(xyz.-) $(abc) $(def-.) $(foo) $(bar) -o $@

sub f_jkl			# A multi-line sub statement.
{
  return "jkl";
}

perl {				# A multi-line Perl statement.
  sub f_bar { return "bar"; }
}

sub f_ghi {{			# A double-paren sub statement.
  return 'ghi';
}}

perl				# A double-paren Perl statement.
  {{
    *{"f_def-."} = sub { 'def' };
  }}

perl {
  $Mpp::pid = $$;
  run qw(./script.pl statement-script.out b);
}


function:
	&echo $((makeperl scalar reverse( '$(abc):$(xyz.-)' ) )) ${perl f_foo . f_bar} -o $@
	&echo ${perl f_ghi . f_jkl} -o>>$@


oneline:
	makeperl { open my $$f, '>$(output)'; print $$f "single1\n" }
	perl { open my $f, '>>' . f_output; print $f "single2\n" }


multiline:
	makeperl {{
	  open my $$f, '>$(output)'; print $$f "multi1\n";
	}}
	perl {{
	  open my $f, '>>' . f_output; print $f "multi2\n";
	}}

rule-script.out:
	makeperl {{
	  $$Mpp::pid = $$$$;		# How much is that in Euros? :-)
	}}
	&./script.pl $(output) d
###	2	755	1067451878	1066077772	script.pl
open my $f, ">>$ARGV[0]" or die "open $ARGV[0]: $!";
print $f "$0: running $ARGV[1] (", $Mpp::pid == $$ ? 'same' : 'different', " pid)\n";
###	D	755	1067451878	1066078592	answers
###	2	644	1067451878	1066078500	answers/function
zyx:cba foobar
ghijkl
###	1	644	1067451878	1190053907	answers/n_files
5 1 0
###	2	644	1067451878	1066078086	answers/multiline
multi1
multi2
###	1	644	1104006511	1209131381	answers/statement-script.out
./script.pl: running b (same pid)
###	1	644	1067451878	1209131415	answers/rule-script.out
./script.pl: running d (same pid)
###	1	644	1067451878	1066078086	answers/statements
xyz abc def foo bar
###	2	644	1067451878	1066078086	answers/oneline
single1
single2