> In the actual file, is the first record really spread out over three lines,
> or is that just the result of line-wrapping in your email message?

The first three lines can be omitted they will not be included in the input 
file.
And yes it was wrapped by my email. Sorry about that.

> 
> For the first two records below is the output I am trying to get. I
> need to print out the record it belongs to in brackets. Like the
> following:

> You show only '[1]' below. Do you want the '[1]' replaced by '[2]' in the
> second record, '[3]' in the third record, etc.?

Yes this was a mistake on my part. How you explain it in the previous statement 
is what I am trying to obtain.

> 
> u
> csno=871
> svgrp=0
> antfc=1
> cdmanbr_list1.ncs_c[1]=871
> cdmanbr_list1.nghbrantf[1]=2
> cdmanbr_list1.pgn_c[1]=0
> cdmanbr_list1.bandclass[1]=1900
> cdmanbr_list1.anbeaplt=n
> cdmanbr_list1.nghb_conf=0
> cdmanbr_list1.hdhandoff=n
> u
> EXIT
> 
> 
> u
> csno=871
> svgrp=0
> antfc=1
> cdmanbr_list1.ncs_c[1]=873
> cdmanbr_list1.nghbrantf[1]=3
> cdmanbr_list1.pgn_c[1]=1
> cdmanbr_list1.bandclass[1]=1900
> cdmanbr_list1.anbeaplt=n
> cdmanbr_list1.nghb_conf=0
> cdmanbr_list1.hdhandoff=n
> u
> EXIT
> 
> The script so far is:
> 
> #!/usr/bin/perl

You should have here:

use strict;
use warnings;



> use Getopt::Std;
> 
> getopts('f:d:m: h');
> 
> sub usage()
> {
>   print "USAGE:  make_fci.pl -f <comma delimited file> -d <roamer
> service list>\n";
>   print "                   -m <rcv mode (i,d,r,u)> [-h help]\n";
> }
> 
> if($opt_h)
> {
>    usage();
>    exit(0);
> }
> 
> $dialplan=$opt_d;
> $mode = "";
> 
> if($opt_m =~ /^[idur]$/)
> {
>    $mode=$opt_m;
> } else {
>    usage();
>    exit(1);
> }
> 
> 
> if($opt_f ne "")
> {
>    open(FIN,"$opt_f") || "Can't open file:  $opt_f.\n Error:  $!";
> } else {
>    usage();
>    exit(1);
> }
> 
> @DB_FIELDS = 
> ("csno=","svgrp=","antfc=","cdmanbr_list1.ncs_c[1]=","cdmanbr_list1.nghbrantf[
> 1]=","cdmanbr_list1.pgn_c[1]=","cdmanbr_list1.bandclass[1]=","cdmanbr_list1.an
> beaplt=","cdmanbr_list1.nghb_conf=","cdmanbr_list1.hdhandoff=");

> With a little more work, you can read these headers from the first record!

How may I do this?

> 
> print "fci\n";
> print "$mode\n";
> while(<FIN>)
> {
>    $_ =~ s/ //g;
>    chomp();
>    @data = split(",",$_);
>    print $DB_FIELDS[0],"$data[0]\n";
>    print $DB_FIELDS[1],"$data[1]\n";
>    print $DB_FIELDS[2],"$data[2]\n";
>    print $DB_FIELDS[3],"$data[3]\n";
>    print $DB_FIELDS[4],"$data[4]\n";
>    print $DB_FIELDS[5],"$data[5]\n";
>    print $DB_FIELDS[6],"$data[6]\n";
>    print $DB_FIELDS[7],"n\n";
>    print $DB_FIELDS[8],"0\n";
>    print $DB_FIELDS[9],"n\n";

> All of those similar-looking lines are crying out for a loop.

Do you mind showing me how?

>    print "$mode\n";
>    print "EXIT\n";
>    print "$mode\n";
> }
> print "<\n";
> print "<\n";
> print "<\n";
> close(FIN);

> You will want to keep a record counter that you increment for each record
> read. What else you need to do depends upon your answers to the above
> questions.

Do you mind showing me how to keep record counter?

Thank you





-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to