[10679] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4271 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 21 19:07:19 1998

Date: Sat, 21 Nov 98 16:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 21 Nov 1998     Volume: 8 Number: 4271

Today's topics:
        A Newbie Question: OUTPUT <msim@primenet.com>
    Re: A Newbie Question: OUTPUT (Greg Ward)
    Re: Beginner Book? (SnowSimulation)
        bsp lib for perl yawny@email.com
    Re: CGI security -- help!!!!!! (brian d foy)
    Re: CGI tools - Shopping Basket <kteicher@apk.net>
    Re: CGI tools - Shopping Basket birgitt@my-dejanews.com
        CGI/perl question <softsci@eagle.ca>
    Re: CGI/perl question <dan@clockwork.net>
    Re: detecting hard drives (Greg Ward)
    Re: help: can't find HTTP_COOKIE. my cookies don't go (brian d foy)
    Re: hiding a URL (brian d foy)
    Re: How do I sort this list by "port" number? (Ilya Zakharevich)
    Re: How do you pass parameters to Perl script from HTML (brian d foy)
    Re: How do you pass parameters to Perl script from HTML (Tom McGee)
    Re: How to parse a <SELECT ... MULTIPLE> list in script (brian d foy)
        HTTP_REFERER and Browser History <btate@primary.net>
    Re: HTTP_REFERER and Browser History <dan@clockwork.net>
    Re: HTTP_REFERER and Browser History (Tom McGee)
    Re: interpolate please? (Mark-Jason Dominus)
    Re: Lexical var in nested sub (Mark-Jason Dominus)
    Re: Matching Text Outside HTML Tags (Greg Ward)
    Re: Matt's SSI image help (brian d foy)
    Re: opening an already opened file (Greg Ward)
    Re: Passing HASH as a parameter bhoylma@uswest.com
    Re: Perl Usage Survey - interpretations, anyone? birgitt@my-dejanews.com
    Re: Promote a TIEREF to hash.... (Mark-Jason Dominus)
        Quick Perl prob. <amcnulty@nortel.co.uk>
    Re: Recommend Perl books? (Greg Ward)
        Regex for Matching Text Outside HTML Tags Gary.Karcz@nau.edu
    Re: Regex for Matching Text Outside HTML Tags (Matthew Bafford)
    Re: Regex for Matching Text Outside HTML Tags <dan@clockwork.net>
    Re: Requesting URLs from a perl script (brian d foy)
    Re: reset one variable? (Greg Ward)
    Re: shopping cart birgitt@my-dejanews.com
    Re: The dumbest question ever - HELP!!! <perlguy@technologist.com>
        trouble with the parameter from HTML <christian@acreare.de>
    Re: trouble with the parameter from HTML <dan@clockwork.net>
    Re: trouble with the parameter from HTML (brian d foy)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 21 Nov 1998 21:05:28 GMT
From: Sim Mong Chuan <msim@primenet.com>
Subject: A Newbie Question: OUTPUT
Message-Id: <7379uo$8l1$1@nnrp02.primenet.com>

I would like to know how to send output to a file or screen
by using the same subroutine.

In C language, I can do the following: 

 For example:

         void print_something(FILE *filehandle)
             {
                // print something using filehandle
              }

        When calling the function, if I do:
          print_something(stdout);  // it prints to the screen
          print_something(fp); // it writes to a file that I open with fp

Is there a way to substitue the value of the fileheader thru actual 
parameters by STDOUT or a filehandle?
I hope you understand my question.
Thank you in advance.


Sim

-- 
-------------------------------------------------------------------------------
msim                                      __  __     ____  ___       ___ ____
msim@primenet.com                        /__)/__) / / / / /_  /\  / /_    /
                                        /   / \  / / / / /__ /  \/ /___  /
-------------------------------------------------------------------------------


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

Date: 21 Nov 1998 23:42:02 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: A Newbie Question: OUTPUT
Message-Id: <737j4a$1bd$6@news0-alterdial.uu.net>

On 21 Nov 1998 21:05:28 GMT, Sim Mong Chuan <msim@primenet.com> wrote:
>I would like to know how to send output to a file or screen
>by using the same subroutine.
>
>In C language, I can do the following: 
[C code deleted -- this is a Perl newsgroup! >grin<]
>
>Is there a way to substitue the value of the fileheader thru actual 
>parameters by STDOUT or a filehandle?
>I hope you understand my question.
>Thank you in advance.

Two ways: if you have existing code that only writes to STDOUT, you can
redirect STDOUT before calling it.  Here's one way:

   {   
      local *STDOUT = *MYFILE;
      inflexible_output_routine (...);
   }

Note the use of a dummy scope to restrict the region in which
reassigning STDOUT has an effect.

If you're writing new code, it's better to make it take a filehandle as
an argument.  This is easy:

   sub smart_output_routine
   {
      my ($filehandle, ...) = @_;

      print $filehandle "this is output";
      #OR:
      $filehandle->print "this is output";
   }

The tricky bit is how to call that subroutine, which is not at all
obvious.  If you're using traditional filehandles (like STDOUT), do
this:

   smart_output_routine (\*STDOUT, ...);

or, if you're using modern IO::File objects, just do the obvious thing:

   my $file = new IO::File 'file' or die "...";
   # ...
   smart_output_routine ($file, ...);

Hope this works (the code is untested and off the top of my head -- read 
the fine manual to understand what I've done before relying on it!).

        Greg

-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Sat, 21 Nov 1998 12:49:43 -0800
From: SnowSim@halcyon.com (SnowSimulation)
Subject: Re: Beginner Book?
Message-Id: <SnowSim-2111981249440001@blv-ux100-ip17.nwnexus.net>

In article <ex$yyZOF#GA.330@nih2naac.prod2.compuserve.com>, "AJ"
<ajonsson@csi.com> wrote:

[snip]

>...I think telling someone to become comfortable
> in programming in a compiled language before learning a scripting language
> seems, to me, to be the wrong approach...

it is but that's never stopped anyone

> ...I've had the MacPerl book recommended to me.  One of
> these days I need to get it and see how that works out.

nice effort...check out their web site if you can't seem to find the time
for the paper version


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

Date: Sat, 21 Nov 1998 23:22:26 GMT
From: yawny@email.com
Subject: bsp lib for perl
Message-Id: <737hv4$ihl$1@nnrp1.dejanews.com>

Anybody have any good Perl code to implement basic BSP algorithms (searching &
sorting, file i/o)?

I can't seem to find any myself, and can't believe that nobody's written any.

thanks,

Rafael

(if it matters I'm trying to sort vast amounts of 5-50 character strings
(1,000,000+), write the data to a file, and then search through the files
later looking for matches -- must be ASAP (as speedy as possible))

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 21 Nov 1998 15:55:16 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: CGI security -- help!!!!!!
Message-Id: <comdog-ya02408000R2111981555160001@news.panix.com>

In article <73725a$esj$1@mur2.odyssey.on.ca>, "Kumar Sundaram" <softsci@eagle.ca> posted:

> How would you write a secure CGI script? 

see the URL in the .sig.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sat, 21 Nov 1998 16:15:07 -0500
From: "Keith Teicher" <kteicher@apk.net>
Subject: Re: CGI tools - Shopping Basket
Message-Id: <737ah1$847$1@ash.prod.itd.earthlink.net>

Check out www.onlineorders.net -  over 150 choices are listed.  The site is
a directory of ecommerce and shopping cart solutions.  Free, FrontPage and
traditional programs are all indexed.


juliegee@iname.com wrote in message <7368hb$igk$1@nnrp1.dejanews.com>...
>Hi all,
>
>I am writing some HTML pages for a company and they need some CGI.
>They have around 9,000 products and I think they need something like
>a "Shopping basket" on their web site.
>
>Is there a CGI program available or a Tool to help me write the CGI
>for a "Shopping basket" type web site.
>
>What I mean by shopping basket is the user should be able to browse through
>the products and add each one to the shopping basket as he/she likes.
>Then at the end, the "check out", the CGI will give them a list of all
things
>put in the basket and the total cost.
>
>If there are any programs avaliable to help me with this, please let me
know.
>
>All replies are greatly appreciated.
>
>Julie Gee.
>juliegee@iname.com
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own





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

Date: Sat, 21 Nov 1998 22:13:52 GMT
From: birgitt@my-dejanews.com
Subject: Re: CGI tools - Shopping Basket
Message-Id: <737dum$fee$1@nnrp1.dejanews.com>

In article <slrn75dosl.a2.jonathan@core.dumped.org>,
  jonathan@core.dumped.org (Jonathan Bobin) wrote:
> In article <7368hb$igk$1@nnrp1.dejanews.com>, juliegee@iname.com wrote:
> >Hi all,
> >
> >I am writing some HTML pages for a company and they need some CGI.
> >They have around 9,000 products and I think they need something like
> >a "Shopping basket" on their web site.
> >
> >Is there a CGI program available or a Tool to help me write the CGI
> >for a "Shopping basket" type web site.
>
> Your best bet would be to go with a company that does it already, like
> http://stores.yahoo.com, which is pretty cheap afaik.
>
> I'm sure that there are free CGI programs out there... try a website like
> http://www.freecode.com/
>

hmm, a bit weird someone can't find a shopping cart these days (Altavista
keyword search "shopping cart" gives them back like a swarm of flies).

A bit weirder, someones asks in clpm for a shopping cart, and is pointed
to Netscape. At least one should point to a free shopping cart written
in perl, like "Minivend" (www.minivend.com).

Birgitt

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 21 Nov 1998 16:18:00 -0500
From: "Kumar Sundaram" <softsci@eagle.ca>
Subject: CGI/perl question
Message-Id: <737arm$f7h$1@mur2.odyssey.on.ca>

Hello everyone,
I am using the following code to check for required fields in a html form
and generate a html ouput page if one or more required field is not filled
in.  It's all working fine!! But, I do have a small problem with it.  That
is,  Lets say I have 5 required fields in my html
form(name,email,city,country,zip), if I fill in all 4 fields except one
(email), my html output page is still showing that I have not filled in all
five fields.  It supposed to be showing that I have not filled in only one
field, in this case, that is email field.  Does anyone have a simple
solution to this?  By the way, I am very new to CGI/Perl programming.  This
is my first program I am working on.  Thanks in advance for your help!!
@required = split (/,/, $INPUT{'required'});
foreach $required (@required)
{ 
if ($INPUT{$required} eq "") 
{ 
 print ("Content-Type: text/html\n\n");
 print ("<html><head><title>MISSING REQUIRED FIELDS</title></head>\n");
 print ("<font size=4>\n");
 print ("The following form fields were not filled in when you submitted your form\,\n");
 print ("but are required information.<br>\n");
 print ("</font>\n");
 print ("<hr width=\"100%\">\n"); 
 print ("<br>\n");
foreach $required (@required) 
{
 print ("$required<br>\n");
} 
 print ("<br>\n");
 print ("<hr width=\"100%\">\n");
 print ("</html>\n");
exit; 
}  
}





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

Date: Sat, 21 Nov 1998 16:35:46 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: CGI/perl question
Message-Id: <36574040.8089917F@clockwork.net>

Your problem lies in that you haven't organized your blocks of code correctly, if the code
you posted is accurate. All of the code gets executed after the statement:

if ($INPUT{$required} eq "")

So if only one field is missing, it still runs through the loop:

foreach $required (@required)
{
 print ("$required<br>\n");
}

which will list every field, whether it was entered or not. What you probably are trying to
do is something more like:

@required = split(/,/, $INPUT{'required'});
foreach $required (@required) {
    if ($INPUT{$required} eq "") {
        push (@missing, $required);
    }
}

if (@missing > 0) {  # scalar context
    # put the error message here, the missing fields are listed in @missing
} else {
    # successful post
}


Dan Brian
dan@clockwork.net




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

Date: 21 Nov 1998 23:19:22 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: detecting hard drives
Message-Id: <737hpq$1bd$1@news0-alterdial.uu.net>

On Fri, 20 Nov 1998, Jye Tucker <jye@buckconsultants.com.au> wrote:
>What I am trying to do is to ask the script to detect what hard drives are
>connected to the machine so that I can use the mount system command to
>mount them. 
>
>Has anyone heard of any modules or techniques for detecting hardware or am
>I just going to have to grep through the output of dmesg?

Whatever you do, it will probably be very unportable -- there just isn't
a standard way of doing this.  Depending on FreeBSD's capabilities,
there might be nicer alternatives.  If it has something like Linux'
/proc filesystem, perhaps the information you need is in there
(somehow).  Or you could make an a priori list of "all possible" drives
in a PC system (eg. under Linux I'd start with /dev/hd[abcd] (for four
IDE disks -- since you're just looking for disks, partitioning doesn't
matter) and /dev/sd[abcdefg] (seven SCSI disks).  Then try to read a
sector from each one in turn.  Again under Linux, I get chunks of
gibberish from /dev/hda and /dev/hdc (my hard disk and CD-ROM) and
"Device not configured" errors from /dev/hd[bd] and /dev/sd? -- because 
I have no SCSI devices and no other IDE devices.  You might have to
worry about long timeouts though -- I suppose you could fork a
sub-process for each 'poke' and kill 'em if they don't respond back
within x seconds.

Of course, this only detects IDE and SCSI devices, it doesn't tell you
which are hard disks and which are CD-ROM drives, tape drives, etc.
That's left as an exercise for the reader (meaning I'm clueless).

Good luck!

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Sat, 21 Nov 1998 15:57:20 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: help: can't find HTTP_COOKIE. my cookies don't go
Message-Id: <comdog-ya02408000R2111981557200001@news.panix.com>

In article <3655A5F4.58A40F6C@nextel.es>, mikel <muriarte@nextel.es> posted:

> CGI_perl: when i print the ENV array: the HTTP_COOKIE doesn't exist

see the docs referenced in the CGI Meta FAQ.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sat, 21 Nov 1998 15:53:48 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: hiding a URL
Message-Id: <comdog-ya02408000R2111981553480001@news.panix.com>

In article <3654D47A.5612CE7B@sprynet.com>, Balazs Rauznitz <prauz@sprynet.com> posted:

> >         Hello...I'm not sure if this is a Perl-specific question, but
> > I thought maybe it could be accomplished within a Perl CGI script.  Is
> > there any way to cause the browser to hide the URL of a
> > (protected/secure) web page, thus causing the browser NOT to display
> > it in the LOCATION field?

> No; it is neither a perl question nor is it possible as far as I know.

as far as you know is hardly a proof though.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 21 Nov 1998 23:29:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How do I sort this list by "port" number?
Message-Id: <737ic5$i68$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Randal Schwartz 
<merlyn@stonehenge.com>],
who wrote in article <8c67cmx7ei.fsf@gadget.cscaper.com>:

> There are many of my one-off programs that are not -w clean.  Some are
> not even "use strict" clean.  Perl is a tool to get the job done. 

It is very important to preserve a possibility to use Perl for one-off
expert-written jobs.  It is no less important to make Perl a
friendlier place to visit.

Experts will have no problems with

	alias perl '\perl -Moneoff'

in their command-line shells.  This means that except
backward-compatibility, there is no problem with making Perl more
programmer-friendly.  Backward-compatibility may be solved by renaming
the compiled-with-friendly-options perl to perly or perfy.

Ilya


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

Date: Sat, 21 Nov 1998 15:59:04 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How do you pass parameters to Perl script from HTML #exec statement?
Message-Id: <comdog-ya02408000R2111981559040001@news.panix.com>

In article <Pine.GSO.4.05.9811201103370.19882-100000@lance.netdoor.com>, Aaron Delong <delonad@netdoor.com> posted:

> Have you tried adding your arguments like this:
> 
> <!--#exec cgi="/cgi-shell/my_script.pl?arg1=one&arg2=two&arg3=three"-->

have you?  

have you read the docs to understand why you can't do this? see the
CGI Meta FAQ to discover how bad your advice is.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
hint: <!--#include virtual="....?parameters"-->


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

Date: Sat, 21 Nov 1998 22:59:02 GMT
From: tamcgee@home.com (Tom McGee)
Subject: Re: How do you pass parameters to Perl script from HTML #exec statement?
Message-Id: <tamcgee-2111981759500001@cc1017583-a.union1.nj.home.com>

Why is this a problem?

--Tom



In article <comdog-ya02408000R2111981559040001@news.panix.com>,
comdog@computerdog.com (brian d foy) wrote:

>>In article <Pine.GSO.4.05.9811201103370.19882-100000@lance.netdoor.com>,
Aaron Delong <delonad@netdoor.com> posted:
>>
>>> Have you tried adding your arguments like this:
>>> 
>>> <!--#exec cgi="/cgi-shell/my_script.pl?arg1=one&arg2=two&arg3=three"-->
>>
>>have you?  
>>
>>have you read the docs to understand why you can't do this? see the
>>CGI Meta FAQ to discover how bad your advice is.
>>
>>-- 
>>brian d foy                                  <comdog@computerdog.com>
>>CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
>>hint: <!--#include virtual="....?parameters"-->


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

Date: Sat, 21 Nov 1998 15:46:01 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How to parse a <SELECT ... MULTIPLE> list in script using a foreach loop?
Message-Id: <comdog-ya02408000R2111981546010001@news.panix.com>

In article <Pine.BSF.4.02A.9811190047300.28085-100000@dillinger.io.com>, REUBEN LOGSDON <rlogsdon@io.com> posted:

> with multi-select, the browser sends multiple name=value pairs in the post
> data or query.  given the way some people parse teh form data, what
> happens is that you get only the last item.  if you parse the form data
> right then $form{'ITEMS'} will have all the items comma-delimited.  the
> way you have to parse it is:

wrong answer.  if you really want to do A LOT of extra work you could
go this route (and you didn't do the extra work needed, so your code
was horribly broken).  the problem is when commas show up in the input
data.

since you should be using Perl 5, you don't need to store lists as
strings.  use an anonymous array.  no delimiter necessary.

however, until you really understand what is happening, don't lead
others down the wrong path.  let them use CGI.pm and get on with
their lives.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Sat, 21 Nov 1998 17:11:20 -0600
From: "Bob Tate" <btate@primary.net>
Subject: HTTP_REFERER and Browser History
Message-Id: <36574bea.0@news.primary.net>

I am doing some research on the $ENV{'HTTP_REFERER'} variable in Perl.  I
have tried this in Perl 5 and on both a Solaris Unix and Digital Unix
machines.  So far I have not been able to get the $ENV{'HTTP_REFERER'} to
return a response  It is always blank.  I have looked at the %ENV and the
HTTP_REFERER is not listed there either.  I see some references to it and
seen a page or two that show that it does work.  Is its use limited to a
certain version of Perl or web server?

Also, does anyone know how to read in the web browser history from the users
machine?





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

Date: Sat, 21 Nov 1998 17:50:14 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: HTTP_REFERER and Browser History
Message-Id: <365751B6.23AF1FD3@clockwork.net>

HTTP_REFERER (and all CGI ENV variables) are web-server-dependent variables;
I don't know if HTTP_REFERER exists outside of Apache. Also, the script must be
linked to via an <a href> tag or a submitted form from another doc to have a
value set.

Bob Tate wrote:

> I am doing some research on the $ENV{'HTTP_REFERER'} variable in Perl.  I
> have tried this in Perl 5 and on both a Solaris Unix and Digital Unix
> machines.  So far I have not been able to get the $ENV{'HTTP_REFERER'} to
> return a response  It is always blank.  I have looked at the %ENV and the
> HTTP_REFERER is not listed there either.  I see some references to it and
> seen a page or two that show that it does work.  Is its use limited to a
> certain version of Perl or web server?
>
> Also, does anyone know how to read in the web browser history from the users
> machine?





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

Date: Sat, 21 Nov 1998 23:57:49 GMT
From: tamcgee@home.com (Tom McGee)
Subject: Re: HTTP_REFERER and Browser History
Message-Id: <tamcgee-2111981858360001@cc1017583-a.union1.nj.home.com>

I've been able to use it in 4 different flavors of Web servers for NT
(Netscape Commerce, Website Professional, IIS 3 and 4). It's also
documented for Netscape's Unix server.

--Tom

In article <365751B6.23AF1FD3@clockwork.net>, Dan Brian
<dan@clockwork.net> wrote:

>>HTTP_REFERER (and all CGI ENV variables) are web-server-dependent variables;
>>I don't know if HTTP_REFERER exists outside of Apache. Also, the script
must be
>>linked to via an <a href> tag or a submitted form from another doc to have a
>>value set.
>>
>>Bob Tate wrote:
>>
>>> I am doing some research on the $ENV{'HTTP_REFERER'} variable in Perl.  I
>>> have tried this in Perl 5 and on both a Solaris Unix and Digital Unix
>>> machines.  So far I have not been able to get the $ENV{'HTTP_REFERER'} to
>>> return a response  It is always blank.  I have looked at the %ENV and the
>>> HTTP_REFERER is not listed there either.  I see some references to it and
>>> seen a page or two that show that it does work.  Is its use limited to a
>>> certain version of Perl or web server?
>>>
>>> Also, does anyone know how to read in the web browser history from the users
>>> machine?


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

Date: 21 Nov 1998 20:44:14 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: interpolate please?
Message-Id: <7378mu$mbb$1@picasso.op.net>

In article <3654D251.39F6FB46@hotmail.com>,
sara starre  <nospam.perl_rocks@hotmail.com> wrote:
>Since I belong to the "less code is better code" school , I wonder, is
>there any way to make perl interpolate more than $-vars withing a
>literal, such as:
>
>   print "processing case ++$i\n";

	http://www.plover.com/~mjd/perl/Identity/

has a module that lets you write

    print "processing case $eval{++$i}\n";

and it works the way you want.  You can replace `eval' with your
favorite punctuation character if you find it too verbose:

    print "processing case $-{++$i}\n";


But if you're actually going to use this, get the full-featured
`Interpolation' module from CPAN.




-- 

mjd@pobox.com                                             Mark-Jason Dominus
mjd@plover.com                              Plover Systems, Philadelphia, PA



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

Date: 21 Nov 1998 20:54:57 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Lexical var in nested sub
Message-Id: <7379b1$mjn$1@picasso.op.net>

In article <36549AEE.8A21DC00@min.net>, John Porter  <jdporter@min.net> wrote:
>Bret Madhvani wrote:
>> 
>> I'm trying to understand the scope of a lexical variable in a nested
>> sub.
>
>Don't do this.  Nested subs are broken.

He's not talking about lexically nested subs.
He's talking about subs which make calls to other subs.

-- 

mjd@pobox.com                                             Mark-Jason Dominus
mjd@plover.com                              Plover Systems, Philadelphia, PA



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

Date: 21 Nov 1998 23:33:27 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: Matching Text Outside HTML Tags
Message-Id: <737ik7$1bd$4@news0-alterdial.uu.net>

On Sat, 21 Nov 1998, dodadnau@my-dejanews.com <dodadnau@my-dejanews.com> wrote:
>What regex should be used to match text outside of HTML tags in an HTML
>document?

Using a regex to parse HTML is just asking for trouble.  As soon as you
think you've got it working, you'll find another example of valid HTML
which doesn't fit your parameters.  Save yourself a lot of time:
download libwww-perl from CPAN and use it's handy-dandy HTML parsing
modules.  HTML::Parser is the place to start.

        Greg 
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Sat, 21 Nov 1998 15:56:28 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Matt's SSI image help
Message-Id: <comdog-ya02408000R2111981556280001@news.panix.com>

In article <36566711.CCC@sno.net>, bbilling@sno.net posted:

> I have exhausted every effort to make Matt Wright's random SSI image
> script to work to no avail!

the solution is to not use crap from Matt Wright.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 21 Nov 1998 23:25:28 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: opening an already opened file
Message-Id: <737i58$1bd$2@news0-alterdial.uu.net>

On Thu, 19 Nov 1998, sara starre <nospam.perl_rocks@hotmail.com> wrote:
>I had a file that was already opened, and I didn't realize that I hadn't
>closed it. In a sub I opened it again. The open seemed to have no effect
>at all - not even an error even though I was using /usr/local/bin/perl
>-w
>
>Shouldn't it have either said something like (open attempted on already
>opened file) or reset the pointer to record 1? It seemed to do nada!

Under Unix (at least), it's perfectly legal to open a given file as many 
times as you like.  (Well, at least for reading...)  Perl just inherits
this behaviour. 

One subtlety that you didn't mention: did you reuse the same filehandle?
Remember that unless you use IO::File objects or 'local'-ize your
filehandles, the same symbols refers to the same filehandle anywhere in
the same package.  So if you did open (FOO, 'foo') at one point in your
program, and then elsewhere accidentally did open open (FOO, 'foo')
again, I would expect that FOO to refer to the same file as before, but
rewound to the beginning of the file.

Oh, also, reusing Perl filehandles in this way is safe in terms of
memory consumption -- if you open (FOO, ...) without closing it, Perl
will close it for you.  Isn't that nice?  ;-)

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Sat, 21 Nov 1998 23:28:25 GMT
From: bhoylma@uswest.com
Subject: Re: Passing HASH as a parameter
Message-Id: <737iaa$iso$1@nnrp1.dejanews.com>

In article <3655BC32.F97B0A1A@harris.com>,
  "PERL ROCKS!" <emills@harris.com> wrote:
> Gooday! I wonder can you point me to an example of someone who is
> passing an arbitrary-length hash, and subsequently using the hash  as an
> input parameter to a sub? I'm trying to do it by reference, using the
> Camel book illustrations, but I'm not having much sucesss yet. I don't
> necessarily want to make changes to the sub- a local copy should do
> fine.
>

perl -e 'sub hasher {my ($h) = @_;$h->{"dog"} = "cat"; return $h} my %h = ("d
og" => "dog"); my $j = hasher({%h});print qq/J - $j->{"dog"} H - $h{"dog"}\n/'

J - cat H - dog

Peace.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 21 Nov 1998 21:42:08 GMT
From: birgitt@my-dejanews.com
Subject: Re: Perl Usage Survey - interpretations, anyone?
Message-Id: <737c3e$dpt$1@nnrp1.dejanews.com>

In article <36549406.C5FA1D21@min.net>,
  John Porter <jdporter@min.net> wrote:
> Adam Turoff wrote:
> >
> > http://www.ora.de/german/perl/einperl2/autor.html
>
> "stinking animals"?!!!   Where the heck did that come from?
>
> (Turns out it was "skunks".)
>
> John Porter

English: "skunk" -> German: "Stinktier" -> Babelfish:  "Stinking Animal"
because
German: "stinken" =  English: "to stink" and
German: "Tier" = English: "Animal".

free translation of above:

Babelfish stinks as it ain't know that a Stinktier is no Stinking
Animal but a skunk. But a skunk is stinking, so Stinktier doesn't
stink describing a stinking skunk.


:-)


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 21 Nov 1998 20:50:59 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Promote a TIEREF to hash....
Message-Id: <73793j$mjf$1@picasso.op.net>

In article <3654C00D.3553@usa.net>, Lord Vorp  <lordvorp@usa.net> wrote:
>I've been wondering...
>
>Suppose, just suppose, you have a tied object.  For example:
>
>$t = new Tie::IxHash (foo => 'bar' , fuu => 'baz');
>
>Is it possible to tie this OBJECT to a hash?  

It's already tied to a hash.  That's what `tie' does.  Maybe you could
ask your question in a way that shows what you want to do with it?

>or even better, suppose I wanted to pass my tied %hash by ref to a
>function:
>
>&my_func(\%hash)
>
>Is there a way to promote it back to a tied hash?

When the function gets the reference, it still refers to the tied hash.

>
>sub my_func {
>    my $ref = shift;
>    print ref $ref, "\n";
>
>    my %hash = %$ref;

Here you have copied the contents of the tied hash into a new,
untied hash.  Of course %hash is untied.  

But if you use $ref->{foo}, you will be going through the tied hash
and you will get the usual special tied hash behavior.

If you don't want to write arrows, do this:

	local *hash = $ref;

Now %hash is an alias for the tied hash that you passed by reference.
-- 

mjd@pobox.com                                             Mark-Jason Dominus
mjd@plover.com                              Plover Systems, Philadelphia, PA



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

Date: Sat, 21 Nov 1998 23:28:30 -0000
From: "Antony" <amcnulty@nortel.co.uk>
Subject: Quick Perl prob.
Message-Id: <737icb$an7@bmdhh222.europe.nortel.com>

Hey Expert-Type People,


I want to finish a small program that I am working on, but have one little
problem.

My script needs to be run a subroutine every time the timestamp of a certain
file is altered.

I tried a couple of ideas but most seem to impractical and too memory
consuming.


Also, anyone ever come up with many problems in porting UNIX perl scripts
over to WinNT ?
Got any hints for doing it quicker?
Because I'm here all weekend doing just that and it's really starting to get
on my nerves.


Awaiting all helpful comments,

Antony
MMP Release Management
590-4499




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

Date: 21 Nov 1998 23:36:13 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: Recommend Perl books?
Message-Id: <737ipd$1bd$5@news0-alterdial.uu.net>

On Sat, 21 Nov 1998 15:01:50 -0000, OM <om7@cyberdude.com> wrote:
>Can anyone please recommend a good Perl book.  I'm new to Perl and have
>never used it before.  But I do have programming experience.

Start with *Learning Perl* by Randal Schwartz and Tom Christiansen.
Then get *Programming Perl* by Larry Wall and the above two (in reverse
order).  If you're still not sated, *Advanced Perl Programming* by
Sriram Srinivasan is also quite good, and *very* gory.

All are published by O'Reilly & Associates -- you should be able to find 
them in any decent computer bookstore, or order them online at ora.com
or amazon.com (or, no doubt, other online bookstores).  

Tom Christianen has also put up a bunch of Perl book reviews at
www.perl.com.  Obviously he's a tad biased, but it's great fun to read
him ripping into the throwaway 1000+ page "Teach Yourself to Master Perl
in 21 Seconds" garbage.  Do NOT waste your money on these books.

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Sat, 21 Nov 1998 20:07:14 GMT
From: Gary.Karcz@nau.edu
Subject: Regex for Matching Text Outside HTML Tags
Message-Id: <7376h8$9es$1@nnrp1.dejanews.com>

What regex could be used to match strings outside HTML tags?  For example:

<!--Northern Arizona University-->
<type="hidden" name="URL" value="Northern Arizona University">
<a href="http://www.nau.edu/">Northern Arizona University</a>
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                          ^
                                          |
                         Match only this -+

Would like to match "Northern Arizona University" or *any* string outside
*all* HTML tags, while keeping the HTML tags intact.

Thanks!


--Gary

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 21 Nov 1998 15:41:07 -0500
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: Regex for Matching Text Outside HTML Tags
Message-Id: <MPG.10c0ef6d10f05b63989726@news.scescape.net>

In article <7376h8$9es$1@nnrp1.dejanews.com>, Gary.Karcz@nau.edu says...
=> What regex could be used to match strings outside HTML tags?  For example:
        ^^^^^                                        ^^^^
=> [snip]

Those two words are mutually exclusive.

Try HTML::Parser instead.

HTH,

--Matthew


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

Date: Sat, 21 Nov 1998 16:50:34 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: Regex for Matching Text Outside HTML Tags
Message-Id: <365743BA.FCBAE1B9@clockwork.net>

A quickie would be:

@textonly = split(/<[^>]*>)/);

or

$textonly = join ('', split (/<[^>]*>/));

or, to take all HTML tags out of a document,

$textonly = $htmltext =~ s/<[^>]*>//g;

Gary.Karcz@nau.edu wrote:

> What regex could be used to match strings outside HTML tags?

Dan Brian
dan@clockwork.net




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

Date: Sat, 21 Nov 1998 15:52:14 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Requesting URLs from a perl script
Message-Id: <comdog-ya02408000R2111981552140001@news.panix.com>

In article <slrn7595f4.dt.jonathan@core.dumped.org>, jonathan@core.dumped.org (Jonathan Bobin) posted:

> In article <731on0$h0o$1@ubnnews.unisource.ch>, Admin Sunsite wrote:
> >Hi

> >i have a perl script running on a web-server. Depending on user entries i'd
> >like to send the User to a specific URL. How do I do that?

> I am assuming you have the URL you want to send them to in
> the variable $variable:
> 
> print "Content-type: text/html\r\n",
>       "Redirect: $variable\r\n",
>       "\r\n";

if you had done this before, you might have realized that your
"answer" didn't work.

use the method from the specification rather than an extension
supported by a limited number of clients.

print <<"HTTP";
Status: 301 Moved Temporarily
Content-Type: text/html
Location: http://computerdog.com/CGI_MetaFAQ.html

<html>
<head><title>See the CGI Meta FAQ</title></head>
<body>
Please see the <a href="http://computerdog.com/CGI_MetaFAQ.html"
>CGI Meta FAQ</a> for details.
</body>
</html>
HTTP

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 21 Nov 1998 23:29:31 GMT
From: gward@thrak.cnri.reston.va.us (Greg Ward)
Subject: Re: reset one variable?
Message-Id: <737icr$1bd$3@news0-alterdial.uu.net>

On Fri, 20 Nov 1998, forrest reynolds <dropzone@mail.utexas.edu> wrote:
>Hello,
>             I'm looking in the Camel book at "reset".... it doesn't
>mention resetting
>just one variable. Is this possible without using:
>
>              $var = "" ;

Use undef.  Ie. either

   undef $var;

or

   $var = undef;

will do what you want.  Assigning the emtpy string is *very* different.

Anyways, as it says in the Camel, "use of 'reset' is vaguely
deprecated", and anyways it only works on global variables -- and you
shouldn't use global variables!.  It strikes me as one of the odder
leftovers from Perl 4.

        Greg
-- 
Greg Ward - software developer                    gward@cnri.reston.va.us
Corporation for National Research Initiatives    
1895 Preston White Drive                      voice: +1-703-620-8990 x287
Reston, Virginia, USA  20191-5434               fax: +1-703-620-0913


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

Date: Sat, 21 Nov 1998 21:07:05 GMT
From: birgitt@my-dejanews.com
Subject: Re: shopping cart
Message-Id: <737a1h$c7a$1@nnrp1.dejanews.com>

In article <911467877.1911776447@news.mindspring.com>,
  Dustin Puryear <dpuryear@usa.net> wrote:
> I'm looking for a free shopping cart program that is well documented. Any
> suggestions?
>
> Regards, Dustin
>

www.minivend.com


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Sat, 21 Nov 1998 16:04:14 -0600
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: The dumbest question ever - HELP!!!
Message-Id: <365738DE.CE5942EA@technologist.com>

Michael Hamilton wrote:
> 
> I thought I'd post this question before I put my fist through the
> computer screen.
> 
> In the O'Reilly book on Perl for Win32 it gives the "Hello World"
> example.
> 
> Its say to type  - print ("Hello World"/n); - into any text editor and
> then invoke the proram. Easy right. Well I can't do it.

This code looks wrong, see below for an example that WILL work...
 
> 1. By "any text editor" does it mean something like WordPad or the
> little black screen you get when you double-click Perl.exe

Notepad is probably best, wordpad would work though.  The "little black
screen" you are talking about is a DOS windows and would complain if you
entered Perl commands into it.
 
> 2. How do you invoke it. I have tried to associate .plx file with the
> Perl.exe program, but I don't know if I have done it right.

If you need help configuring Perl, please visit:
http://www.activestate.com/support/faqs/win32/

The FAQ is very helpful.

> Could some kind person take pity on an idiot like me and give me an
> idiots step-by-step guide to where to write the code and how to run it.

Type the following into notepad:

print "Hello world!\n";

Then save the file and call it hello.pl

Next, get to an MS-DOS prompt and type:

perl hello.pl

Hello world should print out on your screen.  You successfully wrote
your first Perl program!  Congratulations!

If it didn't work, chances are perl.exe is not in your path.  Add it to
your path to make the program work.  The FAQ at ActiveState covers
Perl's setup...

Good luck!

Brent
-- 
Java?  I've heard of it, it is what I drink while hacking Perl! -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$            Brent Michalski             $
$         -- Perl Evangelist --          $
$    E-Mail: perlguy@technologist.com    $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

Date: Sat, 21 Nov 1998 23:30:57 +0100
From: Christian <christian@acreare.de>
Subject: trouble with the parameter from HTML
Message-Id: <36573F21.46CA0F24@acreare.de>

Hi,
I get the parameters from a html-Script sent by the subit-button and
that works in the perl-script with the line:

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 ......

but if I send the parameter from a html-page by

A HREF='/cgi-bin/buchausg.pl?linkbuch=3311'>

In this case the perl-script don't get the paramater.

What is wrong???

Thanks Christian



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

Date: Sat, 21 Nov 1998 16:40:30 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: trouble with the parameter from HTML
Message-Id: <3657415E.4F375833@clockwork.net>

The CONTENT_LENGTH env variable will only contain that data posted via a
POST form. To get the fields/vars from either a URL as you have or a
GET/HEAD form, you need to access the QUERY_STRING variable (for Apache
and most web servers).

I highly recommend learning to use the CGI.pm module; then you can get
either type of submitted data from structures like $query->param and
$query->url_param.


Christian wrote:

> Hi,
> I get the parameters from a html-Script sent by the subit-button and
> that works in the perl-script with the line:
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> ......
>
> but if I send the parameter from a html-page by
>
> A HREF='/cgi-bin/buchausg.pl?linkbuch=3311'>
>
> In this case the perl-script don't get the paramater.
>
> What is wrong???
>
> Thanks Christian


Dan Brian
dan@clockwork.net




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

Date: Sat, 21 Nov 1998 18:02:41 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: trouble with the parameter from HTML
Message-Id: <comdog-ya02408000R2111981802410001@news.panix.com>

In article <36573F21.46CA0F24@acreare.de>, computer@cfischer.com posted:

> but if I send the parameter from a html-page by
> 
> A HREF='/cgi-bin/buchausg.pl?linkbuch=3311'>
> 
> In this case the perl-script don't get the paramater.
> 
> What is wrong???

use CGI.pm to do the difficult work for you, then concentrate on
the cool things your script does ;)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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