Reputation: 23539
I have a perl script I am writing to parse a file based on regex. The problem is the file always starts with a new line. When I turn on hidden chars in vi it shows up as a "$" (this is vi on cygwin). is there a way I can use regex to remove them? I tried
s/\n//g
But that did not seem to work.
Upvotes: 1
Views: 149
Reputation: 6578
Or just:
#!/usr/bin/perl
use warnings;
use strict;
use File::Slurp;
my @file = read_file('input.txt');
shift(@file);
foreach(@file){
...
}
Upvotes: 1
Reputation: 6552
If indeed your problem is caused solely by the presence of one extra line at the top of your input file, and presuming you are using a typical loop like while (<FILE>) { ... }
, then you can skip the first line of the input file by inserting this line at the very beginning within your loop:
next unless $. > 1;
Upvotes: 3