[14029] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1439 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 19 21:08:45 1999

Date: Fri, 19 Nov 1999 18:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <943063511-v9-i1439@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 19 Nov 1999     Volume: 9 Number: 1439

Today's topics:
    Re: adjusting HTML (Abigail)
    Re: developer required for advanced Perl work <cassell@mail.cor.epa.gov>
    Re: environment vars <cassell@mail.cor.epa.gov>
    Re: file descriptors already used when perl starts (Abigail)
    Re: file descriptors already used when perl starts (Ilya Zakharevich)
    Re: file descriptors already used when perl starts lee.lindley@bigfoot.com
    Re: Getting HTML tags via regular expression <cassell@mail.cor.epa.gov>
    Re: Help me read my database please <jeff@vpservices.com>
    Re: How do I change the date in script so it adds 8 hou <nandu@cimedia.com>
    Re: html via perl <cassell@mail.cor.epa.gov>
    Re: Is there no  length()  function? (Mark-Jason Dominus)
    Re: Keeping string on same line <slanning@bu.edu>
    Re: legal names and about sorting <cassell@mail.cor.epa.gov>
    Re: Limiting Search Results (Thunderdust (TomH))
    Re: perl optimizes away need for /o? was [/o in regexp  <cassell@mail.cor.epa.gov>
    Re: Perl programming sytle <cassell@mail.cor.epa.gov>
    Re: Perl programming sytle <cassell@mail.cor.epa.gov>
        Perl/CGI Programmers Wanted <jamesholmes@mail.com>
    Re: Perl/CGI Programmers Wanted <kbandes@home.com>
    Re: Ping under Win NT without ICMP (Kragen Sitaker)
    Re: Please Help ~~~~~~~ <cassell@mail.cor.epa.gov>
    Re: Q: how to get tied variable within FETCH <ken@bitsko.slc.ut.us>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 19 Nov 1999 19:33:56 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: adjusting HTML
Message-Id: <slrn83buqe.l1a.abigail@alexandra.delanet.com>

Gisle Aas (gisle@aas.no) wrote on MMCCLXXI September MCMXCIII in
<URL:news:m3n1sa7q48.fsf@eik.g.aas.no>:
'' David Cassell <cassell@mail.cor.epa.gov> writes:
'' 
'' >                                                  To get it right
'' > in the general case, you need something which can do the tokenizing
'' > which HTML::Parser does.  BTW, it is not really a parser of HTML,
'' > so the name is somewhat misleading.
'' 
'' ISO 8879 define "SGML parser" like this:
'' 
'' |  4.285 SGML parser: A program (or portion of a program or a
'' |  combination of programs) that recognizes markup in SGML documents.
'' |
'' |  NOTE - If an analogy where to be drawn to programming language
'' |  processors, an SGML parser would be said to preform the functions of
'' |  both a lexical analyzer and a parser with respect to SGML documents.
'' 
'' I think that HTML::Parser is a _parser_ according to this definition,
'' and that the name is _not_ misleading.


I can see the lexical analyzer part, but I don't see where HTML::Parser
parses. All it does is making call backs on encountering _tokens_,
but never on any syntactical constructs.

And last time I checked, it was unware of CDATA declared content. Which
is a requirement to even tokenize HTML.


Since it tokenizes instead of parsing, and doesn't tokenize HTML, I
maintain that the only part of 'HTML::Parser' that isn't misleading
is the '::' part.



    #!/opt/perl/bin/perl -w

    use strict;
    use HTML::Parser;

    use vars qw /@ISA/;

    @ISA = qw /HTML::Parser/;

    my $parser = "main" -> new;

    $parser -> parse (<<HTML);
    <TITLE>Title</TITLE>
    <BODY>
    <SCRIPT>
      This is CDATA.
      <P>
      More CDATA.
    </SCRIPT>
    </BODY>
    HTML

    $parser -> eof;

    sub start {print "This is wrong.\n" if uc $_[1] eq 'P';}
    sub text  {print "This is wrong.\n" if $_ [1] =~ /CDATA/;}

    __END__
    This is wrong.
    This is wrong.
    This is wrong.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Fri, 19 Nov 1999 15:44:52 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: developer required for advanced Perl work
Message-Id: <3835E0F4.397431C3@mail.cor.epa.gov>

Scott McMahan wrote:
[snip]
> That's always the rub -- they want advanced knowledge, but want
> to pay basic rates.

So they end up with programmer-wannabes with only basic knowledge,
and end up overpaying them.  Sounds fair to me.  :-)

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 19 Nov 1999 15:50:24 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: environment vars
Message-Id: <3835E240.B291908@mail.cor.epa.gov>

Martien Verbruggen wrote:
[snip]
> We've seen it here more than once (in fact, we just had one good example
> by the name of Re'em Bar). If you don't tell them to read the docs, they
> just keep asking. I don't know whether this particular poster would
> have, but it's still better to understand, and to learn how to answer
> your own questions.
> 
> And I'll be damned if I get that fish metaphor out of the closet again.
> It's dusty.
> 
> Give a person a banana, and they slip. Show a person a banana tree and
> they can learn how to climb.

Okay, I think it's time for the sing-along.  Everybody!

Just a Spoonful of perldoc
[to the tune of 'A Spoonful of Sugar' from 'Mary Poppins']

The newbie strug-gling with Perl
until he's just about to hurl,
he's sickened by this code that is a pox,
but if he'd only use the docs
he'd sprint out of the blocks,
He'd get
a life
instead of all this strife...

Just a spoonful of perldoc helps the documents get read
the documents get re-ead
the documents get read.
Just a spoonful of perldoc helps the documents get read
in a most convenient way!

The worker hammering on code
to earn the money he is owed,
he feels this nut is just to hard to crack,
but if he'd only read the FAQ
he'd find out how to hack...
It's fast!
It's fun!
It's clear to everyone...

that a  spoonful of perldoc helps the documents get read
the documents get re-ead
the documents get read.
Just a spoonful of perldoc helps the documents get read
in a most convenient way!

David, yes I am spending lots of time with my four-year-old,
why do you ask?
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 19 Nov 1999 17:18:04 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: file descriptors already used when perl starts
Message-Id: <slrn83bmrn.l1a.abigail@alexandra.delanet.com>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MMCCLXXI September
MCMXCIII in <URL:news:814jtn$7op$1@charm.magnus.acs.ohio-state.edu>:
// [A complimentary Cc of this posting was sent to Abigail
// <abigail@delanet.com>],
// who wrote in article <slrn83bfl4.l1a.abigail@alexandra.delanet.com>:
// >    "By convention the Unix shells associate file descriptor 0 with
// >     the standard input of a process, file descriptor 1 with the
// >     standard output, and file descriptor 2 with the standard error.
// >     This is a convention employed by the Unix shells and many Unix
// >     applications -- it is not a feature of the kernel.
// 
// 
// Unless you consider xterm as a shell.  Did you say that when kernel
// starts a user's shell, it has no stdin/stdout/stderr associated to it,
// but has a prepared tty?  Possible.  But is it probable?

No, I did not say that, nor did Stevens say that. All he said was
that the kernel doesn't necessarely map stdin/stdout/stderr to file
descriptors 0/1/2.

However, further reading of Stevens suggest that the entire
stdin/stdout/stderr concept is something that lives in the stdio library,
and isn't something the kernel is aware of.

Oh, BTW, the kernel doesn't start a users shell. The shell is started
from login (or telnetd, or some other daemon), which is started from getty,
which is started from init (or inetd in case of certain daemons).


Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 19 Nov 1999 23:38:50 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: file descriptors already used when perl starts
Message-Id: <814n2a$9ns$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Abigail
<abigail@delanet.com>],
who wrote in article <slrn83bmrn.l1a.abigail@alexandra.delanet.com>:
> // >    "By convention the Unix shells associate file descriptor 0 with
> // >     the standard input of a process, file descriptor 1 with the
> // >     standard output, and file descriptor 2 with the standard error.
> // >     This is a convention employed by the Unix shells and many Unix
> // >     applications -- it is not a feature of the kernel.
> // 
> // 
> // Unless you consider xterm as a shell.  Did you say that when kernel
> // starts a user's shell, it has no stdin/stdout/stderr associated to it,
> // but has a prepared tty?  Possible.  But is it probable?
> 
> No, I did not say that, nor did Stevens say that. All he said was
> that the kernel doesn't necessarely map stdin/stdout/stderr to file
> descriptors 0/1/2.
> 
> However, further reading of Stevens suggest that the entire
> stdin/stdout/stderr concept is something that lives in the stdio library,
> and isn't something the kernel is aware of.

Definitely.  Read what I wrote above as fd 0/1/2 being open to /dev/tty.

> Oh, BTW, the kernel doesn't start a users shell. The shell is started
> from login (or telnetd, or some other daemon), which is started from getty,
> which is started from init (or inetd in case of certain daemons).

Fine.  So this is a question about telnetd/login/etc.  Do the programs
started by them have fd 0/1/2 open to /dev/tty?

Ilya


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

Date: 20 Nov 1999 01:03:02 GMT
From: lee.lindley@bigfoot.com
Subject: Re: file descriptors already used when perl starts
Message-Id: <814s06$l60$1@rguxd.viasystems.com>

Abigail <abigail@delanet.com> wrote:
:>lee.lindley@bigfoot.com (lee.lindley@bigfoot.com) wrote on MMCCLXXI
:>September MCMXCIII in <URL:news:812dqr$r82$1@rguxd.viasystems.com>:
:>--
:>-- Nevertheless, I cannot remember reading any specification that
:>-- guarantees any file descriptor numbers other than 0,1 and 2.

:>Which specification says that?

The one that I cannot remember reading of course.  :-)

:>   "By convention the Unix shells associate file descriptor 0 with
:>    the standard input of a process, file descriptor 1 with the
:>    standard output, and file descriptor 2 with the standard error.
:>    This is a convention employed by the Unix shells and many Unix
:>    applications -- it is not a feature of the kernel. Nevertheless,
:>    many Unix applications would break if these associations weren't
:>    followed.
[snip Stevens attribution]

OK.  It isn't in a specification.  But any operating system that
doesn't give you 0, 1 and 2 for stdin, stdout and stderr, well, like
Stevens says, it will break stuff.  This convention might as well be
a specification.   With C compilers I've used on MVS, FD=0 is 
associated with SYSIN, FD=1 is SYSOUT and FD=2 is either SYSTERM
or its equivalent.  I would bet that C compilers under MS operating
systems emulate the same behavior, but I haven't used one in a long
time.


:>--                           I think that there is a convention that the
:>-- next lowest available number is returned, but I don't know of any
:>-- guarantees.

[snip]
:>    The new file descriptor returned by dup is garanteed to be the
:>    lowest numbered available file descriptor. With dup2 we specify
[snip Stevens attribution]

Thanks for that.  Now can you explain the truss output I showed?
I can only suppose that 4,5 and 6 were opened by one of my parent
processes.  I tried poking around in them and found that 5 was
a dup of 0 (I think -- it read from the keyboard anyway -- it could
have something to do with the tty driver). 

Just a moment.  Ahhhh.  Guess supported by:
rgsun40{ltl}ksh: truss echo true
execve("/usr/bin/echo", 0xFFBEF984, 0xFFBEF990)  argc = 2
open("/dev/zero", O_RDONLY)                     = 3
mmap(0x00000000, 8192, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0xFF
3A0000
open("/usr/dt/lib/libc.so.1", O_RDONLY)         Err#2 ENOENT
open("/usr/openwin/lib/libc.so.1", O_RDONLY)    Err#2 ENOENT
open("/usr/local/rg/lib/libc.so.1", O_RDONLY)   Err#2 ENOENT
open("/usr/lib/libc.so.1", O_RDONLY)            = 7
[snip truss output]

Since a simple csh command exhibits the same behavior and since
we have some evidence that the next lowest available FD is supposed
to be used (assume open works like dup is supposed to), then maybe
we can stretch a bit and assume that inet or the tty driver or
something is using FD's 4,5 and 6.

Does Stevens also make any comments about the advisability of
coding any logic that depends on the numbers contained in file
descriptors?  It seems best to just ignore the actual numbers
and use them as blind tags like they were intended.  (Unless
you are writing Kernel code in which case you aren't using
Perl and this subject is off topic.)

-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: Fri, 19 Nov 1999 16:27:22 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Getting HTML tags via regular expression
Message-Id: <3835EAEA.3691590A@mail.cor.epa.gov>

davidairth@my-deja.com wrote:
> 
> I am trying to parse HTML files and get a list of all of the tags,
> pretty simple.  I am using regular expressions and just about have it,

Probably not.  It's not as simple as you make it sound.

[snip]
> basically, the parsing doesn't stop when it hits the second > tag:
> 
> I am trying: </?b.+>
> 
> Any ideas?

Yes.  First, your regex will not match <b> or </b> , much
less <B> or </B> .  Your regex matches '<', then an optional
'/', then a lower-case 'b', then at least one more character,
and then '>'.  Drop the '.+' part.

But this will only match the lower-case examples, since you
have nothing shown to handle case. [Read about the /i modifier
in the perlre pages to find out about this.]  And it doesn't
handle any other cases.  And none of these will cope with
the examples in the FAQ which will break your regexes.
Use the perldoc program to read this.

perldoc -q HTML.+string

This talks about removing HTML from a string, but it is
really the same problem.  To get all possible cases, you'll
need to use something more like HTML::Parse or HTML::Parser .

Only if you can guarantee that you know all allowed cases
for your data, and that they are well-behaved enough to
encapsulate in regexes, should you go the regex route.
Otherwise you'll get burned somewhere.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 19 Nov 1999 23:38:37 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Help me read my database please
Message-Id: <3835DF32.3B015D46@vpservices.com>

Surfy wrote:
> 
> 1) Open the pipe-delimited database (which already exists) for reading
> 2) Look through it until it finds the right record
> 3) Stop looking once it's found it (each record has a unique id)
> 4) Split the record into individual variables (not an array)
> 5) Close the database

Ok, that's a pretty good plan.  I am going to show you two ways to do it
BUT you must swear on a stack of camels not to just copy my code and
instead learn for yourself why and how it works.

This script assumes that the first line of the pipe database is the
field names e.g something like "id|fruit_name|color" or whatever your
fields are called.

It uses a routine "get_record()" -- you just feed it the directory of
the pipe database, its file name, the name of the field that contains
the id, and the value of the id you are looking for.  It returns a hash
containing all of the fields in the selected record or, if no record is
found, an error message.

get_record() uses the split function on the textfile.  A much more
powerful method is presented in the routine get_record_dbi().  To use
that, you will need to install the modules DBI.pm and DBD::CSV.pm.  Then
change the get_record() in the script to get_record_dbi() and remove the
line that currently says "__END__".  Otherwise, it functions just like
the get_record() routine.

The DBI version would allow you to do many other things with your
database.  Both versions will work regardless of the names or numbers of
fields in your database.

--- start of script ---

#!/usr/local/bin/perl -w
use strict;
my %record = &get_record(    # CHANGE THESE PARAMETERS:
    './',           #    DIRECTORY WHERE FILE IS STORED
    'fruits',       #    FILE NAME
    'id',           #    NAME OF ID FIELD
    '2',            #    VALUE OF ID SOUGHT
);
if( !defined %record ){ print "No matching records found!"; }
else {
    # CHANGE THIS TO PRINT WHATEVER YOU WANT
    # USING FIELD NAMES LIKE THIS: $record{field}
    print "$record{color} is the color of $record{fruit_name}!"
}

sub get_record {
    my($data_directory,$table,$id_field,$id_sought) = @_;
    my(@field_names,%var,$start);
    open(I,"<$data_directory$table") 
       || die "Couldn't open [$data_directory$table]: $!";
    while(<I>){
        chomp;
        if( !$start ) { 
            @field_names = split /\|/;
            $start++;
            next;
        }
        my @row = split /\|/;
        for my $i ( 0 .. $#row ) {
            $var{$field_names[$i]} = $row[$i];
        }
        if( $var{$id_field} eq $id_sought ) { return %var; }
    }
    return ();
}

__END__
sub get_record_dbi {
    use DBI;
    my($data_directory,$table,$id_field,$id_sought) = @_;
    my $dbh = DBI->connect(
        qq#DBI:CSV:f_dir=$data_directory;csv_sep_char=\\|#,
        undef,undef,{RaiseError=>1}
    );
    my $sth = $dbh->prepare(
        "SELECT * FROM $table WHERE $id_field = ?"
    );
    $sth->execute($id_sought);
    return %{$sth->fetchrow_hashref};
}

--- end of script ---

-- 
Jeff


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

Date: 19 Nov 1999 18:02:13 -0500
From: Nandu Shah <nandu@cimedia.com>
Subject: Re: How do I change the date in script so it adds 8 hours on.
Message-Id: <m366yym6fe.fsf@budgie.cimedia.com>

Jeff Pinyan <jeffp@crusoe.net> writes:

> > Where would I put the +8 to make it GMT??
> 
> Well, you merely add the number of seconds in 8 hours to the argument to
> ctime():
> 
>   ctime(time + 8 * 60 * 60)

If you actually want GMT, use gmtime in scalar context (in case your
script moves to a different time zone):

   scalar (gmtime (time))

     or, if you're always using time(), just

   scalar (gmtime)

Nandu


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

Date: Fri, 19 Nov 1999 16:09:18 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: html via perl
Message-Id: <3835E6AE.E7CD0DEF@mail.cor.epa.gov>

Jeremy Gurney wrote:
> 
> In article <38348F80.FB27ECEC@mail.cor.epa.gov>,
>   David Cassell <cassell@mail.cor.epa.gov> wrote:
[snip]
> > But this is still not a Perl question, and as such you'll
> > usually get better, more direct answers asking HTML questions
> > in an HTML newsgroup.  I hope.
> 
> I disagree. In this instace it didn't really matter what was being
> printed it was the fact that the output needed both interpolated strings
> and double quotes - which I would say was a Perl issue.

Okay, I'll give you that one.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 19 Nov 1999 23:19:02 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Is there no  length()  function?
Message-Id: <814ls6$9v1$1@monet.op.net>

In article <3834D2EC.127BEA8E@home.com>,
Rick Delaney  <rick.delaney@home.com> wrote:
>[posted & mailed]
>Well, that's easy enough to test.
>
>    sub foo {
>        print wantarray;
>    }
>    print defined(foo);

I'm not trying to nitpick, but you have to be real careful with that.
Try this:

	sub foo {
	  my $context = wantarray ? 'list' : 'scalar';
	  print "I've been called in $context context.\n";
	}
	print defined(&foo);


Sometimes the answer to `what is the context of defined()' is to unask
the question.  



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

Date: 19 Nov 1999 18:27:53 -0500
From: Scott Lanning <slanning@bu.edu>
Subject: Re: Keeping string on same line
Message-Id: <kusd7t6oydi.fsf@strange.bu.edu>

"Jakob" <asd@ds.aw> writes:
> I need to output a string, and then update the string but keep
> the string on the same line.

Didn't I just answer this the other day? You could use
backspace ("\010"), maybe just backspace clear to the
beginning of the line and print out the whole line again.
    If you need to get user input, then to update a field you
could use POSIX::Termios to put the terminal in non-canonical
mode while getting input. Not for the weak of heart, but there's
an example (of obtaining single-character input) in the Camel and
Ram books; also there's probably a CPAN module to help. ISTR there's
a 'curses' CPAN module, too; that could be used (again, with some
effort--also probably not portable).
    If I misunderstood, please give a concrete example of what
you're trying to do.

-- 
"I do believe God gave me a spark of genius, but he quenched it
in misery." --Edgar Allan Poe


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

Date: Fri, 19 Nov 1999 16:17:04 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: legal names and about sorting
Message-Id: <3835E880.2D47697E@mail.cor.epa.gov>

Larry Rosler wrote:
> 
> In article <slrn83bg74.l1a.abigail@alexandra.delanet.com> on 19 Nov 1999
> 15:24:41 -0600, Abigail <abigail@delanet.com> says...
[snip]
> > I still claim "sort" shouldn't be in the name. GRT, with the T standing
> > for transform is my suggestion - it fits with ST.
> 
> That's GReaT!

Or GriTty, depending on your point of view...

Note that I didn't say GRaTuitous, or GroTesque, or GaRganTuan,
or perhaps most insulting, GubeRnaTorial...  :-)

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 17 Nov 1999 15:23:31 GMT
From: beans@bedford.net (Thunderdust (TomH))
Subject: Re: Limiting Search Results
Message-Id: <3832c708.42764494@news.bedford.net>

If I understand the question, the simplest looking code will be if you
use DBI with a CSV DBD, do a "count(*)"  to get the total number of
records the query will return before going into to "while" loop to get
each record. 

A more sophisticated database engine will be more efficient if you can
use indexes on the search, but starting out with a DBI front end you
can go to a different back end as needed.



On Fri, 19 Nov 1999 16:21:00 GMT, "Rich Pierson"
<info@marinermotel.com> wrote:
 ...
> It's used to search a
>pipe delimited flat ascii text file, consisting of about 5000 records.
>
>I want to figure out a way that I can manipulate the value of $count
>(matching number of records) in such a way as to render the first, lets say,
>10 records, with the option of viewing the next 10 on the next page, and so
>on, and so on.
>
>You know what I mean... "Displaying records 1 through 10 of 56" for example.
>
>So the variable derived from $count which would equal the first 10 records
>would somehow be incorporated in the foreach statement that is used to
>render the table containing the search results.
>
>But how??? Anyone have any ideas, maybe enough to point me in the right
>direction at least?
 ...





Schnoodlewinks-constantly leveling up warrior
Fluffy_the_Fly-lvl.7 warrior (x2-don't ask!)
Flame-QFG5 Paladin


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

Date: Fri, 19 Nov 1999 15:31:00 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: perl optimizes away need for /o? was [/o in regexp with mod_perl]
Message-Id: <3835DDB4.2387D055@mail.cor.epa.gov>

lee.lindley@bigfoot.com wrote:
[snip]
> Actually, I kind of doubt that patches to perlre are welcome.
> I suspect it is due a full rewrite.  Since I have spent much time

Well, perhaps you could submit a few bits at a time.

> reading perlre over the past several months, I gave some thought
> to this potential rewrite.  Then I shuddered a bit and went on
> to something more pleasant.  When you look at the breadth of the
> task -- the range of prior knowledge of the intended audience
> and the complexity of telling the full story of the regexp engine --
> well, "daunting task" becomes a term with a new perspective.

Yep, that's why Jeffrey Friedl ended up with an entire book,
and it doesn't have a number of these features covered.

Instead of writing enough discussion to explain everything
to the new and unwary, perhaps you could send people to 
places where they could learn the basics and be ready for
a more detailed discussion.  I find the tutorial at
www.netcat.co.uk/rob/perl/win32perltut.html is less
error-prone than alternatives I have found.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 19 Nov 1999 15:37:58 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl programming sytle
Message-Id: <3835DF56.12D58A87@mail.cor.epa.gov>

Robert Kiesling wrote:
> 
> David Cassell <cassell@mail.cor.epa.gov> writes:
[snip]
me >                                       But is one also
me > then obligated to write code so that Lisp programmers
me > can read it easily?  And awk programmers?  And FORTRAN
me > programmers?  And Python programmers?  Writing code
me > specifically for another language's practitioners seems
me > like an odd requirement.  You probably do not have
me > people asking you to write your C code to look more like
me > COBOL, do you?  :-)
> 
> I assume you mean Perl code.  Really, idiomatic Perl is a lot

Actually, I meant what I said.  I was trying to make a
point about reciprocity.

> different than C idioms or FORTRAN idioms.  If you could find out if
> anyone has categorized the idioms that Perl can handle due to its
> overloading and contextualization of operators and functions, I'd bet
> you'd be a lot closer to an answer.

Or you could scan the posts of this newsgroup and distill
the high-octane from the crude.
 
> And "hand krufted?"  How many Perl contributors have backgrounds in
> humanities or social sciences, vis-a-vis the traditional sciences that
> are associated with programming?  I was just wondering about that.

Yes, I said "hand-krufted".  I like jargon and puns.

I don't know of a convenient way to assess your query.
But Perl seems to attract people who like human languages
as well as computer languages.  It seems to attract people
who have music backgrounds too.

Of course, it has also attracted a lot of web-people who
have no comp-sci background, no experience with prior
programming languages, and in some cases, no desire to
learn anything new or hear anything contrary to their
pre-conceived notions.  So take all of this with a grain
of salt.

Make that a sack of salt.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 19 Nov 1999 15:39:41 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl programming sytle
Message-Id: <3835DFBD.63C81CC@mail.cor.epa.gov>

Jonathan Stowe wrote:
[snip]
> Well of course that is another issue altogether - I started off as a
> scientist then diverted into literature 

Interesting.  I started college as an English major, and ended
up in theoretical math.  C'est la vie.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 19 Nov 1999 20:01:17 -0500
From: James Holmes <jamesholmes@mail.com>
Subject: Perl/CGI Programmers Wanted
Message-Id: <3835F2DD.263B5C02@mail.com>

Position:      Perl/CGI Programmer
Company:       Liquidation.com
Contact Email: jamesholmes@mail.com
URL:           http://www.liquidation.com
Description:   Exciting new startup still in the beer and pizza
               days.  Looking for 3 - 5 motivated developers to
               assist in on-going development of customized
               auction site.
Requirements:  Required:  Perl, SQL, CGI, UNIX, HTML
               Preferred: Oracle, PL/SQL, mod_perl, Apache,
                          MySql, C/C++, Java


Phone: 410-208-3700
Eamil: jamesholmes@mail.com



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

Date: Sat, 20 Nov 1999 01:13:21 GMT
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: Perl/CGI Programmers Wanted
Message-Id: <3835F602.2A53DBD1@home.com>

James Holmes wrote:
> 
> Position:      Perl/CGI Programmer
> Company:       Liquidation.com
> Contact Email: jamesholmes@mail.com
> URL:           http://www.liquidation.com
> Description:   Exciting new startup still in the beer and pizza
>                days.  

As opposed to the salary and benefits days?

> Looking for 3 - 5 motivated developers to
>                assist in on-going development of customized
>                auction site.

Well, I'll pass on the job, but I'm awfully tempted by those 169
pairs of army issue jungle boots.

Ken Bandes


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

Date: Fri, 19 Nov 1999 23:05:16 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Ping under Win NT without ICMP
Message-Id: <MIkZ3.28999$YI2.1350025@typ11.nn.bcandid.com>

In article <3835B1F5.7DF1811B@gmx.de>, 1789820  <andreas.wahlert@gmx.de> wrote:
>i have a Perl 5 Problem with a ping without ICMP. The script must mutual
>Ping 2 Win NT Servers. Now I'm looking for a Way to find out that the
>Servers are alive without "ping". The Net::Ping Module don't work. There
>is a Message "alarm Function not available" and i can't install another
>Modules because my administrator don't allow this. "net use" also don't
>work because I'm not logged in.

Do you control both machines?  Why don't you run a simple server and a
simple client on each machine (as documented in perldoc perlipc); the
client can connect to the server on the other machine (as documented in
perldoc perlipc), and if it fails (which will take a few minutes), it
can yell, "Fire!"

You could use UDP and select(), instead of TCP and connect(), if you
need a controllable timeout.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Fri, 19 Nov 1999 15:43:37 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Please Help ~~~~~~~
Message-Id: <3835E0A9.6509858E@mail.cor.epa.gov>

Bobo wrote:
> 
> How to write the perl script to get and display the no. of hits of many links
> within a web page?

If you're talking about web counters, then you can:

[1] realize that they don't work, and give up on the idea;
[2] grab one of the nearly-functional down to totally-useless
web counters off the net and then wonder why you count stats
get periodically corrupted;
[3] find a way to access your server logs and analyze those
data instead.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Sat, 20 Nov 1999 00:10:12 GMT
From: Ken MacLeod <ken@bitsko.slc.ut.us>
Subject: Re: Q: how to get tied variable within FETCH
Message-Id: <m33du2xbvh.fsf@biff.bitsko.slc.ut.us>

kragen@dnaco.net (Kragen Sitaker) writes:

> In article <Pine.GSO.4.10.9911151740560.15797-100000@user2.teleport.com>,
> Tom Phoenix  <rootbeer@redcat.com> wrote:
> >At least one of us is confused. Let me give a concrete example.
> 
> Well, it doesn't look like you're confused, unless you and I are
> confused in the same way.  What makes you think Ken is confused?
> 
> >    my $dino = $wilma{'some key'};
> >
> >Now, you seem to be saying that you want %wilma to be the value which will
> >land in $dino. No? 
> 
> It sounds like he wants something like 
> [...{...[...[\\\\{... 'somekey' => \%wilma . . .}...]...]...}..] to
> land in $dino.  So yes.

That sounds right.  Here's the exact concrete example.

The Data::Grove module (in libxml-perl in the XML module directory)
handles deeply nested tree or graph structures (like XML or vector
graphics).  The raw structures do not have Parent references to allow
for multiple references (and to avoid the circular reference).  They
look like this (but they'd be created as objects via new()):

 $child = { Name => 'Rectangle', Bounds => [1, 1, 10, 10] };
 $top   = { Name => 'Picture', Children => [ $child ] } ;

The Data::Grove::Parent module is a helper module that emulates Parent
properties using a tied hash.  You get the "first" tied object by
calling add_magic() on the top of the tree or fragment you're
interested in:

 $tied_top = $top->add_magic();

$tied_top is a tied hash with pseudo-keys Name, Children, Parent, and
Raw, which looks something like this:

   { Name => 'Picture',        # from {Raw}->{Name}
     Children => [ $child ],   # from {Raw}->{Children
     Parent => undef, Raw => $top }

The tied variable is _blessed_ into the same package as the raw
object.  The tied variable is _tied_ to Data::Grove::Parent.  The
underlying object contains just a Parent and Raw properties:

  { Parent => undef, Raw => $top }

Now, when you want to retrieve the child object from the tied parent,
what's supposed to happen is that FETCH is supposed to copy $tied_top
into the Parent property of the underlying object of the $tied_child:

  $tied_child = $tied_top->{Children}[0];

(side note, there's a similar tied array working magic on the Children
array).  The underlying object for $tied_child should look like this:

  { Parent => $tied_top, Raw => $child }

Therefore, the FETCH method needs to be able to get $tied_top so it
can build it in to the underlying object to return for $tied_child.
Since FETCH is only passed the underlying object and the key, what I'm
asking is if there is a way to get the tied variable.

In the end, the whole data structure looks like this:

  underlying objects                 raw objects
  ------------------                 -----------

  $tied_top:                --->     $top:
    { Parent => undef,                 { Name => 'Picture',
      Raw => $top }                      Children => [ $child ] }

    ^                                  |
    |                                  v

  $tied_child:              --->     $child:
    { Parent => $tied_top,             { Name => 'Rectangle',
      Raw => $child }                    Bounds => [ 1, 1, 10, 10 ] }


One possible solution is to store the tied variable in it's underlying
object, but that would create a cycle between the tied variable and
the underlying variable, unless there's magic I'm not aware of.

Here are the relevant methods:

sub add_magic {
    my $self = shift;
    my $parent = shift;

    return Data::Grove::Parent->new($self, $parent);
}

package Data::Grove::Parent;

# new() edited for brevity
sub new {
    my $type = shift;
    my $raw = shift;
    my $parent = shift;

    my $dummy = bless {}, ref($raw);
    tie %$dummy, $type, Parent => $parent, Raw => $raw;
    return $dummy;
}

sub TIEHASH  {
    my $type = shift;

    return bless { @_ }, $type;
}

sub FETCH {
    my $self = shift;
    my $key = shift;

    my $tied_self = ?????;  # here's the problem spot

    if (exists $self->{$key}) {
        return $self->{$key};
    } else {
        my $value = $self->{Raw}{$key};
        if (ref($value) eq 'ARRAY') {
	    # here's where it gets passed down
            $value = Data::Grove::ParentList->new($value, $tied_self);
        }
        return $value;
    }
}

-- 
  Ken MacLeod
  ken@bitsko.slc.ut.us
  <http://bitsko.slc.ut.us/>


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 1439
**************************************


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