seismofish has asked for the wisdom of the Perl Monks concerning the following question:
I love the simplicity and power of one-liners like
perl -pie 's/foo/bar/g;'Is there a way to invoke functionality like this from the middle of a longer perl script without forking another perl instance? I'm thinking along the lines of
sub delete_comments_from_file { my( $path ) = @_; eval "local @ARGV=qw{ -pie s/#.*//; $path };"; }
This would be quicker to write, clearer and less error prone than writing it all long-hand and I know the functionality is all there. I just don't know how to unlock it.
<°}}}>«<
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Avoid re-invocation for -pie processing
by 1nickt (Canon) on Jan 05, 2024 at 19:20 UTC | |
by seismofish (Novice) on Jan 08, 2024 at 11:02 UTC | |
Re: Avoid re-invocation for -pie processing
by tybalt89 (Monsignor) on Jan 05, 2024 at 19:23 UTC | |
Re: Avoid re-invocation for -pie processing
by Anonymous Monk on Jan 05, 2024 at 18:25 UTC | |
Re: Avoid re-invocation for -pie processing
by ikegami (Patriarch) on Jan 08, 2024 at 14:41 UTC | |
by Corion (Patriarch) on Jan 08, 2024 at 15:29 UTC | |
by ikegami (Patriarch) on Jan 10, 2024 at 14:24 UTC | |
Re: Avoid re-invocation for -pie processing
by InfiniteSilence (Curate) on Jan 06, 2024 at 23:54 UTC | |
by seismofish (Novice) on Jan 10, 2024 at 16:53 UTC |