PigInACage wrote: > Hello all. > > I've got a file CSV with 3 column > name,surname,group > > if one of the column has got a space like > Davide,Super Dooper,Group > I cannot use it in a for loop > > for i in `cat list.csv` ; do echo $i ; done > the result is > Davide,Super > Dooper,Group > > how can I have all inone line?
use perl; % perl -pi -e '$_' < names.txt # where names.txt contains Davide,Super Dooper,Group Steve,Ross Bertrand,Engineer Matt,David Delanty,Admin Or, if within a script: #!/usr/bin/perl use warnings; use strict; open CSV, '<', 'names.txt' or die "Can't open the damned file!: $!"; while ( my $entry = <CSV> ){ print "$entry"; } ...this is assuming that you just want to print the entire line, without separating at the comma. If you did, and you wanted to use each item individually: #!/usr/bin/perl use warnings; use strict; open CSV, '<', 'names.txt' or die "Can't open the damned file!: $!"; while ( my $entry = <CSV> ){ my ( $first, $last, $group ) = split( ',', $entry ); print "$first :: $last :: $group"; } Steve -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/