I've quoted below a basic script that reads a file and prints its content. Whatever the file is (/etc/hosts is just an example), the script adds a space for all the lines following line #1, i.e:
line 1
line 2
line 3
I would like it to return the file as it is, i.e:
line 1
line 2
line 3
What's wrong !?
#! /usr/bin/perl -w
use strict;
sub read_file{
my $file = shift;
my @file;
open (FILE, "< $file"
or die "Can't open $file: $! \n";
@file = <FILE>;
close (FILE) or die "FH didn't close: $!";
return @file;
}
my @output = read_file("/etc/hosts"
;
print "@output\n";
line 1
line 2
line 3
I would like it to return the file as it is, i.e:
line 1
line 2
line 3
What's wrong !?
#! /usr/bin/perl -w
use strict;
sub read_file{
my $file = shift;
my @file;
open (FILE, "< $file"
@file = <FILE>;
close (FILE) or die "FH didn't close: $!";
return @file;
}
my @output = read_file("/etc/hosts"
print "@output\n";