[9463] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3057 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 4 01:07:22 1998

Date: Fri, 3 Jul 98 22:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 3 Jul 1998     Volume: 8 Number: 3057

Today's topics:
        "uninitialized values at ... line xxx chunk xxx" HUH? svinson@my-dejanews.com
    Re: "uninitialized values at ... line xxx chunk xxx" HU (Ronald J Kimball)
    Re: 2-byte code match problem (Yun Giljung)
    Re: @list problem (Josh Kortbein)
    Re: @list problem (Tad McClellan)
    Re: @list problem (Josh Kortbein)
    Re: @list problem (Bob Trieger)
    Re: @list problem (Josh Kortbein)
    Re: editing a file properly... (Chip Salzenberg)
        Extensible Report Generator (Phoenixl)
    Re: FREE Shopping Cart (-)
    Re: function prototypes (Gabor)
    Re: Is Perl through CGI enough for this? <wcjones@fccj.org>
    Re: limits of glob() ? (Tad McClellan)
        PERL + File Downloads <strauman@csee.usf.edu>
    Re: Perl Editor for Windows NT ? (Jeremy D. Zawodny)
    Re: The vagaries of read()ing (Ronald J Kimball)
    Re: uses of require and use (Rachel J King)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 04 Jul 1998 02:08:47 GMT
From: svinson@my-dejanews.com
Subject: "uninitialized values at ... line xxx chunk xxx" HUH?
Message-Id: <6nk2rf$a3v$1@nnrp1.dejanews.com>

Can anyone explain why the following errors are being output?

When I test my script using my local Perl interpreter (ver 4.x) on my PC,
everything works beautifully.  But when uploaded and run with Perl 5 on
my ISP's server, the following gets generated (my script's path/file name
is shortened here as "___.pl"):

Use of uninitialized value at ___.pl line 30, chunk 39.
Use of uninitialized value at ___.pl line 21, chunk 39.
Use of uninitialized value at ___.pl line 30, chunk 39.
Use of uninitialized value at ___.pl line 21, chunk 39.
Use of uninitialized value at ___.pl line 30, chunk 40.
Use of uninitialized value at ___.pl line 21, chunk 40.
Use of uninitialized value at ___.pl line 30, chunk 40.
Use of uninitialized value at ___.pl line 21, chunk 40.
Use of uninitialized value at ___.pl line 30, chunk 41.
  .
  . [many lines snipped out]
  .
Use of uninitialized value at ___.pl line 21, chunk 69.
Use of uninitialized value at ___.pl line 30, chunk 70.
Use of uninitialized value at ___.pl line 21, chunk 70.
Use of uninitialized value at ___.pl line 30, chunk 70.
Use of uninitialized value at ___.pl line 21, chunk 70.

The above errors don't happen immediately, but rather after forty or so
lines of input data are successfully processed.  THEN the errors happen,
followed by more successful processing...  go figure!

The "chunk #" (which I have NO idea what that means!) always builds up in
size, inferring that something is not being "released" after a call is
made to my subroutines, which are listed below (note the line numbers,
which correlate with the above errors):

16: # Subroutine to encode a string so it doesn't cause problems in URL
17: # This routine is called cgi_encode in the Perl book (page 205)
18: sub StrToCgi {
19:   local($str) = @_;
20:  $str = &escape($str,'[\x00-\x20"#%/+;<>?&\x7F-\xFF]');
21:  $str =~ s/ /+/g;
22:  return( $str );
23: }
24:
25: # Subroutine to replace all chars in a string matching the passed
26: # pattern with their %XX excape chars.
27: # This routine is in the Perl book (page 205)
28: sub escape {
29:   local($str, $pat) = @_;
30:   $str =~ s/($pat)/sprintf("%%%02lx",unpack('C',$1))/ge;
31:   return( $str );
32: }

The above calls are made from this code snippet (I've even tried to
initialize all the following variables to '' BEFORE the following block,
thinking that might help, but it doesn't)...

 if ($thisState eq $stateAbbr)
    {
    $dealerEncoded    = &StrToCgi( $thisName );
    $contactEncoded   = &StrToCgi( $thisContact);
    $daddrEncoded     = &StrToCgi( $thisAddress );
    $dcityEncoded     = &StrToCgi( $thisCity );
    $dstateEncoded    = &StrToCgi( $thisState );
    $dzipEncoded      = &StrToCgi( $thisZip );
    $dphoneEncoded    = &StrToCgi( $thisPhone );
    $dfaxEncoded      = &StrToCgi( $thisFax );
    $dTollFreeEncoded = &StrToCgi( $thisTollFree );
    $dEMail           = &StrToCgi( $thisEMail );
    $dWebAddr         = &StrToCgi( $thisWeb  );
    $dDesc            = &StrToCgi( $thisDesc );
     .
     .
     .


Is this some bug in Perl 5???  It's PROBABLY a bug in my programming style,
so any help would be appreciated!

Steve

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Sat, 4 Jul 1998 00:48:48 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: "uninitialized values at ... line xxx chunk xxx" HUH?
Message-Id: <1dbm8pg.12zvn3689r5w0N@bay1-210.quincy.ziplink.net>

[posted and mailed]

<svinson@my-dejanews.com> wrote:

> Use of uninitialized value at ___.pl line 30, chunk 39.
> Use of uninitialized value at ___.pl line 21, chunk 39.
> 
> The "chunk #" (which I have NO idea what that means!) always builds up in
> size, inferring that something is not being "released" after a call is
> made to my subroutines, which are listed below (note the line numbers,
> which correlate with the above errors):

The full error message should be something like:
Use of uninitialized value at temp line 5, <FOO> chunk 5.

The chunk refers to the number of times you have read from the specified
filehandle using the <> operator.  'Chunk' instead of 'line' because if
you change $/ you won't be reading one line at a time, you'll be reading
one chunk at a time.  This says that on the 39th read from the relevant
filehandle, you tried to use an uninitialized value.

> 16: # Subroutine to encode a string so it doesn't cause problems in URL
> 17: # This routine is called cgi_encode in the Perl book (page 205)
> 18: sub StrToCgi {
> 19:   local($str) = @_;
> 20:  $str = &escape($str,'[\x00-\x20"#%/+;<>?&\x7F-\xFF]');
> 21:  $str =~ s/ /+/g;
> 22:  return( $str );
> 23: }
> 24:
> 25: # Subroutine to replace all chars in a string matching the passed
> 26: # pattern with their %XX excape chars.
> 27: # This routine is in the Perl book (page 205)
> 28: sub escape {
> 29:   local($str, $pat) = @_;
> 30:   $str =~ s/($pat)/sprintf("%%%02lx",unpack('C',$1))/ge;
> 31:   return( $str );
> 32: }

The only variable you use in line 21 is $str, so $str must be
unitialized - i.e., it's value is undefined.

In line 30, you use the variables $str, $pat, and $1.  Given that you
are returning an undefined value, it's probably $str that is unitialized
here as well.

All this indicates that you are calling the subroutine StrToCgi with an
undefined value.  Can't tell you more from the code provided.

By the way, you should consider using the CGI.pm module, which handles
all this for you.  You'll have to install perl5 on your PC, but, why
wouldn't you, anyway?  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sat, 04 Jul 1998 00:29:57 GMT
From: mingtian@hanmail.net (Yun Giljung)
Subject: Re: 2-byte code match problem
Message-Id: <359d75f3.5352802@usenet.kornet21.net>

cberry@cinenet.net (Craig Berry) wrote:

>Yun Giljung (mingtian@hanmail.net) wrote:
>: like Korean or Chinese, they are 2-byte code, so
>: it like 
>: 
>: ACFE BCA4 A7BC A4D9 (4 characters in hexcode)
>: 
>: so if i try to s// or m// y//  "BCA4" will match twice time
>: in above example, the first is correct but the second is not correct(
>: A7BC A4D9)
>: 
>: how can solve the problem with s//,m//,y//?
>
>Here's a brute-force way to force even byte alignment:
>
>  s/^((?:..)*?)\xBC\xA4/$1\x01\x02/sg;

that was not work.. i solved in 3 ways,

$han = chr(30);
$a = '>H3g H38p5N';
$a =~ s/([\A1-\xFE][\x4E-\x9F\xF9-\xFE])/$han$1/g;
$a =~ s/$hanH3/$han5i/g;
$a =~ s/$han([\A1-\xFE][\x4E-\x9F\xF9-\xFE])/$1/g;
print $a;

add special char before every 2-byte code and try match with
the special char which leads 2 bytes, the above code space
covers KSC5601(Korea), GB2312(China) and BIG5(HK,Taiwan)

any other better ways?

Larry Wall, how about add one special option to s//,m//,y// for us?


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

Date: 4 Jul 1998 00:23:42 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: @list problem
Message-Id: <6njsme$vps$1@news.iastate.edu>

Bob Trieger (sowmaster@juicepigs.com) wrote:
: Sorting is quite not that simple, weird things happen.
: @sortedwplist = sort { $a cmp $b } @wplist; #this is in the FAQ.

Not quite? The sort routine you supply above IS the default sort
routine. It should be exactly as simple as he made it.


Josh

--

__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
            - Thomas Pynchon



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

Date: Fri, 3 Jul 1998 19:42:58 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: @list problem
Message-Id: <iqtjn6.4hb.ln@localhost>

Eric Hilding (nospam@xx.com) wrote:
: It's gotta be something simple that I'm tripping over, but can't
                ^^^^^^^^^

It is about half a dozen somethings  ;-)


: seem to find it.


And it appears that you are not going to tell us what problem
you are having either.

You should really have shared that with us.


What does "tripping" mean here?

Never generates any output?

Generates incorrect output?

Dumps core?

Spits out error messages?

Generates unsorted output?

Something else?

 ...


: I have a lengthy text file of words and phrases (on separate lines)
: that I am trying to read into an @list, sort it alphabetically, and 
: write the sorted thing out to a new text file with only one word or
: phrase per line as with the original.

: # START OF PERL SCRIPT
: print "Enter File Name To Parse: ";	#instructions for entering file name
: $filename = <STDIN>;			#enter file name to parse
: print "Enter Output File Name: ";       #instructions for entering
: output file name
: $pmbfoutfile = <STDIN>;                 #enter output file name
: open (INFILE, "$filename");		#open input file
                ^         ^


1) you should always, yes *always* check the return value from open()
   calls. Had you done something like the below, you would have had
   only a 15 second "stumble" rather than a "trip"  ;-)

   open (INFILE, $filename) || die "could not open '$filename'  $!";


2) those double quotes serve no function, other than implying that
   interpolation is needed (but interpolation is NOT needed, so
   the quotes aren't needed either, and they are actually misleading)


3) I doubt that the $filename is really supposed to end in a newline.

   (if you checked the return value from open() as described above,
    this would have been immediately apparent...
   )

   Probably should do a chomp($filename) before you try using it.


: $totalrecs = 1;			#initialize total record count
: while ($line = <INFILE>)		#primary loop


You should always, yes *always* enable warnings with the -w switch.

Try it, and see what it says about the above line.

Then fix it  ;-)


: {
:  if ($line =~ m/\w+.*/)	#line must begin with alpha or numeric


Your comment does not match your regex there.

change comment to match regex:
   # line must *contain* alpha or numeric or underscore

OR 

change regex to match comment:
   if ($line =~ m/^\w+.*/) 
                  ^
                  ^ anchor to beginning of string

Also the +.* part is unnecessary...


:   {
:    $line =~ m/(.*)/;			#match the word or phrase
:    $pmbfwp = $1;			#assign word or phrase from $1


$1 will contain the value from the *previous* match if your match
was not successful. This is a very confusing bug to try and find.

(Randal pinged me once for doing that. I've never forgotten it)

   $pmbfwp = $1 if $line =~ m/(.*)/;  # much safer


:    $pmbfwp =~ s/^\s+|\s+$//g; 	#whitespace cleanup on word or phrase

Since trimming whitespace from the beginning/end of a string is a
Frequently Asked Question, I figure you already have had a look at
it, and therefore know that the above is a Very Slow way of doing it...


:    @wplist = $pmbfwp;			#assign word or phrase to array list
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

and *delete* everything that was previously in @wplist!

You probably want to *add* to the array here, leaving elements that
are already there alone?

   push @wplist, $pmbfwp;

:    $totalrecs++;			#count the total records
:   }
: }
: close (INFILE);	#close input file	#close the input file
: print "Net Records: $totalrecs -1\n";	#print a count of the total
                                 ^^
: records

You know, of course, that one will NOT be subtracted from $totalrecs
here? You want to print literal '-' and '1' characters?


: @sortedwplist = sort @wplist;		#sort the list alphabetically
:     open (FILE ,">>$pmbfoutfile");	#open output file for append


You should always, yes *always* check the return value from open() calls.

You need another chomp() here too...

(but for this one, you *do* need and want the double quotes, because you
 need interpolation.
)

:     print FILE "@sortedwplist\n";	#write sorted data to new text file
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

AND insert a space between each list element.

See the $" special variable in the perlvar man page...


AND put every single one of them on the *same line* (you remove the
newlines with the s/^\s+|\s+$//g above...)


:     close (FILE);			#close output file
: # END OF PERL SCRIPT

: Any help is appreciated.  Please do NOT e-mail - post to group only.


Hope that helped.

Good luck!
 

--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 4 Jul 1998 01:46:13 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: @list problem
Message-Id: <6nk1h5$3jm$1@news.iastate.edu>

Tad McClellan (tadmc@flash.net) wrote:
: 3) I doubt that the $filename is really supposed to end in a newline.

:    (if you checked the return value from open() as described above,
:     this would have been immediately apparent...
:    )

:    Probably should do a chomp($filename) before you try using it.

Curiously enough, his code worked there for me.

open() is supposed to nail trailing whitespace in the filename; surely
there's something else going on that I'm missing, but man open said
nothing about newlines. What's up?

Josh

--

__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
            - Thomas Pynchon



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

Date: Sat, 04 Jul 1998 02:17:48 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: @list problem
Message-Id: <6nk3gb$425$1@ligarius.ultra.net>

[ posted and mailed ]

kortbein@iastate.edu (Josh Kortbein) wrote:
-> Bob Trieger (sowmaster@juicepigs.com) wrote:
-> : Sorting is quite not that simple, weird things happen.
-> : @sortedwplist = sort { $a cmp $b } @wplist; #this is in the FAQ.
-> 
-> Not quite? The sort routine you supply above IS the default sort
-> routine. It should be exactly as simple as he made it.

When I use sort as he did, it sorts z thru a. That is not what most be are 
looking for when sorting a text file.


Bob Trieger
sowmaster@juicepigs.com
" Cost a spammer some cash: Call 1-800-286-0591
  and let the jerk that answers know that his
  toll free number was sent as spam. "


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

Date: 4 Jul 1998 02:51:47 GMT
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: @list problem
Message-Id: <6nk5c3$6og$1@news.iastate.edu>

Bob Trieger (sowmaster@juicepigs.com) wrote:
: [ posted and mailed ]

: kortbein@iastate.edu (Josh Kortbein) wrote:
: -> Bob Trieger (sowmaster@juicepigs.com) wrote:
: -> : Sorting is quite not that simple, weird things happen.
: -> : @sortedwplist = sort { $a cmp $b } @wplist; #this is in the FAQ.
: -> 
: -> Not quite? The sort routine you supply above IS the default sort
: -> routine. It should be exactly as simple as he made it.

: When I use sort as he did, it sorts z thru a. That is not what most be are 
: looking for when sorting a text file.

Either there's a major misunderstanding (on my part) going on here, or you're
doing something funky.

/home/kortbein% cat sort.pl
#!/usr/local/bin/perl5 -w

@unsorted = qw( Vivaldi Mendelssohn Penderecki Bach Gershwin );
@sorted = sort @unsorted;

map { print "$_\n"; } @sorted;

/home/kortbein% perl5 -w sort.pl
Bach
Gershwin
Mendelssohn
Penderecki
Vivaldi

 ... which is what most people ARE looking for when sorting a text file.
The above use of sort is identical in form to the original poster's.

Josh

--

__________________________________________
She had heard all about excluded middles;
they were bad shit, to be avoided.
            - Thomas Pynchon



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

Date: Sat, 04 Jul 1998 00:43:57 GMT
From: chip@pobox.com (Chip Salzenberg)
Subject: Re: editing a file properly...
Message-Id: <6njtv6$1fi$1@cyprus.atlantic.net>

According to tchrist@mox.perl.com (Tom Christiansen):
>A power tool is not a toy.  Unix is a power tool.

"Everybody thinks they want industrial-strength tools.
 But they forget that 'industrial-strength' also means,
 'Not safe for pets and small children.'"
   -- Peter Norton

-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: 4 Jul 1998 03:17:35 GMT
From: phoenixl@aol.com (Phoenixl)
Subject: Extensible Report Generator
Message-Id: <1998070403173600.XAA26501@ladder01.news.aol.com>

INTRODUCTION

The Extensible Report Generator (ERG) is a set of perl object modules
that lets a user quickly develop object classes which can produce
very configurable reports with a minimal amount of development
effort.  The report generator class can easily be extended to produce
summary information besides just formatting data. The ERG can be
used for such things as "quick and dirty" types of reports, prototyping
of reports, producing information tables for HTML files, exploring
"what if" kinds of questions.

Here's an example of a very simple report produced by the report
generators, including the field headings and the summary lines.

----------------------------------------------------------------------
Directory                       Modify time           Access

docs                            05/27/98 19:03:06     05/27/98
freezer                         05/27/98 14:33:34     05/27/98


File                     Size   Modify time           Access

dirhelp.vtxt            1,383   05/27/98 09:26:42     06/03/98
demo.pl                 2,468   06/03/98 10:50:18     06/03/98
file_reporter.pm        6,366   06/03/98 10:38:58     06/03/98
line_formatter.pm      11,680   06/03/98 10:17:04     06/03/98
old_test.pl             3,258   05/27/98 19:00:06     06/03/98
page_manager.pm         9,719   06/03/98 10:33:20     06/03/98
report_generator.pm    25,540   06/03/98 10:16:42     06/03/98
report_summary.pm       6,821   06/03/98 10:20:04     06/03/98
zzz                       513   05/27/98 10:31:02     06/03/98

Total                  67,748

Average                 7,528
----------------------------------------------------------------------
(At the end of this note are copies of the demo perl file and the
module which extends the report generator class for this report.)


I haven't put up any web pages for these classes yet, but if you would
like a copy, please drop me a note at phoenixL@aol.com .



*****************************************************************************

File:  demo.pl


#! /usr/local/bin/perl

#  version:  1.2
#  date:     7/2/98

#  this program is a demonstration of using the extensible report generator
#  (erg) to produce reports on files in a directory.  the format of the
#  report can be changed by altering the report specification strings.

#  s. luebking   phoenixL@aol.com


require "file_reporter.pm";
require "page_manager.pm";


#  specifications for report generators

$directoryReportSpecification = "20|name|'Directory'  3b  7b  3b 
20|mtime::date-time|'Modify time' 3b 20|atime::date|'Access'";

$fileReportSpecification = "20|name|'File'  3b  7r|size::total::avg|'Size'  3b 
20|mtime::date-time|'Modify time' 3b 20|atime::date|'Access'";


#  specifications for page manager

$pageHeader = undef;
$pageTrailer = "count-format:  '\n' 60b 'Page ' * '\n\n'";
$maxPageLine = 24;


#  get lists of directories and files

@directories = ();
@files = ();

opendir(DIR,".");

while($file = readdir(DIR))
{
   next if ($file =~ /^([.]|[.][.])$/);
   push(@directories,$file) if (-d $file);
   push(@files,$file) if (-f $file);
}


#  create report generators and page manager

$directoryReporter = file_reporter->new($directoryReportSpecification);
$fileReporter = file_reporter->new($fileReportSpecification);
$pageManager = page_manager->new($maxPageLine,$pageHeader ,$pageTrailer );


#  write report

if($#directories < 0)
{
   $pageManager->writeLines("No directories\n");
}
else
{
   $newLine = $directoryReporter->formatFieldHeadings("") . "\n\n";

   foreach $name (sort(@directories))
   {
      $newLine .= $directoryReporter->formatInfo($name);
      $pageManager->writeLines($newLine);

      $newLine = "";
   }

   $pageManager->writeLines("\n");
}

if($#files < 0)
{
   $pageManager->writeLines("No files\n");
}
else
{
   $newLine = $fileReporter->formatFieldHeadings("") . "\n\n";

   foreach $name (sort(@files))
   {
      $newLine .= $fileReporter->formatInfo($name);
      $pageManager->writeLines($newLine);

      $newLine = "";
   }

   if($fileReportSpecification =~ /::total/i)
   {
      $newLine = "\n" . $fileReporter->formatSummary("Total");
      $pageManager->writeLines($newLine);
   }

   if($fileReportSpecification =~ /::avg/i)
   {
      $newLine = "\n" . $fileReporter->formatSummary("Average");
      $pageManager->writeLines($newLine);
   }
}


$pageManager->close();

<<end-of-file>>


*****************************************************************************

File:  file_reporter.pm


package file_reporter;
@ISA = qw( report_generator_base );

#  version:  1.2
#  date:     7/2/98

#  this package is a demo file report generator class based on the report
#  generator class.

#  the package includes:
#
#      new
#	  creates file report generator
#      formatInfo
#         format information for a file
#      fileInfo
#         get information for a file
#      formatFieldValue
#         format a field
#      processSummaryFieldValue
#         process a field value for summary
#      tellSummaryFieldValue
#         tell a summary field value
#      formatSummary
#         format a summary line
#
#  s. luebking   phoenixL@aol.com

require "report_generator.pm";
require "report_summary.pm";



#
#------------------------------------------------------------------------------
#
#  new method
#
#  ARGS:
#
#     1  -  spec string
#
#  RETURNS:  new object

sub new
{
   my $this = shift;
   my $specStr = shift;

   my $self;

   $self = $this->SUPER::new($specStr);


#  set up file report summary in case it's used

   $$self{'report-summary'} = report_summary->new();


   return $self;
}


#
#------------------------------------------------------------------------------
#
#  method to format file info
#
#  ARGS:
#
#     1  -  file name
#
#  RETURNS:  a string with line created by formatting file info
#
#  this method also processes field values to create summary field values

sub formatInfo
{
   my $self = shift;
   my $fileName = shift;

   my $returnStr;
   my @values;

   @values = $self->fileInfo($fileName,$self->tellFieldTypes());

   $self->processSummaryFieldValueList($$self{'report-summary'},"",@values);

   $returnStr = $self->formatLine($self->formatFieldValueList(@values));

   return $returnStr;
}


#
#------------------------------------------------------------------------------
#
#  method to get file information
#
#  ARGS:
#
#     1  -  file name
#     2  -  field type
#     3  -  field type
#     .
#     .
#     .
#
#  RETURNS:  a list of values specified by field type arguments

sub fileInfo
{
   my $self = shift;
   my $fileName = shift;

   my @fieldtypes;
   my @returnList;
   my $valName;
   my @names;
   my %valTable;

   @fieldTypes = @_;

   @returnList = ();


#  build value table

   %valTable = ( "name", $fileName);

   @names = ("dev", "ino", "mode", "nlink", "uid", "gid", "rdev", "size",
                "atime", "mtime", "ctime", "blksize", "blocks");

   foreach $statValue (stat($fileName))
   {
      $valTable{shift @names} = $statValue;
   }

   foreach $fieldType ( @fieldTypes )
   {
      $str = "unknown $fieldType";

      $valName = $fieldType;
      $valName =~ s/::.*//;

      if(defined $valTable{$valName})
      {
         $str = $valTable{$valName};
      }

      push(@returnList,$str);
   }
   
   return @returnList;
}


#
#------------------------------------------------------------------------------
#
#  method to format field value
#
#  ARGS:
#
#     1  -  field type
#     2  -  field value
#
#  RETURNS:  a string with formatted field value

sub formatFieldValue
{
   my $self = shift;
   my $fieldType = shift;
   my $fieldValue = shift;

   my $returnStr;

   $returnStr = $fieldValue;

   if(defined $fieldValue)
   {
      if($fieldType =~ /::date-time/)
      {
         $returnStr = $self->dateStr($fieldValue) . " " .
$self->timeStr($fieldValue);
      }
      elsif($fieldType =~ /::date/)
      {
         $returnStr = $self->dateStr($fieldValue);
      }
      elsif($fieldType =~ /::time/)
      {
         $returnStr = $self->timeStr($fieldValue);
      }
      elsif($fieldType =~ /^size/)
      {
         $returnStr = $self->generalNumberFormatter(
	 			$fieldValue, 3, ",", ".", 0);
      }
   }

   return $returnStr;
}


#======================================================================
#
#  this section contains various methods used for processing information
#  for summaries
#
#======================================================================


#
#------------------------------------------------------------------------------
#
#  method to process summary field value
#
#  ARGS:
#
#     1  -  report summary object
#     2  -  summary type
#     3  -  field type
#     4  -  field value
#
#  RETURNS:  none

sub processSummaryFieldValue
{
   my $self = shift;
   my $reportSummary = shift;
   my $summaryType = shift;
   my $fieldType = shift;
   my $fieldValue = shift;

   my $name;

   $name = $fieldType;
   $name =~ s/::.*//;

   if($fieldType =~ /::total/i)
   {
      $reportSummary->addValue($name . "##total", $fieldValue);
   }

   if($fieldType =~ /::avg/i)
   {
      $reportSummary->avgAddValue($name . "##average", $fieldValue);
   }
}


#
#------------------------------------------------------------------------------
#
#  method to tell summary field value
#
#  ARGS:
#
#     1  -  report summary object
#     2  -  summary type
#     3  -  field type
#
#  RETURNS:  a summary field value of type specified

sub tellSummaryFieldValue
{
   my $self = shift;
   my $reportSummary = shift;
   my $summaryType = shift;
   my $fieldType = shift;

   my $returnValue;
   my $name;

   $name = $fieldType;
   $name =~ s/::.*//;
   $name .= "##\L$summaryType";

   $returnValue = $reportSummary->tellValue($name);

   return $returnValue;
}


#
#------------------------------------------------------------------------------
#
#  method to format summary
#
#  ARGS:
#
#     1  -  summary type
#
#  RETURNS:  a string with line created by formatting summary file info

sub formatSummary
{
   my $self = shift;
   my $summaryType = shift;

   my $returnStr;
   my @formattedValues;

   @formattedValues = $self->formatSummaryFieldValueList(
                            $self->tellSummaryFieldValueList(
			                $$self{'report-summary'},$summaryType));

   $formattedValues[0] = $summaryType;

   $returnStr = $self->formatLine(@formattedValues);

   return $returnStr;
}


#------------------------------------------------------------------------------
#  return 1 for require
1;

<<end-of-file>>



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

Date: Sat, 04 Jul 1998 04:39:36 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: FREE Shopping Cart
Message-Id: <359db1e0.88987223@news2.cais.com>

mnc@diana.law.yale.edu (Miguel Cruz) Said this:

>In article <6ng6m3$pa6$1@nnrp1.dejanews.com>,  <veronica@iminet.com> wrote:
>>spam spam spam
>
>If using the internet for 12 years (especially the last three years) has
>taught me anything at all, it is that nobody is actually named Veronica, and
>if there were, she would sit around in my living room all day long trying to
>get me to visit filthy web sites.
>

Well, fortunately, 12 years ago on arpanet, there weren't that many
veronicas.  

However, the internet you were using might have been entirely
different?




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

Date: 4 Jul 1998 02:59:49 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: function prototypes
Message-Id: <slrn6pr6o6.2bj.gabor@localhost.vmunix.com>

In comp.lang.perl.misc, Ben Cornett <acornet@emory.edu> wrote :
# A question concerning function prototypes:
# 
# sub f1($$);
# $a = "one";
# $b = "two";
# 
# f1 ($a, $b);
# 
# print "$a $b\n";
# 
# sub f1
# {
#   $_[0]="ONE";
#   $_[1]="TWO";
# }
# 
# *******************
# 
# the above produces "ONE TWO" as I would expect,
# however, if f1 is prototyped as f1(\$\$) instead I get "one two";
# similarly, f1(\$$) yields "one TWO"
# I thought '\$' merely forced the argument to begin with a '$'
# why does it prevent f1 from modifying its arguments?
# any thoughts on this will be appreciated,

change $_[0] = 'ONE';
to ${$_[0]} = 'ONE';
if your proto is f1(\$\$);


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

Date: Fri, 03 Jul 1998 21:50:03 -0400
From: Bill 'Sneex' Jones <wcjones@fccj.org>
Subject: Re: Is Perl through CGI enough for this?
Message-Id: <359D8A4A.A997DB4F@fccj.org>

David Rouse wrote:

> Will that combination be enough? Is it possible to build a system that
> will be robust enough to work correctly? If someone fills in a browser
> form that orders a full page ad for a certain day -- and that ad doesn't
> get manifested -- the company would be loosing thousands of dollars.
>
> David Rouse

 Not wanting to state the obvious, but Perl is ONLY as good as your best
programmer.

It won't do for you what you cannot think of doing.  However, to keep your
spirits up, I wrote a complete Human Resources Job Posting system using
Perl in a couple of days.  Yes, some here would wonder if I were a newbie
or even a programmer  :-)

HTH,
-Sneex-
____________________________________________________________________________
Bill Jones | FCCJ Webmaster | Voice 1-904-632-3089 | Fax 1-904-632-3007
Florida Community College at Jacksonville | 501 W. State St. | Jax, FL 32202
mailto:webmaster@fccjmail.fccj.org | http://webmaster.fccj.org/Webmaster
____________________________________________________________________________
        Pay attention to your enemies, for they are
        the first to discover your mistakes.




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

Date: Fri, 3 Jul 1998 20:03:55 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: limits of glob() ?
Message-Id: <r1vjn6.cjb.ln@localhost>

Dan Baker (dtbaker_@flash.net) wrote:
: I've read that using glob() to return a list of items has limitations
  ^^^^^^^^^
: with "large numbers" of items....  


   Did you read it in 'perlop'?

   "Furthermore, due to its current implementation of using a shell, 
    the glob() routine may get "Arg list too long" errors (unless 
    you've installed tcsh(1L) as /bin/csh)."


: What IS the limit? 


   It depends on the shell, not on perl.


: i.e. when should I
: consider using opendir(), readdir(), closedir()?


   Always.

   Assuming that you always want the most robust and portable way
   of coding up stuff  ;-)


: A related topic that I've been wondering about is whether there is any
: *significant* difference using glob() versus the magic <*>.


   Did you even look up glob() in the 'perlfunc' man page?

   I guess not, else you would already have your answer.

   "This is the internal function implementing the <*.c> operator, 
    but you can use it directly."

   Looks like no difference at all...



   C'mon, use the docs Luke...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 03 Jul 1998 23:15:57 -0400
From: "John J. Straumann" <strauman@csee.usf.edu>
Subject: PERL + File Downloads
Message-Id: <359D9E6D.8CF1BD1C@csee.usf.edu>

Hi;

I distribute software via the WWW and would like to combine a file
download anchor with a call to a PERL function. I would like the action
to be that when the user clicks the download button, the PERL script is
called (writing out ENV stuff) and the file downloads...

Anyone know how to do that?

TIA.

John.


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

Date: 03 Jul 1998 23:38:02 -0400
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: Perl Editor for Windows NT ?
Message-Id: <m37m1umgkl.fsf@peach.z.org>

Jonathan Feinberg <jdf@pobox.com> writes:

> PBUhauck@t-online.de (Uwe Hauck) writes:
> 
> > Does anyone know of any Editor (best would be freeware) for Windows
> > NT that understands Perl Syntax ?
> 
>   http://www.cs.washington.edu/homes/voelker/ntemacs.html
> 
> But before you go there, you should take a moment to use DejaNews to
> search for the inmnumerable times this question has been asked and
> answered in this newsgroup.  You'll get plenty of information that
> way.

I'll further suggest using Ilya's cperl-mode instead of the default
perl-mode packaged with GNU Emacs. It tends to be much better in all
respects.

Jeremy
-- 
Jeremy D. Zawodny                   Web Geek, Perl Hacker, etc.
http://www.wcnet.org/~jzawodn/      jzawodn@wcnet.org

LOAD "LINUX",8,1


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

Date: Sat, 4 Jul 1998 00:48:50 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: The vagaries of read()ing
Message-Id: <1dbm9ni.7m1m4iuxqsg0N@bay1-210.quincy.ziplink.net>

John Siracusa <macintsh@cs.bu.edu> wrote:

> I'm in the process of poring through DejaNews and the other
> likely suspects looking for alternate solutions like using
> select(), recv(), etc.  Since I've already written a substantial
> amount of code using the read() family, I'd prefer to find a
> solution to the problem as posed in my previous post.  But I'm
> completely open to alternate solutions if they're "better" in
> some way.  Thanks...

I use select() to determine when I should try to read from the socket.
In my experience, when I was "hung up on", select() would indicate ready
to read, with the call to sysread would reading 0 bytes from the socket.
If that happens, I close the connection.

However, for all I know, that could be a bad assumption.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 4 Jul 1998 00:57:16 GMT
From: rjking@red.seas.upenn.edu (Rachel J King)
Subject: Re: uses of require and use
Message-Id: <6njulc$5b8$1@netnews.upenn.edu>

After playing around with it for a while, I figured out the answer.  I'm 
using require and have all the code as a subroutine.

-Rachel

--
Rachel Jamie King                  *     University of Pennsylvania
rjking@eniac.seas.upenn.edu        *     Engineering and Applied Science
http://www.seas.upenn.edu/~rjking  *     Computer Science and Engineering


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 3057
**************************************

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