Dear Monks,

I am trying to write a script which processes .RES file, where we have compiler switches starting with "-D", Script works like this: it takes .res file as first argument, and processes the file (line by line) matching for the line that contains --gnu which also contains -D switches. The output is a text file as the second argument for the script. Now the worry is that when I use "last" statement after parsing, script will fail, on the other hand, if i use "next" statement, it processes all the lines and give the output which is not required.

I need to process only once after matching the --gnu line. Kindly suggest.

Here is the script used:

open (FH, "$ARGV[0]") or die "couldn't open .RES $! file"; @res=<FH>; close(FH); $ARGV[1]="$ARGV[1]_$ARGV[0].txt"; open (RH, ">$ARGV[1]"); $count=0; foreach $line (@res) { if ($line =~ m/\-\-gnu\s/) { chomp($line); @new = split(" ",$line); foreach $n (@new) { if ($n !~ m/^$/) { if ($n =~ m/^$/) { next; } if (($n =~ /^\-D(\w\_\=\d)*/) || ($n =~ /^\-U(\w\_\=\d)*/) && +($n !~/^\-I(\w\_\=\d)*/)) { $count++; chomp($n); #print "\n$count $n"; print RH "$count $n \n"; } } } } last; } close (RH);
</code>

Here is the .res file for reference:

======== Rebuilding "_arm9e_rvds22b616/hee0pro.o" ======== /cadappl/armrvds/2.2_616/RVCT/Programs/2.2/616/linux-pentium/tcc - +-cpu=ARM9E --debug --no_debug_macros --split_sections --fpu=SoftVFP - +O2 --apcs /interwork -c -I../incl -I/vobs/package187/psifappi/modules +/accessi/incl -I/vobs/package277/psatmapi/modules/atmapi/incl -I/vobs +/project159/vyp1087a/packages/dincust/modules/dinstub/srce/mkstub/inc +l -I/vobs/package275/audiocodec/modules/codeci/incl -I/vobs/package16 +2/psenv/modules/cyc/incl -I/vobs/package170/psbattery/modules/dbat/in +cl -I/vobs/package226/psdbg/modules/dbgman/incl -I/vobs/project159/vy +p1087a/packages/dincust/modules/dinstub/srce/mkstub/incl -I/vobs/pack +age165/pskid/modules/devcgu/incl -I/vobs/project159/vyp1087a/packages +/dincust/modules/dinstub/srce/mkstub/incl -I/vobs/project159/vyp1087a +/packages/dincust/modules/dinstub/srce/mkstub/incl -I/vobs/project159 +/vyp1087a/packages/dincust/modules/dinstub/srce/mkstub/incl -I/vobs/p +ackage165/pskid/modules/devdmau/incl -I/vobs/package165/pskid/modules +/devebi/incl -I/vobs/package165/pskid/modules/devextint/incl -I/vobs/ +package165/pskid/modules/devfci/incl -I/vobs/package165/pskid/modules +/devgeac/incl -I/vobs/package165/pskid/modules/devgpio/incl -I/vobs/p +ackage165/pskid/modules/deviic/incl -I/vobs/package165/pskid/modules/ +deviis/incl -I/vobs/package165/pskid/modules/devintc/incl -I/vobs/pac +kage165/pskid/modules/devjtag/incl -I/vobs/package165/pskid/modules/d +evkbs/incl -I/vobs/package165/pskid/modules/devpdcu/incl -I/vobs/pack +age165/pskid/modules/devpio/incl -I/vobs/package165/pskid/modules/dev +pwm/incl -I/vobs/project159/vyp1087a/packages/dincust/modules/dinstub +/srce/mkstub/incl -I/vobs/package165/pskid/modules/devsc/incl -I/vobs +/package165/pskid/modules/devscon/incl -I/vobs/package165/pskid/modul +es/devsctu/incl -I/vobs/package165/pskid/modules/devspi/incl -I/vobs/ +package165/pskid/modules/devtbu/incl -I/vobs/package165/pskid/modules +/devuart/incl -I/vobs/package165/pskid/modules/devusb/incl -I/vobs/pa +ckage165/pskid/modules/devusim/incl -I/vobs/project159/vyp1087a/packa +ges/dincust/modules/dinstub/srce/mkstub/incl -DTSR1_TRACE_BLOCK_SIZE= +170 -DTSR_DMA_TRACE_DBG -DTST_TASK_NUMBER=10 -DTVOUT_DRV_TVO_HDW -DTW +O_IP_ADDRESS_PER_PROFILE_CPR -DTXSETUP_EXTENDED_FTR -DTYPE1_UMTS_L1_I +NIT_SFI -DUART0_AVAILABLE=1 -DUART0_FLOW_CONTROL_TAT_FTR -DUART1_AVAI +LABLE=1 -DUCS2_EDITOR_FTR -DUCS2_IN_CLASSMARK -DUCS2_SMS -DUICC_3GPP_ +R6_ALIGNMENT_FTR -DUMACUL_RMNI_DEBUG -DUMAC_HSDPA_HISTORY -DUMAC_SPEE +CH_TRACING -DUMTS -DUMTS_BAND_CONFIG=3 -DUMTS_CONFIG_BAND=3 -DUMTS_FA +ST_PAGING_SFI -DUMTS_FTR -DUMTS_HSDPA -DUMTS_L1_FULL_DATA_TRACE_DBG - +DUMTS_MULTIBAND_FTR -DUMTS_RESEL_THRESHOLD_IN_2G_SFI -DUMTS_RRC_HSDPA +_DEBUG _FTR -UPNX5220_2_HDW -UPNX6529_HDW ======== Rebuilding "_arm9e +_rvds22b616/eeprom.ptl" ======== rm -f -f _arm9e_rvds22b616/eeprom.ptl /cadappl/armrvds/2.2_616/RVCT/Programs/2.2/616/linux-pentium/armli +nk --partial -o _arm9e_rvds22b616/eeprom.ptl _arm9e_rvds22b616/hee0 +pro.o _arm9e_rvds22b616/hee1sim.o _arm9e_rvds22b616/hee2util.o _arm9e +_rvds22b616/hee5gsm.o Will store derived object "/vobs/package159/psflash/modules/eeprom/src +e/_arm9e_rvds22b616/eeprom.ptl" ========================================================

In reply to Processing .RES file by raghvens

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.