(Reading time: 1 minute)

The following snippet removes the first character from all the lines in a  file.

 

 
 
 
$file = "d:\\temp.txt";
open (FILE, $file) || die $!;
while (<FILE>) {
 $val = substr $_, 1;
 push (@lines, $val);
}
close FILE;
 
 
open (FILE, ">$file") || die $!;
seek FILE, 0, 0;
truncate $file, 0;
print FILE @lines;
 
 
 
 

Oxygen
Author: Oxygen
Other articles by this author

Chillzee Tag Cloud

Let's Socialize

About Chillzee

Chillzee.com is an entrepreneurship portal.

The site provides informative topics on Organizational and Strategic needs.