Perl Script to Read and Print N Characters from a File

In the below sample script, i am reading and printing first 60 characters from each line/record

open(IN,”
open(OUT,”>output”);
while ()
{
     $st=$_;
     if($st =~ /^(.{60}) +\n/si)
    {
           print OUT “$1\n”;
    }
    else
    {
         print OUT $st;
    }
}
close(output)
close(input)


About mohan

This is Mohan Jayapalan author of TechPages Blog.I am a part time blogger and Currently working for private Software Concern.

© Copyright 2010-2016 www.techpages.org · All Rights Reserved · Powered by WordPress ·