raghvens has asked for the wisdom of the Perl Monks concerning the following question:
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:</code>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);
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" ========================================================
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Processing .RES file
by moritz (Cardinal) on Sep 30, 2009 at 14:52 UTC | |
|
Re: Processing .RES file
by arun_kom (Monk) on Oct 01, 2009 at 08:23 UTC | |
by raghvens (Novice) on Oct 01, 2009 at 11:06 UTC | |
by arun_kom (Monk) on Oct 01, 2009 at 11:24 UTC | |
by raghvens (Novice) on Oct 01, 2009 at 11:47 UTC | |
by arun_kom (Monk) on Oct 01, 2009 at 14:33 UTC | |
| |
|
Re: Processing .RES file
by arun_kom (Monk) on Sep 30, 2009 at 14:55 UTC | |
by raghvens (Novice) on Oct 01, 2009 at 04:31 UTC | |
|
Re: Processing .RES file
by wfsp (Abbot) on Sep 30, 2009 at 15:08 UTC | |
by raghvens (Novice) on Oct 01, 2009 at 05:28 UTC |