#!/usr/bin/perl use strict; use warnings; use Text::ParseWords; # WARNING: this code may generate some warnings # but checking is omitted intentionally my @headers; { local $_ = ; chomp; @headers = parse_line(',', 0, $_); } my @people; while () { chomp; my @fields = parse_line(',', 0, $_); push @people, { map { $headers[$_], $fields[$_] } 0 .. $#headers }; } printf qq(%s says "%s"\n), @{$people[0]}{@headers}; # Isha says "Hello!!" __DATA__ Name,Comment "Isha","""Hello!!""" "Malav" ,"""koni comments nakhu ? tari?""" "Mihir","""Dont know what to write :)""" "Mukesh","""Kya comment add karun""" "Tanmay Anjaria","""I - Intelligent S - Smart H - Highly thoughtful A - Antonyms should be taken for all of the above to know Isha :-)) Just Kidding... Keep Smiling, dear\u2026""" #### my %people; while () { chomp; my @fields = parse_line(',', 0, $_); for (0 .. $#headers) { push @{$people{$headers[$_]}}, $fields[$_]; } } printf qq(%s says "%s"\n), map { $people{$_}[0] } @headers; # Isha says "Hello!!"