#!/usr/bin/perl
use warnings;
use Switch;
while (<>) {
next if /^\s*\/\//;
next if /^\s*$/;
my $line="$_";
chomp($line);
print $line;
print "Checking for line:\n$line";
}
This is my code which takes input file from command line. It takes the following file as input:
// Computes R0 = 2 + 3
@2
D=A
@3
D=D+A
@0
M=D
In the code I tried to remove the newline at the end of each line with the help of chomp function. But when I try to print the line after application of chomp it prints nothing for that line. It gives the following output:
Checking for line: Checking for line: Checking for line: Checking for line: Checking for line: Checking for line:
Why is the line not being printed?