[19908] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2103 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 9 14:10:36 2001

Date: Fri, 9 Nov 2001 11:10:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005333015-v10-i2103@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 9 Nov 2001     Volume: 10 Number: 2103

Today's topics:
    Re: Shift Operators - newbie (Brian Wheeler)
    Re: Shift Operators - newbie <tony_curtis32@yahoo.com>
    Re: Shift Operators - newbie <jasper@guideguide.com>
    Re: Shift Operators - newbie (Brian Wheeler)
    Re: Shift Operators - newbie (Tad McClellan)
        Testing for Files in Directory (Torkjell Arntzen)
    Re: Testing for Files in Directory (Tad McClellan)
    Re: Unix executed thru CGI? <brian@jankoNOnet.SPAMcom.INVALID>
        using formline with mutipal arrays as the list to gener <hillr@ugs.com>
    Re: using formline with mutipal arrays as the list to g <hillr@ugs.com>
    Re: VVP: Variable = system command (vivekvp)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 9 Nov 2001 16:06:11 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: Shift Operators - newbie
Message-Id: <9sgutj$pa4$1@jetsam.uits.indiana.edu>

In article <t_SG7.116314$tb2.9116882@bin2.nnrp.aus1.giganews.com>,
	"Jessica Bull" <jessica.bull@broadwing.com> writes:
> I am trying to parse through someone else's code because modifications need
> to be made to the script.  I am having trouble understanding how the shift
> operator works.  In laymens terms I mean...i have the Programming Perl's
> interpretation on it.    The examples given are:
> 
> 1 << 4;  # Returns 16
> 32 >> 4; # Returns 2
> 
> The portion I am parsing through is:
> if($#remotetcsbpfiles>>0){@xferlist=buildxferlist(@remotetcsbpfiles)};
> 
> The logic of how it is getting the return value is primarily what I am
> looking for.  I appreciate the help.
> 

I suspect its a typo and it works by coincidence.  Left/Right shifts move the 
binary pattern of the number n positions to the left or right.  Observe:

00001 (1 in binary) << 4 = 10000  (16 in binary)
100000 (32 in binary) >> 4 = 000010 (2 in binary)

So, when you shift by 0, it doesn't do anything:
00100 (4 in binary) >> 0 = 00100 (4 in binary)

So $#remotetcsbpfiles>>0 is the same as $#remotetcsbpfiles!=0 and since
the array count cannot be less than 0, it works by luck :)

Brian Wheeler
bdwheele@indiana.edu


------------------------------

Date: Fri, 09 Nov 2001 10:07:24 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Shift Operators - newbie
Message-Id: <87eln8lygz.fsf@limey.hpcc.uh.edu>

>> On Fri, 09 Nov 2001 15:54:01 GMT,
>> "Jessica Bull" <jessica.bull@broadwing.com> said:

> I am trying to parse through someone else's code because
> modifications need to be made to the script.  I am
> having trouble understanding how the shift operator
> works.  In laymens terms I mean...i have the Programming
> Perl's interpretation on it.  The examples given are:

One way to look at it is:

    each >> is "integer division by 2".
    each << is "integer multiplication by 2".

(Just like appending a "0" in decimal multiplies by "10".)

So "16 >> 2" is 16 / 2 / 2 = 4.

> The portion I am parsing through is:
> if($#remotetcsbpfiles>>0){@xferlist=buildxferlist(@remotetcsbpfiles)};

Looks like a typo to me.  Probably it's meant to be ">=",
or possibly just ">".

  if anything in the array, do something with it.

You can also just say @remotetcsbpfiles in the "if"
(scalar context) and test for it being +ve.

Some whitespace and friendlier indenting wouldn't go amiss
either.

  if ($#remotetcsbpfiles >= 0) {
    @xferlist = buildxferlist(@remotetcsbpfiles)
  };

hth
t
-- 
Oh!  I've said too much.  Smithers, use the amnesia ray.


------------------------------

Date: Fri, 09 Nov 2001 16:12:52 +0000
From: Jasper McCrea <jasper@guideguide.com>
Subject: Re: Shift Operators - newbie
Message-Id: <3BEC0084.F91C8CDC@guideguide.com>

Brian Wheeler wrote:
> 
> In article <t_SG7.116314$tb2.9116882@bin2.nnrp.aus1.giganews.com>,
>         "Jessica Bull" <jessica.bull@broadwing.com> writes:
> > I am trying to parse through someone else's code because modifications need
> > to be made to the script.  I am having trouble understanding how the shift
> > operator works.  In laymens terms I mean...i have the Programming Perl's
> > interpretation on it.    The examples given are:
> >
> > 1 << 4;  # Returns 16
> > 32 >> 4; # Returns 2
> >
> > The portion I am parsing through is:
> > if($#remotetcsbpfiles>>0){@xferlist=buildxferlist(@remotetcsbpfiles)};
> >
> > The logic of how it is getting the return value is primarily what I am
> > looking for.  I appreciate the help.
> >
> 
> I suspect its a typo and it works by coincidence.  Left/Right shifts move the
> binary pattern of the number n positions to the left or right.  Observe:
> 
> 00001 (1 in binary) << 4 = 10000  (16 in binary)
> 100000 (32 in binary) >> 4 = 000010 (2 in binary)
> 
> So, when you shift by 0, it doesn't do anything:
> 00100 (4 in binary) >> 0 = 00100 (4 in binary)
> 
> So $#remotetcsbpfiles>>0 is the same as $#remotetcsbpfiles!=0 and since
> the array count cannot be less than 0, it works by luck :)
                  ^^^^^^^^^^^^^^^^^^^^^

True, I suppose, but $#array isn't the array count, it's a slightly
different thing.

my @array = ();
print "$#array\n";

Jasper
-- 
@a=0..63;g(o($_),a($_)?$_<24?"w":$_>39?"b":0:0)for@a;$w=$b=12;while($w||
$b){$z=!$z;$i=" 01234567\n";print$i,(join"",map{($x,$y)=o($_);($x?"":$y)
 .(a($_)?`tput smso`:`tput rmso`).(g(o($_))||" ").`tput rmso`.($x==7?"$y
":"")}@a),$i;$z?n(""):c();g($f,$g,($g==7&&$z)||(!$z&&!$g)?uc w():g($d,$e
));g($d,$e,0);t(1)}sub n{print"\n$_[0]go xyxy\n";($d,$e,$f,$g)=split"",
<STDIN>;v()||n("nfg-")}sub t{@t=($f>$d?$d+1:$d-1,$g>$e?$e+1:$e-1);if($s
==4&&g(@t)&&lc(g(@t))ne w()){if(shift){g(@t,0);$z?--$b:--$w}1}else{0}}sub
v{$s=($d-$f)**2;(lc(g($d,$e))ne w()||$s!=($e-$g)**2||g($f,$g)||($f>7||$f
<0)||($g>7||$g<0)||(($z?$e-$g:$g-$e)>0)&&!(g($d,$e)eq uc w())||!($s==1||
t()))?0:1}sub c{for(sort{rand}@a){($d,$e)=o($_);next if lc(g(o($_)))ne w
();for(@a){($f,$g)=o($_);next if!v();return 1 if t();unshift@q,[$d,$e,$f,
$g]}}($d,$e,$f,$g)=@{$q[0]}or die"win\n"}sub w{$z?"w":"b"}sub o{($_[0]%8,
int($_[0]/8))}sub a{(($_[0]%8)+(int($_[0]/8)))%2}sub g{$n=$_[0]+8*$_[1];
defined$_[2]?$position[$n]=$_[2]:$position[$n]}die$w?"win":"lose"."\n"


------------------------------

Date: 9 Nov 2001 16:17:41 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: Shift Operators - newbie
Message-Id: <9sgvj5$pa4$2@jetsam.uits.indiana.edu>

In article <3BEC0084.F91C8CDC@guideguide.com>,
	Jasper McCrea <jasper@guideguide.com> writes:
> Brian Wheeler wrote:
>> 
>> In article <t_SG7.116314$tb2.9116882@bin2.nnrp.aus1.giganews.com>,
>>         "Jessica Bull" <jessica.bull@broadwing.com> writes:
>> > I am trying to parse through someone else's code because modifications need
>> > to be made to the script.  I am having trouble understanding how the shift
>> > operator works.  In laymens terms I mean...i have the Programming Perl's
>> > interpretation on it.    The examples given are:
>> >
>> > 1 << 4;  # Returns 16
>> > 32 >> 4; # Returns 2
>> >
>> > The portion I am parsing through is:
>> > if($#remotetcsbpfiles>>0){@xferlist=buildxferlist(@remotetcsbpfiles)};
>> >
>> > The logic of how it is getting the return value is primarily what I am
>> > looking for.  I appreciate the help.
>> >
>> 
>> I suspect its a typo and it works by coincidence.  Left/Right shifts move the
>> binary pattern of the number n positions to the left or right.  Observe:
>> 
>> 00001 (1 in binary) << 4 = 10000  (16 in binary)
>> 100000 (32 in binary) >> 4 = 000010 (2 in binary)
>> 
>> So, when you shift by 0, it doesn't do anything:
>> 00100 (4 in binary) >> 0 = 00100 (4 in binary)
>> 
>> So $#remotetcsbpfiles>>0 is the same as $#remotetcsbpfiles!=0 and since
>> the array count cannot be less than 0, it works by luck :)
>                   ^^^^^^^^^^^^^^^^^^^^^
> 
> True, I suppose, but $#array isn't the array count, it's a slightly
> different thing.
> 
> my @array = ();
> print "$#array\n";
> 
> Jasper

Ooops, forgot about the empty list case. :)  Had scalar(@list) stuck in my 
head for some reason :)

Brian


------------------------------

Date: Fri, 09 Nov 2001 16:59:10 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Shift Operators - newbie
Message-Id: <slrn9uo05b.n36.tadmc@tadmc26.august.net>

Jessica Bull <jessica.bull@broadwing.com> wrote:
>I am trying to parse through someone else's code because modifications need
>to be made to the script.  I am having trouble understanding how the shift
>operator works.  In laymens terms I mean...i have the Programming Perl's
>interpretation on it.    


Do you understand bits and bytes and such?


>The examples given are:
>
>1 << 4;  # Returns 16


1  in binary:     00000001
16 in binary:     00010000

The << has "shift"ed (taking zeros in on the right) 4 places.


>32 >> 4; # Returns 2

32 in binary:     00100000
2  in binary:     00000010


>The portion I am parsing through is:
>if($#remotetcsbpfiles>>0){@xferlist=buildxferlist(@remotetcsbpfiles)};


I sure hope it doesn't _literally_ look like that, without spaces and such...

Shifting zero bits does not change anything, so the >> is essentially
a no-op there.

Looks like a (harmless yet silly) bug in the code.

Maybe the original "programmer" typed one too many > characters?


>The logic of how it is getting the return value is primarily what I am
>looking for.


perlop says:

---------
Binary ">>" returns the value of its left argument shifted right by
the number of bits specified by the right argument.  Arguments should
be integers.  (See also L<Integer Arithmetic>.)
---------

so the return value from $#remotetcsbpfiles>>0 is the value
of $#remotetcsbpfiles (which is not changed by shifting zero places).


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 9 Nov 2001 09:07:32 -0800
From: torkjell.arntzen@aftenposten.no (Torkjell Arntzen)
Subject: Testing for Files in Directory
Message-Id: <2a5f8fc1.0111090907.528486f0@posting.google.com>

Hello...

I'm new to perl and have I basic question I hope someone can help me with.

When testing for files in a directory with the -f  and -d option.
Even thouh I'm sure that an object is a directory  -f returns that it is a file.
The only objek it returns as a directory is the "." directory.

I expect that I've missunderstood something. 

This is the code...:



my $Dir = 'PerlTest';



sub readDir {
my $d = $_[0];
opendir DH, $d or die " $d \t Not a valid Dir";
	while (my $name = readdir DH) {
	next if $name=~/^\./;
	if (-f $name) {
		print "This is a file\t\t $name\n";
		}
	else {
		print "This is a Directory\t\t $name\n";
	} 

	}
}


&readDir($Dir);


------------------------------

Date: Fri, 09 Nov 2001 17:28:22 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Testing for Files in Directory
Message-Id: <slrn9uo1vj.nat.tadmc@tadmc26.august.net>

Torkjell Arntzen <torkjell.arntzen@aftenposten.no> wrote:
>
>I'm new to perl and have I basic question I hope someone can help me with.


If you had read the docs for the functions that you are using,
you would not need anyone else's help...


>opendir DH, $d or die " $d \t Not a valid Dir";
>	while (my $name = readdir DH) {

>	if (-f $name) {


   perldoc -f readdir

(my underlining)

--------------------
If you're planning to filetest the return values out of a "readdir", 
you'd better prepend the directory in question.  Otherwise, because 
we didn't "chdir" there, it would have been testing the wrong file.
--------------------


   if (-f "$d/$name") {


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 09 Nov 2001 18:45:53 GMT
From: "Brian Janko" <brian@jankoNOnet.SPAMcom.INVALID>
Subject: Re: Unix executed thru CGI?
Message-Id: <BvVG7.107676$U7.8809203@bin1.nnrp.aus1.giganews.com>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9uml2b.l40.tadmc@tadmc26.august.net...
>
> You can read the documentation for any module installed on
> your system with the perldoc program:
>
>    perldoc File::Copy
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



Thanks for the help.  I appreciate it!

Brian





------------------------------

Date: Fri, 9 Nov 2001 10:02:49 -0800
From: "Ron Hill" <hillr@ugs.com>
Subject: using formline with mutipal arrays as the list to generate a report
Message-Id: <3bec1c81$1@usenet.ugs.com>

#!/app/perl5/bin/perl -w
use Date::Calc qw(Days_in_Month);
use Time::Local;
use Mail::Mailer;
use POSIX;
use strict;
use vars
qw(@byspain @bywhite @byandrew @bystark @bymartinrs @byostrin @byrobertsl
@bymonth @byyear);

my $db_name = 'g:/hillr/phone_data.db';

############################################################################
############################################################################

my ( $month, $year ) = (localtime)[ 4, 5 ];
$year += 1900;
my $days_in_month = Days_in_Month( $year, $month );

my $in_time = timelocal( 0, 0, 0, 1, $month, $year - 1900 );
my $out_time = timelocal( 0, 0, 0, $days_in_month, $month, $year - 1900 );
my $year_to_date = timelocal( 0, 0, 0, 1, 0, $year - 1900 );

############################################################################
#
#
############################################################################
my %month = (
  '1'  => 'January',
  '2'  => 'Feburary',
  '3'  => 'March',
  '4'  => 'April',
  '5'  => 'May',
  '6'  => 'June',
  '7'  => 'July',
  '8'  => 'August',
  '9'  => 'September',
  '10' => 'October',
  '11' => 'November',
  '12' => 'December'
);

my %managers = (
  'spain'    => 'systems',
  'andrew'   => 'applications',
  'stark'    => 'St. Louis',
  'martinrs' => 'IMAN',
  'jfwhite'  => 'Solid Edge',
  'ostrin'   => 'STP',
  'robertsl' => 'Ames'
);
my $ir_hash = process_db($db_name);

#generate monthly information
foreach my $rp( values %$ir_hash ) {

    push ( @bymonth, $rp )
      if $rp->{DATE} >= $in_time && $rp->{DATE} <= $out_time;
}
my @sorted_month = sort { $a->{MANAGER} cmp $b->{MANAGER} } @bymonth;
my $total_month = gen_monthly(@bymonth);    #total for All GTAC arrayref
my ( $total_spain, $total_jfwhite, $total_andrew, $total_stark,
$total_martinrs,
  $total_ostrin, $total_robertsl, $by_spain, $by_jfwhite, $by_andrew,
$by_stark,
  $by_martinrs, $by_ostrin, $by_robertsl ) = by_dept(@bymonth);

#generate yearly information
foreach my $rz( values %$ir_hash ) {
    push ( @byyear, $rz )
      if $rz->{DATE} >= $year_to_date && $rz->{DATE} <= $out_time;
}
my $total_year = gen_monthly(@byyear);    # total for ALL GTAC YTD

my ( $total_spain_year, $total_jfwhite_year, $total_andrew_year,
  $total_stark_year, $total_martinrs_year, $total_ostrin_year,
  $total_robertsl_year, $by_spain_year, $by_jfwhite_year, $by_andrew_year,
  $by_stark_year, $by_martinrs_year, $by_ostrin_year, $by_robertsl_year ) =
  by_dept(@byyear);

my $picture = <<END_PICTURE;

Telephone Surveys

For the month of @<<<<<<<< the Applications group completed @##, St. Louis
@##, Systems @##, IMAN group @##, STP @##, Solid Edge group @##, and the
Ames group @##, for a total of @##.

Overall results are as follows:
Question Number % Rating Scoring for All Groups Good to Superior (4 & 5
range)

Question 1      @## % good to superior
Question 2      @## % good to superior
Question 3      @## % good to superior
Question 4      @## % good to superior
Question 5      @## % good to superior
Question 6      @## % good to superior

Question 1 = Service on subject call (specific IR is referenced)
Question 2 = Customer perception of SE's technical competence
Question 3 = Attitude and manner of SE
Question 4 = Overall experiences with GTAC services
Question 5 = Accessibility of the appropriate SE (% reaching party selected)
Question 6 = Please rate your experience with the web tool, UGAnswer

Question Number % Rating by group scoring Good to Superior (4 & 5 range)

   Appl Stl Sys IMAN STP Solid Edge Ames
Question 1  @## @## @## @## @## @##  @##
Question 2  @## @## @## @## @## @##  @##
Question 3  @## @## @## @## @## @##  @##
Question 4  @## @## @## @## @## @##  @##
Question 5  @## @## @## @## @## @##  @##
Question 6  @## @## @## @## @## @##  @##

Year-to-Date Totals - Applications group completed @###, St. Louis @###,
Systems @###, IMAN group @###, STP @###, Solid Edge group @###, and the Ames
group @###, for a total of @###.

Question 1 =   @##% good to superior
Question 2 =   @##% good to superior
Question 3 =   @##% good to superior
Question 4 =   @##% good to superior
Question 5 =   @##% good to superior
Question 6 =   @##% good to superior

Question Number % Rating Year-to-Date by group scoring Good to Superior (4 &
5)

   Appl Stl Sys IMAN    STP Solid Edge Ames
Question 1  @## @## @## @## @## @##  @##
Question 2  @## @## @## @## @## @##  @##
Question 3  @## @## @## @## @## @##  @##
Question 4  @## @## @## @## @## @##  @##
Question 5  @## @## @## @## @## @##  @##
Question 6  @## @## @## @## @## @##  @##
END_PICTURE

formline $picture, $month{$month}, $total_andrew, $total_stark,
$total_spain,
  $total_martinrs, $total_ostrin, $total_jfwhite, $total_robertsl,
  $total_andrew + $total_stark + $total_spain + $total_martinrs +
  $total_ostrin + $total_jfwhite + $total_robertsl, $$total_month[0],
  $$total_month[1], $$total_month[2], $$total_month[3], $$total_month[4],
  $$total_month[5], $$by_andrew[0],   $$by_stark[0],    $$by_spain[0],
  $$by_martinrs[0], $$by_ostrin[0],   $$by_jfwhite[0],  $$by_robertsl[0],
  $$by_andrew[1],   $$by_stark[1],    $$by_spain[1],    $$by_martinrs[1],
  $$by_ostrin[1],   $$by_jfwhite[1],  $$by_robertsl[1], $$by_andrew[2],
  $$by_stark[2],    $$by_spain[2],    $$by_martinrs[2], $$by_ostrin[2],
  $$by_jfwhite[2],  $$by_robertsl[2], $$by_andrew[3],   $$by_stark[3],
  $$by_spain[3],    $$by_martinrs[3], $$by_ostrin[3],   $$by_jfwhite[3],
  $$by_robertsl[3], $$by_andrew[4],   $$by_stark[4],    $$by_spain[4],
  $$by_martinrs[4], $$by_ostrin[4],   $$by_jfwhite[4],  $$by_robertsl[4],
  $$by_andrew[5],   $$by_stark[5],    $$by_spain[5],    $$by_martinrs[5],
  $$by_ostrin[5],   $$by_jfwhite[5],  $$by_robertsl[5], $total_andrew_year,
  $total_stark_year,  $total_spain_year,   $total_martinrs_year,
  $total_ostrin_year, $total_jfwhite_year, $total_robertsl_year,
  $total_andrew_year + $total_stark_year + $total_spain_year +
  $total_martinrs_year + $total_ostrin_year + $total_jfwhite_year +
  $total_robertsl_year, $$total_year[0], $$total_year[1], $$total_year[2],
  $$total_year[3], $$total_year[4], $$total_year[5], $$by_andrew_year[0],
  $$by_stark_year[0],    $$by_spain_year[0],    $$by_martinrs_year[0],
  $$by_ostrin_year[0],   $$by_jfwhite_year[0],  $$by_robertsl_year[0],
  $$by_andrew_year[1],   $$by_stark_year[1],    $$by_spain_year[1],
  $$by_martinrs_year[1], $$by_ostrin_year[1],   $$by_jfwhite_year[1],
  $$by_robertsl_year[1], $$by_andrew_year[2],   $$by_stark_year[2],
  $$by_spain_year[2],    $$by_martinrs_year[2], $$by_ostrin_year[2],
  $$by_jfwhite_year[2],  $$by_robertsl_year[2], $$by_andrew_year[3],
  $$by_stark_year[3],    $$by_spain_year[3],    $$by_martinrs_year[3],
  $$by_ostrin_year[3],   $$by_jfwhite_year[3],  $$by_robertsl_year[3],
  $$by_andrew_year[4],   $$by_stark_year[4],    $$by_spain_year[4],
  $$by_martinrs_year[4], $$by_ostrin_year[4],   $$by_jfwhite_year[4],
  $$by_robertsl_year[4], $$by_andrew_year[5],   $$by_stark_year[5],
  $$by_spain_year[5],    $$by_martinrs_year[5], $$by_ostrin_year[5],
  $$by_jfwhite_year[5],  $$by_robertsl_year[5];

my $temp_var = $^A;

#my $aa_temp = ();
foreach my $y(@sorted_month) {
    chomp $y->{MANAGER};
    $temp_var .=
      $managers{ $y->{MANAGER} } . "-" . $y->{COMPANY} . "\n" . "IR NUMBER:"
      . $y->{IR} . "\n" . $y->{COMMENTS} . "\n\n";
}

print $temp_var;
#mail_report($temp_var);

############################################################################
#
#
#
#
#
#
############################################################################

sub by_dept {

    my (@bydate) = @_;

    foreach my $manage(@bydate) {
        SWITCH: for ( $manage->{MANAGER} ) {

            /spain/ && do {
                push ( @byspain, $manage );
                last SWITCH;
            };

            /jfwhite/ && do {
                push ( @bywhite, $manage );
                last SWITCH;
            };

            /andrew/ && do {
                push ( @byandrew, $manage );
                last SWITCH;
            };

            /stark/ && do {
                push ( @bystark, $manage );
                last SWITCH;
            };
            /martinrs/ && do {
                push ( @bymartinrs, $manage );
                last SWITCH;
            };
            /ostrin/ && do {
                push ( @byostrin, $manage );
                last SWITCH;
            };
            /robertsl/ && do {
                push ( @byrobertsl, $manage );
                last SWITCH;
            };

            # DEFAULT

            warn "User defined type skipped";

        }    #end SWITCH
    }

    my $total_spain    = $#byspain + 1;
    my $total_jfwhite  = $#bywhite + 1;
    my $total_andrew   = $#byandrew + 1;
    my $total_stark    = $#bystark + 1;
    my $total_martinrs = $#bymartinrs + 1;
    my $total_ostrin   = $#byostrin + 1;
    my $total_robertsl = $#byrobertsl + 1;

    my $by_spain    = gen_monthly(@byspain);
    my $by_jfwhite  = gen_monthly(@bywhite);
    my $by_andrew   = gen_monthly(@byandrew);
    my $by_stark    = gen_monthly(@bystark);
    my $by_martinrs = gen_monthly(@bymartinrs);
    my $by_ostrin   = gen_monthly(@byostrin);
    my $by_robertsl = gen_monthly(@byrobertsl);

    return ( $total_spain, $total_jfwhite, $total_andrew, $total_stark,
      $total_martinrs, $total_ostrin, $total_robertsl, $by_spain,
$by_jfwhite,
      $by_andrew, $by_stark, $by_martinrs, $by_ostrin, $by_robertsl );
}

############################################################################
#this is the sub that generates the initial hash of hashes of all IR's that
have been
#processed
#
#
#
############################################################################
sub process_db {
    my ($filename) = @_;
    my %byirnum = ();
    open( IN, "<$filename" ) or die "Can't open filename:$!";

    while (<IN>) {
        my ( $sename, $inter, $customer, $company, $server, $tele, $ir,
$date,
          $quest1, $quest2, $quest3, $quest4, $quest5, $comments,
$comments2,
          $fields, $tool, $manager ) = split ( /\|&\|/, $_ );

        my $record = {
            NAME      => "$sename",
            INTERVIEW => "$inter",
            CUSTOMER  => "$customer",
            COMPANY   => "$company",
            SERVER    => "$server",
            TELE      => "$tele",
            IR        => "$ir",
            DATE      => "$date",
            Q1        => "$quest1",
            Q2        => "$quest2",
            Q3        => "$quest3",
            Q4        => "$quest4",
            Q5        => "$quest5",
            COMMENTS  => "$comments",
            COMMENTS2 => "$comments2",
            FIELD     => "$fields",
            Q6        => "$tool",
            MANAGER   => "$manager",
        };
        $byirnum{ $record->{IR} } = $record;

    }    #end while
    close(IN);
    return \%byirnum;

}

############################################################################
#
#
#
############################################################################

sub gen_monthly {

    my (@bydate) = @_;

    if ( $#bydate == 0 ) {

        my @norecord = (0, 0, 0, 0, 0, 0);

        return \@norecord;

    }
    my ( $q1_month, $q2_month, $q3_month, $q4_month, $q5_month, $q6_month )
=
      ( 0, 0, 0, 0, 0, 0 );
    foreach my $item(@bydate) {

        if ( $item->{Q1} >= 4 ) {
            $q1_month++;
        }
        if ( $item->{Q2} >= 4 ) {
            $q2_month++;
        }

        if ( $item->{Q3} >= 4 ) {
            $q3_month++;
        }
        if ( $item->{Q4} >= 4 ) {
            $q4_month++;
        }

        if ( $item->{Q5} >= 4 ) {
            $q5_month++;
        }
        if ( $item->{Q6} >= 4 ) {
            $q6_month++;
        }
    }
    eval {
        $q1_month = floor( $q1_month / ( $#bydate + 1 ) * 100 );
        $q2_month = floor( $q2_month / ( $#bydate + 1 ) * 100 );
        $q3_month = floor( $q3_month / ( $#bydate + 1 ) * 100 );
        $q4_month = floor( $q4_month / ( $#bydate + 1 ) * 100 );
        $q5_month = floor( $q5_month / ( $#bydate + 1 ) * 100 );
        $q6_month = floor( $q6_month / ( $#bydate + 1 ) * 100 );
    };

    if ($@) {
        $q1_month = 00;
        $q2_month = 00;
        $q3_month = 00;
        $q4_month = 00;
        $q5_month = 00;
        $q6_month = 00;
    }

    my @qtotal_monthly =
      ( $q1_month, $q2_month, $q3_month, $q4_month, $q5_month, $q6_month );

    return \@qtotal_monthly;

}

sub mail_report {

    my ($message) = @_;

    my $mailer = new Mail::Mailer qw(sendmail);

    my %headers = (
      'To'       => 'someone@somewhr,
      'Cc'       => 'spain@ugs.com',
      'Reply-To' => 'hillr@ugs.com',
      'Subject'  => "Phone survey report for the month of $month{$month}"
    );

    $mailer->open( \%headers );

    print $mailer $message;

    $mailer->close;
    return (0);
}







------------------------------

Date: Fri, 9 Nov 2001 10:23:41 -0800
From: "Ron Hill" <hillr@ugs.com>
Subject: Re: using formline with mutipal arrays as the list to generate a report
Message-Id: <3bec1d66@usenet.ugs.com>

Please disreguard this, God how I hate outlook

Sorry,

Ron Hill




------------------------------

Date: 9 Nov 2001 10:24:34 -0800
From: vivekvp@spliced.com (vivekvp)
Subject: Re: VVP: Variable = system command
Message-Id: <9bf633be.0111091024.648b8ca@posting.google.com>

I guess system is used for returning success or failure of a system
call.  Not for displaying data.

V

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrn9ulpsn.ki5.tadmc@tadmc26.august.net>...
> vivekvp <vivekvp@spliced.com> wrote:
> >
> >$last=system("tail test.txt")
> >
> >and have the variable $last filled with the last lines of the file
> >'test.txt'.
>  
> >#!/usr/bin/perl                     
> 
> You should ask for all the help you can get:
> 
>    #!/usr/bin/perl -w
>    use strict;
> 
> 
> >open (sd,"all.sds");       <---this is a file of all the *.txt files
> 
> 
> You should always, yes *always*, check the return value from open():
> 
>    open (SD,"all.sds") or die "could not open 'all.sds'  $!";
> 
> it is also conventional to use UPPER CASE for filehandles, else
> your code will stop working when you upgrade to Perl version
> 12.5 and it has a new 'sd' keyword in it...
> 
> 
> >any help?
> 
> 
> You can get help by reading the documentation for the functions
> that you use!
> 
>    perldoc -f system
> 
> tells you how to capture an external program's output.
> 
> You must have missed it, try reading it again.


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 2103
***************************************


home help back first fref pref prev next nref lref last post