NAME
File::Edit - A naive, probably buggy, file editor.
SYNOPSIS
use File::Edit;
# Replace string in file
File::Edit->new('build.gradle')
->replace('minSdkVersion 16', 'minSdkVersion 21')
->save()
;
# Edit text, save to file
File::Edit->new()
->text(" minSdkVersion 16\n targetSdkVersion 29")
->replace('minSdkVersion 16', 'minSdkVersion 21')
->save('build.gradle')
;
# Swap lines, save to file
File::Edit->new()
->text(" Do this first\n Now do that\n Don't do this")
->swap('Do this', 'do that')
->save('todo.txt')
;
METHODS
new
my $fe = File::Edit->new("some_file.txt");
Reads in a file for editing.
text
my $fe = File::Edit->new()->text(some_text);
Reads in some text for editing.
replace
$fe->replace($old, $new);
Replace the $old portion of a single line with $new.
save
my $fe = File::Edit->new("some_file.txt");
$fe->save(); # Saves to "some_file.txt"
$fe->save("other.txt") # Saves to "other.txt"
swap( $text_1, $text_2 )
The swap($s1, $s2) method finds the line containing string $s1 and finds the line containg string $s2 and swaps both lines.
AUTHOR
Hoe Kit CHEW, <hoekit at gmail.com>
BUGS
Please report any bugs or feature requests to bug-file-edit at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Edit. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc File::Edit
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
CPAN Ratings
Search CPAN
LICENSE AND COPYRIGHT
This software is Copyright (c) 2021 by Hoe Kit CHEW.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)