[6334] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 956 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 15 15:07:10 1997

Date: Sat, 15 Feb 97 12:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 15 Feb 1997     Volume: 7 Number: 956

Today's topics:
     Re: [Q] Finding matching line based on surrounding line <art2mis@apk.net>
     compiling GD on NetBSD (Matthew Ahrens)
     Re: Compiling Perl on UnixWare (Thanh Ma)
     Re: eval in C (Andrew M. Langmead)
     File Upload on WEB (Yun-ho Chung)
     Re: File Upload on WEB (Nathan V. Patwardhan)
     Re: HELP loop prob (Tad McClellan)
     How do I filter Files ending with ".std"  and reject th <patrickt@tm.net.my>
     Re: How do I filter Files ending with ".std"  and rejec (Nathan V. Patwardhan)
     Re: How do you write to seperate frames? <flavell@mail.cern.ch>
     newlines and textarea boxes <editor@mbeacon.com>
     Perl/Win95, nothing Happens!!! (Sub Zero)
     Re: Perl/Win95, nothing Happens!!! (Nathan V. Patwardhan)
     Pipes and redirects using NT <sjohnson@ibm.net>
     Re: Pipes and redirects using NT (Nathan V. Patwardhan)
     Re: Pipes and redirects using NT (Dave Thomas)
     Problem using diagnostics.pm <imran@science.gmu.edu>
     Re: QUES: what is "undump"? <tchrist@mox.perl.com>
     Re: RegEx, Email & Friedl's "Mastering..." Book <tchrist@mox.perl.com>
     renaming all functions with a common prefix <jasons@infinity.cs.unm.edu>
     Re: renaming all functions with a common prefix (Dave Thomas)
     Re: RFC: Statistics for comp.lang.perl.misc <tchrist@mox.perl.com>
     Re: running prog from within perl script <art2mis@apk.net>
     Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
     Re: Uploading files in perl4 !! (Nathan V. Patwardhan)
     Re: using "$var" considered harmful?! (was Re: Q: openi <tchrist@mox.perl.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 15 Feb 1997 18:24:22 GMT
From: "Craig or Diana Duncan" <art2mis@apk.net>
Subject: Re: [Q] Finding matching line based on surrounding lines
Message-Id: <01bc1b6c$f7e59f10$c108b7ce@zeus>

Eric D. Carter <ecarter@a-lincoln.hnet.uci.edu> wrote in article
<5dvg9l$2s4@news.service.uci.edu>...
[stuff deleted]
> Well, now after I've created this I need to grab a specific line 
> but I need to take into account the surrounding lines.
> 
> Example:
> 
> while (<>) {
> 	if /Name:(.*)/ {
> 		$name = $1;
> 	}
> 	elsif /Number:(.*) {
> 		$number = $1;
> 	}
> }
> 
> The line I'm looking for follows the format:
> -	<12/34/56> 
> where the numbers can be any date.  The problem is that
> I need to know whether the pattern matched is under the
> name or number or whatever.
[more stuff deleted]

This may be inelegant, but a simple finite state machine solves this
problem well.
Try the following:

$prior = '';
while (<>) {
	if /Name:(.*)/ {
		$name = $1;
		$prior = 'name';
	}
	elsif /Number:(.*) {
		$number = $1;
		$prior = 'number';
	}
	elsif /-	<(\d{1,2}\/\d{1,2}\/\d{1,2})>/ {
		if ($prior eq 'name') {
			#whatever
		} elsif ($prior eq 'number') {
			#whatever
		} else {
			#whatever
		}
	}
	else {
		$prior = '';
	}
}

By the way, don't trust the regular expression above, I didn't test it and
I rarely get them right on the first try ;-)

Diana
-- 
Diana Duncan (or possibly Craig) -> happy pair of techies                  
|  Excitement, Adventure
REALOGIC, Inc. (or Innovative Business & Training Solutions)            |  
              and
art2mis@apk.net, dduncan@realogic.com, cduncan@atrium-hr.com   |     
Really Wild Things



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

Date: Sat, 15 Feb 1997 18:38:30 GMT
From: matt@callnet.com (Matthew Ahrens)
Subject: compiling GD on NetBSD
Message-Id: <330901f2.98891122@news.alt.net>

I am having some trouble compiling the GD perl library on NetBSD/mac68k. If
anyone has any tips, or a compiled binary for this platform, please let me
know. Here is the output i get from 'make' right before it dies:

Running Mkbootstrap for GD ()
chmod 644 GD.bs
LD_RUN_PATH="" ld -o ./blib/arch/auto/GD/GD.so -Bforcearchive -Bshareable
-L/usr/local/lib GD.o  libgd/libgd.a   
libgd/libgd.a(mtables.o): Definition of symbol `_cost' (multiply defined)
libgd/libgd.a(mtables.o): Definition of symbol `_sint' (multiply defined)
libgd/libgd.a(mtables.o): Size element definition of symbol `_cost'
(multiply defined)
libgd/libgd.a(mtables.o): Size element definition of symbol `_sint'
(multiply defined)
libgd/libgd.a(libgd.o): Definition of symbol `_cost' (multiply defined)
libgd/libgd.a(libgd.o): Definition of symbol `_sint' (multiply defined)
libgd/libgd.a(libgd.o): Size element definition of symbol `_cost' (multiply
defined)
libgd/libgd.a(libgd.o): Size element definition of symbol `_sint' (multiply
defined)
*** Error code 1

Stop.

thanks,
--matt


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

Date: Sat, 15 Feb 1997 15:45:26 GMT
From: tma@encore.com (Thanh Ma)
Subject: Re: Compiling Perl on UnixWare
Message-Id: <E5nIFr.CuE@encore.com>

david.getchell@paonline.com (David Getchell) writes:

>I am having a hard time getting Perl to compile on UnixWare 2.1. The
>version of Perl is 5.003. It fails several of the tests during the
>self-check. I also was unable to use dynamic loading. Suggestions?

Why bother ? It has been done on www.freebird.org://..///utils/

-- 
Thanh Ma
tma@encore.com


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

Date: Sat, 15 Feb 1997 15:03:53 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: eval in C
Message-Id: <E5nGII.F72@world.std.com>

phuerta@ibm.net (Paulino Huerta) writes:

>How to simulate the perl function eval

I assume you mean making a C function eval() which would take C
code. If you mean a C function eval() that would take perl code see
the perlembed man page.

One option would be to see if you can find a C interpreter to link
into your program, then feed your the code you want to eval to the
interpreter. You're much more likely to find a interpreted C subset
rather than a full ANSI C.

Otherwise I'm sure someone could create a C version of eval on a
system that has dynamic loading of code. On unix, see the dlopen() and
dlsym() man pages.
-- 
Andrew Langmead


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

Date: Sat, 15 Feb 1997 16:47:55 GMT
From: nedoli@csailab.kookmin.ac.kr (Yun-ho Chung)
Subject: File Upload on WEB
Message-Id: <3305e866.5816338@news.nuri.net>

Hello...
I want to file upload on WEB.
How use CGI with Perl???
Help me....


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

Date: 15 Feb 1997 17:18:57 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: File Upload on WEB
Message-Id: <5e4r61$b00@fridge-nf0.shore.net>

Yun-ho Chung (nedoli@csailab.kookmin.ac.kr) wrote:

: I want to file upload on WEB.
: How use CGI with Perl???

This group has nothing to do with CGI.  This is comp.lang.perl.misc.
I suggest that you check out comp.infosystems.www.authoring.cgi, and
peruse the article for instances of the word "upload."  Please also
refer to http://www.dejanews.com, and query for: "web upload perl cgi",
which gives 101 (+/-) matches.

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: Sat, 15 Feb 1997 10:07:17 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: HELP loop prob
Message-Id: <lvm4e5.gc1.ln@localhost>

Lewis Taylor (lewis@thereel.com) wrote:
: I have tried to emulate the following code:

: print OUTPUT ":$FORM{'qu1'}";
: print OUTPUT ":$FORM{'qu2'}";
: print OUTPUT ":$FORM{'qu3'}";
: print OUTPUT ":$FORM{'qu4'}";
: etc ...

: in a loop thus:

: for ($i=1; $i <= 14; $i++)

: {
: $field=$FORM{'qu$i'};
: print OUTPUT ":$field";
: }

: but this loop (and variations) do not seem to work. What a I doing
                                                      ^^^^^^^^^^^^^^
: wrong?
  ^^^^^

Not using -w maybe?

Not printing out the hash key to see what perl is seeing maybe?

Not wrong, but poor style:

   use lower case for variable names


------------------------
#! /usr/bin/perl -w

%form = ('qu1' => 'one',
         'qu2' => 'two',
         'qu3' => 'three',
         'qu4' => 'four'
);

for ($i=1; $i <= 4; $i++)

{
print 'qu$i', "\n";
}
------------------------

>From the output of this, you might say to yourself "My variables
aren't getting interpolated"...

So then you would consult the free documentation included with the
perl distribution, searching for 'interpolat'. In the perlop man page
you would find:

----------
=head2 Quote and Quotelike Operators

While we usually think of quotes as literal values, in Perl they
function as operators, providing various kinds of interpolating and
pattern matching capabilities.  Perl provides customary quote characters
for these behaviors, but also provides a way for you to choose your
quote character for any of them.  In the following table, a C<{}> represents
any pair of delimiters you choose.  Non-bracketing delimiters use
the same character fore and aft, but the 4 sorts of brackets
(round, angle, square, curly) will all nest.

    Customary  Generic     Meaning    Interpolates
        ''       q{}       Literal         no
        ""      qq{}       Literal         yes
        ``      qx{}       Command         yes
                qw{}      Word list        no
        //       m{}    Pattern match      yes
                 s{}{}   Substitution      yes
                tr{}{}   Translation       no
----------

and you would notice that single quotes do not interpolate. So then
you would notice that double quotes _do_ interpolate.

Then you would have solved your problem in a few minutes instead of
posting an waiting for _someone else_ to read the free documentation
(that is included with the perl distribution) for you.


$field=$form{"qu$i"};


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Sun, 16 Feb 1997 01:08:09 -0800
From: Patrick Tan <patrickt@tm.net.my>
Subject: How do I filter Files ending with ".std"  and reject those with '.std_inc'?
Message-Id: <3306CE79.1635@tm.net.my>

Hello,
I have two types of files in my directory, STDF_DIR, i.e.
  * those ending with '.std'
  * those ending with '.std_inc'

My current method doesn't filter them by the ending portion, since
it greps anything which matches 'std'.

@DirList = readir(DIR);
@StdfList = grep(/std/i,@DirList);

How do I indicate that I'm interested in '.std', but not '.std_inc'?

Appreciate all the help....

Best Regards,
-Patrick Tan-


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

Date: 15 Feb 1997 17:25:56 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: How do I filter Files ending with ".std"  and reject those with '.std_inc'?
Message-Id: <5e4rj4$b00@fridge-nf0.shore.net>

Patrick Tan (patrickt@tm.net.my) wrote:

: @DirList = readir(DIR);
: @StdfList = grep(/std/i,@DirList);

: How do I indicate that I'm interested in '.std', but not '.std_inc'?

@entries = grep(/std$/i, readdir(DIR));

If you don't want case insensitivity, remove the 'i'.

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: Sat, 15 Feb 1997 14:53:20 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: How do you write to seperate frames?
Message-Id: <Pine.HPP.3.95a.970215154205.22616D-100000@hpplus08.cern.ch>

On Tue, 11 Feb 1997, Joel D. Martinsen wrote:

> I have a program that outputs some formated data from a database.  I
> want to know how I can send the output to a seperate frame in the
> netscape window that the frame the cgi script was called from.  

Well, you'll do it by generating some HTML (strictly I should say NHTML)
from your Perl script.  This question is asked in one form or another
about twice a day in the HTML authoring group, which is the most
appropriate place for asking it. An answer can be found in the WDG's
draft Frames FAQ, at http://www.htmlhelp.com/design/frames/faq/ 

It always puzzles me why people think that when they use Perl to
write HTML, they would have to ask their HTML questions in a Perl
programming group.




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

Date: 15 Feb 1997 19:42:39 GMT
From: "Geoffrey Baker" <editor@mbeacon.com>
Subject: newlines and textarea boxes
Message-Id: <01bc1b78$61f4f440$4291f4c7@geoff.biddeford.com>

Hello all,

This is probably a very silly question, but I have modified a simple perl
script to allow me to set up forms that allow certain users to update
certain pages.

My problem is that I have a textarea box which the user inputs info into.

I cannot get it to format the text properly. I can get it to replace a
newline with a <BR> command, but I cannot get it to replace two newlines
with a <P> command!

Here is a snippet:
The following line takes output from a textarea box named "conditions" and
replaces newlines with <BR> tags.

	$in{'conditions'} =~ s!\n!<BR>!g;

However, this line:

$in{'conditions'} =~ s!\n\n!<P>!g;

will NOT replace two newlines with a <P> tag.

I have no idea what I am doing wrong here; can someone help me out of this
simple trap?


Thanks very much!

Geoffrey Baker
editor@mbeacon.com


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

Date: 15 Feb 1997 11:47:22 GMT
From: subzero@syix.com (Sub Zero)
Subject: Perl/Win95, nothing Happens!!!
Message-Id: <5e47oa$gth$2@neko.syix.com>

Hey Perlies...

   I have recently started playing around with perl5 for Win95, I have 
multiple perl scripts running right now (http://www.sandra.org) but I did not 
create them, I have found them on the web. I bought a Perl book and am trying 
my best to learn perl. I have found that when I use the date command, it does 
not insert nothing into the result.. I downloaded the DOS Port of Date for Unix 
and it is in the same directory as perl.exe, The thing that gets me is, when I 
execute the script by the dos prompt, (perl.exe mycgi.cgi) it works, it inserts 
the date and time... but when i execute it from the HTML Browser, no go. What 
is going on? How can I fix this?   

   I am using WebSite1.1e with 32 Megs of Ram, a 200mhz Pentium proccessor, and 
perl5.003, Also, my $ENV{'REMOTE_ADDR'}; all of those don't work, along with a 
little form I made, When the data is put in the URL:
  http://sandra.org/cgi-perl-bin/sandwich.cgi?protein=Turkey

  on the output, it does not say I chose turkey, when I DID! And I practically 
copied the script out of the book.... (Just to make shure it worked, but it 
don't!)

    PLEASE HELP!!
    Thank You
    Richard
    http://www.sandra.org
    subzero@sandra.org



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

Date: 15 Feb 1997 19:15:10 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Perl/Win95, nothing Happens!!!
Message-Id: <5e51vu$ibm@fridge-nf0.shore.net>

Sub Zero (subzero@syix.com) wrote:
: Hey Perlies...

You should read about perl's localtime() function.

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: 15 Feb 1997 15:27:59 GMT
From: "Scott T. Johnson" <sjohnson@ibm.net>
Subject: Pipes and redirects using NT
Message-Id: <01bc1b54$b28bf210$d74a48a6@scott>

Perl Newbie and I have search for 2 hours on the Internet for an answer to
this question.

I have started to learn Perl on an NT box.   The boox is great but doesn't
tell how to use redirects and pipes under NT.   If I have a text file that
I would like to replace all tabs with spaces, how do I pipe that file into
a perl script and then send the results to a second file.   UNIX this is
easy, NT I can't figure.

Thanks,
Scott


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

Date: 15 Feb 1997 16:05:22 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Pipes and redirects using NT
Message-Id: <5e4ms2$658@fridge-nf0.shore.net>

Scott T. Johnson (sjohnson@ibm.net) wrote:

: I have started to learn Perl on an NT box.   The boox is great but doesn't
: tell how to use redirects and pipes under NT.   If I have a text file that
: I would like to replace all tabs with spaces, how do I pipe that file into
: a perl script and then send the results to a second file.   UNIX this is
: easy, NT I can't figure.

Oh, it's easier than this, friend.  :-)  There are a number of ways to do
this, but here are some suggestions:

(1) Get an introductory book, like _Learning Perl_ by Randal Schwartz.
(2) Your solution could be the same on NT as it would be on Unix.
(3) Check out the FAQ, http://www.perl.com/perl/ -> follow links to FAQ.

$file = '/path/to/file/filename';
open(IN, "$file") || die("No:$!\n");
open(OUT, ">$file.new") || die("Out: $!\n");
while(<IN>) {
   $_ =~ s/\t/ /g;
   print OUT $_;
}
close(OUT);
close(IN);

rename("$file.new", "$file");

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: 15 Feb 1997 16:17:52 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Pipes and redirects using NT
Message-Id: <slrn5gbo8c.psb.dave@fast.thomases.com>

On 15 Feb 1997 15:27:59 GMT, Scott T. Johnson <sjohnson@ibm.net> wrote:
> Perl Newbie and I have search for 2 hours on the Internet for an answer to
> this question.
> 
> I have started to learn Perl on an NT box.   The boox is great but doesn't
> tell how to use redirects and pipes under NT.   If I have a text file that
> I would like to replace all tabs with spaces, how do I pipe that file into
> a perl script and then send the results to a second file.   UNIX this is
> easy, NT I can't figure.

Would you believe exactly like you'd do it on Unix (except perhaps
for the quoting?

   D:\> echo hello | perl -pe "s/l/#/g" >tmp1
   
   D:\> type tmp1
   he##o
   
Dave
   

-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Sat, 15 Feb 1997 13:39:09 -0400
From: Imran Shah <imran@science.gmu.edu>
Subject: Problem using diagnostics.pm
Message-Id: <3305F4BD.4B1AB3E9@science.gmu.edu>

Hello,

I am trying to use the diagnostics.pm module as shown in the manpage.
The program dies in the compilation stage whith the following errors:-

couldn't find diagnostic data in /usr/lib/perl5/pod/perldiag.pod 
/usr/lib/perl5/i586-linux/5.003 /usr/lib/perl5
/usr/lib/perl5/site_perl/i586-linux /usr/lib/perl5/site_perl .
/users/ishah/bin/test_diag at /usr/lib/perl5/diagnostics.pm line 225,
<POD_DIAG> chunk 507.
BEGIN failed--compilation aborted at /users/ishah/bin/test_diag line 3,
<POD_DIAG> chunk 507.

I have been running perl 5.003 on linux 2.0 for a while with out any
problems. I would be grateful for any advice.

Cheers

Imran

-- 
//	Imran Shah				
//	imran@science.gmu.edu
//	Computational Sciences &Informatics	
//	George Mason University


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

Date: 15 Feb 1997 18:25:56 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: QUES: what is "undump"?
Message-Id: <5e4v3k$4ke$3@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    sg94bwh5@dunx1.ocs.drexel.edu (John Nolan) writes:
:In Programming Perl (2nd ed, page 336), they mention in passing
:that you can take the coredump of a compiled perl script, 
:"undump" it using the undump program, and create an 
:executable.  Does anyone know what undump is?  

I would give up on undump.  Unless you've got a Sun or a Vax, it's
not very available, and even then, it does very little good, and
in fact a bit of harm.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    if (rsfp = mypopen("/bin/mail root","w")) {     /* heh, heh */
        --Larry Wall in perl.c from the perl source code


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

Date: 15 Feb 1997 18:15:18 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: RegEx, Email & Friedl's "Mastering..." Book
Message-Id: <5e4ufm$4ke$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    cggatt@worldnet.att.net (24601) writes:
: Problem - I use (.*) to match everything
:after the colon and this breaks on the \n. How would I tell the
:expression to match the multiple line, as above, but go back to
:matching normally on the 'Date:' line. 

Well, first you have to have a multiline string in your record, 
as in for example pre-setting $/ to the empty string.
Then you use /s and /m for the matches.

Multiline matching does you no good without a multiple line string.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

Can you sum up plan 9 in layman's terms? It does everything 
    Unix does only less reliably    --Ken Thompson


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

Date: 14 Feb 1997 23:13:35 -0700
From: Jason Stewart <jasons@infinity.cs.unm.edu>
Subject: renaming all functions with a common prefix
Message-Id: <xjnu3nefvg0.fsf@infinity.cs.unm.edu>

Hi,

I have a project in which a would like to change all of the function
names by adding a common prefix to all function definitions,
declarations, and calls. My thought was to first build up a database
of all the functions defined in the project, and then to go through
the data base one function at a time changing every occurrence of that
function in the project to use the new name.

Has anyone done this?

I was hoping to build the database (semi) automatically with Perl's
help. I was definately counting on using Perl to rename everything. 

If I could use Perl for the database building, what regexp or series
of regexps could I use to match a C function definition?

Is there any smarter algorithm to use for the renaming part other than
popping a name of my list of functions and going through each file?

Any thoughts are welcome.
jas.


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

Date: 15 Feb 1997 18:33:17 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: renaming all functions with a common prefix
Message-Id: <slrn5gc067.q8g.dave@fast.thomases.com>

On 14 Feb 1997 23:13:35 -0700, Jason Stewart <jasons@infinity.cs.unm.edu> wrote:
> Hi,
> 
> I have a project in which a would like to change all of the function
> names..
> 
> I was hoping to build the database (semi) automatically with Perl's
> help. I was definately counting on using Perl to rename everything. 

Could well do it with Perl and a package called C-Scan (you'll need
Data/Flow as well). It extracts function definions (along with a whole heap
of other stuff if you want) relatively easily:

   use C::Scan;

   $c = new C::Scan 'filename' => 'disp.c';

   # Text of function definitions
   $fde = $c->get('fdecls');

   print join("\n", @$fde), "\n";
   
Alternatively, you could use ctags or etags to extract the function name and
parse the output file.

For the replacement, you'll need to be careful only to replace full words.
What you do for text in strings is something of a mystery. 

   int test(void)
   {
      if (...)
         printf("test failed in routine test\n");
    }
    

Finally, before you do anything, you might want to find out if cscope is
available on your system - it'll do it all for you interactively (I think -
its a while since I've used it).

Regards

Dave



-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 15 Feb 1997 18:27:19 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: RFC: Statistics for comp.lang.perl.misc
Message-Id: <5e4v67$4ke$4@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    gbacon@CS.UAH.Edu (Greg Bacon) writes:
:[Please mail me any comments, questions, suggestions, etc.]
:
:    - A line in the body of a post is considered to be original if it
:      does *not* match the regular expression /^(?:>|:|\S+>)/.

I suggest you use an algorithm more like this if you want that kind
of thing:

--tom

#!/usr/local/bin/perl -w
#
# cfoq: check fascistly overquoted by tchrist@mox.perl.com
#   (wants perl 5.0 or better; developed under 5.002)
#
# INPUT:   a news article
# OUTPUT:  if -v, then shows how much it found and where
#
# OPTIONS: -v for verbose flag
#	    -t NN to change tolerance percentage from 50%
#	    -m for minimum lines that get subject to percentage counting;
#		otherwise, it just checks for ANY new lines.  This way 
#		short little 6-line messages with 4 lines of quoting don't
#		get hassled
#
# EXIT:	   2 (bad failure) if no new lines
#	   1 (failure)     if tolerance exceeded
#	   0 (success)     otherwise

# 5.0 might work, but I developed it under 5.002
require 5.002;  

use strict;

use vars qw{
    $MINLINES  $opt_m 
    $VERBOSE   $opt_v
    $TOLERANCE $opt_t
}; 

use Getopt::Std;
getopts("vt:m:") || die "usage: $0 [-v] [-t tolerance] [-m minlines] [input_file]\n";

my (
    $total, 		# total number of lines, minus sig and attribution
    $quoted_lines, 	# how many lines were quoted
    $percent, 		# what percentage this in
    $pcount, 		# how many in this paragraph were counted
    $match_part,	# holding space for current match
    $gotsig,		# is this the sig paragraph?
);

$total = $quoted_lines = $pcount = $percent = 0;

$MINLINES  = $opt_m || 20;
$VERBOSE   = $opt_v;
$TOLERANCE = $opt_t || 50; 

$/ = ''; 	# set record reading to paragraph mode
<ARGV>;   	# consume and discard header of message

while (<ARGV>) {

    # strip sig line, remember we found it
    $gotsig = s/^-- \n.*//ms;

    # strip attribution, possibly multiline
    if ($. == 2) { s/\A.*?(<.*?>|\@).*?:\n//s }  

    # toss trailing blank lines into one single line
    s/\n+\Z/\n/;

    # now reduce miswrapped lines from idiotic broken PC newsreaders
    # into what they should have been
    s/(>.*)\n\s*([a-zA-Z])/$1 $2/g;

    # count lines in this paragraph
    $total++ while  /^./mg;

    # is it a single line, quoted in the customary fashion?
    if ( /^(>+).*\n\Z/ ) {
	$quoted_lines++;
	print " 1 line  quoted with $1\n" if $VERBOSE;
	next;
    } 

    # otherwise, it's a multiline block, which may be quoted
    # with any leading repeated string that's neither alphanumeric
    # nor string
    while (/^(([^\w\s]+).*\n)(\2.*\n)+/mg) {  # YANETUT
	$quoted_lines += $pcount = ($match_part = $&) =~ tr/\n//;
	printf "%2d lines quoted with $2\n", $pcount 	if $VERBOSE;
    } 

    last if $gotsig;
} 

$percent = int($quoted_lines / $total * 100);
print "$quoted_lines lines quoted out of $total: $percent%\n"
						    if $VERBOSE;

if ($total == $quoted_lines) {
    print "All $total lines were quoted lines!\n"   if $VERBOSE;
    exit(2);
}

if ($percent > $TOLERANCE) { 
    if ($total < $MINLINES) {
	print "but since $total is less than $MINLINES lines, that's ok\n"
						    if $VERBOSE;
	exit 0;
    } else { 
	exit 1;
    }
} else {
    exit 0;
} 

__END__
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    The only disadvantage I see is that it would force everyone to get Perl.
    Horrors.  :-)
                    --Larry Wall in  <8854@jpl-devvax.JPL.NASA.GOV>


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

Date: 15 Feb 1997 18:02:14 GMT
From: "Craig or Diana Duncan" <art2mis@apk.net>
Subject: Re: running prog from within perl script
Message-Id: <01bc1b69$e04203b0$c108b7ce@zeus>

$encryptpass = `pngen`;		# These are backticks
	OR
$encryptpass = qx/pngen/;

You could also open the program as a filehandle, piping in the output, but
I think that's a little extreme, yes?

Diana Duncan
art2mis@apk.net

Iqbal Gandham <igandham@prestel.net> wrote in article
<3301EB7B.13DD@prestel.net>...
> I have a program called pngen
> the oupt from this is password: encryptpass
> 
> I need to runthis program from another perl script. How do
> I do this . I want to store the values to a string.



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

Date: 15 Feb 1997 16:59:58 GMT
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <5e4q2e$s15@info.uah.edu>

Following is a summary of articles spanning a 7 day period,
beginning at 07 Feb 1997 16:39:08 GMT and ending at
15 Feb 1997 07:39:12 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^(?:>|:|\S+>)/.
    - All text after the last cut line (/^-- \n/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" e-mail address and name.

Totals
======

Total number of posters:  483
Total number of articles: 1022
Total number of threads:  439
Total volume generated:   1833.4 kb
    - headers:    619.5 kb
    - bodies:     1129.9 kb (881.4 kb original)
    - signatures: 81.7 kb

Averages
========

Number of posts per poster: 2.1
Number of posts per thread: 2.3
Message size: 1837.0 bytes
    - header:     620.7 bytes
    - body:       1132.1 bytes (883.2 bytes original)
    - signatures: 81.9 bytes

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   54    59.2 ( 30.7/ 28.4/ 20.5)  Nathan V. Patwardhan <nvp@shore.net>
   42    75.9 ( 24.9/ 51.0/ 28.0)  Tad McClellan <tadmc@flash.net>
   39    60.8 ( 22.8/ 29.2/ 15.6)  Dave@Thomases.com
   34    45.8 ( 17.9/ 24.0/  6.6)  Jim Anderson <jander@jander.com>
   29    56.4 ( 15.7/ 31.6/ 23.0)  mike@stok.co.uk
   27    62.8 ( 18.8/ 39.7/ 30.7)  Tom Christiansen <tchrist@mox.perl.com>
   26    40.6 ( 20.2/ 20.4/ 15.1)  Tom Phoenix <rootbeer@teleport.com>
   20    43.4 ( 11.3/ 32.0/ 25.3)  nelson <nmljn@wombat.staff.ichange.com>
   12    15.9 (  7.5/  8.4/  3.8)  Ilya Zakharevich <ilya@math.ohio-state.edu>
   11    22.0 (  8.4/  9.5/  5.3)  Randal Schwartz <merlyn@stonehenge.com>

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

 154.2 (  0.6/153.6/149.3)      1  hunter be hunted <sisiyang@wam.umd.edu>
  75.9 ( 24.9/ 51.0/ 28.0)     42  Tad McClellan <tadmc@flash.net>
  62.8 ( 18.8/ 39.7/ 30.7)     27  Tom Christiansen <tchrist@mox.perl.com>
  60.8 ( 22.8/ 29.2/ 15.6)     39  Dave@Thomases.com
  59.2 ( 30.7/ 28.4/ 20.5)     54  Nathan V. Patwardhan <nvp@shore.net>
  56.4 ( 15.7/ 31.6/ 23.0)     29  mike@stok.co.uk
  45.8 ( 17.9/ 24.0/  6.6)     34  Jim Anderson <jander@jander.com>
  43.4 ( 11.3/ 32.0/ 25.3)     20  nelson <nmljn@wombat.staff.ichange.com>
  40.6 ( 20.2/ 20.4/ 15.1)     26  Tom Phoenix <rootbeer@teleport.com>
  32.0 (  1.2/ 30.8/ 23.6)      2  Jason Stewart <jasons@infinity.cs.unm.edu>

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

   11  Perl vs Korn Shell
   11  Loops in perl
   10  Randal trashed yet again--*sigh*
   10  ANNOUNCEMENT: Perl documentation and FAQ discontinued
    9  Need help - just starting perl
    9  on the fly graphs
    9  read and write +> at the same time - HOW?
    9  Case insensitive comparison
    8  Using $ENV{'QUERY_STRING'}
    8  REQ: Getting the amount of files in a certain directory.

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

 154.2 (  0.6/153.6/149.3)      1  perl
  35.2 (  2.1/ 32.8/ 24.6)      4  PerlXS
  25.8 (  1.2/ 24.6/ 23.7)      2  Q: how best to share a hash between packages
  18.2 (  5.1/ 13.0/  5.7)      9  Need help - just starting perl
  16.9 (  2.2/ 14.6/ 12.2)      3  PROGRAM: how to check for nice/valid email address
  16.5 (  7.2/  8.2/  5.4)     11  Loops in perl
  16.3 (  7.6/  7.7/  5.4)     11  Perl vs Korn Shell
  15.5 (  6.2/  7.4/  4.8)     10  Randal trashed yet again--*sigh*
  15.0 (  5.1/  9.2/  5.0)      9  on the fly graphs
  14.2 (  2.4/ 11.9/  5.6)      4  Matt's Script: SSI Random Banner Generator

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      28  comp.lang.perl.modules
      11  comp.lang.perl.tk
      10  comp.lang.perl
       7  comp.emacs.xemacs
       5  ford.comp.www
       5  ford.comp.lang.perl
       4  comp.databases.sybase
       4  perl.porters-gw
       3  alt.fan.e-t-b
       3  sci.math

Top 10 Crossposters
===================

Articles  Address
--------  -------

      15  Jackson Dodd <jackson@usenix.org>
       7  Richard E. Depew <red@redpoll.mrfs.oh.us>
       5  aure@cid.com
       4  Chris Nandor <pudge@pobox.com>
       4  Stijn van Dongen <stijnvd@cwi.nl>
       4  Tony Ellison <ellison@ingress1.murdoch.edu.au>
       3  Tom Christiansen <tchrist@mox.perl.com>
       3  "Sriram Srinivasan." <sriram@sirius.com>
       3  Mark Peskin <mpeskin@mail.utexas.edu>
       3  Nathan V. Patwardhan <nvp@shore.net>


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

Date: 15 Feb 1997 15:53:01 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Uploading files in perl4 !!
Message-Id: <5e4m4t$658@fridge-nf0.shore.net>

jrduval@total.net wrote:
: I need to upload files from a HTML(CGI) page to my directory. I know the
: procedure to take the file from the page but i do not know how to
: transfer it to my server. Any help would be greatly welcome

(1) You should get cgi-lib.pl -> search for this using Yahoo
(2) You should read the documentation included with cgi-lib.pl and on
    the cgi-lib.pl website.
(3) You should post follow-ups to comp.infosystems.www.authoring.cgi

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: 15 Feb 1997 18:22:01 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: using "$var" considered harmful?! (was Re: Q: opening a file RW without deleting it.)
Message-Id: <5e4us9$4ke$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Russell_Schulz@locutus.ofB.ORG (Russell Schulz) writes:
:over and over in the group I see people write code like
:
:  $var1="$var2";
:
:and always people respond
:
:  why are the quotes there???
:
:like they're HARMFUL or something.  I find that I do this a lot when
:I'm expecting to add in another variable, or I want to have constant
:text around the string, or I just don't know what I'm going to do with
:it exactly.

You are making a *BIG MISTAKE* if you do this, one that will come
back to bite and gnaw and chew and never spit you out again.

For example:

    f([a, b, c]);

    sub g {
	my $stuff = shift;
	print "@stuff\n";
    } 

    sub f {
	my $arg = shift;
	g("$arg");	# WRONG BAD OUCH
    } 

See the problem?  It's simply a dirty habit that you shouldn't get into.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

If you want your program to be readable, consider supplying the argument.
            --Larry Wall in the perl man page 


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 V7 Issue 956
*************************************

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