Results 1 to 3 of 3

Thread: How to remove text using PERL

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    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";

  3. #3
    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");

Similar Threads

  1. Replies: 5
    Last Post: 02-07-2011, 10:42 AM
  2. Remove the end of a text file
    By Amie in forum Software Development
    Replies: 6
    Last Post: 22-01-2010, 09:03 PM
  3. How to remove Worm.Perl.SHS.{A-B}from my system?
    By WILTON in forum Networking & Security
    Replies: 5
    Last Post: 24-12-2009, 02:23 AM
  4. Handling basic text file using Perl
    By Amie in forum Software Development
    Replies: 3
    Last Post: 06-11-2009, 11:37 PM
  5. How do I remove border from text box
    By Digamber in forum Windows Software
    Replies: 2
    Last Post: 28-07-2009, 05:50 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,763,082.99766 seconds with 16 queries