<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: parsing c file using perl script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553043#M840424</link>
    <description>First of all, you have the file content in $str, but that includes the newlines. Newlines are *not* matched by . in regular expressions, unless you add /s modifier.&lt;BR /&gt;&lt;BR /&gt;Secondly, (i hope you typoed) the first defenition is illegal: it misses '= {' on the declaration line. But assuming it was there in the first place,&lt;BR /&gt;&lt;BR /&gt;my %arr;&lt;BR /&gt;while ($str =~ m/\bconst\s+static\s+(\w+)\s*=\s*{(.*?)};/gs) {&lt;BR /&gt;$arr{$1} = $2;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;will place array1 in $arr{array1}, array2 in $arr{2} etc&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
    <pubDate>Fri, 27 May 2005 01:44:25 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2005-05-27T01:44:25Z</dc:date>
    <item>
      <title>parsing c file using perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553041#M840422</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am newbie to perl script programming. &lt;BR /&gt;I have given a c file, that has two arrays like&lt;BR /&gt;&lt;BR /&gt;const static  array1&lt;BR /&gt;  {1, 0, 0, 0, 0, 0},&lt;BR /&gt;  {1, 1, 0, 0, 0, 0},&lt;BR /&gt;  {0, 1, 0, 0, 0, 0},&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;const static  array2= {&lt;BR /&gt;  {"104804",339},&lt;BR /&gt;  {"106546",999},&lt;BR /&gt;  {"106547",999}&lt;BR /&gt;};&lt;BR /&gt;&lt;BR /&gt;I want to know how to extract the only first array using perl script&lt;BR /&gt;&lt;BR /&gt;I have used the follwing regular expression to parse the elements like this.&lt;BR /&gt;&lt;BR /&gt;I have my file contents in $str.&lt;BR /&gt;&lt;BR /&gt;  @struct= $str=~m/$structure\[\].*};/g;&lt;BR /&gt;  @struct_lines = $struct[0]=~m/[ ]*{[ -:{,\t\"_A-Za-z0-9.]*}/g;&lt;BR /&gt;&lt;BR /&gt;But when I print the $struct[0], it is extracting all the array elements. &lt;BR /&gt;&lt;BR /&gt;Could anybody help me in extracting only the first array?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Poornima.&lt;BR /&gt;</description>
      <pubDate>Thu, 26 May 2005 23:59:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553041#M840422</guid>
      <dc:creator>Poornima</dc:creator>
      <dc:date>2005-05-26T23:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: parsing c file using perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553042#M840423</link>
      <description>@struct= $str =~ m/const static[^;]*};/g;&lt;BR /&gt;&lt;BR /&gt;Something like this will leave you will array1 in $struct[0], array2 in $struct[1] etc.</description>
      <pubDate>Fri, 27 May 2005 00:42:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553042#M840423</guid>
      <dc:creator>Ermin Borovac</dc:creator>
      <dc:date>2005-05-27T00:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: parsing c file using perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553043#M840424</link>
      <description>First of all, you have the file content in $str, but that includes the newlines. Newlines are *not* matched by . in regular expressions, unless you add /s modifier.&lt;BR /&gt;&lt;BR /&gt;Secondly, (i hope you typoed) the first defenition is illegal: it misses '= {' on the declaration line. But assuming it was there in the first place,&lt;BR /&gt;&lt;BR /&gt;my %arr;&lt;BR /&gt;while ($str =~ m/\bconst\s+static\s+(\w+)\s*=\s*{(.*?)};/gs) {&lt;BR /&gt;$arr{$1} = $2;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;will place array1 in $arr{array1}, array2 in $arr{2} etc&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Fri, 27 May 2005 01:44:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553043#M840424</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-05-27T01:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: parsing c file using perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553044#M840425</link>
      <description>Thanks guys,&lt;BR /&gt;&lt;BR /&gt;That solved my problem.&lt;BR /&gt;&lt;BR /&gt;-Poornima.</description>
      <pubDate>Fri, 27 May 2005 02:29:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-c-file-using-perl-script/m-p/3553044#M840425</guid>
      <dc:creator>Poornima</dc:creator>
      <dc:date>2005-05-27T02:29:27Z</dc:date>
    </item>
  </channel>
</rss>

