Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 23-06-2009
Member
 
Join Date: Apr 2009
Posts: 79
How to remove text using PERL

Suppose i have a variable which pointed towards some string with special character for example : $b="abcdef^bbwk#kdbcd@"; I need a perl script which will open that file delete the first line as per the given example and if possible write them back.
Reply With Quote
  #2  
Old 23-06-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: How to remove text using PERL

#!/usr/bin/perl
Code:
$b = "abcdef^bbwk#kdbcd@";
$b =~ s/[^b-zA-Z0-9]*//g;

print $b . "\n";
Reply With Quote
  #3  
Old 23-06-2009
Member
 
Join Date: Jan 2009
Posts: 199
Re: How to remove text using PERL

Code:
open(IN,"<perl.txt);
open(OUT,">new_perl.txt");
while (IN)
{
   # if not first line ($.) write current line ($_) to out file
    $. > 1 and print(OUT $_);
}
close(IN);
close(OUT);

# if you want to overwrite the original
rename("new_perl.txt","perl.txt");
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to remove text using PERL"
Thread Thread Starter Forum Replies Last Post
Can we use Mod to remove ?K.O.? ?YOU WIN? giant text from SSF4: EA? Vrishabh Video Games 5 02-07-2011 10:42 AM
Remove the end of a text file Amie Software Development 6 22-01-2010 09:03 PM
How to remove Worm.Perl.SHS.{A-B}from my system? WILTON Networking & Security 5 24-12-2009 02:23 AM
Handling basic text file using Perl Amie Software Development 3 06-11-2009 11:37 PM
How do I remove border from text box Digamber Windows Software 2 28-07-2009 05:50 PM


All times are GMT +5.5. The time now is 10:31 AM.