Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Perl: how to delete line from file?

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
geek73666



Joined: Wed Mar 30, 2011 7:37 am
Posts: 4

PostPosted: Wed Mar 30, 2011 7:41 am    Post subject: Perl: how to delete line from file? Reply with quote

I'm writing a simple Perl script, and want to delete a user specified line from a file. Can anyone help me? Question Question
Back to top
View user's profile Send private message
geek73666



Joined: Wed Mar 30, 2011 7:37 am
Posts: 4

PostPosted: Sat Apr 09, 2011 2:11 am    Post subject: Reply with quote

I know how now!!! Use tie::file and splice, like this:
Code:

use Tie::File;
tie @array, 'Tie::File', 'filename';
splice @array, 1,1;

That will delete the second line from the file filename Smile seems obvious now... Embarassed
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast