Search code examples
arraysperlcsvchomp

Chomp doesn't work with perl script


I have this script

open (DICT,'file 0 .csv'); 

my @dictio = <DICT>;
chomp @dictio;
print @dictio;

My file 0 .csv is like this :

AAAA , a
AAAT , b
AAAC , c

So using chomp I want to delete the new row character, but when I print it my array dissapear. And when I print my array without using chomp it prints like the initially file.

So what am I doing wrong with the command chomp?

Thanks


Solution

  • Try this

    open (my $DICT, '<', 'file 0 .csv') or die "cannot open file "; 
    
    my @dictio = <$DICT>;
    chomp @dictio;
    print @dictio;