in reply to RFC: pianobar event example
Just to save some typing you could have written :-
$line = '"'.$data{title}.'","'.$data{album}.'","'.$data{artist}.'" +,"'.$data{songStationName}.'"'; if defined($data{coverArt}) { $line .= ',"' . $data{coverArt} . '"' ; } $line .= "\n";
But building CSV lines & quoting fields always gets a bit messy, so you might like to look at Text::CSV which knows how to get it right.
Then your code could look something like this :-
my @values = map { $data{$_} } qw/title album artist .../; $csv->combine(@values); $line = $csv->string();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RFC: pianobar event example
by soonix (Chancellor) on Aug 14, 2014 at 13:11 UTC |