[8199] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1817 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 5 14:08:51 1998

Date: Thu, 5 Feb 98 11:00:28 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 5 Feb 1998     Volume: 8 Number: 1817

Today's topics:
    Re: **SEARCH**ing for an answer (Jeff Stampes)
    Re: A regex problem <Peter.Kruse@psychologie.uni-regensburg.de>
    Re: A regex problem <*@qz.to>
        Array of Records <duncan.halstead@symbios.com>
        Best module for finding out if a string is valid date <nospam_sloscialo@chubb.com_nospam>
    Re: converting href and src tag values to lowercase? <joneil@cks.ssd.k12.wa.us>
        Defeated scripter- desperate for help <pjmone@symbioticinc.com>
    Re: Defeated scripter- desperate for help <pjmone@symbioticinc.com>
        Delimiting file entries (john a barbuto)
    Re: Filtering Problem <Joergen.Lang@schwaben.de>
        getting perl system calls to run in different shells Sharyl_griffith@ftw.paging.mot.com
    Re: getting perl system calls to run in different shell (Andrew M. Langmead)
    Re: Help - need telnet client in perl <spamfree@yahoo.com>
        help stream lining script... <fil@amnh.org>
        installing Image::Size 2.6 <cnewell@ableweb.com>
        Is there a way to do this? (Sean McAfee)
    Re: local() scoping rules - unusual results (M.J.T. Guy)
    Re: Mail checker.... <*@qz.to>
    Re: Passing Javascript variables to Perl CGI? petcrows@bigfoot.com
        Perl for VM/CMS? <slegrand@ibm.net>
    Re: Perl Stock Quote Retriever (Tim Alexander)
    Re: Quickie: regexp for valid e-mail addresses <*@qz.to>
    Re: recreating sed with perl <sgordon@athena.lbl.gov>
        Redirect with cookies ??? <kbo@kmd.dk>
        Redirecting STDIN/STDOUT to socket <andersma@idt.ntnu.no>
    Re: rename directory ... solution (WIN NT) (Jeffrey R. Drumm)
    Re: replacing things i perl <*@qz.to>
    Re: size limit to the length of a perl script <lenzo@cs.cmu.edu>
    Re: solution for multiline comments??? <*@qz.to>
    Re: solution for multiline comments??? <*@qz.to>
    Re: split /\s*,\s*/ <steves@wco.com>
    Re: Tie-Dee-Perl (Cleanliness is next to Goodliness, or (Andrew M. Langmead)
    Re: Tie-Dee-Perl (Cleanliness is next to Goodliness, or <vladimir@cs.ualberta.ca>
    Re: unix command <ray@icix.net>
        variable -> form ->varibale (Vjekoslav Balas)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 5 Feb 1998 17:03:26 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: **SEARCH**ing for an answer
Message-Id: <6bcrcu$p7p$1@neocad.com>

Mike (vbmike@usa.net) wrote:
: I'm in need of a way to search a web site consisting of 5000+ documents in
: ONE directory.  How can I do so?  

By using perl of course.

This is the sort of task that perl thrives on...you'll probably
want to learn a little bit about perl's file operators, reading
in data from files, and regular expressions for matching data.
All the help you could need is available in the free documentation
that comes with perl, and is also available (along with the latest
version) at http://www.perl.com 


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


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

Date: 05 Feb 1998 12:14:37 +0100
From: Peter Kruse <Peter.Kruse@psychologie.uni-regensburg.de>
Subject: Re: A regex problem
Message-Id: <m3ra5icnhd.fsf@arnulf.de>

In article <34D95A8F.AFE3C25A@coos.dartmouth.edu> Chipmunk
<rjk@coos.dartmouth.edu> writes: 

> Peter Kruse wrote:
> > 
> > how about:
> > while(<>) {
> >         while(s/(<h3>[^<]*)<p>/$1/gi){}
> >         print;
> > }
> > which assumes that <h3> and </h3> are not separated by newline.
> 
> Actually, it doesn't.  [^<] can match a newline.
                              ===
yes, but won't here, since $_ only contains one line.

> What it does assume, unfortunately, is that there are no tags
> aside from <p> with the <H3>
> i.e.:
> 
> <H3>This is <b>really</b> important<p>So pay attention</H3>

I thought about this, but was not mentioned in the original posting.
Do you have a solution?

	pete

> 
> Chipmunk
> 
-- 
-rw-r--r--   1 pete   users   0 Jan  8 16:40 .signature


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

Date: 5 Feb 1998 17:13:25 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: A regex problem
Message-Id: <qz$9802051202@qz.little-neck.ny.us>

Chipmunk  <rjk@coos.dartmouth.edu> wrote:
> Peter Kruse wrote:
> > while(<>) {
> >         while(s/(<h3>[^<]*)<p>/$1/gi){}
> >         print;
> > }
> > which assumes that <h3> and </h3> are not separated by newline.
> Actually, it doesn't.  [^<] can match a newline.

Yes, but $/ is probably still set to \n.

> What it does assume, unfortunately, is that there are no tags
> aside from <p> with the <H3>

That is a problem, too.

Elijah
------
nearly made the same comment as Chipmunk when he saw that


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

Date: Thu, 05 Feb 1998 11:08:34 -0700
From: Duncan Halstead <duncan.halstead@symbios.com>
Subject: Array of Records
Message-Id: <34DA0022.1BBB8A6A@symbios.com>

I'm trying to create an array of records; however, with little success. 
I'm using the following code:

@Array[$index]->{RECORD_NAME} = $value;

The compiler thinks that RECORD_NAME is an undefined hash reference, which
makes sense. Only, I'm not sure how do do what I actually want.   Do I need
to declare the record prior to using it, and then new each index before
putting data in it?  Any ideas?

Thanks.

Duncan Halstead
Symbios, Inc.


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

Date: Thu, 5 Feb 1998 11:51:55 -0500
From: "Sergio Loscialo" <nospam_sloscialo@chubb.com_nospam>
Subject: Best module for finding out if a string is valid date
Message-Id: <6bcqtm$2k5@sidney.chubb.com>

I am looking for advice on a date/time module.  Which one
would best suit my purposes to simply check if the date
entered is a valid date.  I don't want users to simply key in
anything...but I want to accept things like "1/1/98", "1/1/1998"
or "01/01/98" or even "Jan. 1, 1998".  I will also need to compare
that date with the system date to determine the number
of days different.

I found a few modules on the web, but want to know which
one would be the best as they _seem_ to do basically the
same thing.
----
Sergio Loscialo
Chubb Computer Services
http://ccs.chubb.com




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

Date: Thu, 05 Feb 1998 08:28:31 -0800
From: Jerome O'Neil <joneil@cks.ssd.k12.wa.us>
To: "Rob W. Walls" <wallsr@jcave.com>
Subject: Re: converting href and src tag values to lowercase?
Message-Id: <34D9E8AF.9D52717F@cks.ssd.k12.wa.us>

You don't need to change your html, you need to change your server.  Compile in
mod_speling and all your case and .htm problems will go away.

Jerome

Rob W. Walls wrote:

> I am setting up an apache web server and transfering pages originally
> designed on MS FrontPage.  The horrors of filename case sensitivity have
> caused maximum irritation!  I wrote a little perl script to convert all
> file names in a dir to lowercase, but I now need to look inside EVERY html
> file and change all path/file references to lowercase also.  I am pretty
> new to perl (and Unix) , but I know this can be done.  I just can't seem to
> get there from here.  A wildcard file search and a look inside all matched
> files for href= and src= values would be just the ticket.  Anyone care to
> share a tip on how to do this or where to find a script already written to
> do this?
> thanks,
> wallsr@jcave.com





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

Date: Thu, 05 Feb 1998 11:26:31 -0500
From: Paul Mone <pjmone@symbioticinc.com>
Subject: Defeated scripter- desperate for help
Message-Id: <6bcpa6$krm@bgtnsc03.worldnet.att.net>

I wrote my first Perl script about a week ago.  It didn't take me too
long to write it but naturally is has taken me a very very long time to
debug it.  Now I am stumped.
The program creates a daily password that is basically the date
encrypted with a specific product code.  the attributes are proper, the
files are in there proper place, and there are no syntax errors that I
know of.  I have successfully run the script in Perl for Win32.  The
script recieves form input via the POST method.  I am not completely
comfortable posting the entire script on the newsgroup, because it's
sensitive information, but I am hoping that one of you seasoned pros can
take a few minutes to look over the script- please email me and I will
send you a copy of the script.  Have Mercy,
					Paul


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

Date: Thu, 05 Feb 1998 11:31:25 -0500
From: Paul Mone <pjmone@symbioticinc.com>
Subject: Re: Defeated scripter- desperate for help
Message-Id: <6bcpjc$krm@bgtnsc03.worldnet.att.net>

Paul Mone wrote:
> 
> I wrote my first Perl script about a week ago.  It didn't take me too
> long to write it but naturally is has taken me a very very long time to
> debug it.  Now I am stumped.
> The program creates a daily password that is basically the date
> encrypted with a specific product code.  the attributes are proper, the
> files are in there proper place, and there are no syntax errors that I
> know of.  I have successfully run the script in Perl for Win32.  The
> script recieves form input via the POST method.  I am not completely
> comfortable posting the entire script on the newsgroup, because it's
> sensitive information, but I am hoping that one of you seasoned pros can
> take a few minutes to look over the script- please email me and I will
> send you a copy of the script.  Have Mercy,
>                                         Paul
Jesus, I forgot some important information...
   1. I do not have telnet access to my server,
   2. I get an error msg in the log that CGIWrap produces- 
      "malformed header from script. Bad header=HTTP/1.0 "GET"

I presume this can help slve the problem quicker.


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

Date: 5 Feb 1998 18:00:42 GMT
From: jab@acm.org (john a barbuto)
Subject: Delimiting file entries
Message-Id: <slrn6djvjp.3c7.jab@lapent.cs.uml.edu>

Perl gurus,

I have a data file consisting of dictionary entries, and i'd like to set
off the entries with a %%.  I've come up with this:

   open(DAT, $file) or die "Could not open $file!: $!\n";

   while(<DAT>) {
      if (/^[A-Z]{3,}/) {  # 3 or more capital entries indicates an entry 
         insert %% and a newline before $_
      }    
   }

I'm having trouble with the part indicated by pseudocode.  Any help would
be appreciated.  Thanks!

-jab



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

Date: Thu, 05 Feb 1998 19:48:42 +0000
From: Joergen Lang <Joergen.Lang@schwaben.de>
Subject: Re: Filtering Problem
Message-Id: <34DA1799.61AA@schwaben.de>

> I have a database of tourdates to deal with. It's in simple ASCII and
> has the following form:

Thanks to all folks out there who helped me out.
The script is running nicely and now I'm stuck with the next question...
I'll post that seperately under the subject "Umlaute".

ok, again: THANKS ! (big one)

Joergen :-)
-- 
____________________________________________________________

    '&`      Joergen Lang:
     #       
     #       <mailto:Joergen.Lang@schwaben.de>
    _#_      <mailto:Joergen_Lang@magicvillage.de>
   ( # )     
   / O \     HOELDERLIN EXPRESS Management:
  ( === )    <mailto:music.contact@p-net.de>
   `---'     

HOELDERLIN EXPRESS Website:
<http://www.musiccontact.com/hx>

             --- Electric Body Folk ---

_____________________________________________________________


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

Date: Thu, 05 Feb 1998 10:21:40 -0600
From: Sharyl_griffith@ftw.paging.mot.com
To: sharyl_griffith@ftw.paging.mot.com
Subject: getting perl system calls to run in different shells
Message-Id: <886694395.973471747@dejanews.com>

I'm trying to get my perl scripts with system calls to run regardless of
which shell a user is running.	Is there an easy way to do this?

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Thu, 5 Feb 1998 18:28:05 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: getting perl system calls to run in different shells
Message-Id: <Enx4Mt.E2y@world.std.com>

Sharyl_griffith@ftw.paging.mot.com writes:

>I'm trying to get my perl scripts with system calls to run regardless of
>which shell a user is running.	Is there an easy way to do this?

I assume by "system calls" you mean calls to the system() function,
not executing calls to the operating system with syscall(). (or
sysread(),syswrite(), socket() or loads of other named operating
system calls)

The function system(), if it needs to spawn a shell, will always use
/bin/sh. It does not use the users $SHELL variable nor login shell
specified in /etc/passwd.

If perl is passed a list to system or is sure excactly what the shell
will do (there are no shell metacharacters in the string for the shell
to intepret.) it will execute the command itself, bypassing any shell.

-- 
Andrew Langmead


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

Date: Thu, 05 Feb 1998 10:53:15 -0500
From: Dave Bushong <spamfree@yahoo.com>
Subject: Re: Help - need telnet client in perl
Message-Id: <34D9E06A.F00AF848@yahoo.com>

Richard Karon wrote:

> Does anyone have a telnet client in perl that allows both interactive
> and batch modes?

There was a good treatment of the subject in The Perl Journal #8 (Winter
'97), page 32.

Dave
--
reply to bushong at bigger dot com




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

Date: 05 Feb 1998 13:08:39 -0500
From: Fil Krohnengold <fil@amnh.org>
Subject: help stream lining script...
Message-Id: <ehvhutj55k.fsf@hammond.amnh.org>


Howdy - 

I'm working on a lil' script which ideally will be running through
entries in a DNS forward map and yanking out all records related to a
particular host based on a txt record.  An example "host entry" would
look like this:


somehost	in	a	some.ip.addr.254
		in	hinfo	CPU	os
		in	txt	"Location: 3-4-59-9"
		in	txt	"Dept: somedept"
		in	txt	"Workstation: someone"

So what I'd want this script to do would be to identify a "host
entry" tied to a particular dept (specified on command line) and then
copy all of those entries into a new file.  So far, the basic form
I've been working with seems grossly inefficient:


#!/magic/pseudocode_interpreter

open host_file for reading
open tmp_file for writing
open output_file for appending

read host_file
  copy one host entry to tmp_file
	# i'm defining this by telling the script to 
	# start copying at the first line that matches /in\ta/
	# and to stop copying when it sees it again
  execute check() subroutine
  if check returns TRUE
	append contents of tmp_file to output_file
	remove tmp_file
           #(or truncate - haven't gotten truncate to work yet) 
  else 
	just remove tmp_file
	(and continue onto the next host entry)

subroutine check {
   open tmp_file for reading
      for each line
         next unless /Dept:/
            if { we find a match for dept_string specified \
                 on command line}
	       return TRUE
	    else
	       return FALSE
}


I'm having trouble getting this to work properly as is, but I was
wondering if maybe I should be exploring a different path...

[Read as: can't find my bug and I'm stalling.]

Thanks!

-fil
___________________________________________________________________________
Fil Krohnengold    |  UNIX Systems Admin, Interdepartmental Laboratories
fil@amnh.org       |  The American Museum of Natural History 
212/769-5294	   |  CPW @ 79thSt / NY, New York / 10024



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

Date: Thu, 05 Feb 1998 12:47:09 -0500
From: Chris <cnewell@ableweb.com>
Subject: installing Image::Size 2.6
Message-Id: <34D9FB1C.FE0B741E@ableweb.com>

Dear Perl Gods,

I'm running perl 5.03 on a Sparc V with Solaris 2.5x.

When I run the 'make && make test' during the install the machine barks
at me that it couldn't locate IO/File.pm. All of my reading tells me
that this is a module that is standard with perl. I couldn't even find
where I could download just this module. I don't see the module under my
lib directory anywhere so I can't be sure that it *is* really
there...there is a diectory named File but no File.pm inside...I find
nothing called IO or File.pm.

I've added the results of my attempted make below in case I'm not
properly understanding the error message. Any help would be greatly
appreciated!

Thanks

Chris Newell
cnewell@ableweb.com

aw# make && make test
cp Size.pm ./blib/lib/Image/Size.pm
AutoSplitting Image::Size (./blib/lib/auto/Image/Size)
/usr/bin/perl -I./blib/arch -I./blib/lib
-I/opt/GNUperl5/lib/sun4-solaris/5.003L
Extracting imgsize (with variable substitutions)
Manifying ./blib/man1/imgsize.1
Manifying ./blib/man3/Image::Size.3
cp imgsize ./blib/script/imgsize
PERL_DL_NONLAZY=1 /usr/bin/perl -I./blib/arch -I./blib/lib
-I/opt/GNUperl5/lib/t
t/all...............Can't locate IO/File.pm in @INC at t/all.t line 4.
BEGIN failed--compilation aborted at t/all.t line 4.
FAILED before any test output arrived
        Test returned status 2 (wstat 512)
FAILED--1 test script could be run, alas -- no output ever seen
*** Error code 29
make: Fatal error: Command failed for target `test_dynamic'
aw#




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

Date: Thu, 05 Feb 1998 16:57:50 GMT
From: mcafee@joust.rs.itd.umich.edu (Sean McAfee)
Subject: Is there a way to do this?
Message-Id: <icmC.174$zg1.963181@news.itd.umich.edu>

I've been working with a product called SNAP, which implements its own
object-oriented environment.  My current project entails processing flat
report files containing patient information, insurance information, etc.
This information has to be extracted into SNAP objects.

For the extraction part, I naturally chose Perl.  Currently what I do is
process the files with a script, which outputs several Oracle SQL*Loader
files.  The script calls SQL*Loader to load the report information into an
Oracle database.  SNAP then loads its own object model with the contents of
the various database tables, using its own routines.

This is a fairly roundabout way to do things, and it recently occurred to
me that it would much faster and simpler if I could embed a Perl
interpreter into my SNAP application, along with a Perl module of my own
devising which would write the freshly-extracted report information
directly into SNAP objects.

This approach calls for a program which incorporates both Perl and SNAP
code.  (SNAP provides access to its innards via a large set of external
functions.) The create_object routine was simple enough to write, but now
I'm not so sure integrating the two programs is feasible.  The SNAP
functions are available only as a set of static libraries.  I don't know
how I would go about compiling a standalone Perl module incorporating SNAP
code which may depend on a SNAP runtime environment being active.  Is this
kind of thing even possible?

Thanks in advance for any help.

--
Sean McAfee | GS d->-- s+++: a25 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: 5 Feb 1998 18:46:05 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: local() scoping rules - unusual results
Message-Id: <6bd1dd$mll$1@lyra.csx.cam.ac.uk>
Keywords: local, scoping

Tom Christiansen  <tchrist@mox.perl.com> wrote:
>
>Only my() declares local variables.

Absolutely true.   But in the interests of terminological sanity,
it's probably better to call them "lexical variables" and avoid the
phrase "local variable" entirely in a Perl context.


Mike Guy


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

Date: 5 Feb 1998 17:09:16 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Mail checker....
Message-Id: <qz$9802051147@qz.little-neck.ny.us>

Dave O. <sloop@mailcity.com> wrote:
> and forward.  You really can do cool things when you use the tools
> intended for the job... and there's no reason that your procmailrc
> file can't invoke a perl script if you really want to get fancy.

Sure there is. Perhaps perl doesn't exist on the mail server. Perhaps
the procmail was compiled with RESTRICT_EXEC defined. Etc. If a mail
server lets me call perl from a procmailrc, chances are very good I
can get a shell on that machine even if the system administator won't
let me log in to it. (Of course I can do that even if I only have the
ability to specify any program I want from a .forward file.)

Elijah
------
besides procmail has many deficiencies


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

Date: Thu, 05 Feb 1998 12:37:38 -0600
From: petcrows@bigfoot.com
To: petcrows@bigfoot.com
Subject: Re: Passing Javascript variables to Perl CGI?
Message-Id: <886702516.1392574469@dejanews.com>

In article <MPG.f43608d5366a88989b9d@news.dimensional.com>,
  kenny@kacweb.com (Kenny A. Chaffin) wrote:
>
> In article <886603945.855572489@dejanews.com>, petcrows@bigfoot.com
> says...
> > Greetings.
> >
> > I would like to log to a file all the referring http pages that
> > access my site as well as the user's host name. The HTTP_REFERER
> > variable is not available in Perl CGI on my ISPs server, but the
> > Javascript document.referrer does work ok.
>
> What? Who's your ISP?? I've never seen/heard of this.
> Document.referrer does not work on all browsers/versions.
>

My ISP is ieighty.net. I have requested that they add it but they have not
complied nor responded yet.

And also scott@softbase.com wrote:
>Piece of cake: create a page on the fly, and put a hidden form
>variable on it using JavaScript's document.write functionality.

Hmmm. I guess the main problem with that approach is that I would have to
do it for all my pages.

I have tried to take another approach where I set a cookie with
Javascript and then get the cookie with Perl, but I'm not sure about the
Perl syntax. When I run the Perl program it stops executing when I try to
access the cookie. Here is the program:

#!/usr/local/bin/perl

require 'cookie.lib';

$mainlog = "main.log";
$shortdate = `date +"%D %T %Z"`;
chop ($shortdate);
print "Content-type: text/plain\n\n";
print "This is another test";

&GetCookies('Birdage_referrer_cookie');
print "2";
print $cookie('Birdage_referrer_cookie');
$referrer_value = `cookie('Birdage_referrer_cookie')`;
print "3";
print "This is a test";
open (MAINLOG, ">>$mainlog");
print MAINLOG "Time: $shortdate\n";
print MAINLOG "User: $ENV{'REMOTE_IDENT'}\n";
print MAINLOG "Host: $ENV{'REMOTE_HOST'}\n";
print MAINLOG "Addr: $ENV{'REMOTE_ADDR'}\n";
print MAINLOG "With: $ENV{'HTTP_USER_AGENT'}\n";
print MAINLOG "Page: $ENV{'DOCUMENT_URI'}\n";
print MAINLOG "From1: $ENV{'HTTP_REFERER'}\n\n";
print MAINLOG "From2: $referrer_value";
print "Time: $shortdate<BR>";
print "User(REMOTE_IDENT): $ENV{'REMOTE_IDENT'}<BR>";
print "Host(REMOTE_HOST): $ENV{'REMOTE_HOST'}<BR>";
print "Addr(REMOTE_ADDR): $ENV{'REMOTE_ADDR'}<BR>";
print "With(HTTP_USER_AGENT): $ENV{'HTTP_USER_AGENT'}<BR>";
print "Page(DOCUMENT_URI): $ENV{'DOCUMENT_URI'}<BR>";
print "From1(HTTP_REFERER): $ENV{'HTTP_REFERER'}<BR><BR>";
print "From2: $referrer_value";
print $testing;
close (MAINLOG);
exit;

--------

As you can see in the above I print out a 2 and a 3 to see how far it
gets. A 2 comes out but a 3 does not - thus it's failing on the two lines
dealing with the cookies. I used Matt's Script Archive cookie library.

Here FYI is the Javascript program which does work ok...

<SCRIPT LANGUAGE="JavaScript">
<!----------

var from = document.referrer // page the user is comming from // var here
= "http://www.ieighty.net/~jhigbee/filter_page_for_journal.htm"
//previous page

// alert("From:"+from);//remove this line to use the script for real
//alert("Here:"+here);//remove this line to use the script for real
// else history.back()
// else document.location.replace('dogma.htm'); //Page to go to if OK

write_cookie ("Birdage_referrer_cookie",from);


/******************************************************************************
function write_cookie (name, value);
function write_cookie (name, value, path);

write_cookie creates a cookie with the name, value, and path given in the
parameters.  If no path is supplied, write_cookie uses the document's
default cookie path.  Each cookie is set with an expiration time of 1
year.
*************************************************************************
*****/

function write_cookie (name, value, path)
{
// Build the expiration date string:
   var expiration_date = new Date ();
   var Month = expiration_date . getMonth();
   var Day = expiration_date . getDay();
   var Year = expiration_date . getYear();

// alert (expiration_date);
// alert (Month);
// alert (Day);
// alert (Year);

  Day = 1; // The getDay() function does not work properly - therefore
just set it to one and increment the Month 2 times

   Month = eval(Month) + 2;

//   alert (Month);

  if (Month == 12) {  // The Month value starts from 0	Month = 0;  //
set the expiration date to be the 1st day of whichever month is 2 months
away from the current  Year = Year + 1;  // month. Thus the month is
incremented by 2, but the day is set to 1.  }  if (Month > 12) {  Month =
1;  Year = Year + 1;  }

//   alert (Month);
//   alert (Year);

//   expiration_date . setYear (expiration_date . getYear () + 1);

//   alert (expiration_date);
   expiration_date . setMonth (Month);  // Expire cookie after a month
   expiration_date . setDate (Day);
   expiration_date . setYear(Year);

//   alert (expiration_date);

   expiration_date = expiration_date . toGMTString ();

//   alert (expiration_date);

// Build the set-cookie string:  var cookie_string = escape (name) + "="
+ escape (value) + "; expires=" + expiration_date;  if (path != null)
cookie_string += "; path=" + path;

// Create/update the cookie:
   document . cookie = cookie_string;
}

/******************************************************************************
                        function read_cookie (key)
                        function read_cookie (key, skips)

  read_cookie searches through the current document's cookie string
(i.e., the  concatenation of all cookies readable by the current
document) for a cookie	whose name is identical to key.  If read_cookie
finds a matching cookie, it  returns a string containing the value of
cookie.  If read_cookie cannot find a  match, it returns null instead.

  An optional skips parameter may be supplied if there is a need to
select among  multiple cookies with the same name.  If a skips parameter
is supplied,  read_cookie will skip that many occurrences of matching
cookies and then return  the next one it finds, or null if there aren't
any more.

******************************************************************************/

function read_cookie (key, skips)  {  // Set skips to 0 if parameter was
omitted:  if (skips == null)  skips = 0;

  // Get cookie string and separate into individual cookie phrases:  var
cookie_string = "" + document . cookie;  var cookie_array = cookie_string
 .. split ("; ");

  // Scan for desired cookie:  for (var i = 0; i < cookie_array . length;
++ i)  {  var single_cookie = cookie_array [i] . split ("=");  if
(single_cookie . length != 2)  continue;  var name  = unescape
(single_cookie [0]);  var value = unescape (single_cookie [1]);

                                        // Return cookie if found:
                                        if (key == name && skips -- == 0)
                                                return value;
                                }

                                // Cookie was not found:
                                return null;
                        }

// JavaScript ends ---------->
</SCRIPT>

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 5 Feb 98 17:47:46 GMT
From: "Shawn Legrand" <slegrand@ibm.net>
Subject: Perl for VM/CMS?
Message-Id: <01bd325e$289e0080$eb2b2581@slegrand>

I have found ports of the Perl language available for OS/390. Does anyone
know if there is there a port of Perl for VM/CMS?
Thanks for your help.




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

Date: Thu, 05 Feb 1998 16:29:59 GMT
From: tim@danan.com (Tim Alexander)
Subject: Re: Perl Stock Quote Retriever
Message-Id: <34dae81b.6670142@news.internetmci.com>

On Thu, 05 Feb 1998 01:13:49 -0500, Chipmunk <rjk@coos.dartmouth.edu>
wrote:

<snip>
>> 
>> # Call up Yahoo, and get the page for the symbol ORCL (for example)
>> use LWP::Simple;
>> $doc = get 'http://quote.yahoo.com/q?s=orcl';

change this to: 
$doc = get 'http://quote.yahoo.com/q?s=orcl&f=sl1d1t1c1ohgv&e=.csv';

and you get a .csv instead.  Look Ma!  No HTML!  ; )




======================================
tqa
"It is amazing what you can accomplish
 if you do not care who gets the credit." 
 Harry Truman


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

Date: 5 Feb 1998 16:54:02 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Quickie: regexp for valid e-mail addresses
Message-Id: <qz$9802051136@qz.little-neck.ny.us>

In article <6bbbq6$c8u$2@Masala.CC.UH.EDU>, Woody Jin <wjin@cs.uh.edu> wrote:
> In article <6ba6eu$b4v$3@client3.news.psi.net>, abigail@fnx.com wrote:
> >Note that mailer programs don't validate. 
> Mailer programs don't validate, but we can use mail daemons.

You might think that, but you would be wrong.

> For example, I remember that I was able to use - I don't remember the
> option correctly - "/usr/lib/sendmail -bv user@host.name" 
> to see whether it is deliverable (it may not work correctly depending
> on the sendmail configuration. but then you can set up the config
> file and use sendmail option to use the alternate config file).

Well, If I do this:

:r! /usr/lib/sendmail -bv 'this-will-bounce@qz.to'
this-will-bounce@qz.to... deliverable: mailer procmail, host
/etc/procmailrcs/rc.luser, user this-will-bounce@/etc/procmailrcs/rc.luser

It tells me it is deliverable, but I know it is an invalid address. If
I replace the config file with one that does not use sendmail's "luser
relay" feature when verifying addresses, then some addresses that *are*
deliverable will get a "User unknown" response. Quite simply, my SMTP
daemon does not know what addresses are valid at my site.

> Also, you can directly telnet to the mail port and use VRFY command.

:r! grep Privacy /etc/sendmail.cf
O PrivacyOptions=authwarnings,noreceipts,noexpn,novrfy

> So, there is obviously a way to verify users.

Nothing is obvious in the world of email.

Elijah
------
needs luser relaying for a mail toy


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

Date: Thu, 05 Feb 1998 10:41:55 -0800
From: Shawn Gordon <sgordon@athena.lbl.gov>
To: michael_moore@idx.com
Subject: Re: recreating sed with perl
Message-Id: <34DA07F3.33205A4E@athena.lbl.gov>

This is done easily with the -p and -i switches.

-p : wraps a while loop around a statement and prints the $_ to STDOUT

-i : makes a back up of the original file.

Hence, the following: perl -pi.bak -e "s/trees/flowers/g" file
replaces all occurences of 'trees' with 'flowers'.

See the camel book for more info

shawn


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

Date: Thu, 05 Feb 1998 17:51:22 +0100
From: Kim Bo Hansen <kbo@kmd.dk>
Subject: Redirect with cookies ???
Message-Id: <34D9EE0A.240A@kmd.dk>

I am trying to redirect a page and set a cookie at the same time.

print redirect(-url=>$absolute_scripts_path . 'contract_example.pl',
               -nph=>1,
	       -cookie=>[$cookie]);

the url exists, and according to the CGI.pm this should be possible.

The browser redirects correctly to the named URL, but the cookie is
not set.

Any suggestions are appreciated

Kim


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

Date: 5 Feb 1998 18:15:30 GMT
From: "Anders Mathisen" <andersma@idt.ntnu.no>
Subject: Redirecting STDIN/STDOUT to socket
Message-Id: <01bd326b$88a6e390$b339f181@zappa>

I am trying to write a simple client/server system where the client is a
java applet, and the server is a perl script. The server shall excecute a
console application redirecting the input/output streams of the application
so it communicates with the client and not the console.

I have tried to use open2, but it doesnt seem to work, anybody have example
code on this? 

I would be very grateful.


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

Date: Thu, 05 Feb 1998 15:45:44 GMT
From: drummj@mail.mmc.org (Jeffrey R. Drumm)
Subject: Re: rename directory ... solution (WIN NT)
Message-Id: <34d9d64a.1199614524@news.mmc.org>

On Thu, 05 Feb 1998 14:52:28 +0100, Mauro Quartini <mauro@franchisetech.com>
wrote:

>I'll speak about win NT world.
>We can not call directly:
>
>$some_dir="C:\\one_dir";
>$other_dir="C:\\two_dir";
>
>$cmd="move $some_dir $other_dir";
>
>because and error occurrs.

I'm assuming you're using a system() in there somewhere. FYI:

$adir = '\\testa';
$bdir = '\\testb';
$errorlevel = system('move',$adir, $bdir);
if ($errorlevel) {print "errorlevel was: $errorlevel\n"};

works just fine on my system, although "move" errors if the drive letters are
different (I get the same results at the command line, too). Must be because
"move" is an internal in NT, and an external in DOS (with somewhat enhanced
functionality, if anything about DOS can be called "enhanced").

Since this is the case, why not use the rename function? It works on
directories as well as file names. For example:

rename $adir, $bdir or die "Uh oh: $!\n";

Note that Perl on NT works just fine with forward slashes in path names when
you're using internal functions . . . if you have to worry about portability
across other OSes, it might be worth staying away from the backslashes (except
where you need them, of course).

BTW, this is with Gurusamy Sarathy's port of 5.004.02 . . .

-- 
                Jeffrey R. Drumm, Systems Integration Specialist
        Maine Medical Center - Medical Information Systems Group
                                             drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented!" - me


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

Date: 5 Feb 1998 17:30:28 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: replacing things i perl
Message-Id: <qz$9802051208@qz.little-neck.ny.us>

Real <real@earthling.net> wrote:
> Martin Raknerud <marthy@feskar.net> wrote in article
> > But what if i want to add something ex after the keyword. Ex:
> > I have a text containing headlines looking like this
> > @headline: Fish shot dead in street
> > 
> > And i want it replace with 
> > <h1>Fish shot dead in street</h1>

$indicator = '@headline:';
$HEADLINES = '/path/to/file';
open HEADLINES or die "Argh! $!";

while(<HEADLINES>) {

  s%^			# line anchor
     \Q$indicator\E	# $indicator with metas quoted
     \s*  		# optional whitespace
         (.*)		# the headline, captured to $1
   %<h1>$1</h1>%x;	# Now with HTML tags added. (/x -> extended format)

  # do stuff...
}

> $header = "Fish shot dead in street";

This will only match the one header.

> open(FILE, "<$n") or die;
> while (<FILE>)
> {
>    s/(^$header)/<h1>$1<\/h1>/;

What if $header had a "+", "*", ".", etc, in it? If you don't use /
as the delimiter, you don't need the backslash there.

> Real
> (99% sure)
> > Martin
> >   - 50% lamer
> >   - 50% confused

Elijah
------
very sure


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

Date: Thu, 05 Feb 1998 11:27:53 -0500
From: Kevin Lenzo <lenzo@cs.cmu.edu>
Subject: Re: size limit to the length of a perl script
Message-Id: <34D9E889.5FFC8CE2@cs.cmu.edu>

Well, once for fun i generated a decision tree
for text-to-phoneme conversion from a large
corpus.  With 3 letters to the left and 3 to
the right, the tree can have a whole bunch
of internal nodes.

So, just to see what would happen, i generated
the decision tree as a single perl script
that was 123,000 lines long, rather than using
table lookup.  It's a huge nested series of
if (feat[x] eq "blah") sort of things, the order
determined by the reduction in impurity at
each stage in the classic decision-tree sense.

  lenzo@protected: wc r1d7.pl
   123400  437751 3354003 r1d7.pl

It runs fine on my linux machine and on
the alpha, it just takes a while to
start up :)

So, while i know you're sorta focussing
on cgis (i guess), i just wanted to point out that
perl can deal with ginormous well-formed
perl programs.

kevin
lenzo at cs cmu edu


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

Date: 5 Feb 1998 16:38:53 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: solution for multiline comments???
Message-Id: <qz$9802051126@qz.little-neck.ny.us>

Bart Lateur <bart.mediamind@tornado.be> wrote:
> mgjv@comdyn.com.au (Martien Verbruggen) wrote:
> >BTW. Would you ask on comp.lang.c if it maybe was possible to have
> >shell style comments in c source?
> Weeellllll....  "//" style comments are a pretty common feature.

I think that "/*" would produce a syntax error anywhere but in a quoted
string (counting m// and s///, etc, as quoted strings), so feel free to
try to patch perl to do this. I suspect Larry might not like it though.

Elijah
------
oh, yeah, m"^#/*" and related things should be ignored, too.


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

Date: 5 Feb 1998 16:34:17 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: solution for multiline comments???
Message-Id: <qz$9802051057@qz.little-neck.ny.us>

Chipmunk  <rjk@coos.dartmouth.edu> wrote:
> Chip Salzenberg wrote:
> > Pod (or rather =... =cut) *is* very definitely part of the Perl language.
> > That _is_ Perl's multiline comment syntax.  It just so happens that there
> > are tools that can read those comments and use them as documentation, but
> > Perl doesn't know that.
 ...
> Note that in the third and fourth pieces of code, only the first line is a
> comment.  =head1 and =cut are interpreted as part of the code.  Not entirely
> unreasonable.  But definitely inconsistent with the other code samples.  A
> good multiline commenting syntax shouldn't be so ambiguous.

All comments in perl are ambiguous. Deal with it.

In a sh script 

	 s=s#foo#bar#;

Assigns 's' to $s. In perl

	$s=s#foo#bar#;

Assigns a 1 or 0 to $s depending on weather or not the s/// of $_ succeded.

And for a real comment stripping hell (stolen from one of my old posts)
consider these:

        s# foo  \# bar
         # qux   #x;

        s# wee  [\#] fun
         # neat  #x;

        s[ fee(.*fie.*)foe ][
                        ($a=$1,               # $1 can't be modified
                         $a =~ s# \s #"."#xge # tr might be faster
                         && $a  # replace with null if s/// failed
                            ]xe;

        $a=~s=j.k.l=wingo=s&&s&#(?#foo)&s;&;

And some new ones for people who remember the answers to what those
ones do.

	s# $ \#ARGV # x #x;

	s# $\#ARGV # xx #x;

	s# ( [\#\s\w]+ ) (?\#?) # ($a=$1, $a =~ s\# \s \#.\#xg, $a) #xe;

There are no context free comments in perl. Playing around with toke.c
from the perl source, I have not been able to implement some of my ideas
for such a thing. Perl parsing is quite complex.

Elijah
------
sees a "which of these is legal" stump-the-guru question in this stuff


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

Date: Thu, 05 Feb 1998 09:55:20 -0800
From: Steven Smith <steves@wco.com>
To: Gabor <gabor@vmunix.com>
Subject: Re: split /\s*,\s*/
Message-Id: <34D9FD08.D96@wco.com>

Hi Gabor

Thanks!

Gabor wrote:
 ...
 <1991Jun24.231628.14446@jpl-devvax.jpl.nasa.gov>


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

Date: Thu, 5 Feb 1998 18:43:41 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Tie-Dee-Perl (Cleanliness is next to Goodliness, or Perl-White Code)
Message-Id: <Enx5Ct.5H8@world.std.com>

Jason Christian <jason@primal.ucdavis.edu> writes:

>On 4 Feb 1998, Craig Berry wrote:

>>   open NUMBERS, "< numbers.txt" or die "Can't open numbers.txt: $!";
>>   $numbers = <NUMBERS>;
>>   close NUMBERS;

>Following the age-old advice to lurk before posting, I did manage to
>avoid breaking cplm rule number one, which reads "never say 'open'
>without saying 'die'," or something like that.  That rule is more about
>practicality than simply cleanliness:  it is nice to know what broke.

I'd say the rule is a little more general than that. "Always check the
return value from open" doesn't mean "cause the script to exit if the
file doesn't exist." It means "find out if there was an error, and do
whatever you feel is necessary."

You may want to just warn() instead of die().

open NUMBERS, '< numbers.txt' or warn "Can't open numbers.txt: $!\n";

notice, this is what perl does for its implicit open with the read on
the null filehandle <>

~/tmp>echo foo > foo
~/tmp>echo baz > baz
~/tmp>perl -pe ';' foo bar baz
foo
Can't open bar: No such file or directory
baz

You may want to log to syslog.

You may want to use some built in default.

if(open NUMBERS, '< numbers.txt') {
   $numbers = <NUMBERS>;
   close NUMBERS or undef $numbers;
}

$numbers = 42 unless defined $numbers;

You can do whatever you want to handle it, just do something.
-- 
Andrew Langmead


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

Date: 05 Feb 1998 11:29:22 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
Subject: Re: Tie-Dee-Perl (Cleanliness is next to Goodliness, or Perl-White Code)
Message-Id: <omu3adaosd.fsf@tees.cs.ualberta.ca>

In article <Pine.OSF.3.95.980204164052.2473C-100000@primal.ucdavis.edu> Jason Christian <jason@primal.ucdavis.edu> writes:

> unless (def($pun{'tie'})){die "Help$!"}
          defined
> > +    open NUMBERS, "irrationals.txt" or die
> > Danger! Danger, Will Robinson!
> > (open NUMBERS), ("irrationals.txt" or die...)
> Right.
Wrong. "or", unlike "||", is lower precedence than comma.



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

Date: Thu, 05 Feb 1998 12:24:02 -0500
From: Ramon Castillo <ray@icix.net>
To: Kelby Valenti <kelby@mplx.com>
Subject: Re: unix command
Message-Id: <34D9F5B2.156F@icix.net>

You have several ways to run a unix command from Perl.

You can check "perldoc -f exec".

Also you can do someting like this with backsticks:

from the prompt line:

>perl -e'$foo=`ps -ef|grep inetd`;print $foo;'

Or you can also say piping out from a perl script:

#!/usr/local/bin
open (NS,"nslookup $domain|");
      while (<NS>)
             {
              print $_;
             }


I hope this help


RC
-- 
#!/usr/local/bin/perl

use Heart::WithBrain;
while ($god->bless == $Internet && $Perl == $Cool){
       $Be = "Happy";
       $Live = "Love";
       $Hack = "Fun";
}      #  RC          ray@icix.net


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

Date: 5 Feb 1998 16:25:23 GMT
From: eedvab@eed.ericsson.se (Vjekoslav Balas)
Subject: variable -> form ->varibale
Message-Id: <6bcp5j$mj820@aken.eed.ericsson.se>


Hi,
Maybe someone could give a pointer how I would do this:
I have a number of data in a file (A) something like this (with pattern repeating (but no of activities/goal variable):
Goal1:...
Comment:...
Responsible:...
Status:
Activity:
Comment:
Responsible
Status:
I would like to fetch this data and present it on www in a form (eg. as a table) via which the user could change the "changeable data". The form output would then be used to update file (A).

My idea was to use perl to parse the file, then place the data in variables which
would be included in html code. All is well till here - but not sure how
to get the data out of the form so that I know which variable it was in. Thanks,Vjeko



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

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

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