[21757] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3961 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 13 00:06:17 2002

Date: Sat, 12 Oct 2002 21:05:08 -0700 (PDT)
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, 12 Oct 2002     Volume: 10 Number: 3961

Today's topics:
    Re: array variable reference versus literal vector ques <garry@ifr.zvolve.net>
        complex hash structure -- any ideas? (Jeremy Miller)
    Re: complex hash structure -- any ideas? <garry@ifr.zvolve.net>
    Re: Extensible event loop architecture <troc@netrus.net>
    Re: Extensible event loop architecture <nospam-abuse@ilyaz.org>
    Re: Extensible event loop architecture <nospam-abuse@ilyaz.org>
    Re: Help parsing HTML <aemily@colsd.org>
    Re: Help parsing HTML <bongie@gmx.net>
    Re: Help parsing HTML <kurzhalsflasche@netscape.net>
    Re: Help! How do you move one html page to another in P <flavell@mail.cern.ch>
    Re: Help! How do you move one html page to another in P <jeff@vpservices.com>
        How to create a bundle? <dd@4pro.net>
    Re: How to get perldb's x programmatically? <comdog@panix.com>
    Re: newb here learning Perl (Mark Jason Dominus)
    Re: newb here learning Perl (Mark Jason Dominus)
        Perl 5.8 test failure <rsteinmetz@mindspring.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 12 Oct 2002 23:00:06 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: array variable reference versus literal vector question
Message-Id: <slrnaqha4v.4c0.garry@zfw.zvolve.net>

On Sat, 12 Oct 2002 18:29:58 +0200, Daniel Pfeiffer
<occitan@esperanto.org> wrote:

> Do I have a chance of finding out whether I was passed a reference
> to an array variable, of to a literal vector which was only used for
                                ^^^^^^^^^^^^^^

Huh?  I think you mean an anonymous array reference.  


> passing in a list?  Question is whether there is any point in
               ^^^^

I think you mean an array reference.  

> changing values in the vector or if it's lost afterwards.


An array reference _and_ an anonymous array reference both produce
referents that are legal lvalues.  If the subroutine is defined as
modifying the referent[*], then how can the subroutine know that the
values are being discarded by the caller?  


> $ perl -e 'sub a($){print "@_\n"} a \@a'
> ARRAY(0x8161190)
> 
> $ perl -e 'sub a($){print "@_\n"} a []'
> ARRAY(0x8148a8c)
> 
> Both look alike, though the first is more powerful.


  $ perl -e 'sub a($){print "@_\n"} a(my $x = [])'

How do you know that the array reference is being thrown away by the
caller?  Shouldn't this be something the caller can do, if he wants
to?  E.g., the statement `close($fh);' throws away the return from
close() which is common on input files.  Why should close() worry
about it?  

Maybe what you really want is a way to determine if a subroutine is
being called in void context?  


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

[*] That's probably not a wise interface design in Perl, though.  

-- 
Garry Williams


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

Date: 12 Oct 2002 17:26:20 -0700
From: piranha@602.org (Jeremy Miller)
Subject: complex hash structure -- any ideas?
Message-Id: <f043146d.0210121626.787c204d@posting.google.com>

Hello,
I've recently taken on a project involving mapping out a network
device's
physical slots, ports, logical ports and pvcs.. Anyhow, I'm running
into a situation where I would like to present the data in a
hierarchical way so that it's easy to read and understand, but storing
the data in an elegant fashion is posing quite a challenge.  Here's
the output I would like to have:

SLOT    PPORT   LPORT   PVC     STATE
------- ------- ------- ------- -------
13 .... ....... ....... ....... up
        1 ..... ....... ....... up
                19 .... ....... down
        2 ..... ....... ....... up
                19 .... ....... down
                30 .... ....... down
                        200 ... inactive
14 .... ....... ....... ....... down
        2 ..... ....... ....... down
                37 .... ....... down
                        33 .... inactive
                        131147  inactive

As you can see, I need to be able to keep track of all "slots", each
"pport" on the "slot", each "lport" on each "pport", each "pvc" on
each "lport" and finally, the "state" of each item.  I currently have
all the above data in various hashes, and can print it individually,
but would like to combine them into one, so that I can have one main
loop to access and print the data in a nice way =)  Anybody have any
ideas/insight??

Thanks,
-jm


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

Date: Sun, 13 Oct 2002 02:30:01 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: complex hash structure -- any ideas?
Message-Id: <slrnaqhmei.4c0.garry@zfw.zvolve.net>

On 12 Oct 2002 17:26:20 -0700, Jeremy Miller <piranha@602.org> wrote:
> Hello,
> I've recently taken on a project involving mapping out a network
> device's
> physical slots, ports, logical ports and pvcs.. Anyhow, I'm running
> into a situation where I would like to present the data in a
> hierarchical way so that it's easy to read and understand, but storing
> the data in an elegant fashion is posing quite a challenge.  Here's
> the output I would like to have:
> 
> SLOT    PPORT   LPORT   PVC     STATE
> ------- ------- ------- ------- -------
> 13 .... ....... ....... ....... up
>         1 ..... ....... ....... up
>                 19 .... ....... down
>         2 ..... ....... ....... up
>                 19 .... ....... down
>                 30 .... ....... down
>                         200 ... inactive
> 14 .... ....... ....... ....... down
>         2 ..... ....... ....... down
>                 37 .... ....... down
>                         33 .... inactive
>                         131147  inactive
> 
> As you can see, I need to be able to keep track of all "slots", each
> "pport" on the "slot", each "lport" on each "pport", each "pvc" on
> each "lport" and finally, the "state" of each item.  I currently have
> all the above data in various hashes, and can print it individually,
> but would like to combine them into one, so that I can have one main
> loop to access and print the data in a nice way =)  Anybody have any
> ideas/insight??

Add sorting, if desired: 

  #!/usr/local/bin/perl
  use warnings;
  use strict;
  use Data::Dumper;

  my %elements = (
	  "192.168.50.173" => {
	      13 => {
		  STATE => "up",
		  1     => {
		      STATE => "up",
		      19    => {
			  STATE  => "down",
		      },
		  },
		  2     => {
		      STATE => "up",
		      19    => {
			  STATE  => "down",
		      },
		      30    => {
			  STATE  => "down",
			  200    => "inactive",
		      },
		  },
	      },
	      14 => {
		  STATE => "down",
		  2     => {
		      STATE => "down",
		      37    => {
			  STATE  => "down",
			  33     => "inactive",
			  131147 => "inactive",
		      },
		  },
	      },
	  },
	  );

  while ( my ($elt, $elt_val) = each %elements ) {
      print "$elt\n\n";
      print "SLOT    PPORT   LPORT   PVC     STATE\n",
	    "------- ------- ------- ------- -------\n";

      while ( my ($slot, $slot_val) = each %{ $elt_val } ) {
	  next if $slot eq "STATE";
	  printf "%-7d %s %s %s %s\n", $slot, '.'x7, '.'x7,
	      '.'x7, $slot_val->{STATE};

	  while ( my ($pport, $pport_val) = each %{ $slot_val } ) {
	      next if $pport eq "STATE";
	      printf "        %-7d %s %s %s\n", $pport, '.'x7, 
		  '.'x7, $pport_val->{STATE};

	      while ( my ($lport, $lport_val) = each %{ $pport_val } ) {
		  next if $lport eq "STATE";
		  printf "                %-7d %s %s %s\n", $lport,
		      '.'x7, $lport_val->{STATE};

		  while ( my ($pvc, $pvc_val) = each %{ $lport_val } ) {
		      next if $pvc eq "STATE";
		      printf "                        %-7d %s %s %s\n",
			  $pvc, $pvc_val;
		  }
	      }
	  }
      }
  }

-- 
Garry Williams


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

Date: Sun, 13 Oct 2002 00:35:24 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: Extensible event loop architecture
Message-Id: <slrnaqhftq.8ma.troc@eyrie.homenet>

On Sat, 12 Oct 2002 20:25:06 +0000 (UTC), Ilya Zakharevich wrote:
> Benjamin Goldberg wrote in article
> <3DA7AA41.B1CA3169@earthlink.net>:
>> No -- it means that the only kinds of events that POE *cares about* are
>> ones associated with filehandles.
> 
> Could you explain *why* some kinds of events are more important to POE
> than the others (even if the low-level loop is replaced)?

I can: Because they are common event types that POE supports by
default.

There exists an infinite number of uncommon events that POE does not
care about.  Users who need them must implement them as extensions.
This was explained in previous messages.

By the way, POE also handles signals, timers, and arbitrary user
events.  It's not solely limited to file events.

> But what makes them *events*?

Your extension makes them events.  It creates a public API to manage
them (for example: add lock, remove lock).  It creates a private API
to call the OS as needed.  This was explained in previous messages.

Your private API calls _data_ev_enqueue() to inject events into the
dispatch queue.

> You probably again think about a *full replacement* of an event loop.
> As you already see, this leads to not-scalable solutions.

select() is one of the least scalable ways to watch for I/O.  Its API
is one of the slowest and most cumbersome to work with.  And, as you
say, it is only limited to watching file descriptors.

Your favorite operating system probably has much more scalable and
featureful syscalls.  It may even have a syscall that can watch a
mutex and I/O at the same time.  I don't know why you would insist
that people not use these calls if they are available.

> What is needed is a way to *extend* the functionality of an existing
> event loop (probably already consisting of several cooperating
> subsystems).

Add a new cooperating subsystem.  Use OS threads if necessary.

> This API supposes that the event which triggers a subsystem is
> passed to the event-core via a specified callback (which can, e.g,
> write a word to a pipe)

I think what you call the "event-core" is POE::Kernel.  Bridges (and
new event types) use its _data_ev_enqueue() method to insert events
into its dispatch queue.  An example follows.

> There must also be a callback so that the core may inform the
> subsystem to stop (e.g., when the events served by the subsystem
> need to be reconfigured) and to start.

POE has loop_halt() and loop_run(), which are used to halt and restart
the event loop.

> The problem is that there definitely are *different* mechanisms of
> extension that the asyncroneous ones (such as implemented via
> threads or signal handlers).  I'm afraid that I'm blindfolded (by
> doing one particular implementation) and my API

POE bridges already support (and use) signal handlers.  Here is one,
with an example of a _data_ev_enqueue() call.

  $SIG{$signal} = \&_loop_signal_handler_generic;

  ...

  sub _loop_signal_handler_generic {
    $poe_kernel->_data_ev_enqueue
      ( $poe_kernel,  # Event source.
        $poe_kernel,  # Event destination.
        EN_SIGNAL,    # Event name.
        ET_SIGNAL,    # Event type.
        [ $_[0] ],    # Event parameters (signal name).
        __FILE__, __LINE__, time()   # Debugging information.
      );
    $SIG{$_[0]} = \&_loop_signal_handler_generic;
  }

You constantly seem to think POE needs things it already has.  Maybe
you should actually look at it.  I recommend the cvs version, which
has a more mature bridge API and better documentation than the CPAN
version.

  % export CVS_RSH=/usr/bin/ssh
  % cvs -d:pserver:anonymous@cvs.poe.sourceforge.net:/cvsroot/poe login
  (empty password)
  % cvs -d:pserver:anonymous@cvs.poe.sourceforge.net:/cvsroot/poe co poe

> E.g., suppose that select()-like events are expected very rare, but
> the sybsystem events should be processed in a tight loop.  Then a
> subsystem would like to be run in the main thread, and would like to
> relocate the event-core into a secondary thread.  Definitely there
> may be other scenarios as well.

POE's bridge API includes a loop_run() function, which lets an event
loop take over POE.  You are therefore free to write a new loop that
dispatches events in your own special way.

POE::Loop::Event

  sub loop_run {
    Event::loop();
  }

POE::Loop::Gtk

  sub loop_run {
    Gtk->main;
  }

POE::Loop::Tk

  sub loop_run {
    Tk::MainLoop();
  }

POE::Loop::Select and POE::Loop::Poll (their loop_do_timeslice()
functions are very different)

  sub loop_run {
    my $self = shift;
    while ($self->_data_ses_count()) {
      $self->loop_do_timeslice();
    }
  }

>> If SMTT only cares about only F events, then it can use POE as a
>> backend, regardless of what POE, in turn, uses as a backend.
> 
> But SMTT may use different kind of events, e.g., if it plots via Tk on
> Windows.

POE already supports replacing select() with Tk calls, so both SMTT
and POE can share Tk.  Therefore:

SMTT can use Tk callbacks.
SMTT can use POE events.
SMTT can make Tk callbacks generate POE events.

-- Rocco Caputo / troc@pobox.com / poe.perl.org / poe.sf.net


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

Date: Sun, 13 Oct 2002 01:23:56 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Extensible event loop architecture
Message-Id: <aoahvc$13s9$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Benjamin Goldberg 
<goldbb2@earthlink.net>], who wrote in article <3DA89463.7721427F@earthlink.net>:
> > You cannot wait simultaneously on a mutex and select(); so if the
> > select()-like functionality goes through POE, and the rest through a
> > "plugged-in subsystem", then the communication should go via a special
> > pipe.
> 
> You can't *extend* POE's event loop, you can only replace it with a
> custom event loop.  I was suggesting replacing it with a custom event
> loop which is slightly more scalable (but is dependent on the existance
> of preemptive OS level threads).

I see.  My experience with my projects where an event loop engine
would be handy is that to be scalable/portable, *all* of them require
an extensible event loop.  This is why I never went any further in
implementing these projects.  :-(

So from my POV, an event engine is useless unless it is extensible.
Of course, for a lot of stuff any architecture-neutral substitute to
select() comes handy...

> PS: As far as I know, the system I'm suggesting *is* fully scalable, if
> you don't need a perl interpreter in any of those lightweight threads.

As far as the subsystems are asyncroneous *and* interruptable, yes,

> Each helper thread would perform it's blocking operation, then gain the
> event queue lock, then add an event to the queue, then signal the event
> cond, then unlock.

As I said, this is not enough.  What if the application disables the
callback which the subsystem triggers?  You need to unblock the
blocked operation.  On some architectures this is possible, on some
not (e.g., signals may be not delivered to threads != 1).

> The main thread would acquire the event queue lock, wait for the cond if
> there are no queued events, copy out one event and decrement the number
> of items in the queue, then unlock and return the event.
> 
> (To cancel events on a filehandle, the simplest way I can think of is to
> lock the queue, kill the thread which is doing select(),

Killing threads

 a) is not portable;

 b) can easily lead to a deadlock;

In the API I discussed in the previous message, the subsystem should
have a callback "stop me".  E.g., a subsystem waiting by select()
could open a pipe to itself, and would wait *also* for the pipe to
become readable; the callback will write to the pipe.  A subsystem
waiting for a semaphore would again create an extra "wakeup"
semaphore, and would actually wait on the combination of the requested
semaphore *and* on a wakeup one.

Do not know how to wakeup a thread which waits on flock() to complete...

> > As you already see, this leads to not-scalable solutions.  What is
> > needed is a way to *extend* the functionality of an existing event
> > loop (probably already consisting of several cooperating subsystems).
> 
> Then design an *extensible* replacement, and use that replacement, and
> if you need any extending, then extend it.  Just because POE's default
> event loop isn't itself extensible doesn't prevent you from switching to
> something which is.

There is none.  And I physically cannot fix *all* the broken things
around...  But the scheme you propose below looks quickly doable.

> Eh?  Main thread reads events from the queue.  Helper threads put events
> into the queue.  Main thread needs not know how those helper threads
> work.  It just looks in the queue and returns event structs.

So in your design all the subsystems are created equal; a fully
symmetric scheme, not one modeled on "extend me" scheme.  A "central
dispatcher" which handles all the subsystems.

The only drawback of this scheme I can immediately see is the
duplication of the overhead: all the events go through 2 event
handlers: first of all, a "native" handler (such as select()), then
the central dispatcher (which, e.g., reads sizeof(event_t*) bytes from
a pipe).  As I said, in many situations it is important to have the
central dispatch to also handle "the most important" type of events.
E.g., the select()-based subsystem may work as the central dispatcher
too if it convinces other subsystems to communicate via a pipe.

One needs a way to switch which of the subsystems duplicates as the
central dispatcher on the fly.  Hmm, it is enough to interrupt all the
other subsystems, and re-register a different on_event_callback with
these subsystems.

So it looks like as far as all the subsystems may work asyncroneously,
it is enough to design the API for the subsystem requesting that it
works as a central dispatcher (so becomes a syncroneous one).

> > But SMTT may use different kind of events, e.g., if it plots via Tk on
> > Windows.

> If it uses other types of events, then you should have said so. 
> Changing the problem domain is *not* helping your argument.

Well, this is the initial specification as I wrote it (to start this
discussion).  You probably missed it then...

Ilya





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

Date: Sun, 13 Oct 2002 01:31:24 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Extensible event loop architecture
Message-Id: <aoaidc$141u$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Rocco Caputo 
<troc@netrus.net>], who wrote in article <slrnaqhftq.8ma.troc@eyrie.homenet>:
> There exists an infinite number of uncommon events that POE does not
> care about.  Users who need them must implement them as extensions.
> This was explained in previous messages.
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I'm afraid this is an overstatement.

> You constantly seem to think POE needs things it already has.  Maybe
> you should actually look at it.

i compiled the docs into the online book.  This is 250K when
*compressed*.  I'm afraid this is close to be useless if one navigates without a pilot.

> I recommend the cvs version

I will try to navigate it again having what you wrote at hand...

Thanks for your suggestions,
Ilya


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

Date: Sat, 12 Oct 2002 16:11:46 -0700
From: "Emily, Amanda" <aemily@colsd.org>
Subject: Re: Help parsing HTML
Message-Id: <3da8a5fb_2@news.vic.com>

Thanks for the suggestion Dominik, but I found another way to make it work.

Below is what I did

#!C:\perl\bin\perl.exe

system("wget -q http://weather.yahoo.com/forecast/USWA0088_f.html -O
c:\weather_temp.txt");

$/ = "";

open (FORECAST, 'c:\\weather_temp.txt') || die "Uh... file not found.\n";
$string = <FORECAST>;
close (FORECAST);

$string =~ s¡ \n¡ ¡g;
$string =~ s¡\n ¡ ¡g;
$string =~ s¡\n¡¡g;
$string =~ s¡<![- ]+TEXT FORECAST[- ]+><font face="arial">¡¦¿¡g;
$string =~ s¡</font><![- ]+ENDTEXT FORECAST[- ]+>¡¿¦¡g;

@Array = split (/¦/, $string);

foreach $element (@Array)
 {
  if (index ($element, "¿") gt -1)
   {
    $element =~ s¡¿¡¡g;
    $element =~ s¡^\s+¡¡;
    print "  $element\n";
   }
 }

exit;




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

Date: Sun, 13 Oct 2002 01:07:50 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Help parsing HTML
Message-Id: <3101479.HYS3cVF16N@nyoga.dubu.de>

Emily, Amanda wrote:
> <!-- TEXT FORECAST-->
                    ^ no space here
[...]
> <!-- ENDTEXT FORECAST-->
                       ^ neither here

> I am trying to grab everything between the comments and output it.

You maybe want to use HTML::Parser oder HTML::TokeParser.

> The perl script that I tried to use is as follows:
> 
> #!C:\perl\bin\perl.exe
> 
> system("wget -q http://weather.yahoo.com/forecast/USWA0088_f.html -O
> c:\weather_temp.txt");
> open(FILE, 'c:\\weather_temp.txt') || die "Uh... file not found.\n";
>   while( <FILE> )
>    {
>    print if
>      /<!-+\s+TEXT FORECAST\s+-+>/i
                            ^^^ you want at least one whitespace here
>          ..
>          /<!-+\s+ENDTEXT FORECAST\s+-+>/i;
                                   ^^^ same here

Maybe you want \s* instead of \s+.

Ciao,
        Harald

PS: My comments will only make sense when viewed using a monospaced 
font. :)

-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Face it, Bill Gates is a Persian cat and a monocle away from being
a villain in a James Bond movie.
                -- Dennis Miller


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

Date: Sun, 13 Oct 2002 03:24:50 +0200
From: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: Help parsing HTML
Message-Id: <3DA8CB62.7080501@netscape.net>

Emily, Amanda announced:
> Thanks for the suggestion Dominik, but I found another way to make it work.
> 
> Below is what I did
> 
> #!C:\perl\bin\perl.exe
> 
> system("wget -q http://weather.yahoo.com/forecast/USWA0088_f.html -O
> c:\weather_temp.txt");
> 
> $/ = "?";
> 
> open (FORECAST, 'c:\\weather_temp.txt') || die "Uh... file not found.\n";
> $string = <FORECAST>;
> close (FORECAST);
> 
> $string =~ s¡ \n¡ ¡g;
> $string =~ s¡\n ¡ ¡g;
> $string =~ s¡\n¡¡g;
> $string =~ s¡<![- ]+TEXT FORECAST[- ]+><font face="arial">¡¦¿¡g;
> $string =~ s¡</font><![- ]+ENDTEXT FORECAST[- ]+>¡¿¦¡g;
> 
> @Array = split (/¦/, $string);
> 
> foreach $element (@Array)
>  {
>   if (index ($element, "¿") gt -1)
>    {
>     $element =~ s¡¿¡¡g;
>     $element =~ s¡^\s+¡¡;
>     print "  $element\n";
>    }
>  }
> 
> exit;
> 
> 
Hello,

you don't have to use wget. LWP::Simple can read web pages for you:

#!perl -w
use strict;
use LWP::Simple;
my $content = get("http://weather.yahoo.com/forecast/USWA0088_f.html");
die ('could not get any data') unless $content;
my ($forecast)=($content=~/<!-- TEXT FORECAST-->(.*?)<!-- ENDTEXT
FORECAST-->/s);
print $forecast;

That's shorter and you don't even need the temporary file...

Dominik






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

Date: Sun, 13 Oct 2002 00:34:46 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Help! How do you move one html page to another in Perl?
Message-Id: <Pine.LNX.4.40.0210130014380.30100-100000@lxplus073.cern.ch>

On Oct 12, Zordiac inscribed on the eternal scroll:

> >  How do I decode a CGI form?
> >  You use a standard module, probably CGI.pm. Under no
> >  circumstances should you attempt to do so by hand!
>
> Jeff my perl cgi script has to work on different machines
> how can the script be portable - I know I never mentioned
> this before - if it needs the CGI module downloaded.

If there isn't a CGI.pm module available in the Perl installation,
then it's quite an old version of Perl.  The best advice would be to
install a newer version of Perl.  If you cannot do that yourself for
policy reasons, then look at the Perl FAQ item about installing a
module on a private path and adjusting your script to point to that
private copy.  It's very easy - just calmly follow the instructions.

< http://www.perldoc.com/perl5.8.0/pod/perlfaq8.html
#How-do-I-keep-my-own-module-library-directory- >

> Thank you for the script. I just got it working but had to
> move the -T bit on first line.

If you're a newcomer to CGI programming, then -T is a most valuable -
I'd go so far as to say _the_ most valuable contribution to security
that you can use.  Occasionally it will appear to cause you grief, but
it's worth it to protect yourself from using user-supplied data in
ways that are potentially dangerous not only to your script but to
your reputation...

> ME > b) take user input from any page
>
> By this I meant the script is invoked and user input is taken
> from the first html displayed page.

Try to think of the sequence of events as they happen.  In the CGI
model, some user/client/agent will request a URL from the server, the
server recognises this as a request to invoke a CGI script, possibly
with a query string and so on, prepares the input for your script and
then invokes it.  The input is right there waiting for the script to
use: it's confusing to talk in terms of "taking user input from a
page" as if you needed to go out there somehow and get it.  The script
runs - usually for a brief time, producing a result - which is usually
a new web page, or might be some other kind of transaction response
such as a redirection (Location: response), and then terminates.  Now
the ball is in the client's court again.

> A button is clicked and the
> script POSTs this in effect back to itself

By all means - this is often a useful way of organising things.

> - as I could not figure out another way of doing this.

No problem...

It's just that you seem to be describing the procedure in a somewhat
confusing way, and I was worrying that you might be confusing yourself
as much as you were confusing me.

good luck, but for questions about CGI that are not specifically
Perl-language related you really should be looking at the
comp.infosystems.www.authoring.cgi group (check its posting
guidelines).



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

Date: Sat, 12 Oct 2002 18:15:01 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Help! How do you move one html page to another in Perl?
Message-Id: <3DA8C915.1000802@vpservices.com>

Zordiac wrote:

> Again thanks one and all for the comments - please bear 
> with me as I would like to clarify some things:
> 
> 
> Jeff wrote
> 
>>The FAQ says:
>> How do I decode a CGI form?
>> You use a standard module, probably CGI.pm. Under no
>> circumstances should you attempt to do so by hand!
>>
> 
> Jeff my perl cgi script has to work on different machines
> how can the script be portable


CGI.pm should be available anywhere perl is.  If not, just download it 
into your own directory and read perldoc modinstall.

> Thank you for the script. I just got it working but had to
> move the -T bit on first line.


The -T bit is for Taint which means if your program doesn't work with 
it, your program is tainted, i.e. has potentiall security holes.  You're 
much better off trying to get your program to work with it, see perldoc 
perlsec.

> What I want to do is get a user
> to input a file name on one page and then 


untaint the filename so you know it isn't passing dangerous values, and 
then ...

> display a record from
> that file on another page. And allow the user to select another
> record and have that displayed. Theres more to it than that but
> thats the basics.


CGI.pm will happily work for all that.

-- 
Jeff




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

Date: Sat, 12 Oct 2002 18:59:54 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: How to create a bundle?
Message-Id: <aoa9iq$kp4gl$1@ID-159100.news.dfncis.de>

I found just a little section in the CPAN pod, nothing at all in the faq,
and almost nothing more in the google NG search.

Where could I find some more documentation about the creation of CPAN
bundles?

Thank you

--
-.. --- -- .. --.. .. ---
-.. . -- .. -.-. .... . .-.. .. ...






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

Date: Sat, 12 Oct 2002 17:06:15 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: How to get perldb's x programmatically?
Message-Id: <121020021706153686%comdog@panix.com>

In article <GMVp9.516365$Ag2.20052735@news2.calgary.shaw.ca>, Peter Scott <peter@PSDT.com> wrote:

> In article <111020021755135916%comdog@panix.com>,
>  brian d foy <comdog@panix.com> writes:
> >In article <ao6tvu$c37$1@reader1.panix.com>, Da Witch <heather710101@yahoo.com> wrote:

> >> I prefer the formatting used by Perl's debugger's "x" command than
> >> that produced by Data::Dumper.  Where is the code responsible for
> >> generating the output of the "x" command?

> >the debugger is just a perl script that should be in your perl5 lib.
> >look for perl5db.pl.

> That approaches cruel and unusual punishment.  See how long it takes to
> trace through perl5db.pl to see what happens with the x command.

it doesn't take that long.  if you want to know how the debugger does something,
just look in the script. :)

-- 
brian d foy <comdog@panix.com> - Perl services for hire
The Perl Review - a new magazine devoted to Perl 
<http://www.theperlreview.com>


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

Date: Sat, 12 Oct 2002 22:56:58 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: newb here learning Perl
Message-Id: <aoa9bq$sk6$1@plover.com>

In article <anu7s0$arm$01$1@news.t-online.com>,
=?ISO-8859-1?Q?Johannes_F=FCrnkranz?=
  <johannes.fuernkranz@t-online.de> wrote:
>John W. Krahn wrote:
>> 
>> news:comp.lang.perl.moderated sends an E-Mail/FAQ thing when you post
>> for the first time.
>
>I've tried to post there several times, never received anything.
>I tried to register by sending E-mail to the administrators, never 
>received a reply.

What address did you use?  I'm an administrator, and I've never seen
any mail from you.

The correct address (as announced in the instructions that are posted
to the group every week) is

        mjd-clpm-admin@plover.com

>The part I liked most about the welcome-message was:
>
>6. Will I receive a rejection notice if my submission is rejected?
>Absolutely.  Always.  Without fail.  Yes.  In case this isn't clear:
>     POSTS ARE NEVER REJECTED SILENTLY.
>
>
>They sure had me on that one...

I take exception to whatever your insinuation is here.  

If you didn't receive a reply, it's not because your post was silently
rejected; it's because we never moderated your post at all, either
because it didn't arrive here, or because we didn't receive your reply
to the registration message.

According to the logs, two of your articles have arrived here, nd
they're still being held, waiting for you to reply to the registration
messages.  My mail logs don't go back as far as August, so I don't
know whether the machine here was able to deliver the registration
instructions to you or not.  Please send me email so that we can work
out whatever the problem is.

(That goes for anyone else who has been unable to post to
comp.lang.perl.moderated.)

I'm going to repeat that again:  POSTS ARE NEVER REJECTED SILENTLY.

Never.  We've rejected about 1250 articles total over the lifetime of
the group, and as far as I know, every one of them has received a
reply, except for four or five that were obviously spam.

Hope this helps.




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

Date: Sat, 12 Oct 2002 23:07:19 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: newb here learning Perl
Message-Id: <aoa9v7$trl$1@plover.com>

In article <vTpo9.92433$O8.2209253@twister.tampabay.rr.com>,
Frito - Lay <ChrisFL@cfl.rr.com> wrote:
>  Hello all!
>I am learning Perl and was directed to this newsgroup by an e-book. It said
>something about an E-Mail/FAQ thing I will get when I post for the first
>time, so I am posting. I hope to learn and become proficient at Perl, and I
>will return to this newsgroup whenever I need help, or just want to see
>whats happening.

One of the attendees at a class I taught last week suggested that
there should be a mailing list that sends out a weekly Perl quiz or
problem to solve, and that sounded like a good idea, so I just set it up.

To subscribe to the quiz-of-the-week list, send a note to

        perl-qotw-subscribe@plover.com



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

Date: Sat, 12 Oct 2002 22:55:34 GMT
From: Rob <rsteinmetz@mindspring.com>
Subject: Perl 5.8 test failure
Message-Id: <3DA8A863.1010200@mindspring.com>

I have a web server running an old version of Suse Linux, I got caught 
in a upgrade cascade trying to add some capabilities.

I wanted to up upgrade the Perl installation to 5.8 and it compiled 
without failure but make test failed on Users:pwent. It was the only 
failure.

I ran the additional test recommended but it did not give any more 
information. I also tried to compile 5.6.1, with identical results.

Any suggestions on what may be wrong or how to go about tracking it down?

-- 
Rob

"Never ascribe to malice that which can be adequately explained by stupidity"



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.

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 V10 Issue 3961
***************************************


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