[6972] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 597 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 10 19:17:09 1997

Date: Tue, 10 Jun 97 16:00:28 -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           Tue, 10 Jun 1997     Volume: 8 Number: 597

Today's topics:
     "Transparent" support for multiple perl binaries <smuskiew@ede.sanders.lockheed.com>
     Re: ---: Basic Perl question! Please HELP :------------ (Jeff Stampes)
     6million lines !! <djp@sai-baba.demon.co.uk>
     Re: AWK vs Perl For Misc Data Processing Tasks (Mark A Mandel)
     Re: Berkely DB Files - Apache, Perl and Linux <zenin@best.com>
     Re: blank lines (Jot Powers)
     Re: blank lines <sibsib@hotmail.com>
     Re: blank lines <rootbeer@teleport.com>
     Double Quote in replacement string (City of Beverly Hills)
     Re: Double Quote in replacement string (Tad McClellan)
     Re: extract character from string array and use as inte <chilton@scci-ad.com>
     How to lock files on Win'95? (CHAN TANG Eric-Aubert)
     htons() <dfox@pobox.com>
     Re: inconsistent opendir behaviour in Perl for win32 <wm_n00@tarrcity.demon.co.uk>
     make file blues ... help (IFHRK)
     Re: negation in regex <usenet-tag@qz.little-neck.ny.us>
     Re: negation in regex <staci@datahost.com>
     Re: Netscape .db files (Paul Marquess)
     Re: newbie: flat file tabulating question <ajohnson@gpu.srv.ualberta.ca>
     News servers function in Perl  Is it possible ? (Ccadic)
     Re: News servers function in Perl  Is it possible ? <rootbeer@teleport.com>
     Re: Parsing Comma Delemited Text DataBase (Alan Citterman)
     Re: Perl Database (Which is better) <enzrowi@nzsf00.epa.ericsson.se>
     Re: Perl script as login shell? <rootbeer@teleport.com>
     Re: Please help with IPC problem (Jeff Stampes)
     Re: Problems w/matching a header and printing the follo <rootbeer@teleport.com>
     Re: Regexpert's assistance required. <jbokma@caiw.nl>
     returning/handling errors from a module (Jon Drukman)
     Simple, but yet hard reg exp problem? (Andreas Olsson)
     Slow load-time in Perl - does 5.004 fix? <microsys@IntNet.net>
     Re: What does "UNIX" stand for.. (Kevin Schaffer)
     Re: Y2K Compliant? (A. Deckers)
     Re: Y2K Compliant? (A. Deckers)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 10 Jun 1997 17:44:20 -0400
From: Steve Muskiewicz <smuskiew@ede.sanders.lockheed.com>
Subject: "Transparent" support for multiple perl binaries
Message-Id: <339DCAB4.7DE14518@ede.sanders.lockheed.com>

Hi,

Does anyone know of a clever way to "transparently" call the proper perl
binary (depending on platform) to execute a script while still allowing
the use of a "generic" token (ie. "#!/usr/local/bin/perl") at the top of
a script?

We support 3 different platforms in our UNIX environment (sunos,
solaris, hp-ux) and I've installed perl into the same top-level
directory, with all of the binaries in their own directories (ie.
bin/sun4-sunos, etc.)  The docs, FAQ, etc. talk alot about
architecture/platform specific libraries, but I haven't found anything
that touches on the location of the binaries and dealing with that,
short of doing a little bit of preparation at the top of every perl
script.

We have some engineers here who want to be able to run their Perl
scripts from any machine, but (of course) don't want to have to change
or add anything to their scripts!  Up to now, we've only had perl on
sunos, so it didn't make a difference.

(Of course, I've considered having a script that sets up the PATH
environment variables to the proper binary and just using the token
"#!/bin/env perl", but this is no good for passing args...like "-w" to
perl.)

Thanks to anyone who can come up with anything helpful!

-steve


-- 
-Steve Muskiewicz
 CAE Tool Development & Integration Engineer
 Engineering Design Environment
 Sanders, A Lockheed-Martin Company  Nashua, NH
 (603) 885-4394
 smuskiew@ede.sanders.lockheed.com


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

Date: 9 Jun 1997 21:26:27 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: ---: Basic Perl question! Please HELP :-----------------
Message-Id: <5nhse3$7sl$1@neocad.com>

Farshad Abasi (fabasi@unixg.ubc.ca) wrote:
: Hello,

: Is this a valid call to a PERL script? I am not having any luck with it :-(

: <frame src="test.cgi" name=body>

Hmmm..this looks like html code...maybe this has something to do with 
a CGI?  Perhaps comp.infosystems.www.authoring.cgi could help you? 

: My script runs OK from the shell (ie if I type "perl test.cgi" it generates the 
: page OK, but if I go to the web browser and try the script off my server (ie 
: http://myurl.com/test.cgi) then nothing works.

Gosh.,..this sounds almost like the FAQ "My CGI script runs from
the command line but not the browser.  Can you help me fix it?"

If you look in the FAQ, you'll see the relevant answer references:

http://www.perl.com/perl/faq/idiots-guide.html
http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml
http://www.perl.com/perl/faq/perl-cgi-faq.html
http://www-genome.wi.edu/WWW/faqs/www-security-faq.html
http://www.boutell.com/faq/




--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Tue, 10 Jun 1997 20:57:50 GMT
From: "Daniel J Pearce" <djp@sai-baba.demon.co.uk>
Subject: 6million lines !!
Message-Id: <01bc75e0$65ed35e0$03d4dec2@sai-baba.demon.co.uk>


I'm searching a LARGE amount of data using Perl, and have a dwindled down
while statement controlling the flow of the data.

The logfiles are in ascii format and seperated with ;

The lines have 29 parts which I am addressing in an array....

Reports have to be generated using an interactive front end to input the
search criteria, options include 25 of the 29 elements in the array.

The scripts I have written to do the work are efficient, since the source
has been stripped down to increase search times, trying not to lose any
functionality.

Would storing the data in a Perl DB help speed up the operation, or slow it
down, keeping in mind that to reduce the time involved in analysing the
files either requires less source operation on it, or indeed faster I/O.

Any ideas ?

Daniel J Pearce
djp@sai-baba.demon.co.uk


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

Date: Tue, 10 Jun 1997 18:17:31 GMT
From: mam@world.std.com (Mark A Mandel)
Subject: Re: AWK vs Perl For Misc Data Processing Tasks
Message-Id: <EBKo58.A3L@world.std.com>

I've been using Thompson AWK for DOS, which is a lot better than what
there is of standard awk. I'm switching to perl because it's more
generally capable and it's standardized cross-platform, at least as far as
our in-house needs go.

-- Mark A. Mandel, Sr. Linguist, Dragon Systems, Inc.  
   http://www.dragonsys.com/   


Nathan T. Wild (nwild@codville.mb.ca) wrote:
: I have been happily working with AWK under UNIX and DOS for several years. 
: We are porting some AWK-based systems over to NT, and I am wondering
: whether I should invest in the NT version of our AWK compiler, or just take
: this opportunity to switch to Perl?

: AWK has been extremely useful, and at my first glance, Perl appears to be
: extremely cryptic (more so than it has to be!).  Is there a distinct
: advantage to using Perl over AWK.  If so, can anyone direct me to some
: documentation that is aimed at AWK programmers.  I have found several good
: Perl docs, but I think a document aimed at AWK programmers would save me a
: lot of time...




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

Date: 10 Jun 1997 19:13:08 GMT
From: Zenin <zenin@best.com>
Subject: Re: Berkely DB Files - Apache, Perl and Linux
Message-Id: <5nk904$3je$1@nntp2.ba.best.com>

Mike Sleath <mike@guardian.co.uk> wrote:
> I am using Apache 1.2 and Linux 2.X (RedHat 4.1).  I am attempting to use
> Berkeley DB files for authorization, using perl scripts and DB_File to
> manage three databases.  I also have it locking (well, not locking the
> actual database, because that looks awful, but using lock files) so that
> there is no simultaneous access.  Here's my problem.  During testing, when
> we are adding to the databases, at some indeterminite time, suddenly one
> of the databases will lose 20-70 entries.  Another point, one of the other
> ones will lose them.  Obviously this is not workable for a user database
> (I keep losing them!).

	I had similar problems with DB_File running on IRIX.  The fix was
	to run GDBM_File (GNU DBM).  It's not quite as fast, but it seems
	to be /much/ more stable on non-BSD systems then DB_File.

-Zenin
 zenin@best.com


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

Date: 10 Jun 1997 18:07:26 GMT
From: jot@tmp.medtronic.com (Jot Powers)
Subject: Re: blank lines
Message-Id: <5nk54u$ol5$1@gazette.corp.medtronic.com>

In article <EBKL3t.6yA@seas.ucla.edu>, trit@olympic.seas.ucla.edu (Tri Duy Tram) writes:
>	I was wondering how can I do a regular expression that will only
>catch blank lines?  I have text like:
>
>blah blah blah . . . .
>blah blah . . . .
>
>more blahs blah . . .
>
>I tried $var !~ /a-z/ || $var !~ /A-Z/ || $var /0-9/
>but that doesn't seem to work.  Any help will be appreciated.
>

$var =~ /^\s*$/

Undoubtably, various goo roo's will have better answers.

(Also, yours would fail to work in locations that used special
characters.  If you want your strategy look at \w and \W)

-Jot
-- 
Jot Powers  jot@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."




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

Date: Tue, 10 Jun 1997 14:07:23 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: blank lines
Message-Id: <339D97DB.12353735@hotmail.com>

Tri Duy Tram wrote:
> 
>         I was wondering how can I do a regular expression that will only
> catch blank lines?  I have text like:

Do you mean 

1. lines with nothing (except the eol)?

or 

2. lines with nothing (except the eol) except whitespace?

Try:

1. match against /^$/

2. match against /^\s*$/

Scott

-- 
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net


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

Date: Tue, 10 Jun 1997 15:19:28 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tri Duy Tram <trit@olympic.seas.ucla.edu>
Subject: Re: blank lines
Message-Id: <Pine.GSO.3.96.970610151724.20918a-100000@kelly.teleport.com>

On Tue, 10 Jun 1997, Tri Duy Tram wrote:

> 	I was wondering how can I do a regular expression that will only
> catch blank lines? 

What's a blank line?

    $line eq ''

    $line eq "\n"

    $line =~ /^\s*$/

Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 10 Jun 1997 15:58:47 GMT
From: ir003251@mindspring.com (City of Beverly Hills)
Subject: Double Quote in replacement string
Message-Id: <5nk7n1$mmc@camel1.mindspring.com>


I use Perl script to insert href to specific strings in the html
document.

I would like to search the string for the variable and provide href to
it, e.g replace  phrase "Click $here" with "Click <A
HREF="$here">$here</A>"

The problem is I can't incert double quote into the replacement
string.  I can incert the single quote though: 

$here="THERE";
s?$here?"<A HREF='/subdir/" . $here . " .HTM'>" . $here . "</A>"?e;
 
and get  the result:
<A HREF='/subdir/THERE.HTM'>THERE</A>

But not all browsers can process address in single quotes correctly,
and I've got a lot of "NOT FOUND" errors from my WEB server.

How I can get <A HREF="/subdir/THERE.HTM">THERE</A>
(with url in double quotes) after replacement?
It looks like escape character \ does not work with " (double quote).

Please reply via e-mail. Thanks.

Broni Kaganovich
bkaganov@ci.beverly-hills.ca.us



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

Date: Tue, 10 Jun 1997 15:19:14 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Double Quote in replacement string
Message-Id: <2sckn5.au1.ln@localhost>

City of Beverly Hills (ir003251@mindspring.com) wrote:

: I use Perl script to insert href to specific strings in the html
: document.

: I would like to search the string for the variable and provide href to
: it, e.g replace  phrase "Click $here" with "Click <A
: HREF="$here">$here</A>"

No problem.


: The problem is I can't incert double quote into the replacement
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^

Why not?

What happened when you tried it?


: string.  I can incert the single quote though: 

: $here="THERE";
: s?$here?"<A HREF='/subdir/" . $here . " .HTM'>" . $here . "</A>"?e;
                                                                   ^
                                                                   ^
Oh I see. You are using an eval().

So you don't have a simple replacement string. You have some perl
code that will generate the replacement string.


You should not use and eval() unless you need to. It is slower.

You don't need to. See code below...


[ choosing a regex metacharacter (?) as your regex delimiter is not
  a good habit to get into...
]


If you insist on perpetrating a UUOE, you could use one of the
alternate quoting mechanisms (UNTESTED):


# use single quotes instead:
s#$here#'<A HREF="/subdir/' . $here . '.HTM">' . $here . '</A>'#e;
        ^^^^^^^^^^^^^^^^^^^           ^^^^^^^^           ^^^^^^

#use yet another way of quoting:
s#$here#qq(<A HREF="/subdir/) . $here . qq(.HTM">) . $here . qq(</A>)#e;
           ^^^^^^^^^^^^^^^^^               ^^^^^^               ^^^^

or you could even backwack the double quotes (but only the ones that
the eval() doesn't need to delimit the strings):

s#$here#"<A HREF=\"/subdir/" . $here . " .HTM\">" . $here . "</A>"#e;
                 ^^                          ^^


: and get  the result:
: <A HREF='/subdir/THERE.HTM'>THERE</A>


: How I can get <A HREF="/subdir/THERE.HTM">THERE</A>
: (with url in double quotes) after replacement?


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

$here = "THERE";

$_ = "Click $here";

s#$here#<A HREF="/subdir/$here.HTM">$here</A>#;

print "$_\n";
---------------------


: It looks like escape character \ does not work with " (double quote).



The replacement part is already "double quotish". So it will do variable
interpolation, which is all you need. You do not need to resort to s///e



: Please reply via e-mail. Thanks.

Please read the newsgroup.


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


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

Date: Tue, 10 Jun 1997 12:25:31 -0500
From: Chris Hilton <chilton@scci-ad.com>
To: David Dougal <ddougal@concentric.net>
Subject: Re: extract character from string array and use as integer
Message-Id: <339D8E0B.FF6D5DF@scci-ad.com>

David Dougal wrote:
> 
> 
> @array = ("w0123456789","l0123456787","w0134265879", "t0123456789",
>           "w0123456789", "w0123456789");
> 
> How can I extract the third character from one of the string elements and then
> use the character as an integer?

#Pick one of the strings

$string = $array[3];

#Extract the third character

$third = substr($string, 2, 1);

#Just use it like a number

$sum = $third + 4;

#Or do it all at once

$sum = substr($array[3], 2, 1) + 4;

-- 

Chris
Be seeing you.


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

Date: 10 Jun 1997 19:59:56 GMT
From: chantane@JSP.UMontreal.CA (CHAN TANG Eric-Aubert)
Subject: How to lock files on Win'95?
Message-Id: <5nkbns$lvi@epervier.CC.UMontreal.CA>

How do you lock a file in Win'95 ?

With 'flock(FILE...)' I get the message : flock() is not available on
Win95.

With 'fcntl(FILE, F_RDLOCK...)' I get the message : fcntl is not
implemented at <file>.pl line xx.
(Of course, I did put 'use Fcntl').


Thanks in advance.
-- 
  ____________________________________________________________
   (3/1R&() Eric-Aubert Chan Tang <chantane@JSP.UMontreal.CA>
            http://www.jsp.umontreal.ca/~chantane/


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

Date: Tue, 10 Jun 1997 14:12:20 -0400
From: Daniel Fox <dfox@pobox.com>
Subject: htons()
Message-Id: <339D9904.74E2EFD0@pobox.com>

Is there a way to do htons() in perl?

Please reply by email.


Thanks..

-- 
Daniel Fox
dfox@pobox.com


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

Date: Tue, 10 Jun 1997 20:54:36 +0100
From: Wm <wm_n00@tarrcity.demon.co.uk>
Subject: Re: inconsistent opendir behaviour in Perl for win32
Message-Id: <9wF02RA8DbnzEwYo@tarrcity.demon.co.uk>

Tue, 10 Jun 1997 08:53:06 <Pine.GSO.3.96.970610084915.20918B-
100000@kelly.teleport.com>
Tom Phoenix <rootbeer@teleport.com> posted...

>On Mon, 9 Jun 1997, Wm wrote:
>
>> directories that could be tested for existence but not read (eg execute
>> only permission on a Unix directory for example; I can see the file and
>> that it is a directory but I may not have permission to open it and see
>> its contents) appeared to be the sort of thing that might produce
>> different behaviour between -d and opendir.
>
>Agreed: -d and opendir don't have produce the same results for every name. 
>But if -d says it's a directory, opendir's failure should get a different
>error value than "no such file or directory". And if -d says it's _not_ a
>directory, then there's no way opendir should be able to open it! 
>
>Hope this helps!

It certainly does (if only my confidence in having been cautious 
previously).

We shall have to see if Activeware respond to Simon's message to them.
-- 
Wm ... did you know?  My spell checker wants tarrcity to be atrocity.


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

Date: 10 Jun 1997 17:11:05 GMT
From: cpeterma@emerald.tufts.edu (IFHRK)
Subject: make file blues ... help
Message-Id: <5nk1r9$54v$1@d2.tufts.edu>

This is the source of my WOAH's:

util.c: In function `Perl_croak':
util.c:962: number of arguments doesn't match prototype
proto.h:45: prototype declaration
util.c: In function `Perl_warn':
util.c:1017: number of arguments doesn't match prototype
proto.h:466: prototype declaration
util.c: In function `Perl_my_popen':
util.c:1442: warning: return makes pointer from integer without a cast
*** Error code 1
make: Fatal error: Command failed for target `util.o'

I am compiling on an Ultra-2 running SunOS 5.5.1

Any ideas on what idiocy I am committing.  If you would like I can send
you my config.sh file and you can have a good laugh.

Thanks 

Charles Peterman

--
In the end we all know what we've done,                 Computer Engineer
but how many of us can say                                     Vegetarian
we know what we are doing now?                             Weight Trainer
Charles Peterman        Tufts University       cpeterma@emerald.tufts.edu
    


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

Date: 10 Jun 1997 19:12:05 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: negation in regex
Message-Id: <5nk8u5$e86$1@news.netusa.net>

Michael Stearns  <staci@datahost.com> wrote:
[see <URL:news:339D8476.7255@datahost.com> for example]
> I'm trying to figure out how to write a regex that will insert the
> opening and closing table tags. It seems like I need to match a pattern
> that has:

Seems to me a case of trying to be too clever.

> - a line of text, which doesn't include a <T...> tag followed by a line
> that includes the pattern "<TR><TD>line2</TD><TD>23></TD></TR><P>".
> 
> -for the end of the table I think I need to do the same thing with the
> two lines flipped around.
> 
> But I don't see how to write a regex that finds a line of text that does
> not include <TR> or <TD>. Can anyone tell me how to do this? Or if there
> are any recommended alternate methods, please fill me in.

$previous="";

while($line=<INPUT>) {
  ...
  if ( ( $line =~ /<T[DR]\b/i ) && ! ( $previous =~ /<T[DR]\b/i ) ) {
    # do stuff to $line
  }
   elsif ( ! ( $line =~ /<T[DR]\b/i ) && ( $previous =~ /<T[DR]\b/i ) ) {
    # do stuff to $line
  }
  ...

  # Ignore blank lines for purposes of $previous
  if ( $line =~ /\S/ ) {
    $previous=$line;
  }
}

It could be done without using $previous, but I would want to know
more about how you have it stored in memeory and what other handy
constraints apply before trying this in a pair of s/// for each
table end.

Elijah
------
feel free to tighten or loosen my regexps as needed


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

Date: Tue, 10 Jun 1997 14:02:09 -0700
From: Michael Stearns <staci@datahost.com>
Subject: Re: negation in regex
Message-Id: <339DC0D1.61FF@datahost.com>

Eli the Bearded wrote:
> 
> Michael Stearns  <staci@datahost.com> wrote:
> [see <URL:news:339D8476.7255@datahost.com> for example]
> > I'm trying to figure out how to write a regex that will insert the
> > opening and closing table tags. It seems like I need to match a pattern
> > that has:
> 
> Seems to me a case of trying to be too clever.
> 

Ahhh. I am afraid an overabundace of cleverness is not my problem here.

> $previous="";
> 
> while($line=<INPUT>) {
>   ...
>   if ( ( $line =~ /<T[DR]\b/i ) && ! ( $previous =~ /<T[DR]\b/i ) ) {
>     # do stuff to $line
>   }
>    elsif ( ! ( $line =~ /<T[DR]\b/i ) && ( $previous =~ /<T[DR]\b/i ) ) {
>     # do stuff to $line
>   }
>   ...
> 
>   # Ignore blank lines for purposes of $previous
>   if ( $line =~ /\S/ ) {
>     $previous=$line;
>   }
> }

I do not understand how $previous is interacting with $line in this
example. For this process to work, it seems like $previous needs to be
referring to the line directly preceding $ line at all times. How are
you getting $previous to be sychronized with $line in this manner?

Thanks,
Michael


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

Date: 10 Jun 1997 20:50:29 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: Netscape .db files
Message-Id: <5nkeml$4lp$1@pheidippides.axion.bt.co.uk>

[ Posted & Mailed]

Daniel Wang (danwang@trek.CS.Princeton.EDU) wrote:

: Anyone know what format the netstape .db files are in? Anyone have a perl
: script that will let me play with them? 

Berkeley DB 1.85. Below is an extract from the latest DB_File
documentation about reading Netscape history files:

Paul

  Here is a snippet of code that is loosely based on Tom Christiansen's
  ggh script (available from your nearest CPAN archive in
  authors/id/TOMC/scripts/nshist.gz).

    use strict ;
    use DB_File ;
    use Fcntl ;

    use vars qw( $dotdir $HISTORY %hist_db $href $binary_time $date ) ;
    $dotdir = $ENV{HOME} || $ENV{LOGNAME};

    $HISTORY = "$dotdir/.netscape/history.db";

    tie %hist_db, 'DB_File', $HISTORY
        or die "Cannot open $HISTORY: $!\n" ;;

    # Dump the complete database
    while ( ($href, $binary_time) = each %hist_db ) {

        # remove the terminating NULL
        $href =~ s/\x00$// ;

        # convert the binary time into a user friendly string
        $date = localtime unpack("V", $binary_time);
        print "$date $href\n" ;
    }

    # check for the existence of a specific key
    # remember to add the NULL
    if ( $binary_time = $hist_db{"http://mox.perl.com/\x00"} ) {
        $date = localtime unpack("V", $binary_time) ;
        print "Last visited mox.perl.com on $date\n" ;
    }
    else {
        print "Never visited mox.perl.com\n"
    }

    untie %hist_db ;




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

Date: Tue, 10 Jun 1997 02:17:20 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: newbie: flat file tabulating question
Message-Id: <339CFF80.72B8713B@gpu.srv.ualberta.ca>

Chris Martin wrote:
!
! Hi folks !
! 
! I have a web page form that users submit a number of fields
! (date, name, location, problem, comments) to a flat file,
! separated by "|".  I have another script which then reads in
! the file, and prints it in a html table.  No problem.....
! However, i would lilke to be able to have another script
! that would read the file and summarize the results.  For
! example, there are about 10 locations to choose from, and
! for each location, there are about 10 problems to choose
! from.  I would like it to do a report such as "for each
! location, there are so many of this problem type reported".
! The script is to do this for all locations, tabulating the
! number of each problem reported.
! 
! I have read a lot of the faq's, and online tutorials, etc,
! but i'm really stumped as to how to start. I know that this
! is probably an easy one for experienced folks, but could
! someone please help a newbie by giving me some ideas, or
! point me in the right direction.  Thanks for any assistance
! you can offer.


one way that might help you get started:

while (<DATA>) {
   @array=split /\|/;
   $hash{"$array[2]:$array[3]"}++;
}

foreach $item (sort keys %hash) {
   ($loc,$prob)=split /:/,$item;
   print<<EOF;
In \"$loc\" the problem \"$prob\" 
was reported $hash{$item} time(s)

EOF
}

__DATA__
01/01/97|joe|Ellesmere Island|too cold|really
03/10/97|joe|Ellesmere Island|too cold|I mean it
03/11/97|jane|Ellesmere Island|joe's whining|the baby!
07/01/97|joe|Florida|too wet|rain rain go away
07/01/97|jane|Florida|joe's whining|even on vacation
07/03/97|joe|Florida|too hot|I wish it would rain
07/03/97|jane|Florida|joe's whining|grr!
08/25/97|joe|Ellesmere Island|black-flies|Ugh!
08/22/97|jane|Ellesmere Island|joe|Ugh!
09/15/97|joe|Ellesmere Island|too cold|again!
09/15/97|jane|Ellesmere Island|no divorce court|and no gun!
10/01/97|joe|Ellesmere Island|no jane|sniff
10/01/97|jane|Florida|no problems| :-)

regards
andrew


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

Date: 10 Jun 1997 17:15:20 GMT
From: ccadic@aol.com (Ccadic)
Subject: News servers function in Perl  Is it possible ?
Message-Id: <19970610171500.NAA16868@ladder02.news.aol.com>

I'm looking for a source code which could do this.

Connect to any newsgroups server (specified into the var configuration)
Read all newsgroups titles and save them in a txt file.
Then retrieve any the articles if a word is in it.

With this I would like to make a searching engine for newsgroups. This to
be ale to search for one or more words ( with OR/AND booleans) and
retrieve only articles which contains them.

Any idea or information ?





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

Date: Tue, 10 Jun 1997 14:32:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ccadic <ccadic@aol.com>
Subject: Re: News servers function in Perl  Is it possible ?
Message-Id: <Pine.GSO.3.96.970610143034.20918Z-100000@kelly.teleport.com>

On 10 Jun 1997, Ccadic wrote:

> Connect to any newsgroups server (specified into the var configuration)
> Read all newsgroups titles and save them in a txt file.
> Then retrieve any the articles if a word is in it.

Perl can do this with the NNTP module; you'll find modules on CPAN. Hope
this helps!

    http://www.perl.org/CPAN/
    http://www.perl.com/CPAN/

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 10 Jun 1997 16:01:10 -0500
From: apc@MCS.COM (Alan Citterman)
Subject: Re: Parsing Comma Delemited Text DataBase
Message-Id: <5nkfam$6nr$1@Mercury.mcs.net>

In article <5njnaf$rta@panix.com>, Clay Irving <clay@panix.com> wrote:
>In <865935438snz@dhcs.demon.co.uk> Dave Hodgkinson <daveh@dhcs.demon.co.uk> writes:
>
>>In article <5nfj6o$1ar@panix.com> clay@panix.com "Clay Irving" writes:
>
>>> 
>>> I'd be inclined to use the Text::CSV module:
>>> 
>
>>OK, I've searched CPAN for this, which points you to
>>Joseph N Hall, who claims on his home page that the
>>module is not released yet.
>
>>Any offers on where to find it?
>
>ftp://ftp.mcs.net/mcsnet.users/apc/Text-CSV-0.01.tar.gz

Just to clarify, the version referenced above is not Joseph N. Hall's.
It is my first attempt at writing an OO module that might be worth
sharing.

  - Al


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

Date: Wed, 11 Jun 1997 09:47:32 +1200
From: Ross Williamson <enzrowi@nzsf00.epa.ericsson.se>
Subject: Re: Perl Database (Which is better)
Message-Id: <339DCB74.2CBD@nzsf00.epa.ericsson.se>

If you had a realy choice I would say go with Sybase or Oracle but...

I have had very good experiences with Msql.  It's easy to set up, runs
well.  The only 2 things about it
1) It doesn't have a full implementation of SQL like you can't do
	select name,rank,serial from army group by....
	( ie doesn't support groups etc)
2) The versions I have been downloading all expire after a few weeks. 
You can either modify the source to remove the expiry (not really a good
thing)  or register with Mr Hughes :)

I wouldn't recommend DB_File unless your DB is very stable.  

You don't really say whats in the DB or is it mostly reads or
writes/updates.  That will influence the decision.

Ross

Howard Yen wrote:
> 
> I need to develop a site that will have hundreds of thousands
> of users. Currently the site is done using Perl.
> 
> Which of these 3 is the best way to go, in terms of speed,
> expandability and using the least memory.
> 
> 1. Msql
> 2. DB_File
> 3. Sprite
> 
> hy

-- 
+-----------------------------------------------------------------+
     Ross Williamson - Support Engineer - Ericsson New Zealand
              Phone (04)460-1061 - Mobile 025 956 265
   Just "before" someone gets nervous, do they experience cocoons 
                          in their stomach?


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

Date: Tue, 10 Jun 1997 13:26:52 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ben Neil Gerdemann <gerdemb@rice.edu>
Subject: Re: Perl script as login shell?
Message-Id: <Pine.GSO.3.96.970610132054.20918Q-100000@kelly.teleport.com>

On 10 Jun 1997, Ben Neil Gerdemann wrote:

> We are writing a perl script that allows users to automatically create a
> login account for themselves by telneting to a certain account. We are of
> course concerned about this script's security. What is the best way to
> make sure that the users cannot exit from the script and gain unauthorized
> access? 

Read perlsec(1), and you'll know most of what you need. If you exec the
script and then the user terminates it (with control-C, for example) they
won't get a shell, so that's not a problem. (But you may want to trap
SIGINT anyway.)

> The only system we can think of, is turning the Perl script into the
> account's login shell. Is this possible using the new Perl compiler? 

You don't need to compile it; just set the executable script to be the
shell. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/




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

Date: 10 Jun 1997 19:02:51 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Please help with IPC problem
Message-Id: <5nk8cr$33u$1@neocad.com>

Thomas Rock (thomasr@xtek.com) wrote:
: Nothing! I should get a hello message and a fortune. In the spawned 
: annonymous  subroutine I put print statements to STDERR duplicating the 
: prints to STDOUT. 

: Also, how would I send info from the client to the server? I tried doing 
: a print SOCK from the client and a $line = <STDIN> in the server, but the
: server didn't receive anything.


I'm guessing your problems are actually related.  Why on earth are
you doing $line = <STDIN>?  Do you want to read from STDIN?  Nope,
you want to read from the socket...you named your socket
something (probablt SOCK)...try $line = <SOCK>

Your print statements in the server that should be spewing the
fortune to the client should also be a print statement directed
at the Socket you opened. 

Hope this helps...

Jeff

--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Tue, 10 Jun 1997 10:07:45 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: jmack@p3.net
Subject: Re: Problems w/matching a header and printing the following text
Message-Id: <Pine.GSO.3.96.970610100150.20918F-100000@kelly.teleport.com>

On Tue, 10 Jun 1997 jmack@p3.net wrote:

> In this text file there are multiple headings/sections and a few
> paragraphs after each heading.  I'm interested in only a few sections in
> the file and that sections content, I can chuck all the rest. 

    $interested = 0;	# Don't care before first heading
    while (<>) {
	if (/^(\w+)/) {		# Or whatever headings look like
	    $interested = ($1 eq 'UNIX') || ($1 eq 'PIZZA');
	}
	next unless $interested;
	&process($_);
    }

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 10 Jun 1997 20:38:38 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: Regexpert's assistance required.
Message-Id: <01bc75de$700b27a0$c50ab2c2@tschai>



Douglas Seay <seay@absyss.fr> wrote in article
<339C2FCE.1A0224AE@absyss.fr>...
> [posted and mailed]
> 
> Simon Fairey wrote:
> > 
> > Hi,
> > 
> > I am trying to extract fields from a line and am wondering if it
is
> > poosible to do in one go or am I going to have to do some
fiddling
> > about. An example of a line might be:
> > 
> >         item1, function1([0,11], function2() ), item2
> > 
> > What I want is to just extract the three entries
> >         item1
> >         function1([0,11], function2() )
> >         item2
> > 
> > Any help would be appreciated, if its not possible then I guess I
am
> > going to have to do something more elaborate....
> 
> Bad news: What you want to do is not regular.  While Perl's REs are
> powerful, they only work on regular expressions.

If all the lines are of the form:

item1, some function stuff, item2

you can do something like:

($item1, $function, $item2) = /^([^,]+),(.*),([^,])$/;

and strip off trailing/leading spaces...

John


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

Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)

http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]

email: jbokma@caiw.nl  phone: +31 10 4291827



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

Date: 4 Jun 1997 22:45:28 GMT
From: jsd@cyborganic.com (Jon Drukman)
Subject: returning/handling errors from a module
Message-Id: <5n4r68$647$1@its.hooked.net>

i'm developing a module for use in-house.  one of the subroutines will
look up something in a database and return an array of values if the
piece of data can be found.

my question is mainly philosophical... what's the best way to signal
an error back to the calling program?  (ie: the data isn't found,
database isn't available).  right now i'm just returning the array if
the data is found and undef if it isn't, or there's an error.  this
makes for some ugly constructs in the calling program tho..  ideally
what i'd like to do is something that lets me call like this:

if (@data=MyMod::lookitup("query")) {
  print "data was found, it is: @data\n";
} else {
  print "that data not available\n";
}

but it seems that arrays evaluate true whether they're undef or not.

ideas appreciated...

--
Jon Drukman      jsd@gamespot.com             SpotMedia Communications
	     ...I was an infinitely hot and dense dot...


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

Date: Tue, 10 Jun 97 20:00:03 GMT
From: cie95aol@lustudat.student.lu.se (Andreas Olsson)
Subject: Simple, but yet hard reg exp problem?
Message-Id: <5nkbvn$3ko$1@news.lth.se>

Hello!

This problem puzzles me and would really appreciate if someone would help me.

I have a text that looks like this:

<eq-1>a^{b}c</eq-1>
<eq-2>a^{b}c</eq-2>

Now I want to translate the ^{b} command different depending on if I'm within 
the <eq-1>...</eq-1> or the <eq-2>...</eq-2> tag. The final result should look 
like this:

<eq-1>a<super>b</super>c</eq-1>
<eq-2>a<inf>b</inf>c</eq-2>

I've tried the following but it doesn't work properly:

s#^{(.*?)}(.*?</eq-1)#<super>$1</super>$2#gs;
s#^{(.*?)}(.*?</eq-2)#<inf>$1</inf>$2#gs;

The problem appears when I have this combination of input

<eq-1>a^{b}c</eq-1>
<eq-2>a^{b}c</eq-2>
<eq-1>a^{b}c</eq-1>

When I find the ^ in the <eq-2> I don't want the first expression to do 
anything, but it find </eq-1> on the other row and it substitutes incorrect.
I feel that this should be simple but can't find a way to solve it, please 
help me.

Thanks in advance

/Andreas Olsson

cie95aol@student1.lth.se


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

Date: Tue, 10 Jun 1997 17:12:22 -0400
From: "Ronald Klimaszewski" <microsys@IntNet.net>
Subject: Slow load-time in Perl - does 5.004 fix?
Message-Id: <339dc390.0@news.intnet.net>

I'm currently using Perl w/curses for some front-end access to reports. 
This works great.

The only problem is that, because perl is being called from a menu program,
it 
takes 2-3 seconds before anything appears on the screen.  This is quite a
bit of time
for impatient users to sit around wondering whats happening.

My question is, does 5.004 have a faster load time?  My current executible
is approx 1.2MB.

Thanks.  Please email, as I do not get on this list too often.  :-(

Ron Klimaszewski
microsys@IntNet.net







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

Date: Tue, 10 Jun 97 19:32:25 GMT
From: kxs@mindspring.com (Kevin Schaffer)
Subject: Re: What does "UNIX" stand for..
Message-Id: <5nkah1$7qj@camel3.mindspring.com>

In article <339D7121.F121CA82@inorbit.com>, av@inorbit.com wrote:
>Bill (Gates) Erwin wrote:
>
>> UNIX started out as "Castrated MULTICS" and was shortened from there.
>> Check out the "UNIX Haters Handbook" for further details.
>>
>> Bill
>
>I don't know what the "UNIX Haters Handbook" is, but sounds like
>bullshit...
>

Tar Dash Ecks Vee Eff



 .. and don't forget to type in the number of cylinders on your
hard disk.


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

Date: 10 Jun 1997 18:21:03 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: Y2K Compliant?
Message-Id: <slrn5pr6of.is.deckers@news.rediris.es>

In <339D93F5.3113@infinet-is.com>,
	Darin Morgan <dmorgan@infinet-is.com> wrote:
>Please don't flame me.

MUAHAHAHAHAHAHA! If you knew you were doing something wrong, why did
you do it? ;-)

>I do not use perl but have been asked by my employer to find out if
>Perl4 and Perl5 are Year 2000 compliant?

The answer is in the FAQ, at least as far as Perl 5 is concerned.
So please go read the FAQ.

HTH,

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: 10 Jun 1997 20:19:35 GMT
From: deckers@man.ac.uk (A. Deckers)
Subject: Re: Y2K Compliant?
Message-Id: <slrn5prdmm.9eo.deckers@news.rediris.es>

In <uswquvowyjwu.pminews@pc10.sirsi.com>,
	Gnome <gnome@advicom.net> wrote:
>On 10 Jun 1997 18:21:03 GMT, A. Deckers wrote:
>
>>In <339D93F5.3113@infinet-is.com>,
>>	Darin Morgan <dmorgan@infinet-is.com> wrote:
>>>Please don't flame me.
>>
>>MUAHAHAHAHAHAHA! If you knew you were doing something wrong, why did
>>you do it? ;-)
>
>If you cant say something informative, why waste the bandwidth.

Sounds like you should apply that lemma to yourself.

>>>I do not use perl but have been asked by my employer to find out if
>>>Perl4 and Perl5 are Year 2000 compliant?
>>
>>The answer is in the FAQ, at least as far as Perl 5 is concerned.
>>So please go read the FAQ.
>
>So what if it is in the FAQ?  Darin asked a question.  This IS a place
>to post questions about Perl is it not?  And someone looking for a
>quick answer should expect to receive such answers here, should they
>not?  Or may I shouldnt bother asking questions here myself.

Sounds like it, 'cos you obviously don't understand what FAQs are for.
(FAQ = Frequently Asked/Answered Question). The reason people compile
FAQ lists is precisely to avoid the repetition of the same question in
the newsgroup.

While we're at it, could you please fix your newsreader so your lines
wrap before column 80? I rewrapped your text for improved readability.

>Darin: Im sorry I dont know if Perl is year 2000 complient, but if I
>did know the answer, I would give it to you.

Err, did you have something informative to say?

[followup set to more appropriate group]

Alain

-- 
Perl information: <URL:http://www.perl.com/perl/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
        Perl FAQ: <URL:http://www.perl.com/CPAN/doc/FAQs/FAQ/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

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 597
*************************************

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