in reply to How to perform single operation to each line in file
I did some changes in to your code & was able to achieve what you were looking.Here is the code
#!/usr/bin/perl use strict; use warnings; use strict; use warnings; use diagnostics; use Modern::Perl; open FH, '<', 'Perl_file.txt' or die "Could not open file= $!"; while( <FH>) { chomp($_); my $line =$_; $line =~ s/\s+//gs; my $char_a = substr($line, 0, 2); my $char_b = substr($line,2,2); print $char_a; print $char_b; }
Data i inserted in to Perl_file.txt was
Raam larry marry sephali
OUTPUT:
Raamlarrmarrseph
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to perform single operation to each line in file
by Laurent_R (Canon) on Jan 21, 2014 at 18:10 UTC |