473,396 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Output using format

i am working on the script as below, i want an output according to the format. i am trying to put everything in one loop but cannot figure out the way to do so. could anyone please help me with this.

Expand|Select|Wrap|Line Numbers
  1. &file_scan($orifile);
  2.  
  3. sub file_scan {
  4.  
  5.     our $reqfile = $_[0];
  6.  
  7.     open(FILE, $reqfile) or die "Cannot open the file: $!\n";
  8.  
  9.     format STDOUT_TOP =
  10.                                  REPORT
  11. -----------------------------------------------------------------------------------
  12. LINE NO.  EXTRACTION          SERIES
  13. -----------------------------------------------------------------------------------
  14. .
  15. write;
  16.  
  17.     format STDOUT =
  18. @<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<$.,    $store,          $total   
  19. -----------------------------------------------------------------------------------
  20.  
  21.     open(FILE, $reqfile) or die "Cannot open the file: $!\n";
  22.     $text=<FILE>;
  23.     while($text = <FILE>){
  24.         #getting all Extractions with numbers
  25.         if ($text =~ /\{EXTRACTION\}\s\d\d/){ 
  26.             $text =~ s/(\{EXTRACTION\}\s\d\d)/$1/g;
  27.             $counter = $counter + 1;
  28.             $store = $1;
  29.         }
  30.         write;
  31.     }
  32. }
  33.  
  34. our $reqfile = $orifile;
  35. open(FILE, $reqfile) or die "Cannot open the file: $!\n";
  36. undef $/;
  37. $text = readline(FILE);
  38. #Getting the lines between INSTRUMENTS and REQTYPE or EXTRACTION
  39. @array = ($text =~ m/^\{INSTRUMENTS\}(.*?)\s+^[\{REQTYPE\}][\{EXTRACTION\}\s\d\d]/gsm);
  40. foreach (@array){
  41.     chomp $_;
  42.     foreach($_=~ m/\n/g) {
  43.         $count++;
  44.     }
  45.     $count = 0;
  46. }
  47.  
  48.         $col_lmt = 256;
  49.         $total = $col_lmt - $count; 
  50.         write;
  51.     }
  52. }
  53.  
Here is the output am getting;

REPORT
-----------------------------------------------------------------------------------
LINE NO. EXTRACTION DATATYPE SERIES
-----------------------------------------------------------------------------------

-----------------------------------------------------------------------------------
16 {EXTRACTION} 00
-----------------------------------------------------------------------------------
38 {EXTRACTION} 00
-----------------------------------------------------------------------------------
46 {EXTRACTION} 00
-----------------------------------------------------------------------------------
57 {EXTRACTION} 00
-----------------------------------------------------------------------------------
75 {EXTRACTION} 00
-----------------------------------------------------------------------------------
86 {EXTRACTION} 00
-----------------------------------------------------------------------------------
90 {EXTRACTION} 00
-----------------------------------------------------------------------------------
113 {EXTRACTION} 01
-----------------------------------------------------------------------------------
138 {EXTRACTION} 02
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 199 255
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 199 255
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 199 255
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 200 256
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 196 252
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 200 256
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 199 255
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 200 256
-----------------------------------------------------------------------------------
181 {EXTRACTION} 02 200 256
this is what i want the output format:

REPORT
-----------------------------------------------------------------------------------
LINE NO. EXTRACTION DATATYPE SERIES
-----------------------------------------------------------------------------------

-----------------------------------------------------------------------------------
16 {EXTRACTION} 00 199 255
-----------------------------------------------------------------------------------
38 {EXTRACTION} 00 199 255
-----------------------------------------------------------------------------------
46 {EXTRACTION} 00 200 255
-----------------------------------------------------------------------------------
57 {EXTRACTION} 00 196 200
-----------------------------------------------------------------------------------
75 {EXTRACTION} 00 196 225
-----------------------------------------------------------------------------------
86 {EXTRACTION} 00 198 250
-----------------------------------------------------------------------------------
90 {EXTRACTION} 00 196 250
-----------------------------------------------------------------------------------
113 {EXTRACTION} 01 195 235
-----------------------------------------------------------------------------------
138 {EXTRACTION} 02 195 255
-----------------------------------------------------------------------------------
here is the source file

{LOGON} XBGI8
{FORMAT}
{EXTRACTION} 00
{TRIGGER}
1330
{FORMAT}
DCDEFLT=Y
MERGE=Y
TRAN=N
PADTIME=P
MNEMONIC=Y
NOTAVAIL=#NA
DATASEP=,
DATE=MM-DD-YY
SRVRFILEPREFIX=DSOR
{REQTYPE} T -31D
{DATATYPES}
X(IR)*1.0000000/100
{INSTRUMENTS}
ICN3Y
ICS3Y
ICCH3Y
IC5Y
ICN5Y
ICS5Y
ICC5Y
ICD10
ICNK10
ICSE0
{REQTYPE} T -31D
{DATATYPES}
IR
{INSTRUMENTS}
GSCAD
GSEM3M
GSGPM
GSUD3M
{REQTYPE} T -31D
{DATATYPES}
VM
{INSTRUMENTS}
IADC0
IBP00
ICDC00
CS00
IJYCS00
ISF00
{REQTYPE} T -31D
{DATATYPES}
{INSTRUMENTS}
MSKG
MSEFF
{REQTYPE} T -31D
{DATATYPES}
X/100.00000
{INSTRUMENTS}
HKME
{REQTYPE} T -31D
{DATATYPES}
RY
{INSTRUMENTS}
AAUG
AOEG
ABGGV
ACNGV
ADKGVG
AFNA
AFVG1
AHKG1
AIRGG1
{REQTYPE} T -31D
{DATATYPES}
DU
{INSTRUMENTS}
AVG1
AVG2
AAVG3
AAUG4
AAVG5
ABG1
ABDG2
ABDG3
ABDG
{REQTYPE} T -31D
{DATATYPES}
PI
{INSTRUMENTS}
SGVTLNG
{REQTYPE} T -31D
{DATATYPES}
{INSTRUMENTS}
ICG10
UKRPB
UKLTB
ICA5Y
ICU10
{REQTYPE} T -31D
{DATATYPES}
{INSTRUMENTS}
M3DWOGL
{EXTRACTION} 01
{TRIGGER}
1330
{FORMAT}
DCDEFLT=Y
MERGE=Y
TRAN=N
PADTIME=P
MNEMONIC=Y
NOTAVAIL=#NA
DATASEP=,
DATE=MM-DD-YY
SRVRFILEPREFIX=DSCC
{REQTYPE} T -12M
{DATATYPES}
{INSTRUMENTS}
AUNDXR
CN131
DSCCIQ
BDEUSIQ
SDCNR
SWEC
UKEU
{EXTRACTION} 02
{TRIGGER}
1330
{FORMAT}
DCDEFLT=Y
MERGE=Y
TRAN=N
PADTIME=P
MNEMONIC=Y
NOTAVAIL=#NA
DATASEP=,
DATE=MM-DD-YY
SRVRFILEPREFIX=DSORMON
{REQTYPE} T 01/10/1977
{DATATYPES}
{INSTRUMENTS}
EMOCPP
BGPRO
CNPR
DKPR
Aug 28 '07 #1
2 2002
miller
1,089 Expert 1GB
The best advise that I can give you is to avoid using format entirely for many, many reasons. Instead use Perl6::Form

Also, I attempted to fix the formatting of our code, but it appears that your brackets are not balanced.

- Miller
Aug 30 '07 #2
Thanks miller. I did avoided the format and it works fine now.
Sep 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sebastien de Menten | last post by:
Hi, I am using the profile module to watch hot spots in a python application. The default output is already useful but has anyone tried to produce output readable by kcachegrind...
3
by: danmc91 | last post by:
Hi, I'm just getting going with xml and xslt. I'm trying to write what are essentially man pages and I need 3 output formats. 1) nroff -man format for real man pages 2) html for an online...
3
by: Paul Watson | last post by:
It is clear that just using 'print' with variable names is relatively uncontrollable. However, I thought that using a format string would reign the problem in and give the desired output. Must...
8
by: FS Liu | last post by:
Hi, I am writing ATL Service application (XML Web service) in VS.NET C++. Are there any sample programs that accept XML as input and XML as output in the web service? Thank you very much.
11
by: aljaber | last post by:
hi, i am facing a problem with my program output here is the program /*********************************************\ * CD Database * * ...
0
by: surya926 | last post by:
Hello I am loading one input xml file and after manipulating the xml file the data should update in that xml file and returns the updated xml file as a output. Here my problem is i am using...
4
by: john | last post by:
I am reading TC++PL3, and on page 468, at "21.4.3 Floating-Point Output", it formats floating point output in the style: cout.setf(ios_base::scientific, ios_base::floatfield); // use scientific...
5
by: amit.uttam | last post by:
Hey everyone, I've recently jumped big time into python and I'm working on a software program for testing automation. I had a question about proper logging of output. What I would like is: 1....
8
by: victor.herasme | last post by:
Hi, i am building a little script and i want to output a series of columns more or less like this: 1 5 6 2 2 8 2 9 5 The matter is that i don't know in advance how many columns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.