I want to delete part of a line in txt file using file hanling in perl -


such if lines in input file :

  abc !asdas   abc, sadasda  abc. 

the output file shoud be:

  abc  abc,  abc. 

here 1 way it. may need adjust split if data gets different. split on space.

#!/usr/bin/perl  use strict; use warnings;  open (my $in, '<', "in.txt") or die $!; open (my $out, '>', "out.txt") or die $!;  while (<$in>) {     ($val) = split ' ';     print $out "$val\n"; }  close ($in); close ($out); 

if had though, command line:

awk '{ print $1 }' in.txt > out.txt 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -