in reply to Re^2: modifying a file with regex!
in thread modifying a file with regex!

It eliminates two calls to close and allows some lexical variables ($input_h and $output_h) to live in a smaller scope.

Indent it however you like; this ain't Python.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Replies are listed 'Best First'.
Re^4: modifying a file with regex!
by Marshall (Canon) on Mar 17, 2012 at 00:31 UTC
    Calls to close() are not necessary in any event (for this particular code). Code runs the same with or without the "do". The only argument in favor of this "do" is scope of $input_h, etc. The price of the extra indentation level is too high and the gain too low - because of the very limited "life" of these variables.

    I guess like all things, mileage may vary. In Perl, you can eliminate the "do" and just put {}, however I don't think either of these wise in this situation. Obviously you disagree.

      The price of the extra indentation level is too high and the gain too low - this ain't JAVA!

      LOL

        I am sorry that that "got out into the wild" while I was editing my post. That was not appropriate - neither was this "this ain't Phython" comment.