Perl: how to delete line from file?

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Perl: how to delete line from file?

Postby geek73666 » Wed Mar 30, 2011 6:41 am

I'm writing a simple Perl script, and want to delete a user specified line from a file. Can anyone help me? :?: :?:
geek73666
 
Posts: 4
Joined: Wed Mar 30, 2011 6:37 am

Postby geek73666 » Sat Apr 09, 2011 1:11 am

I know how now!!! Use tie::file and splice, like this:
Code: Select all
use Tie::File;
tie @array, 'Tie::File', 'filename';
splice @array, 1,1;

That will delete the second line from the file filename :) seems obvious now... :oops:
geek73666
 
Posts: 4
Joined: Wed Mar 30, 2011 6:37 am


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests