RE: PERL PROGRAM HELP!

2001-06-21 Thread Aaron Craig

At 11:35 20.06.2001 +0100, Govinderjit Dhinsa wrote:
Iv been givin this program to modify, but I can not astblish what some parts
of the program are doing.   From

printf
to
}

Can any body help please and run through it with me pls!



open iscd,$ARGV[0] or die Cannot open $ARGV[0],$!;

this opens a file that's been typed in at the command line

open sortcode,$ARGV[1];

this opens the second file that's been typed in at the command line

while($line=iscd){
 chomp $line;
 @fields=split \t,$line;

this grabs one line at a time from the first file and splits it out into an 
array -- the line is apparently a tab delimited list

 printf sortcode
\n%6.6s%8.8s%3.3s%27.27s%20.20s%35.35s%35.35s%10.10s%1.1s%1.1s%2.2s%2.2s%2.
2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%1.1s%1.1s%6.6s%35.35s%4.4s%4.4s%10.10s
%8.8s,

$fields[0],$fields[1],$fields[2],$fields[4],$fields[5],$fields[6],$fields[7]
,$fields[11],$fields[14],$fields[25],

$fields[26],$fields[27],$fields[28],$fields[29],$fields[30],$fields[31],$fie
lds[32],$fields[33],

$fields[34],$fields[35],$fields[58],$fields[60],$fields[61],$fields[64],
$fields[76],$fields[77],$fields[78],$fields[79];
}

this formats the data from the line and prints it out to the second 
file.  There's probably a cleaner and easier-to-read way to do 
this.  However, if you look at the docs for printf, and compare the input 
and output files you should be able to figure out exactly how the lines are 
getting formatted and printed.

Aaron Craig
Programming
iSoftitler.com




RE: PERL PROGRAM HELP!

2001-06-20 Thread Govinderjit Dhinsa

Hi, I am new to perl and have been chucked in the deep end!!!   I have been
asked to write a perl script, with a output in report style;

Description for script:
Read a file,  (sorted) 
take certain data from the file,  (problem)
put the certain data in to fields.(problem)

The big problem being that the File is not sorted in any form, e.g. no
existing columns or fields or Headings!

What I need to get from the file are:
ID NUMBER, BranchNAME, ADDRESS. 


The file contains the above 3 data types and about another 5, which I need
to get rid off! 

Can any body please suggest how do this task or what I need to read up on
(topics e.g. Report writing etc) or any other tutorials on report writing
or, any thing to show me how to get certain data from a file
please

Any help would be appreciated as I only have two days to this in!!!

Somebody please help!



Re: PERL PROGRAM HELP!

2001-06-20 Thread Me

 Hi, I am new to perl and have been chucked in the deep end!!!   I have
been
 asked to write a perl script, with a output in report style;

 Description for script:
 Read a file,  (sorted)
 take certain data from the file,  (problem)
 put the certain data in to fields.(problem)

 The big problem being that the File is not sorted in any form, e.g. no
 existing columns or fields or Headings!

 What I need to get from the file are:
 ID NUMBER, BranchNAME,
ADDRESS.

 The file contains the above 3 data types and about another 5, which I
need
 to get rid off!

 Can any body please suggest how do this task or what I need to read up
on
 (topics e.g. Report writing etc) or any other tutorials on report
writing
 or, any thing to show me how to get certain data from a file
 please

 Any help would be appreciated as I only have two days to this in!!!

Post an example of the input, 10-20 lines or so.
Also, state roughly how many lines there will be in
an input file.

Reading the file, pulling data out, and structuring
the data you've pulled out, will probably be relatively
easy based on your brief description.

The output might be real simple, or might be tricky,
depending on what's needed.

So, post a better idea of what output is needed.

If the output is going to be pretty short and/or only used
a couple times, it might be best to just keep the output
format extremely simple.

Otherwise, if you can dump the output into some other
software that's good at taking structured data and
doing report layouts of the sort you need, then maybe
use that.

Otherwise, if the output is going to be many pages long,
and you want fairly simple report style pagination and
formatting, then you *might* want to use perl's 'format'
features. To read up on the latter, type the following at
a shell prompt:

perldoc perlform




RE: PERL PROGRAM HELP!

2001-06-20 Thread Kipp, James

This code is a mess, your better off rewriting it.

 
 open iscd,$ARGV[0] or die Cannot open $ARGV[0],$!;
 open sortcode,$ARGV[1];
 while($line=iscd){
 chomp $line;
 @fields=split \t,$line;
 printf sortcode
 \n%6.6s%8.8s%3.3s%27.27s%20.20s%35.35s%35.35s%10.10s%1.1s%1.1
 s%2.2s%2.2s%2.
 2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%2.2s%1.1s%1.1s%6.6s%35.35s%4.
 4s%4.4s%10.10s
 %8.8s,
  
 $fields[0],$fields[1],$fields[2],$fields[4],$fields[5],$fields
 [6],$fields[7]
 ,$fields[11],$fields[14],$fields[25],
  
 $fields[26],$fields[27],$fields[28],$fields[29],$fields[30],$f
 ields[31],$fie
 lds[32],$fields[33],
  
 $fields[34],$fields[35],$fields[58],$fields[60],$fields[61],$f
 ields[64],
$fields[76],$fields[77],$fields[78],$fields[79];
 }
 close iscd;
 close sortcode;
 exit;
 [End of file]
 
 




Re: PERL PROGRAM HELP!

2001-06-20 Thread Gary Stainburn

Hello there,

without some specifics, such as example input and required output there's not 
a lot we can do here.

However, for ideas on how to extract the required data, look at using regex 
(regular expressions) by doing 'perldoc prelre'.  For ideas on formatting the 
report look at perl formatting by doing 'perldoc perlform'.

If you need more help, give us some more to go on.

Gary

On Wednesday 20 June 2001 12:45 pm, Govinderjit Dhinsa wrote:
 Hi, I am new to perl and have been chucked in the deep end!!!   I have been
 asked to write a perl script, with a output in report style;

 Description for script:
 Read a file,  (sorted)
 take certain data from the file,  (problem)
 put the certain data in to fields.(problem)

 The big problem being that the File is not sorted in any form, e.g. no
 existing columns or fields or Headings!

 What I need to get from the file are:
 ID NUMBER, BranchNAME, ADDRESS.


 The file contains the above 3 data types and about another 5, which I need
 to get rid off!

 Can any body please suggest how do this task or what I need to read up on
 (topics e.g. Report writing etc) or any other tutorials on report writing
 or, any thing to show me how to get certain data from a file
 please

 Any help would be appreciated as I only have two days to this in!!!

 Somebody please help!

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000