How to Insert a sub string to each line in perl

Posted by Nano HE on Stack Overflow See other posts from Stack Overflow or by Nano HE
Published on 2010-04-11T09:29:08Z Indexed on 2010/04/11 9:33 UTC
Read the original article Hit count: 435

Filed under:
|

Hi, My code as below, How to remove the blank after add hello. to each lines.

#!C:\Perl\bin\perl.exe 
use strict; 
use warnings; 
use Data::Dumper;  

my $fh = \*DATA;  

#my($line) = $_;
while(my $line = <$fh>)
{
    print "Hello.".$line;
    chomp($line);

}


__DATA__  
Member Information 
    id = 0  
    name = "tom" 
    age = "20"

Output:

D:\learning\perl>test.pl
Hello.Member Information
Hello.    id = 0 # i want to remove the blank between Hello. and id
Hello.    name = "tom" # same as above
Hello.    age = "20" # same

D:\learning\perl>

© Stack Overflow or respective owner

Related posts about perl

Related posts about input-output