xsawyerx / ref-util-rewriter

Rewrite your code to use Ref::Util
Other
1 stars 2 forks source link

rewrite_file does not perform an in place updated as documented #9

Closed atoomic closed 5 years ago

atoomic commented 5 years ago

After fixing the __insert_before_child issues from GH #6 I could noticed that rewrite_file does not perform an "in place" update as documented in the POD...

Steps to reproduce:

Create a test.pl file

sub is_array {

    return ref $_[0] eq 'ARRAY';
}

1;

then run the one-liner

perl -Ilib -MRef::Util::Rewriter -E 'use Test::More; note "Before:\n", qx[cat test.pl]; Ref::Util::Rewriter::rewrite_file( "test.pl" ); note "After:\n", qx[cat test.pl];'

output

# Before:
#
# sub is_array {
#
#     return ref $_[0] eq 'ARRAY';
# }
#
# 1;
# After:
#
# sub is_array {
#
#     return ref $_[0] eq 'ARRAY';
# }
#
# 1;

The function rewrite_file returns the updated content but do not perform the update...

xsawyerx commented 5 years ago

Fix merged. :)