#!/bin/sh type pl > /dev/null 2>&1 || { echo This uses pl, the much enhanced perl one-liner wrapper! Install it as App::pl. echo See details on https://perl1liner.sourceforge.io/ exit 1 } echo "Loop over @ARGV with -o and initialize with -B for BEGIN handling. Use pl's" '$R & $I (aliased to $RESULT & $ARGIND)' pl -oB '$x = -INF' '$x = $_, $R = $I if $x < $_' 5 2 9 1 7 6 pl -oB '$x = -INF' '$x = $_, $RESULT = $ARGIND if $x < $_' 4 2 3 1 5 0 echo Same, setting @ARGV Perl-style with -A instead pl -oA '$x = -INF; (5, 2, 9, 1, 7, 6)' '$x = $_, $R = $I if $x < $_' pl -oA '$x = -INF; (4, 2, 3, 1, 5, 0)' '$x = $_, $R = $I if $x < $_' echo echo "Use pl's" '$R (aliased to $RESULT) as an accumulator (decumulator?)' pl -n '($R) = "$_$R" =~ /\A(.*\/).*(\n\1|\Z)/' <