CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...: Re: [gopsi1234] Generate a C file from CSV file using perl: Edit Log



Zhris
Enthusiast

Jun 20, 2014, 6:42 PM


Views: 55602
Re: [gopsi1234] Generate a C file from CSV file using perl

Heres one of many ways, keeping to the flip-flop/range approach:


Code
#!/usr/bin/perl  
use strict;
use warnings;

while ( <DATA> )
{
if ( /CHIP/ .. /END/ and not /CHIP|END/ )
{
s/\s+$//;

printf "{%s, FLASH_CONFIGURATION_DEVICE(%s, %s, %s, %s, %s, %s, %s, %s, %s)}\n",
(split /, /)[1..9,0];
}
}

__DATA__
vendorid, memid, size, devid, cmd, addr, mode, dummy, conf_wid, rate
CHIP XXX
0xBF, 0x2501, 256, yyy, 1, 3, 0, 0, 0, 20
END
CHIP YYY
0xBF, 0x2501, 512, yyy, 1, 3, 0, 0, 0, 20
END


Chris


(This post was edited by Zhris on Jun 20, 2014, 6:49 PM)


Edit Log:
Post edited by Zhris (Enthusiast) on Jun 20, 2014, 6:43 PM
Post edited by Zhris (Enthusiast) on Jun 20, 2014, 6:44 PM
Post edited by Zhris (Enthusiast) on Jun 20, 2014, 6:49 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives