CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Remove 8 characters from the begining of a line

 



Serja
New User

Aug 14, 2013, 12:27 PM

Post #1 of 3 (767 views)
Remove 8 characters from the begining of a line Can't Post

I want to remove the first 8 characters from a file on EACH line.

It would be like:



example test 1 2 3 4 5

example test 1 2 3 4 5

example test 1 2 3 4 5



To return:

test 1 2 3 4 5

test 1 2 3 4 5

test 1 2 3 4 5

Hoping to see just an example of this if that's ok. Thanks!

while ($data = <INFILE>){


$data =~ s/\^,/\^/;
if (substr ($data, 0, 7) eq 'ITEMINT') {
$data =~ s/,,//;
}
print OUTFILE $data;
}


FishMonger
Veteran / Moderator

Aug 14, 2013, 1:44 PM

Post #2 of 3 (764 views)
Re: [Serja] Remove 8 characters from the begining of a line [In reply to] Can't Post


Code
$data =~ s/^.{8}//;



Serja
New User

Aug 15, 2013, 7:27 AM

Post #3 of 3 (756 views)
Re: [FishMonger] Remove 8 characters from the begining of a line [In reply to] Can't Post

Thank you so much, it works perfectly. I had way too much going on in there! Smile

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives