Amarendu has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: Perl Script to edit the contents of a txt file
by marto (Cardinal) on Sep 12, 2012 at 07:10 UTC

      Nor is it a requirement divination service. Notwithstanding, tobyink's telepathic powers are much stronger than mine today, and he or she has come up with a program that seems like a reasonable candidate to actually do what the OPer seems to actually want done given the dense wadge of input/output posted. Oh well, at least we can be thankful there wasn't 20K of it...

Re: Perl Script to edit the contents of a txt file
by nemesdani (Friar) on Sep 12, 2012 at 07:09 UTC
    In a private message I'll send you my bank account, after receiving the 120$ fee (thanks in advance), I'll answer urgently.


    I'm too lazy to be proud of being impatient.
Re: Perl Script to edit the contents of a txt file
by tobyink (Canon) on Sep 12, 2012 at 07:52 UTC

    Summint like...

    use Path::Class qw(file); use Text::CSV; my $input = \*STDIN; my $output = \*STDOUT; # ... or use open() to open file handles my $csv = Text::CSV->new({allow_whitespace => 1, eol => "\n"}); while (my $row = $csv->getline($input)) { $row->[4] = file($row->[4])->basename; pop @$row until $row->[-1]; $csv->print($output, $row); }
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Perl Script to edit the contents of a txt file
by Rudolf (Pilgrim) on Sep 12, 2012 at 07:12 UTC

    To edit the file, your going to have to copy the entire thing into perl, I would suggest into an array. And then make your changes there afterwhich you can write back to the file as a clean slate to preform your edit.

Re: Perl Script to edit the contents of a txt file
by aitap (Curate) on Sep 12, 2012 at 16:19 UTC

    Perl Script to edit the contents of a txt file
    The question looks like the author wants a text editor written in Perl. There are many choices, from simple exec(ENV{EDITOR},@ARGV) if defined $ENV{EDITOR}; to Text::Editor::Easy or even Padre.

    Or did Amarendu mean something else?

    Sorry if my advice was wrong.