[7461] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1086 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 26 17:07:25 1997

Date: Fri, 26 Sep 97 14: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           Fri, 26 Sep 1997     Volume: 8 Number: 1086

Today's topics:
     Re: Any Recommendations for portable signal processing? (Bennett Todd)
     Re: call from IMG tag (Abigail)
     Re: Curses for Perl (Frank Merrow)
     Re: Date Algorithm needed (Bennett Todd)
     embeded perl inc <gjspeier@dev6k.cnf.com>
     Re: embeded perl inc (Mike Stok)
     Re: embeded perl inc (Mike Stok)
     Re: Getting next array element in a foreach <mthurn@irnet.rest.tasc.com>
     Help w/open3, pipes, threads(kinda long) (Shane Knapp)
     How to access Manual page <kinlam@mec.cuny.edu>
     how to create array of file handles? (Trudno zhit' v derevne bez nagana.)
     How to get close match on keywords <tou@tou.com>
     Re: How to get close match on keywords (Honza Pazdziora)
     Re: Julian Date Routine (Abigail)
     Re: Julian Date Routine <74561.610@CompuServe.COM>
     method calls in modules (Adam Luther)
     Re: method calls in modules (Ken Williams)
     Nearest Neighbor routine <joeallen@gizmo.usc.edu>
     Newbie URL Redirection Question lmain@ti.com
     Re: Newbie URL Redirection Question (Mike Stok)
     Re: Newbie URL Redirection Question (Faust Gertz)
     Re: Parsing e-mail folder (newbie) (Toni Tiainen)
     Re: Perl Generator? <selden@NOSPAM.instinet.com>
     Re: Perl to Java Compiler? (Jeff R. Stone)
     Re: predictable random numbers across continued runs (Jason Gloudon)
     Re: printing variables... <fearless@io.com>
     Re: printing variables... <fearless@io.com>
     Re: Reading files (newb) <mgenberg@marjar.com>
     Re: Reading files (newb) (Jason Gloudon)
     Re: Regular expression <ptimmins@netserv.unmc.edu>
     Re: Regular expression <ptimmins@netserv.unmc.edu>
     Re: substituting special chars (Bennett Todd)
     Re: symbolic dereferencing of my() variables -- can it  (Bennett Todd)
     Re: symbolic dereferencing of my() variables -- can it  (Rahul Dhesi)
     Re: Text::English (Gene Hsu)
     Re: Y2K <seay@absyss.fr>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 26 Sep 1997 20:32:36 GMT
From: bet@network.rahul.net (Bennett Todd)
Subject: Re: Any Recommendations for portable signal processing?
Message-Id: <slrn62o6v0.n43.bet@waltz.rahul.net>

On Fri, 19 Sep 1997 19:43:56 GMT, Adrian Pepper <arpepper@math.uwaterloo.ca> wrote:
>Now, one thing which surprises me is that
>
>keys %SIG
>
>is not initialized to anything.

Hmm.

    ; perl -le 'for(keys %SIG){print}'|pr -6tb
    XCPU        BUS         USR2        URG         PROF        WINCH
    ILL         USR1        INFO        PIPE        TRAP        CHLD
    QUIT        XFSZ        TTOU        CONT        IO          FPE
    STOP        TSTP        ALRM        SEGV        TERM        TTIN
    EMT         INT         KILL        VTALRM      PWR         SYS
    ABRT        IOT         HUP         POLL

I only have 5.004 perls around; perhaps this is a problem with older perls?

I tested it on Linux, SunOS 4.x, and Solaris 2.x. THe above output is from
Linux.

-Bennett


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

Date: 26 Sep 1997 17:51:48 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: call from IMG tag
Message-Id: <slrn62ntlm.235.abigail@betelgeuse.rel.fnx.com>

Michael A. Watson (fishrman@shell.wco.com) wrote on 1487 September 1993
in <URL: news:60gkkb$sr1$2@news.wco.com>:
++ I saw a posting that said you could call a PERL script from a HTML
++ IMG tag like this: <IMG SRC="http://your_url/cgi-bin/your_script.cgi">.

Of course. HTML doesn't care. The browser doesn't care. HTTP
doesn't care. The server doesn't care. There is really, really,
really, really nothing perl specific to this. It could be
anything. It might be getting something from a database. It
might be an Intercal program. Really.

++ I could not get this to work at all. Any hints?

Uhm, did you plug in your computer? Are you sure you are
asking the question in the right group (I highly doubt it,
rec.collecting.banana.peels seem to be more appropriate.)

++ Also if it is possible to do this how can you pass arguments?

Sure you can:
<IMG SRC="http://your_url/cgi-bin/your_script.cgi%20arg1%arg2%arg3">,
that's just fine. Of course, you might want to reprogram your
server to pass arg1, arg2, arg3 as actual arguments, but that's
a server issue, and not to be addressed in this newsgroup.

The perl program really doesn't care whether it's called by an
HTTP server, the cron deamon, or your cat logging on at night.



Abigail


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

Date: 25 Sep 1997 12:53:23 -0700
From: fmerrow@qualcomm.com (Frank Merrow)
Subject: Re: Curses for Perl
Message-Id: <60effj$e7n@pure.qualcomm.com>

>I have written a perl program on UNIX that uses the Curses module.  I
>was wondering if anyone knew where I could get a curses module for the
>WIN32 platform.

Virtually EVERYTHING Perl can be found directly or via link at CSPAN.  Fire
up Yahoo and query "CSPAN +perl" then follow the links.

Frank


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

Date: 26 Sep 1997 17:20:41 GMT
From: bet@network.rahul.net (Bennett Todd)
Subject: Re: Date Algorithm needed
Message-Id: <slrn62nrn8.2ll.bet@waltz.rahul.net>

On Thu, 25 Sep 1997 16:12:52 GMT, Ed.Q.Bridges <eqbridges@cbs.com> wrote:
>given GMT and a +/- integer offset from GMT and a +/- integer offset
>correction for DST, i need to be able to determine the current date
>for several different timezones around the world.
>
>what i need is a function equivalent to localtime() that takes a
>parameter for a timezone and returns the localtime *at that timezone*
>(rather than the machine that the localtime function is running on).

Different people will tackle this in different ways. You will find modules to
help with most any approach at CPAN; look in modules/by-module/Time/ and
Date/. These would be either

	<URL:http://perl.org/CPAN/modules/by-module/Time/>
	<URL:http://perl.org/CPAN/modules/by-module/Date/>

or

	<URL:http://perl.com/CPAN/modules/by-module/Time/>
	<URL:http://perl.com/CPAN/modules/by-module/Date/>

Now _My_ favourite approach would be to split it into subproblems, each of
which I already feel comfortable handling, using my favourite intermediate
representation for times, Unix time_t (seconds since 1970-01-01-00:00:00 GMT).
The modules in TimeDate, including Date::Parse, Date::Format, Time::Zone,
would make this very easy. Other people would feel more comfortable using
different approaches, I'm sure.

-Bennett


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

Date: Fri, 26 Sep 1997 12:58:39 -0700
From: Guy Joseph Speier <gjspeier@dev6k.cnf.com>
Subject: embeded perl inc
Message-Id: <342C13EF.41C6@dev6k.cnf.com>

call me a moron, but could someone please
explain how to embed perl code in a c program ...

i've tried with man page examples, but they don't
do the trick ... I guess what I'd really like is
a small example & the command to compile ..

even this won't work:

#include <stdio.h>
#include <EXTERN.h>               /* from the Perl distribution     */
#include <perl.h>                 /* from the Perl distribution     */

static PerlInterpreter *my_perl;  /***    The Perl interpreter    ***/
int main(int argc, char **argv, char **env)
   {
   my_perl = perl_alloc();
   perl_construct(my_perl);
   perl_parse(my_perl, NULL, argc, argv, env);
   perl_run(my_perl);
   perl_destruct(my_perl);
   perl_free(my_perl);
}

> cc -o embed embed.c -L/usr/local/lib/perl5/aix/5.002/CORE-I/usr/local/lib/perl5/aix/5.002/CORE -lperl -lm

i get the error:
1501-106: (S) Include file EXTERN.h not found.
    1501-106: (S) Include file perl.h not found.
"embed.c", line 5.24: 1506-046 (S) Syntax error.
"embed.c", line 9.4: 1506-045 (S) Undeclared identifier my_perl.


-- 
Guy J. Speier, CNF Service Company


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

Date: 26 Sep 1997 20:17:37 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: embeded perl inc
Message-Id: <60h591$ks0@news-central.tiac.net>

In article <342C13EF.41C6@dev6k.cnf.com>,
Guy Joseph Speier  <gjspeier@dev6k.cnf.com> wrote:
>call me a moron, but could someone please
>explain how to embed perl code in a c program ...

>#include <stdio.h>
>#include <EXTERN.h>               /* from the Perl distribution     */
>#include <perl.h>                 /* from the Perl distribution     */
>
>static PerlInterpreter *my_perl;  /***    The Perl interpreter    ***/
>int main(int argc, char **argv, char **env)
>   {
>   my_perl = perl_alloc();
>   perl_construct(my_perl);
>   perl_parse(my_perl, NULL, argc, argv, env);
>   perl_run(my_perl);
>   perl_destruct(my_perl);
>   perl_free(my_perl);
>}
>
>> cc -o embed embed.c -L/usr/local/lib/perl5/aix/5.002/CORE-I/usr/local/lib/perl5/aix/5.002/CORE -lperl -lm

Do you need a space before the -I so that the compiler driver sees it?

I use something like

  cc -o try try.c `perl -MExtUtils::Embed -e ccopts -e ldopts`

e.g.

[mike@stok tmp]$ more try.c

#include <EXTERN.h>
#include <perl.h>

static PerlInterpreter *my_perl;

int 
main (int argc, char **argv, char **env) {
  my_perl = perl_alloc ();
  perl_construct (my_perl);

  perl_parse (my_perl, NULL, argc, argv, env);

  perl_destruct (my_perl);
  perl_free (my_perl);
}
[mike@stok tmp]$ cc -o try try.c `perl -MExtUtils::Embed -e ccopts -e ldopts`
[mike@stok tmp]$ ./try -e 'print "Hello\n"'
Hello

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 26 Sep 1997 20:25:58 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: embeded perl inc
Message-Id: <60h5om$l99@news-central.tiac.net>

In article <60h591$ks0@news-central.tiac.net>,
Mike Stok <mike@stok.co.uk> wrote:

>#include <EXTERN.h>
>#include <perl.h>
>
>static PerlInterpreter *my_perl;
>
>int 
>main (int argc, char **argv, char **env) {
>  my_perl = perl_alloc ();
>  perl_construct (my_perl);
>
>  perl_parse (my_perl, NULL, argc, argv, env);

Due to a cut & paste error a crucial line is missing here:

  perl_run (my_perl);

>
>  perl_destruct (my_perl);
>  perl_free (my_perl);
>}

Sorry,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 26 Sep 1997 16:21:11 -0400
From: Kingpin <mthurn@irnet.rest.tasc.com>
Subject: Re: Getting next array element in a foreach
Message-Id: <eubu1f6d3c.fsf@irnet.rest.tasc.com>

  Use an integer index as the loop counter (what a novel idea) instead
of the actual item:

foreach my $i (1..scalar(@a))
  {
  if ($a[$i] eq 'd')
    {
    # do something with $a[$i+1];
    # you can even play with $i if you like!?!
    } # if
  } # foreach

-- 
 - - Martin "Kingpin" Thurn                    mthurn@tasc.com
     Research Software Engineer           (703) 834-5000 x2926
     The Information Refinery              http://tir.tasc.com
     TASC, Inc.                            http://www.tasc.com

I don't reply to "No.Spam" modified email-addresses.


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

Date: 26 Sep 1997 18:53:59 GMT
From: skknapp@nas.nasa.gov (Shane Knapp)
Subject: Help w/open3, pipes, threads(kinda long)
Message-Id: <60h0c8$av6$1@cnn.nas.nasa.gov>

hey all
i found the problem:
i had to set the filehandle to a scalar variable before i called open3().  it
looks/looked like open3() doesn't like arrays(scalar/associative) as its
filehandles.

later-

shane

--
**************************************************************
* Shane Knapp          * "I am riding a bike through a realm *
* NAS Lan Team         *  called consciousness and I have    *
* Sterling Software    *  squeaky brakes."                   *
* skknapp@nas.nasa.gov *				     * 
**************************************************************


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

Date: Fri, 26 Sep 1997 15:32:20 -0500
From: "kinlam" <kinlam@mec.cuny.edu>
Subject: How to access Manual page
Message-Id: <60h6ma$qvk@news.cuny.edu>

 Hi :
    I have just install perl on AIX , and I note it that there are some
manual doc.
that come with it,  Can anyone help to access it

Kin
e-mail : kin@mec.cuny.edu





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

Date: 26 Sep 1997 18:56:22 GMT
From: alex@kawo2.rwth-aachen.de (Trudno zhit' v derevne bez nagana.)
Subject: how to create array of file handles?
Message-Id: <60h0gm$15u$1@news.rwth-aachen.de>

Hi,

how do you create an array of handles? Or how do you get
a file handle if you know a file descriptor? (the way back
is fileno).

I am trying to convert my non-forking server program from 
C to Perl, but dont understand how do you handle several 
sockets in Perl: accept() uses file handles, but how can 
i store several sockets for later check with select()?

Thanks!
/Alex

PS: I've seen that IO:Socket can be used for server programs,
but i am not allowed to install it at my web-server.

-- 
russkaya literatura v ------ http://www.simplex.ru/lit.html
internete http://www.friends-partners.org/~afarber/lit.html
java preferans ------------ http://www.simplex.ru/pref.html
besplatnye kommercheskie ob'yavleniya http://www.simplex.ru



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

Date: Fri, 26 Sep 1997 07:51:25 -0700
From: Joel Shellman <tou@tou.com>
Subject: How to get close match on keywords
Message-Id: <342BCBED.7B976CFD@tou.com>

I need something that will find words that are close but not exactly the same.

Basically I need a comparison function that will return a score on how close two
words are together, and then I can just judge on how close, close enough is.

Because I wouldn't be surprised if this is answered in the FAQ, can someone also
point out where to get the FAQ?

Thanks,

-joel
-- 
TaoTree Research and Development
Web Development/Design, Virtual Servers, hosting, Perl/CGI programming
http://www.tou.com/rd/

Revolutionary new clicks-based Banner Exchange Guarantees you traffic
http://www.tou.com/ite/


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

Date: Fri, 26 Sep 1997 19:13:41 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How to get close match on keywords
Message-Id: <adelton.875301221@aisa.fi.muni.cz>

Joel Shellman <tou@tou.com> writes:

> I need something that will find words that are close but not exactly the same.
> 
> Basically I need a comparison function that will return a score on how close two
> words are together, and then I can just judge on how close, close enough is.
> 
> Because I wouldn't be surprised if this is answered in the FAQ, can someone also
> point out where to get the FAQ?

man perlfaq6, use module String::Approx.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 26 Sep 1997 18:04:38 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Julian Date Routine
Message-Id: <slrn62nudn.235.abigail@betelgeuse.rel.fnx.com>

Brian Ewins (Brian.Ewins@dont.spam.me) wrote on 1487 September 1993 in
<URL: news:342B8023.1B89@dont.spam.me>:
++ Doug Seay wrote:
++ > 
++ > Ben Fogarty wrote:
++ > >
++ > > Any of you GURUs out there have a Julian date routine in perl?
++ > > I need it to evaluate a running log and delete prior to a certain
++ > > date. Julian date works best. I would appreciate same if you
++ > > have it, or a pointer to it's location if you know of one.
++ > 
++ > Did Date::Manip not do what you want?  And you don't truely mean

Date::Manip is a great module, but kind of useless if you want
to run with -T; it uses tainted data.

++ > "julian" do you?  You most likely mean Gregorian year with days into
++ > year (yday) instead of month/day.  The Julian calendar starts a long
++ > time before Christ and is only really used in a few domains (astronomy
++ > is one IIRC).
++ 
++ He probably really does mean Julian dates. This is provided in (eg)
++ Oracle databases and its the number of days since Jan 1st 4712 BC.
++ (Of course! ;o) ) It's useful occasionally for timestamping as it
++ gives a simple integer for date comparisons. The only time I've seen
++ this used in anger was when someone wrote a SQL statement which ordered
++ on date or some other (non-date) field based on a parameter;
++ since the sorting would only work on a single type, Julian date was 
++ used to convert dates to numbers first. Ugly, but it worked.
++ 
++ In perl, you are much better using unix's internal time format
++ (seconds since the epoch) as returned from time(); it does the
++ same job.

That really depends. If you want to have a integer value for yesterday,
does it matter much whether you translate yesterdays date to the Julian
date or to time() format? Furthermore, time() format is rather limited,
it only works for dates 1970 - 2038. Julian days have a much wider range,
as they aren't wasting half of the bits on the specific time of a day.

Julian days have been used to calculate the first line of this posting.


Abigail


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

Date: Fri, 26 Sep 1997 15:22:38 -0400
From: Kevin Goess <74561.610@CompuServe.COM>
Subject: Re: Julian Date Routine
Message-Id: <en$2NGry8GA.193@nih2naac.prod2.compuserve.com>

Just in case poor Ben means the same thing we mean at my company 
by "Julian date," which is the number of days into the year a day 
is, here's a simple subroutine.

# **************************************************************
# SUBROUTINE JULIAN_DATE
# Converts mm/dd/yy or mm-dd-yy to julian date yyddd
# NOTE: requires an array 
# @days_in_month = (0,31,28,31,30,31,30,31,31,30,31,30,31);  
# either here or in main
# **************************************************************
sub julian_date{
	local ($month, $day, $year, $x, 
$julian_date,$date_wanted);
	$date_wanted = $_[0];
	$date_wanted =~ s#-#/#g;          #change from mm-dd-yy 
to mm/dd/yy
   $date_wanted =~ s#\s#/#g;          #change from mm dd yy to 
mm/dd/yy
	($month,$day,$year) = split ('/',$date_wanted);

	if (($year%4)==0){
		$days_in_month[2] = 29;
		if ($year%100==0){
			$days_in_month[2] = 28;


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

Date: Fri, 26 Sep 1997 19:44:14 GMT
From: aluther@cdi.org (Adam Luther)
Subject: method calls in modules
Message-Id: <342c0eee.102071031@news.igc.apc.org>

I know this is probably some thing stupid, but ...

I've installed a module (GIFgraph), and tried the test program that
comes in the documentation which includes the following line of code:

$my_graph= new GIFgraph::chart();

when I try to run it perl gives me the following message:

Cannot locate object method "new" via module "GIFgraph::chart".

the sub new is in GIFgraph.pl

Any Ideas?

TIA
Adam Luther
Center for Defense Information


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

Date: Fri, 26 Sep 1997 16:08:05 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Re: method calls in modules
Message-Id: <ken-2609971608050001@news.swarthmore.edu>

You probably want something like this:

----------- in main program ----------------------------------

use GifGraph::chart;

$my_graph = new GIFgraph::chart;
$my_graph->spiffy_method("olive");
# etc.

----------- in file GIFgraph/chart.pm ------------------------

package GIFgraph::chart;

sub new {
   my $package = shift;
   # stuff...
}

sub spiffy_method {
   my $self = shift;
   my $arg1 = shift;
   # stuff...
}


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

See if that kind of thing works for you.


In article <342c0eee.102071031@news.igc.apc.org>, aluther@cdi.org (Adam
Luther) wrote:

>I know this is probably some thing stupid, but ...
>
>I've installed a module (GIFgraph), and tried the test program that
>comes in the documentation which includes the following line of code:
>
>$my_graph= new GIFgraph::chart();
>
>when I try to run it perl gives me the following message:
>
>Cannot locate object method "new" via module "GIFgraph::chart".
>
>the sub new is in GIFgraph.pl
>
>Any Ideas?
>
>TIA
>Adam Luther
>Center for Defense Information

-Ken Williams
 The Math Forum
 ken@forum.swarthmore.edu


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

Date: Fri, 26 Sep 1997 13:33:37 -0700
From: Joe Allen <joeallen@gizmo.usc.edu>
Subject: Nearest Neighbor routine
Message-Id: <342C1C21.183CD1C0@gizmo.usc.edu>

Hi, 

I use the following snippet to determine the euclidean distance
between a set of target vectors and a set of vectors output by a
neural net.  It opens a file of target vectors and a file of output
vectors and returns, for each output vector, the name of the target
vector that is closest to it in euclidean distance (the so called
nearest neighbor).

Its a pretty pedestrian approach and it takes a subjectively long time
when the files are large (2-300 elements per vector, 1000 line files).
Can anyone suggest a general solution that might be faster? Actually
any comments appreciated. The vectors are of arbitrary length, have a
name in the first column, and are made up of floats, e.g.:

#Targets
a 1 0 0 . . . etc 
b 0 1 0
c 1 1 0
 ...etc.

#Outputs
output1 .90897 .78765 .69076
output2 .00897 .78765 .69076
output3 .48767 .23987 .87349
 ...etc.

Thanks, 

Joe Allen
joeallen@siva.usc.edu


#!/usr/bin/perl -w 
use diagnostics;

open(TARGETS,"<$ARGV[0]") or die "cant open targets: $!\n";
open(OUTPUTS,"<$ARGV[1]") or die "cant open outputs: $!\n";

while (<TARGETS>)
{
    next if /^$/;
    @line = split;
    $targetname[$.]=shift @line;
    for $i (0..$#line){$targets[$.][$i] = $line[$i];}
}

$targetlength=$#line;
$.=0;

while (<OUTPUTS>)
{
 $mindiff=10000000;
 next if  /^$/;
 @line = split;
 $outputname[$.]=shift @line;
 
 if ($targetlength!=$#line){die "vector lengths unequal\n";};
 
 for $i (1..$targetlength)
 {
     $diff=0;
     for $j (0..$#line){
	 $diff += (abs(($targets[$i][$j]-$line[$j])**2));
     }
     $diff= sprintf("%.3f", $diff**.5);
     
     if($diff<=$mindiff){ $mindiff=$diff; $winner=$targetname[$i] }; 
 }
 print "$outputname[$.]  $winner $mindiff\n" ;
}


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

Date: Fri, 26 Sep 1997 13:19:58 -0500
From: lmain@ti.com
Subject: Newbie URL Redirection Question
Message-Id: <342BFCCE.7CB6@ti.com>

Greetings!!  I am brand new to Perl (2 days) and I am working on a CGI
for my company.  I am trying to find a way to send the user to a
particular site.  Unfortunately, my Perl 5 book and all my searching on
the web has left me clueless.  I don't want to spout html out, just send
them to another page (for now).
Can anybody help me??  Please!

Thank you!

Lisa


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

Date: 26 Sep 1997 19:12:07 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Newbie URL Redirection Question
Message-Id: <60h1e7$hgn@news-central.tiac.net>

If you're  using a modern perl then make sure that you have the CGI module
installed (of late it's been included with the distribution.  If you use
the CGI module then its documentation says:

       GENERATING A REDIRECTION INSTRUCTION


          print $query->redirect('http://somewhere.else/in/movie/land');

       redirects the browser elsewhere.  If you use redirection
       like this, you should not print out a header as well.  As
       of version 2.0, we produce both the unofficial Location:
       header and the official URI: header.  This should satisfy
       most servers and browsers.

       One hint I can offer is that relative links may not work
       correctly when you generate a redirection to another
       document on your site.  This is due to a well-intentioned
       optimization that some servers use.  The solution to this
       is to use the full URL (including the http: part) of the
       document you are redirecting to.

       You can use named parameters:

           print $query->redirect(-uri=>'http://somewhere.else/in/movie/land',
                                  -nph=>1);

       The -nph parameter, if set to a true value, will issue the
       correct headers to work with a NPH (no-parse-header)
       script.  This is important to use with certain servers,
       such as Microsoft Internet Explorer, which expect all
       their scripts to be NPH.

To get the documentation to the CGI module you can use the command

  perldoc CGI

Lincoln Stein has some simple examples which you may want to use to
familiarise yourself with the module at:

  http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html

Hope this helps,

Mike

In article <342BFCCE.7CB6@ti.com>,  <lmain@ti.com> wrote:
>Greetings!!  I am brand new to Perl (2 days) and I am working on a CGI
>for my company.  I am trying to find a way to send the user to a
>particular site.  Unfortunately, my Perl 5 book and all my searching on
>the web has left me clueless.  I don't want to spout html out, just send
>them to another page (for now).
>Can anybody help me??  Please!
>
>Thank you!
>
>Lisa


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Fri, 26 Sep 1997 19:15:13 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Newbie URL Redirection Question
Message-Id: <342d0516.1988339@news.wwa.com>

On Fri, 26 Sep 1997 13:19:58 -0500, lmain@ti.com wrote:

>I am brand new to Perl (2 days) and I am working on a CGI
>for my company.  

How do I get a job like that?  :-)

>I am trying to find a way to send the user to a particular site.  
>[snip] I don't want to spout html out, just send them to another
>page (for now). Can anybody help me??

You might try the following untested code.

:#!/usr/local/bin/perl -w
:use strict;
:use CGI;                       #   Evoke the CGI module
:my ($query) = new CGI;         #   Create a new CGI object
:my ($url);                     #   URL to which you want to send the user
:$url = 'http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html';
:print $query->redirect($url);  #   Generate the redirection request
:exit (0);


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

"Ah, here it is, So-crates.  'The only true wisdom is in knowing that
you know nothing.'  That's us, dude." 
-- Ted, _Bill & Ted's Excellent Adventure_


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

Date: Fri, 26 Sep 1997 22:25:19 GMT
From: toni@futurecad.com (Toni Tiainen)
Subject: Re: Parsing e-mail folder (newbie)
Message-Id: <342c3524.612967936@news.aksi.net>

On Wed, 17 Sep 1997 08:39:56 -0600, rbush@up.net wrote:

>In article <341E36FA.A7AE5A41@pplus.best.com>,
>  dave@hmw.com wrote:
>>
>> In the next few days I will need to create (or help create) a script
>> that will parse the e-mail folder file on a UNIX (actually, SGI IRIX)
>> system to get the most recent message and output that message to an
>> external text file. The file will be inserted (via server-side include)
>> into an HTML file.

 What about using pop service for this?


 #!/usr/bin/perl

 use Mail::POP3Client;

$pop = new Mail::POP3Client("me", "mypass", "mypophost");

$latest=$pop->HeadAndBody($pop->Count);
open(FILE,">somefile") || die "Cannot open file for writing";

print FILE "$latest\n";
close(FILE);

In a real application you would like to check for the return value
of pop->Count to see if the authentication is successful and there
is >0 messages to get.

                                                                   
Toni Tiainen  toni@futurecad.com  


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

Date: Fri, 26 Sep 1997 13:11:43 -0400
From: Michael Shael O'Neill Selden <selden@NOSPAM.instinet.com>
Subject: Re: Perl Generator?
Message-Id: <342BECCF.3EE0@NOSPAM.instinet.com>

Tom Phoenix wrote:
> 
> On Thu, 25 Sep 1997, Peter Prymmer wrote:
> 
> > Have you had much chance to play with SpecPerl?
> 
> No, and I can't find it on the Web (although I may not have searched hard
> enough). What is it, and what is it good for?
> 
> --
> 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/
>               Ask me about Perl trainings!

Tom,
   To quote the SpecPerl author, "specPerl 0.2 is a 
modification of specTcl which emits code suitable for perl/Tk, 
instead of Tcl/Tk".  SpecTcl, in turn is "a graphical user 
interface (GUI) builder that makes it easy to build cross 
platform Tcl/Tk UI scripts". The SpecPerl home page can be 
found at http://keck.ucsf.edu:80/~kvale/specperl.html.
   My only additional comment would be that I looked at SpecPerl 
but continue to hand code my Perl/Tk.  Enjoy.


Michael.
-- 
Michael Shael O'Neill Selden, DBA, JAPH, DADDY
selden@instinet.com
Remove "NOSPAM." From Address To Return Mail
PGP Public Key Available Upon Request


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

Date: 26 Sep 1997 12:58:18 -0400
From: jstone@america.net (Jeff R. Stone)
Subject: Re: Perl to Java Compiler?
Message-Id: <l6sousf1w5.fsf@transquest1.delta-air.com>

Randal Schwartz <merlyn@stonehenge.com> writes:

> 
> >>>>> "Jeff" == Jeff R Stone <jstone@america.net> writes:
> 
> Jeff> It all depends on your definition of "platform".  Java is in the
> Jeff> process of working (seeping?) its way into all sorts of smart cards
> Jeff> and other embedded devices that are unlikely to support Perl in its
> Jeff> current incarnation.
> 
> You mean it will finally make it into the proverbial "smart toaster",
> where it was designed for originally?
> 
> That'd be cool. :-)
> 
> Now, treating millions of web browsers like they are merely smart
> toasters... that's what puzzles me.
> 
> :-)
> 
> print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
> ## legal fund: $20,990.69 collected, $186,159.85 spent; just 340 more days
> ## before I go to *prison* for 90 days; email fund@stonehenge.com for details
> 
> -- 
> Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
> Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
> Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
> Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
> Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me

I can't figure out how much smarter my toaster needs to be... but hey,
who am I to stand in the way of "progress"?

Forgetting all the discourse about the language itself, the thing that
Java has going for it is that Sun is really a hardware company.  They
have the will and the means to see that Java virtual machines make
their way into silicon.  That is something that the Perl community
will have a much harder time accomplishing.  For that reason, I am
very interested in seeing what Larry cooks up in O'Reilly's skunk
works.

Jeff

-- 
| Jeff Stone <jstone@america.net>                          |



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

Date: 26 Sep 1997 20:36:53 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: predictable random numbers across continued runs
Message-Id: <60h6d5$k51$2@daily.bbnplanet.com>

Greg Bacon (gbacon@adtran.com) wrote:
: [Posted and mailed]

: In article <60f2oq$bt6@lynx.dac.neu.edu>,
: 	zbrown@lynx.dac.neu.edu (Zachary Brown) writes:

: One way of doing what you want is to record the seed you use and then
: use a sub like

:     sub get_random {
:         my $arg = shift || 1;

:         $random_count++;
:         rand $arg;
:     }

: When you want a random number, call this wrapper (note that $random_count
: should be a global).  When you stop your program, it should keep the seed
: and $random_count somewhere it can find it when it restarts.  Have an
: initialization sub like

:     sub resume_rand {
:         my $seed  = shift;
:         my $count = shift;

:         srand $seed;

:         for (my $i = 0; $i < $count; $i++) {
:             rand;
:         }
:     }

This may work ok, but why make the script's minimum run time grow by
a call to rand every time. The orginal poster may really want to implement
his own rand, so he can save the seed and avoid solutions like these. Also,
this method depends on the rand implementation on the machine he's using.
If he moves his script to a different machine, he won't necessarily be able to 
repeat sequences from a different machine.

eg.
bullwinkle:jgloudon>perl
srand 456;
for (1..10){
        print rand, "\n";
}
0.32214002357795834541
0.042942228727042675018
0.054574284236878156662
0.64036398567259311676
0.53867383161559700966
0.27038002852350473404
0.4192280634306371212
0.12754081189632415771
0.28727681608870625496
0.088954373262822628021

jgloudon:bash$ perl     
srand 456;
for (1..10){
        print rand, "\n";
}
0.968496659304947
0.930118450429291
0.65897483099252
0.695307916495949
0.611558642238379
0.180946349631995
0.61163805378601
0.0374416410923004
0.82386334054172
0.130057791247964

Jason Gloudon


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

Date: Fri, 26 Sep 1997 08:51:23 -0700
From: "Creede Lambard" <fearless@io.com>
Subject: Re: printing variables...
Message-Id: <60gm0q$h0k@news.microsoft.com>

Or you should be able to do this:

print <<End_of_prt;
<body background="$hpath\\bkg.jpg">
End_of_prt

Now instead of \b (backspace) you have \\ (backslash).


Eike Grote wrote in message <342B7C5D.15FB@theo.phy.uni-bayreuth.de>...
>Hi,
>
>Michele Beltrame wrote:
>>
>> Hallo!
>>
>> Suppose you've got a piece of code like:
>>
>>         print <<End_of_prt;
>>         <body background="$hpathbkg.jpg">
>>         End_of_prt
>
>Use this instead:
>
>  <body background="${hpath}bkg.jpg">





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

Date: Fri, 26 Sep 1997 09:07:51 -0700
From: "Creede Lambard" <fearless@io.com>
Subject: Re: printing variables...
Message-Id: <60gmvk$8vs@news.microsoft.com>


Oops. When I wrote in message <60gm0q$h0k@news.microsoft.com>...

>Or you should be able to do this:
>
>print <<End_of_prt;
><body background="$hpath\\bkg.jpg">
>End_of_prt
>
>Now instead of \b (backspace) you have \\ (backslash).
>
>

I forgot I'm in the minority here. The above will work on a Windows system.
For Unix, this might be better:

$fullhpath = $hpath . "/bkg.jpg";

print <<End_of_prt;
<body background="$fullhpath">
End_of_prt

Or, if you don't plan to use $hpath again in your script, you could do

$hpath .= "/bkg.jpg";

and then change the line in the here section to

<body background="$hpath">

Hope this helps.

-- Creede

open (BLACKBOARD,"afterschool.txt");
print BLACKBOARD ("I will remember that not everybody uses Windows.\n" x
100);





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

Date: Wed, 24 Sep 1997 22:00:55 -0400
From: Marc Genberg <mgenberg@marjar.com>
Subject: Re: Reading files (newb)
Message-Id: <3429C5D6.4823DD08@marjar.com>



Tom MacMillan wrote:

> Hi.
>
> Sorry to bother you with this but I'm really confused about reading files... I
> know how to open it in Input mode, etc... but what I'd like to do is open a
> file, and read each line of the file into a separate variable or element of an
> array.  If you could help me I'd really appreciate it.
>

why not try something like this:

my $counter=0;
my @data;

open (DATA, "./data.file");
while(<DATA>) {
     chomp;
     $data[$counter] = $_;
     $counter++;
}
close (DATA);


--

+==============================>
Marc Genberg
mgenberg@marjar.com
http://www.marjar.com
+==============================>




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

Date: 26 Sep 1997 20:23:34 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Reading files (newb)
Message-Id: <60h5k6$k51$1@daily.bbnplanet.com>

Marc Genberg (mgenberg@marjar.com) wrote:


: Tom MacMillan wrote:

: why not try something like this:

: my $counter=0;
: my @data;

: open (DATA, "./data.file");
: while(<DATA>) {
:      chomp;

:      $data[$counter] = $_;
:      $counter++;
These two are better as one

	push @data, $_;


Jason Gloudon


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

Date: Fri, 26 Sep 1997 13:38:27 -0500
From: Patrick Timmins <ptimmins@netserv.unmc.edu>
Subject: Re: Regular expression
Message-Id: <342C0123.29B9@netserv.unmc.edu>

Sorry, that m in front should be an s .
Pat

Patrick Timmins wrote:

> this will match any occurences of the format you stated (regardless of
> what the actual ip # is) and replace it with whatever is in $newip :
> 
> m/http\:\/\/[\d.]+\/test\.html/$newip/;
> 
> hope this helps.
> 
> Patrick Timmins
> U. Nebraska Medical Center


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

Date: Fri, 26 Sep 1997 13:34:59 -0500
From: Patrick Timmins <ptimmins@netserv.unmc.edu>
Subject: Re: Regular expression
Message-Id: <342C0053.3FD8@netserv.unmc.edu>

Claus wrote:
> 
On Fri, 26 Sep 1997, Claus wrote:
> I need to replace the following in a line
> "http://193.21.123.21/test.html"
> The ip number wil change but the front and end data will be the same,
> but I can't make a expression that wil detect the data.
> 
> Example of line :
> <IMG SRC="http://193.21.234.21/webcam.jpg" NOSAVE HEIGHT=240 WIDTH=320>
> 
> Claus

this will match any occurences of the format you stated (regardless of
what the actual ip # is) and replace it with whatever is in $newip :

m/http\:\/\/[\d.]+\/test\.html/$newip/;

hope this helps.

Patrick Timmins
U. Nebraska Medical Center


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

Date: 26 Sep 1997 20:02:49 GMT
From: bet@network.rahul.net (Bennett Todd)
Subject: Re: substituting special chars
Message-Id: <slrn62o578.kes.bet@waltz.rahul.net>

On Thu, 25 Sep 1997 17:37:43 +0200, Per Fredrik Kvarme <perkva@itk.ntnu.no> wrote:
>	I want to translate paths and file names from a PC NFS system, for
>use on UNIX. Part of that means I have to substitute all the MS-DOS "\"
>chars with the UNIX "/". I've tried $string =~ s/\\/\//g and lots of other

That works for me:

perl -e '$string = "c:\\user\\files\\";$string =~ s/\\/\//g;print $string,"\n";'
c:/user/files/

Are you sure $string really has what you think it has in it? And that you are
then using the value of $string later and not something else? Also, a little
easier than the "s" string-replace command would be a "y" (AKA "tr") command
like 'y#\\#/#'.

-Bennett


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

Date: 26 Sep 1997 20:06:33 GMT
From: bet@network.rahul.net (Bennett Todd)
Subject: Re: symbolic dereferencing of my() variables -- can it be done?
Message-Id: <slrn62o5e8.kes.bet@waltz.rahul.net>

On 22 Sep 1997 20:08:28 GMT, Rahul Dhesi <c.c.eiftj@78.usenet.us.com> wrote:
>      $$_ = &something($_);	# $a = &something('a') and so on

Ick. You're using the interpreter's symbol table as an associative array. Why
not use your own ---

	$mystuff{$_} = &something{$_};

%mystuff can naturally be my() as desired.

-Bennett


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

Date: 26 Sep 1997 20:47:51 GMT
From: c.c.eiftj@78.usenet.us.com (Rahul Dhesi)
Subject: Re: symbolic dereferencing of my() variables -- can it be done?
Message-Id: <60h71n$crn$1@samba.rahul.net>

In <Pine.GSO.3.96.970923075321.1200J-100000@usertest.teleport.com> Tom
Phoenix <rootbeer@teleport.com> writes:

>Rethink the way you're attacking the problem, and use (perhaps) a hash or
>another technique instead. Every programming problem can be solved without
>using eval STRING and without using soft references. Hope this helps!

But it seems to make it even more ugly.  Everywhere else in the code I
simply used $a, $b, etc.  With hashes I would replace every instance by
$x{'a'}, $x{'b'}, etc. which is tedious and error-prone.
-- 
Rahul Dhesi <dhesi@spams.r.us.com>


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

Date: Fri, 26 Sep 1997 13:23:06 -0700
From: gene@moreinfo.com (Gene Hsu)
Subject: Re: Text::English
Message-Id: <gene-ya02408000R2609971323060001@corp.supernews.com>

In article <Pine.GSO.3.96.970925094902.14378A-100000@theory.uwinnipeg.ca>,
Randy Kobes <randy@theory.uwinnipeg.ca> wrote:

>     A Text::English package is contained in
> 
>         $CPAN/authors/id/ULPFR/perlindex-1.200.tar.gz

Thanks.  I finally got the info from the author, and he referred me to the
CPAN.pm method of searching for the information (which, I guess is more
efficient than the ftp & browse your favorite CPAN site method).  I'll just
have to read the perldocs on CPAN.

-- Gene


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

Date: Fri, 26 Sep 1997 17:44:41 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Y2K
Message-Id: <342BD869.1AB932CD@absyss.fr>

[posted and mailed]

Mark Keisler wrote:
> 
> Is anyone aware of any Y2K related bugs with perl?  We are currently
> using perl4.036 as well as perl5.002.  Could I get some kind of
> assurance from LArry or Randall as to perl's soundness in the face of
> year 2000?

It is in the FAQ.  It seems to be an extremely FAQ.  And even more so
because no one seems to bother reading the existing FAQ.

As the same question was asked two days ago in c.l.p.misc, it should
still be on your news server spool.  I'd guess it was in DejaNews too. 
The thread is "Is Perl Year2000 compliant?"

Please do your homework before posting.

- doug

PS - The FAQ answer should be valid for those two ancient version of
Perl you are using.  Perl 4 needs to be abandoned, and Perl 5.002 has
security holes.


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

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

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