Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Perl Script to edit the contents of a txt file

by Amarendu (Initiate)
on Sep 12, 2012 at 07:02 UTC ( [id://993151]=perlquestion: print w/replies, xml ) Need Help??

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

This node falls below the community's threshold of quality. You may see it by logging in.

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://993151]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (7)
As of 2024-04-23 15:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found