in reply to split a line by control ^D character
my $FileLocation = '/home/RND/Sample.txt'; open my $FILE, '<', $FileLocation or die "$!"; my @LineDetails = do { local $/ = chr(4); <$FILE> }; map { print "$_\n" } @LineDetails;
This eliminates both for loops.
Note that the foreach keyword is actually a synonym for the for keyword, so in your original post, you can have replaced "foreach" with "for" in both places, which also simplifies your code.
|
|---|