[9178] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2796 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 3 10:07:24 1998

Date: Wed, 3 Jun 98 07:02:35 -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           Wed, 3 Jun 1998     Volume: 8 Number: 2796

Today's topics:
    Re: Piping in Win32 Perl... <quednauf@nortel.co.uk>
        Problem with system() and PATHEXT on NT <bjs@iti-oh.com>
    Re: Problems with select(). (M.J.T. Guy)
    Re: Sendmail from CGI bug <noels@ozinet69.zip.com.au>
        study; <jenkinsrd@cf.ac.uk>
    Re: study; <zenin@bawdycaste.org>
    Re: study; <zenin@bawdycaste.org>
    Re: Submitting http request and getting/parsing resulti (Jonathan Stowe)
    Re: Taking data out of strings <qdtcall@esb.ericsson.se>
    Re: Taking data out of strings (Marek Jedlinski)
    Re: TIP : Complex CGI scripts <fty@utk.edu>
    Re: WIN32 <dturley@ravine.binary.net>
        X ticks with GIFgraph <jurgen@pallas.tid.es>
        Year 2000 Compliant <robertpage@capitalgroup.co.uk>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 03 Jun 1998 09:19:35 +0100
From: "F.Quednau" <quednauf@nortel.co.uk>
Subject: Re: Piping in Win32 Perl...
Message-Id: <35750717.7E1F826@nortel.co.uk>

Prasanna Pendse wrote:

> I am trying to pipe some ouput into bc (nt port) like this:
>
> chomp(@data = qx!$cat c:\inetpub\cgi-bin\a.bc | $bc!);
> $num_d = scalar @data;
> $d = join("\n", @data);
> print "num_d: $num_d\n";
> print $d;
>
> this works if I run it on the commandline, but can't see the output
> through my browser... (@data is empty and $num_d is 0).
>
> Let me know what I did wrong (or if this is a Perl for Win32 problem and
> if there is any way to get around it...)

Is not your main problem I suppose, but you should also print
'content:text/html' to the browser, so it understands what is coming (if it
would be coming).


--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________





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

Date: Wed, 3 Jun 1998 08:37:44 -0400
From: "Brian J. Sayatovic" <bjs@iti-oh.com>
Subject: Problem with system() and PATHEXT on NT
Message-Id: <6l3gb0$9ul$1@malgudi.oar.net>

    I've narrowed down my problem to this simple test program.  As is, it
doesn't work.  However, if I switch the two system() lines, it does work.
Whether or not it works seems to have something to do with redirection.

    I can do a system call to any normal command (.exe, .com, etc.).
However, when I do, I can't seem to view STDOUT.  If I do redirect it to a
file, however, the output will be in the file.  Furthermore, if I try to use
a command made executable via PATHEXT (such as script.pl) it doesn't work
*unless* I also run/redirect as in the commented system line.

    Any ideas?

# --- script.pl ---
if($ARGV[0]  eq '') {
 $index =0;
} else {
 $index = $ARGV[0];
}

print "index = $index\n";

if($index <= 2) {
 open(FILE, ">temp$index");
 print FILE "Inside infinite loop...\n";
 print FILE "PATHEXT = $ENV{'PATHEXT'}\n";
 print FILE "Leaving loop...\n";
 close(FILE);

# system("script " . ($index + 1) . " && echo I_HATE_THIS > foo$index");
 system("script " . ($index + 1));
} else {
 open(FILE, ">temp$index");
 print FILE "Breaking loop!\n";
 close(FILE);
}

exit;




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

Date: 3 Jun 1998 08:14:06 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Problems with select().
Message-Id: <6l30ke$6i3$1@lyra.csx.cam.ac.uk>

Tom Phoenix  <rootbeer@teleport.com> wrote:
>
>That's a very C-like way of printing! :-)  In Perl, printf is rarely used; 
>this would be simpler as a regular print statement. 

Well, I certainly use printf quite a lot.   I think you meant to say

"In Perl, printf is rarely used just to interpolate variables in the
output."


Mike Guy


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

Date: Wed, 3 Jun 1998 20:14:58 +1000
From: "Noel Sampol" <noels@ozinet69.zip.com.au>
Subject: Re: Sendmail from CGI bug
Message-Id: <6l37k3$kmv$1@the-fly.zip.com.au>


Randy Kobes wrote in message ...
>[ snip ]
>
>Hi,
>    I tried the code, using two valid email addresses for $owner_email
>and $email, and got the messages sent to both addresses. But,
>looking at my man page for sendmail, doesn't the '-n' switch mean
>to not do aliasing? Maybe removing the -n would work.
>
> Best regards,
> Randy Kobes
>
<snip>

Thanks for trying it out... and to those who were not happy about my post
about sendmail from CGI script, I apologise for any inconvenience caused but
I guess I got really desperate for any help as my post said. And yes, I did
post to the sendmail news group but had no success of finding a solution to
this bug. In future, I shall attempt to adhere to news group 'rules' even if
I'm desperate for help again. And, just for information, I have helped
others with their posts in the past even if they posted to the wrong
newsgroup... but I'm not condoning that people should post irrelevant posts
to newsgroups ;-). Anyway, the '-n' switch was a 'fix' offered from some
other newsgroup.

Thanks again and please accept my apologies

Noel Sampol
noels@ozinet69.zip.com.au

Please remove '69' when replying.





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

Date: Wed, 03 Jun 1998 11:58:08 -0700
From: Dean Jenkins <jenkinsrd@cf.ac.uk>
Subject: study;
Message-Id: <35759CC0.72CA@cardiff.ac.uk>

I'd like to speed up the following search using study.

Where is the best place to put it and would it be better to build a 
string for eval (if so how)? There are about 20 - 40 keywords and 1000 
lines to search in the form of a (|) delimited text database.


foreach $keyword (@words) { # for each keyword
 foreach $card (@lines) { # for every line
  if ($card =~ /\b$keyword/i) {
     $num = split(/$keyword/i,$card) - 1; # number of keywords in line
     $meds{$card} = scalar($meds{$card} + $num);
     if ($card =~ /^[^\|]*$keyword[^\|]*\|/i) {  # if keyword is in the 
first line
        $meds{$card} = $meds{$card} + 15; # add something to the score
     }
  }
 }
}

--
Dean Jenkins - Llandough Hospital, Cardiff, Wales.
 12-lead ECG library
 http://homepages.enterprise.net/djenkins/ecghome.html


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

Date: 3 Jun 1998 13:32:06 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: study;
Message-Id: <896881231.963828@thrush.omix.com>

Dean Jenkins <jenkinsrd@cf.ac.uk> wrote:
: Where is the best place to put it and would it be better to build a
: string for eval (if so how)? There are about 20 - 40 keywords and 1000
: lines to search in the form of a (|) delimited text database.

	You probably need not worry about study, it only really helps when
	you are doing a large number of searches on a string, else it just
	slows them down.  It might help with the 20 - 40 you're using, but
	it's not likely.  An algorithm change would probably help a lot
	more.

: foreach $keyword (@words) { # for each keyword
:  foreach $card (@lines) { # for every line
:   if ($card =~ /\b$keyword/i) {

	Why the extra search?  Use the $num to do your test, if you
	even need the test (see below);

:      $num = split(/$keyword/i,$card) - 1; # number of keywords in line

	This is 1/3 slower then a while() loop on my system.  You might
	want to try this:

	$num++ while ($card =~ /\b$keyword/i);

:      $meds{$card} = scalar($meds{$card} + $num);

	...Scalar?  Why not +=?

	$meds{$card} += $num;

	Probably just a style issue, but style counts.

	In this case, why the extra var:

	$meds{$card}++ while ($card =~ /\b$keyword/i);

:      if ($card =~ /^[^\|]*$keyword[^\|]*\|/i) {  # if keyword is in the first line
:         $meds{$card} = $meds{$card} + 15; # add something to the score

	All together, something like this might be a little faster:

	foreach my $keyword (@words) {
	    foreach my $card (@lines) {
	        $meds{$card}++ while ($card =~ /\b$keyword/i);
	        $meds{$card} += 15
	        	if ($card =~ /^[^\|]*$keyword[^\|]*\|/i);
	    }
	}

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 3 Jun 1998 13:38:48 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: study;
Message-Id: <896881633.867593@thrush.omix.com>

Zenin <zenin@bawdycaste.org> wrote:
: 	You probably need not worry about study, it only really helps when
: 	you are doing a large number of searches on a string, else it just
: 	slows them down.  It might help with the 20 - 40 you're using, but
: 	it's not likely.  An algorithm change would probably help a lot
: 	more.

	Forgot to mention, you probably will want to consult the Benchmark
	module to see exactly what is the fastest method.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Wed, 03 Jun 1998 11:38:16 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Submitting http request and getting/parsing resulting page?
Message-Id: <357533cd.8113685@news.btinternet.com>

On Wed, 03 Jun 1998 04:24:24 GMT, sylviamoestl@my-dejanews.com wrote :

>Hello,
>
>I'd like to be able to do the following programatically in Perl:
>
>Take numerous URL strings (for example,
>http://www.xxx.com/test.spl?parameter=ABC)
>Send them out over the internet
>Return the page that the URL returns, be able to parse it out, etc.
>

There was a recent thread on this.  If you search on dejanews for:

Subject:      cron job via perl ??
From:         Kerem Yaman <kyaman@earthlink.net>
Date:         1998/05/27
Message-ID:   <356CE415.4E0F9861@earthlink.net>
Newsgroups:   comp.lang.perl.misc

And have  a look at the thread.

This should get you going.  After you have tried out some of the ideas
there and if you are have further problems with your perl code please
post back a small example of what is not working for our perusal.

/J\ 
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 03 Jun 1998 10:43:31 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Taking data out of strings
Message-Id: <islnreyix8.fsf@godzilla.kiere.ericsson.se>

Ray Rarey <rayr@accessus.net> writes:

> I have no trouble with reading lines and printing them in files, but I
> can't figure out how to break up the data.

Bring up the perlfunc manpage and search for "string". The very first
hit you get will give plenty of pointers to useful functions.
-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: Wed, 03 Jun 1998 12:05:38 GMT
From: cicho@polbox.com (Marek Jedlinski)
Subject: Re: Taking data out of strings
Message-Id: <35763bde.985745@news.nask.org.pl>
Keywords: If you're happy and you know it, clunk your chains.

[posted and emailed]

Ray Rarey <rayr@accessus.net>  wrote:


>Can anyone help me with this one? I've been trying different approaches,
>but nothing works. This is what i'm trying to do:
>For our school, we have a website that lists all the people that made
>the honor roll (about 1,600, so I want to make the pages with perl) and
>each line of data in the files is written like this:
>LAST NAME, FIRST NAME             GRAD. YEAR           GPA
>I want to get perl to read the files, take out each line one at a time,
>and  print the person's names in a table cell, their grad year in a
>cell, and their gpa in a cell.

You didn't say _precisely_ how your data is formatted in the original file.
How are the fields in each record delimited - with spaces, tabs, otherwise?
At any rate, you probably need `split'. Assuming the simplest possible
case, data items separated by single spaces:

	# read a line from the file into $line, and then do:
	@recs = split( ' ', $line );

You'll then have:
LAST NAME 	in $recs[0]
FIRST NAME	in $recs[1]
GRAD YEAR	in $recs[2]
GPA			in $recs[3]

which you can then print out in any order, etc.

Of course if there is, for instance, variable number of spaces between the
items, you'll need to collapse them into single spaces first, etc.

 .marek




-- 
After things go from bad to worse, the cycle will repeat itself.
http://come.to/fnord/


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

Date: Wed, 03 Jun 1998 08:31:20 -0400
From: Jay Flaherty <fty@utk.edu>
To: Pascal Wolff <ujiw@rz.uni-karlsruhe.de>
Subject: Re: TIP : Complex CGI scripts
Message-Id: <35754218.2454C48E@utk.edu>



Pascal Wolff wrote:

>         foreach $pp (&param){
>             if ($pp =~ /^tofrm.*/) {
>                 &$$pp;
>                 exit;
>             }
>         }
>
> The only drawback I can think of right now is that 'use strict' complains
> very heavily.

I'll bet this code snippet above is where 'strict' complains. try it this way:

foreach $pp (&param){
    if ($pp =~ /^tofrm.*/) {
        *function = $pp;
        function();
        exit;
    }
}

Jay
--
**********************************************************************
Jay Flaherty                                               fty@utk.edu
"Once in awhile you get shown the light, in the strangest of places if
you look at it right" - R. Hunter
**********************************************************************




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

Date: 3 Jun 1998 13:09:40 GMT
From: David Turley <dturley@ravine.binary.net>
Subject: Re: WIN32
Message-Id: <6l3huk$m4q$1@oksennus.binary.net>

Andy Murren <andy@interactive.net> wrote:

> > There's a beta Apache server that runs on Win32 now. I haven't tried it
> > yet. Why not? Well, I am not in any hurry to try pre-beta crashware.


Couldn't most windoze software be considered pre-beta crashware? :-)
_____________________________________________________________________
David Turley
dturley@pobox.com
http://www.pobox.com/~dturley

"You don't want to be the only person sitting on a crocodile's back."
                                        -- heard on a PBS nature show
______________________________________________________________________


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

Date: Wed, 03 Jun 1998 13:29:30 +0200
From: Jurgen Koeleman <jurgen@pallas.tid.es>
Subject: X ticks with GIFgraph
Message-Id: <3575339A.E84EF726@pallas.tid.es>

I am using the module GIFgraph to display GIF output for a graph, but
have a problem with it and don't know how to solve it.

I want to use the ticks on the X-axis, but not for each data point.
E.g. for all the minutes of the day there is a data point, but the
ticks are only needed once every 60 minutes.
Does somebody know how to do this?


Jurgen Koeleman




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

Date: 3 Jun 98 11:20:15 GMT
From: "Robert Page" <robertpage@capitalgroup.co.uk>
Subject: Year 2000 Compliant
Message-Id: <01bd8edf$c44131a0$ef0416c3@ccb030.capital>

Can anyone point me in the direction of information covering the various
versions of Perl that covers year 2000 compliancy.



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

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

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