#!/usr/bin/perl
open(SARAN,"first.txt") or die "Can't Open: $!\n";
while($line=<SARAN>)
{
print "$line\n";
}
close SARAN;
Hi,
In the above perl script, i need one functionality…
in first.txt, each line starts with some space in front..
I need to print the lines without space in front…
What to do.
thanks..
Your question is ambiguous: Do you want to print the lines that do not start
with space(s) or print all the lines after removing any leading space(s)?
@codaddict showed how to do the latter. I will show how to do the former:
Note the following:
usestrictwill help you catchprogramming errors.
usewarningswill alert you todubious constructs.
SARANare package globals. Use lexicalfilehandles.
open, especially if the filename isnot hardcoded.
$line,print "$line\n"would cause newlines to be doubled.