![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Help with Perl Scripting Issue. | manik112 | Shell Programming and Scripting | 23 | 12-13-2008 12:52 PM |
| Perl Script Issue - Please Help * Thanks!!! | jroberson | Shell Programming and Scripting | 8 | 11-03-2008 03:47 AM |
| perl issue .. | zedex | Shell Programming and Scripting | 3 | 09-13-2008 11:22 PM |
| issue with if loop in perl | amitrajvarma | Shell Programming and Scripting | 4 | 01-09-2008 12:02 AM |
| Perl problem (compiling issue) | 01000101 | Shell Programming and Scripting | 3 | 05-24-2006 10:15 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
Let me explain this further, the output of my file looks as following :
"Domain","address","department","displayname","sn","roomno","site","location" "Internal","1234","HCM","John D","JOHN D","rocks" 12","seigo" "Internal","12345","TDM","Mr Say","Mr Say T","hupt","margo" There are three ways in which this csv file is written out: First the header, then the first field value (Internal) which remains same across all the rows,and last all the fields values for each user in a row. As pointed by you, the following line prints only the first field value: @dn = map {s/[a-z]+=//gi; tr/"//d; $_ = ucfirst} # organization this line prints the header: print '"'.(join '","', "DuPont_ECD_Report",map {$_->[0]} @fields)."\"\n"; # header and last line which prints out fields values: print '"'.(join '","', "@dn",map {get $entry, $_->[1], $_->[2]} @fields)."\"\n"; the above line uses a subroutine "get", which I am unable to comprehend as how it process each entry. sub get { return $_[0]->exists($_[1]) ? $_[0]->get($_[1])->[$_[2] ? $_[2] : 0] : ''; } The issue is to remove the quotes occuring within the field values as mentioned in the first row. Hope this makes things clear. Thanks. |
|
|||||
|
Ah, @dn is only the first field? That's weird. Why use an array?? Oh well. So for the second join, just do this:
Code:
print '"'.(join '","', "@dn",grep {tr/"//d,$_} map {get $entry, $_->[1], $_->[2]} @fields)."\"\n";
Don't worry about this get routine so much. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| perl, perl shift, shift, shift perl |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|