All, 

the data below is my end result from my code below, but I am wondering and 
trying to find a better way to print this from an array that may be 
populated with only 1 element or 39 elements? 
as you can see there is only 18 elements, but I cannot have 39 print lines 
if an array is not populated w/39 elements, right?  So I opted for the 
line highlighted to try and print all elements.  The reasoning is if I 
have a file that has max 40 lines in it (1-40) I will need to print all 40 
and anywhere in between 1-40 so instead of having 39 print lines will the 
print map work with my necessary syntax characters; -w 'barcode= or ' ?
I could have the E strings be $_....   thinking to myself....  ; ? )

thank you, !


edm01:/usr/local/bin/perld>> perl traverse_array.pl testtapes
-w 'barcode=E00085 or barcode=E00086 or barcode=E00096 or barcode=E00184'
-w 'barcode=E00245 or barcode=E00271 or barcode=E00293 or barcode=E00351'
-w 'barcode=E00524 or barcode=E00584 or barcode=E00585 or barcode=E00586'
-w 'barcode=E00587 or barcode=E00588 or barcode=E00589 or barcode=E00654'
-w 'barcode=E00702 or barcode=E00771 or barcode=E00876'


Here is my code:


#!/usr/local/bin/perl -w
use strict;
open (FH,"/usr/local/bin/perld/derektapes") or die "cannot open FH: $! 
\n";
my @a=();
my $i=0;
my $ct=0;
my $or_string=" or ";
my $w_param="-w '";
my $b_param="barcode=";
while (<FH>) {
        chomp $_;
        $a[$i]=$_;
        $i++;
}
#               if ( $ct == 0 ) {
        #       print map {$_, "\n"} @a;
                print $w_param; print $b_param; print $a[0];
                print $or_string;print $b_param; print $a[1];
                print $or_string;print $b_param; print $a[2];
                print $or_string;print $b_param; print "$a[3]'\n";

                print $w_param; print $b_param; print $a[4];
                print $or_string; print $b_param; print $a[5];
                print $or_string; print $b_param; print $a[6];
                print $or_string; print $b_param; print "$a[7]'\n";

                print $w_param; print $b_param; print $a[8];
                print $or_string; print $b_param; print $a[9];
                print $or_string; print $b_param; print $a[10];
                print $or_string; print $b_param; print "$a[11]'\n";

                print $w_param; print $b_param; print $a[12];
                print $or_string; print $b_param; print $a[13];
                print $or_string; print $b_param; print $a[14];
                print $or_string; print $b_param; print "$a[15]'\n";

                print $w_param; print $b_param; print $a[16];
                print $or_string; print $b_param; print $a[17];
                print $or_string; print $b_param; print "$a[18]'\n"


Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
614-566-4145

Reply via email to