Its a script to keep track of identation. On the "Leaving" line, indent is decreased, on "Entering" they are increased. We then see that spaces are printed, based off the indent variable. In detail:
/usr/bin/perl -ne
-n
flag puts a while(<>)
loop around the script, which basically makes perl read from stdin or from argument files.
BEGIN { $|=1 }
Autoflush is turned on.
if (/(bmake|create_dirs\.sh)\[\d+\] Leaving/) { --$indent };
This regex here looks for lines such as
bmake[9] Leaving
create_dirs.sh[2] Leaving
When found, the $indent
variable is decreased by 1.
print " "x($indent * 4), "$_" ;
This prints a space, repeated 4 * $indent
times, followed by the input line.
if (/(bmake|create_dirs\.sh)\[\d+\] Entering/) { ++$indent }
This line increases indent by the same method as above.
More explanation on the regex (See it here, though I cleaned up the syntax from this site):
NODE EXPLANATION
--------------------------------------------------------------------------------
( group and capture to $1:
--------------------------------------------------------------------------------
bmake literal string 'bmake'
--------------------------------------------------------------------------------
| OR
--------------------------------------------------------------------------------
create_dirs\.sh literal string 'create_dirs.sh'
--------------------------------------------------------------------------------
) end of $1
--------------------------------------------------------------------------------
\[ literal string '['
--------------------------------------------------------------------------------
\d+ digits (0-9) (1 or more times (matching
the most amount possible))
--------------------------------------------------------------------------------
\] Leaving literal string '] Leaving'