[13408] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 818 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 16 12:11:53 1999

Date: Thu, 16 Sep 1999 09:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <937497911-v9-i818@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 16 Sep 1999     Volume: 9 Number: 818

Today's topics:
    Re: ? about bare word. (Kragen Sitaker)
    Re: ? about bare word. (Larry Rosler)
    Re: Anyone know what "premature script header means"? <kbandes@home.com>
        CONTEST: Range Searching <tchrist@mox.perl.com>
        Empty key in Berkeley DB Hash <tanner@ultra.math.uni-potsdam.de>
    Re: Encrypting (and decrypting) password <jerrad@networkengines.com>
    Re: End Of File <aqumsieh@matrox.com>
    Re: HELP PARSE EMAIL ADDRESSES PLEASE <rootbeer@redcat.com>
        How can I know if string have points? <abel.almazan@ogilvyinteractive.es>
    Re: How can I know if string have points? <gellyfish@gellyfish.com>
    Re: How to get the Envoriment parameters recorded? (Kragen Sitaker)
        Invalid constant TIOCNOTTY ??? pkey@sghms.ac.uk
    Re: Kerberos? <jerrad@networkengines.com>
    Re: Kerberos? <rootbeer@redcat.com>
        Making and using a DB. (Help!!!) <mattking@techie.com>
    Re: NDBM_File problem. <jsmith@mcs.drexel.edu>
    Re: need to write www search engine <madebeer@igc.apc.org>
    Re: Newbe question on Substitution <prNOSPAMesutti@atitech.ca>
        Open2 and Filehandle Limits <edwardwjsmith@hotmail.com>
    Re: Parsing Tab Delimited File (Kragen Sitaker)
    Re: passing "=" as an argument to CGI <hardpack@my-deja.com>
    Re: passing in multiple file names <madebeer@igc.apc.org>
    Re: PERL (cgi) and Databases -> How To? (Jon S.)
    Re: Perl + ICQ <rootbeer@redcat.com>
    Re: Please help a newbie! - sorry for the mistake! (Larry Rosler)
    Re: Splitting a line and honoring "strings" <aqumsieh@matrox.com>
        testing data types <khowe@performance-net.com>
    Re: testing data types <tchrist@mox.perl.com>
    Re: testing data types <gellyfish@gellyfish.com>
        Thank you <brock@governet.net>
    Re: trimming spaces from a string (Greg Bacon)
    Re: trimming spaces from a string (Larry Rosler)
    Re: trimming spaces from a string <aqumsieh@matrox.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Sep 1999 14:44:46 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: ? about bare word.
Message-Id: <yn7E3.14494$N77.1073211@typ11.nn.bcandid.com>

In article <37E0F5A8.47FBEB19@scmp.com>, scmpoper  <scmpoper@scmp.com> wrote:
>Hello:
>Do anyone know what's wrong with the code below:
>print "\${\"value\"} is ${"value"}\n";

print "\${\"value\"} is ${\"value\"}\n";

Dunno why.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 08:48:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: ? about bare word.
Message-Id: <MPG.124ab142bea22626989f8e@nntp.hpl.hp.com>

In article <yn7E3.14494$N77.1073211@typ11.nn.bcandid.com> on Thu, 16 Sep 
1999 14:44:46 GMT, Kragen Sitaker <kragen@dnaco.net> says...
> In article <37E0F5A8.47FBEB19@scmp.com>, scmpoper  <scmpoper@scmp.com> wrote:
> >Hello:
> >Do anyone know what's wrong with the code below:
> >print "\${\"value\"} is ${"value"}\n";
> 
> print "\${\"value\"} is ${\"value\"}\n";
> 
> Dunno why.

Because the closing delimiter of a string is found before its contents 
are analyzed.

  print qq(\${"value"} is ${"value"}\n);

  print "\${'value'} is ${'value'}\n";

  print "\${value} is ${value}\n";

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 16 Sep 1999 14:18:17 GMT
From: Kenneth Bandes <kbandes@home.com>
Subject: Re: Anyone know what "premature script header means"?
Message-Id: <37E0FC94.59780F6D@home.com>

David Cassell wrote:
> I recommend going to
>     http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
> for Tom Christiansen's rudely-named-but-still-helpful
> "Idiot's Guide to Solving Perl CGI Problems".  Working through
> this guide will not only help you, but will also teach you more
> about how CGI works - and doesn't work.

Good document but bad link (at least at the moment). Try
http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
or any CPAN mirror.

Ken Bandes


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

Date: 16 Sep 1999 08:52:46 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: CONTEST: Range Searching
Message-Id: <37e1043e@cs.colorado.edu>

We're lately been stricken with questions about what comes down to
variations on the same essential theme: how to search a stream for matches
and then produce as output some number of lines before or after the match
as well as the matched line.  This has to work efficiently for an input
stream of unlimited length.

Perl's two range operators lend themselves to simple solutions for some
of these kinds of things, like

    # print lines between PAT1 and PAT2
    while (<>) {
	print if /PAT1/ .. /PAT2/;
    } 

But that's not good for the general case of catching things before or
counting things afterwards

So here's the challenge: devise idiomatic solutions to the
following problems.  

    1) Write a "patfore" program that prints out up to N lines
       before the match as well as the match itself.  Here's
       the usage message:

	    patfore [-B N] pattern [files ...]

    2) Write a "pataft" program that prints out up to N lines
       after the match as well as the match itself.  Here's
       the usage message:

	    pataft [-A N] pattern [files ...]

    3) Write a "patba" program that prints out up to
       X lines before the match and Y lines after the match.

	    patba [-A X] [-B T] pattern [files ...]

       or both N before and after:

	    patba [-C N] pattern [files ...]

For Extra Credit:
    Provide alternate solutions that also coalesce with overlapping
    ranges.  For example, if you ask for 2 lines before and after, and
    lines 2, 4, and 5 all contain matches, the output should comprise
    lines [1-7] rather three separate output blocks showing lines.
    [1-4], [2-6], and [3-7].

Solutions will be judged upon these overall criteria:

    Objective: 

      * correctness: does it actually do the right thing?  if not, 
	nothing else matters. :-)
      * space efficiency: don't use more space than minimally needed
      * time efficiency: is your solution fast?
      * test coverage: do you include test data to check all border cases?

    Subjective:

      * conciseness:  keep it short.  no frills.  just a few lines.
      * clarity: is this understandable to a native perl speaker?
      * idiom: does this look like natural perl?  does it use cool
	perl features absent in other languages?
      * creativity: is your solution cleverly different from those
	of others?

To see what I mean by "idiomatic", here's an example of something I just
provided that is of a similar nature to these problems:

    # Print all line pairs where the first one ends 
    # in YIN and the next starts with YANG.  
    while (<DATA>) {
	$n = /YIN$/ ... $n or next;
	$pair .= $_;
	1 - $n || next;
	/^YANG/ && print $pair;
	$pair = '';
    } 

If you wanted to be more obvious, you could certainly write that as:

    while (<DATA>) {
	$n = /YIN$/ ... $n or next;
	$pair .= $_;
	next if $n == 1;
	print $pair if /^YANG/;
	$pair = '';
    } 

The point of that demo is that these problems shouldn't take zillions of
lines to code up, and also that I consider range operators plenty obvious
to native perl speakers and potentially useful to this problem domain.
You don't *have* to use them, and some solutions don't so clearly call
for them as did this one, but do please feel free to employ them if you're
so inclined.  (I expect a lot of solutions using a circular @buff array.)

The prize is that winners will have their solutions published in the FAQ,
and if it's cool enough, perhaps even featured in the Perl Journal.

Please post all solutions and discussion to Usenet.

Good luck, and thanks for helping save the world!

--tom
-- 
"Without knowing what I am and why I am here, life is impossible."
				- Leo Tolstoy  


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

Date: Thu, 16 Sep 1999 16:36:45 +0200
From: Andreas Tanner <tanner@ultra.math.uni-potsdam.de>
Subject: Empty key in Berkeley DB Hash
Message-Id: <37E1007D.E0775FA0@ultra.math.uni-potsdam.de>


Thanks to everyone answering my previous question.

I understood that Berkeley Db is good for storing hashes with long
values.

So what is wrong with the following script?

use DB_File;
use diagnostics;

tie %a,"DB_File","a";
%a=();
$a{''}='zzz'x10000;

foreach (keys %a) {print;}
untie %a;

It produces lots if 'z's..

Any help appreciated.

Andreas



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

Date: Thu, 16 Sep 1999 11:07:03 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: Re: Encrypting (and decrypting) password
Message-Id: <37E10797.C4432296@networkengines.com>

Why continure passing the password around?
Why not some cookie that says they are logged in?
Try Apache::ASP


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

Date: Thu, 16 Sep 1999 10:40:34 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: End Of File
Message-Id: <x3ybtb2hqcd.fsf@tigre.matrox.com>


"Ethan H. Poole" <ehpoole@ingress.com> writes:

> It wouldn't hurt to test that <MYFILE> returns a defined value.  Otherwise
> you could potentially abort prematurely if the last line contained only a
> '0' (zero) character.

As has been discussed in this ng dozens of times:

1) Newer versions of Perl (5.005+) test for defined() automatically,
so you don't have to do it explicitly.

2) Unless you screwed around with $/, the only place where a line
could exist without a line terminator (\n) will be the very last line
of your file. But this is a very very rare case.

--Ala



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

Date: Thu, 16 Sep 1999 08:51:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: HELP PARSE EMAIL ADDRESSES PLEASE
Message-Id: <Pine.GSO.4.10.9909160849100.25903-100000@user2.teleport.com>

On Wed, 15 Sep 1999, Larry Rosler wrote:

>   #!perl -nw
>   print "$1\n" if /\s(\S+@\S+)\s/

Of course, that won't necessarily find or extract an e-mail address from a
text stream. In fact, I can't think of a real-world use for that program.
Oh, well!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 16 Sep 1999 17:00:18 +0200
From: Abel =?iso-8859-1?Q?Almaz=E1n?= <abel.almazan@ogilvyinteractive.es>
Subject: How can I know if string have points?
Message-Id: <37E10602.62732A22@ogilvyinteractive.es>

How can I know if string have points?

I have a string $var and I want to know if this string have the char
'.':

my var can be as this:  $var="../" or $var="/../../"

Thanks




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

Date: 16 Sep 1999 17:02:31 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can I know if string have points?
Message-Id: <37e11497_1@newsread3.dircon.co.uk>

Abel Almazán <abel.almazan@ogilvyinteractive.es> wrote:
> How can I know if string have points?
> 
> I have a string $var and I want to know if this string have the char
> '.':
> 
> my var can be as this:  $var="../" or $var="/../../"
> 

if ( index($var,'.') > $[ - 1 )
  {
    # blah
  }

/J\
-- 
"While we've been on the air we've had reports that Prince Charles has
eaten beef on the bone" - Justin Webb, BBC One O'Clock News


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

Date: Thu, 16 Sep 1999 15:07:16 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: How to get the Envoriment parameters recorded?
Message-Id: <EI7E3.14525$N77.1075764@typ11.nn.bcandid.com>

In article <37B3266A.8970EAA3@microcal.com>, Larry Yu  <yu@microcal.com> wrote:
>Hello,
>I want to record the download record. Is there a way put the user's
>reffer page into that log? How to get that information.
>I use Perl script to write a log file.

What is the download record?  You can get the HTTP Referer header from
$ENV{HTTP_REFERER}.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 14:52:28 GMT
From: pkey@sghms.ac.uk
Subject: Invalid constant TIOCNOTTY ???
Message-Id: <37e10413.172790427@news.dl.ac.uk>

i get this message when testing a password changing perl script:

anyone seen it before?

######################################

Invalid constant TIOCNOTTY in /opt/perl5.004_04/lib/chat2.pl, line 10.
If thisconstant is present in your system, and you need it, please
edit `/opt/perl5.004_04/Ioctl-0_7/Ioctl.def'
and add it at the end. Then, go to the /opt/perl5.004_04/Ioctl-0_7
directory, and regenerate the Ioctl extension by typing `make
install'.
(You probably will need root privs to do this.) You may wish to
contact the
perl5 developers (or leave a message on comp.lang.perl) if you think
this
constant should be supplied in the distribution.

BEGIN failed--compilation aborted at /opt/perl5.004_04/lib/chat2.pl
line 10. 

#########################################

I have defined TIOCNOTTY in /opt/perl5.004_04/Ioctl-0_7/Ioctl.def but
i still get the same error message.

can anyone tell me how to fix it?

thanks

paul



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

Date: Thu, 16 Sep 1999 11:28:59 -0400
From: jerrad pierce <jerrad@networkengines.com>
Subject: Re: Kerberos?
Message-Id: <37E10CBB.4484B283@networkengines.com>

http://web.mit.edu/mjacknis/mit/perl/lib/kerberos/

http://www.cpan.org/authors/id/JHORWITZ/Krb4-1.0.readme

Please try a simple search on the web or CPAN before asking for a module


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

Date: Thu, 16 Sep 1999 08:46:24 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Kerberos?
Message-Id: <Pine.GSO.4.10.9909160844410.25903-100000@user2.teleport.com>

On Wed, 15 Sep 1999, Timothy J Flynn wrote:

>     Does anyone know of a Kerberos module for Perl?  

If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-)  Hope this helps!

    http://www.cpan.org/

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 16 Sep 1999 16:48:29 +0200
From: "Matt King" <mattking@techie.com>
Subject: Making and using a DB. (Help!!!)
Message-Id: <7rqu0g$pt8$1@news.uk.ibm.com>

OK, I have Active PERL 519 running on Windowz 98 with Apache 1.3.6.
Currently I'm trying to get SDBM DB working, but there apears to be an error
in the module. As much as I have tried I can not get it to read or display
all the records in the file. I have tried directly tried searching through
the file and having the script display only the record I want or chock and
pass an error that the record was not found. This method works in that if I
enter a valid record to search for (that shows up in the 'master' listing)
the search shows the record. If I search for a record that I know is not in
the DB, I get the desired error. But if I search for a record that I know is
in the file, but does not show up, I get the error that the record is not in
the file either.!?

It was once recomended that I use DB_File as the DB, but the Win32 version
of both Active Perl and PERL for Win32 do not come with it. So the SDBM_File
method was (and still is being) used. Since it apears that the SDBM_File
does not work correctly (atleast on the Win32 platform), what other DB
functions are there, and how do I use them? Sorry, but I'm going to need an
example of who to read from and write to the DB file.

Here is an example of what works, although not 100% correct.

use SDBM_File;
use Fcntl;

my $fileName = "DATA/Master";

$marker = "¦"; #none of the DB data will have this 'marker' so there will
not be an error with it.

my %data;
tie %data, 'SDBM_File', $fileName, O_RDWR|O_CREAT, 0644;

my $DATA1 = $in{'dat1'};
my $DATA2 = $in{'dat2'};
my $DATA3 = $in{'dat3');

my $saveString = join($marker, $DATA1, $DATA2, $DATA3);

if ($data{$in{'dat4'}}) {
   # update data in the file
    my @data = split(/$marker/, $data{$in{'dat4'}});
    $data[2]++; # This var increases when ever the same $in{'dat4'} is
entered
    $data{$in{'dat4'}} = join($marker, @data);
}
else {
  #add data to the file
  $data{$in{'dat4'} } = $saveString;
}

# Now read everything in the database, and send it to stdout
foreach my $i (sort keys %data) {
  my @data = split(/$marker/, $data{$i});

   print "$i\n";
   print " =>$data[0]\n";
   print " =>$data[1]\n";
    print " =>$data[2]\n\n";
 }
untie %data;

This works very well, right until the file is 4,096 until 8,096 and then
starts again at 14,096 (kb).

Thanks is advance for your help!
Matt




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

Date: Thu, 16 Sep 1999 11:22:04 -0400
From: Justin Smith <jsmith@mcs.drexel.edu>
Subject: Re: NDBM_File problem.
Message-Id: <37E10B1B.A2FA6F8C@mcs.drexel.edu>

"Joseph A. DiVerdi" wrote:

> In article <Pine.OSF.4.05.9909142053350.13794-100000@mail.med.upenn.edu>, Nico Zigouras <zigouras@mail.med.upenn.edu> wrote:
>
> >Hi:
> >
> >I have some databases that need NDBM_File module to access them but the
> >version of Perl that came with RH Linux 6.0 doesn't seem to have it or let
> >my CGI access it.
> >I am trying to install a new Perl but getting errors when trying to load
> >NDBM_File.
> >

I think that this is a Redhat 6.0 problem rather than

a Perl problem. When I compile Perl from scratch (rather

than using Redhat's package) I find that it fails the AnyDBM tests

(and other tests related to DBM's). Somehow, Redhat's libraries

are wrong (glibc, I think).

--
______________________________________________________________________
                                        |
Time blows wildly against my door       | Justin R. Smith
Stirring discarded sorrows              | Department of Mathematics and
Like dead leaves of summers past        |     Computer Science
Memories of forgotten lore              | Drexel University
Making way for new tomorrows            | Philadelphia, PA 19104
New hopes, new fears,                   |
         and new ways that last         | Office: (215) 895-1847
                                        |
c Justin R. Smith, March 14, 1994       | Fax:    (215) 895-1582

My home page: http://www.mcs.drexel.edu/~jsmith





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

Date: Wed, 15 Sep 1999 23:58:24 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: need to write www search engine
Message-Id: <APC&1'0'50775dae'e98@igc.apc.org>

The Perl module WWW::Search let's you search AltaVista.
Altavista let's you specify domain:gov as a boolean requirement

For example 
http://www.altavista.com/cgi-bin/query?\
pg=aq&kl=en&r=electoral+reform&q=domain%3Agov

(or for those without line continuation)
http://www.altavista.com/cgi-bin/query?pg=aq&kl=en&r=electoral+reform&q=domain%3Agov

-Michael



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

Date: Thu, 16 Sep 1999 14:50:18 GMT
From: "Mike" <prNOSPAMesutti@atitech.ca>
Subject: Re: Newbe question on Substitution
Message-Id: <Ks7E3.226$Em1.1256416@bunson.tor.sfl.net>


Thanks Guys!!!






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

Date: Thu, 16 Sep 1999 12:48:28 -0300
From: "E. Smith" <edwardwjsmith@hotmail.com>
Subject: Open2 and Filehandle Limits
Message-Id: <7rr1p3$ct1$1@nova.thezone.net>

I have a question regarding the use of Open2( ).  I open a process, read
from it successfully, write a default answer "yes" to it successfully, then
close the process. The snippit of code I use is below.  This piece of code
is in a loop that is taking the filenames and version numbers ($filename,
$version) from an array. However, this is only working for a limited number
of files.  Once this limit is reached, the program hangs.  I'm wondering
what is wrong? Is there a limit to the number of filehandles I can use?  Is
there something wrong with the code?  I'm fairly new to Perl so it would be
greatly appreciated if someone could provide me with some assistance as to
why this may be happening.  Thanks.

open2(READER, WRITER, "sccsget $filename $version") || die "Can't open
sccsget $!";
    while(<READER>)
    {
        if (/.*ISCS external.*/)
        {
            print WRITER "y\n";
        }
    }
 close WRITER || die "Can't close writer: $!";
 close READER || die "Can't close reader: $!";





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

Date: Thu, 16 Sep 1999 15:05:07 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Parsing Tab Delimited File
Message-Id: <DG7E3.14524$N77.1074751@typ11.nn.bcandid.com>

In article <37e0f584@cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
>In a sane world, where "comma-separated values" actually happens to mean
>the remarkably surprising "comma-separated values", this is all it takes:
>
>    @fields = split(/,/, $line, -1);
>
>You'll notice that this approach also suffices for the passwd file, etc. 
>Those were designed for simplicity.

It's not a general-purpose data format, though; you can't store commas
in its fields.

>No thought
>is given to simplicity of parsing, which means you get something
>that is *not* simple to parse.  Do not call things so-called "CSV

"things like"?

>files" simple, because if they were, then a split would suffice.
>It doesn't, so they aren't.  And they're hardly "comma-separated".
>They're "quasi-comma-separated with inane hacks and idiosyncrasies
>bearing only a superficial and conquently deceptive resemblance to actual
>comma-separated data".

Can you give me an example of one of these formats?

The ones I'm familiar with are quotes-with-doubled-quote, hex encoding,
and quotes-with-backslashed-quote-and-doubled-backslash.  I just posted
a three-line regex that handled quotes-with-backslashed-quote encoding
in whitespace-separated lines.  I think the others are just as simple.

Admittedly, that's not as simple as 'split'.  But it's not even close
to the same level of excessive complexity as parsing Perl, or even
Pascal.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Thu Sep 16 1999
53 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 16 Sep 1999 14:56:48 GMT
From: stampede <hardpack@my-deja.com>
Subject: Re: passing "=" as an argument to CGI
Message-Id: <7rr0f8$eb5$1@nnrp1.deja.com>

In article <37e0a743_1@newsread3.dircon.co.uk>,
  Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>
> Larry Rosler <lr@hpl.hp.com> wrote:
> > [Posted and a courtesy copy mailed.]
> >
> > In article <7rp43h$11f$1@gellyfish.btinternet.com> on 15 Sep 1999
> > 21:46:25 -0000, Jonathan Stowe <gellyfish@gellyfish.com> says...
> >> On Wed, 15 Sep 1999 20:30:19 GMT stampede wrote:
> >> > is there a way to pass an "=" as an argument to CGI?
> >> >
> >> > e.g.,
> >> >
> >> > http://www.foo.org/perl.cgi?url=http://www.foo.com/perl.cgi?x=y
> >
> > That second '?' should be an '&'.
> >
>
> I'm not sure see later ...
>
> > But it's not clear why one wants to duplicate in 'url' a value that
can
> > be accessed by CGI::script_name() or $ENV{SCRIPT_NAME}.
> >
>
> But it isnt - I assumed that foo.com wasnt merely a braino there.
>
> >> > so that foo.com/perl.cgi processes the value "y" as param('x')?
> >>
> >> I'm not sure what you mean ...
> >>
> >> If you mean that you want to post that second URL as a parameter to
> >> the first CGI program then you will want to encode it like:
> >>
>
> <snip URL encoding>
>
> >
> > Yes, it will hurt.  It is destructive.  The parser will see the
escaped
> > '?' (which should be '&' as stated above) and '=' as part of the
data,
> > rather than as separators.  They must be there literally.
> >
>
> That is the point.  I think that he *may* have been wanting to pass
all
> of the second URL *including the parameters* as a parameter to the
first
> CGI program - in which case the '?' before 'x=y' is part of the data
> and therefore must be escaped.
>
> Of course this is second guessing the original poster and I did say I
wasnt
> sure what he meant :)
>
> /J\
> --
> "I'm not Carol Vorderman - you wouldn't see me getting drunk in a
kebab
> shop" - Lily Savage
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 15 Sep 1999 23:43:54 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: passing in multiple file names
Message-Id: <APC&1'0'50775dad'af6@igc.apc.org>

Darren wrote:
> My problem is getting the script to take multiple filenames 

It could read these from a file, or from STDIN 
(or from __DATA__ I suppose)

> loop over the parser with each. How can I do that?

If you want to loop over each file, 
you either might or might not care about treating each file separately. 

If you need to treat each file separately, Martien's pseudo code 
looks good.

When I don't care about treating each file separately,  setting
@ARGV can save lines of code, like this:   

#!/usr/local/bin/perl5 -w

use strict;
use English;

my %big_hash;
my @files = qw( friends enemies neighbors );

# setup hash %exclude of lists we should exclude from export
  local @ARGV = @files;     # now the <> operator will go through
                       # everything in the files listed in @files        
  while (<>) {
    s/\s+//g;                   # toss all white space
    $big_hash{$_} = undef;      # sample of 'doing stuff' here
  }

This may have problems with thousnads of files, I don't know.

HTH,
-Mike




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

Date: Thu, 16 Sep 1999 14:26:57 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: PERL (cgi) and Databases -> How To?
Message-Id: <37e0fdc8.2974524@news.earthlink.net>

On 15 Sep 1999 21:52:08 -0500, abigail@delanet.com (Abigail) wrote:
>Do you however not
>need your ISP to install modules, but you knew that, because you
>read the FAQ, didn't you?

Abigail, I too am a newbie working on this, and, given the immense
numbers of FAQs, I haven't been able to find this one yet.

Can you direct me to where I should look?  Is it in the FAQs at
www.perl.com?

Thanks,

Jon




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

Date: Thu, 16 Sep 1999 08:59:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl + ICQ
Message-Id: <Pine.GSO.4.10.9909160854500.25903-100000@user2.teleport.com>

On Thu, 16 Sep 1999, Jordan Hiller wrote:

> Is there any sort of script or module to send ICQ messages and check
> ICQ online status' from Perl?

Sure there is; the question is whether anyone has written it yet. :-)

If the ICQ protocol is available, someone probably has a module (which
should be on CPAN). If the protocol is proprietary, then someone should
design an open protocol to replace it. :-) But that's outside of the scope
of this newsgroup.

If you find nothing on CPAN, see about searching for the protocol spec.
Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 16 Sep 1999 08:36:14 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Please help a newbie! - sorry for the mistake!
Message-Id: <MPG.124aae4d9d946f81989f8d@nntp.hpl.hp.com>

In article <7rq7s0$t0v$1@nnrp1.deja.com> on Thu, 16 Sep 1999 07:56:52 
GMT, makau@my-deja.com <makau@my-deja.com> says...

When you quote someone, it is courteous to attribute the quote.  I wrote 
these things, and I identify with them.

> > But still worth improvement.
> > You certainly didn't test it at all before posting it.
> 
> Yep, i didn't.
> I thought it would work.
> But seems it doesn't? :-(

Welcome to the real world.  Code posted here is as 'real' as code in 
your own programs.  As you are discovering, people *do* take it 
seriously.

> > Why do you accumulate the output strings here instead of just printing
> > them out a line at a time?
> 
> Because I wanted the code to be as clear as possible.
> I am not a one-liner. Far from that.

Printing a line when you have it in hand is a lot clearer than 
concatenating it to a string that you print eventually.

> > >         while (<INPUT>) {
> > >                 m!^(.{180})(\d{2})(\d{2})(\d{2})(.*)!;
> >
> > What happens if the data are faulty and this match fails?
> 
> If the data is faulty, it's not my fault :)
> The guy said all the lines used this format.

Defensive coding requires you to check the success of a match before 
using the results.  What else did the guy say that might or might not be 
true?  Does he have a good bridge to sell you?

> > >                 $data .= "$1$2/$3/$4$5";
> >
> > Where, oh, where, has my little newline gone?
> 
> Oups... I thought the pattern matching caught it!
> Yeah, I should have written $data .= "$1$2/$3/$4$5\n"

Now you know, as you would have learned earlier had you tested the code 
before posting it.  It is amazing how much I have learned that way!

> > WHY, oh why, do you quote the whole article, *after* your response to
> > it?
> 
> 1- The more interesting part is the reply, NOT the former post.
> 2- Because it takes on one's nerves to scroll the original post down to
> the reply (when the original post is indeed put before the reply).
> 
> Ain't I right?

Not even a little bit.  Blindly quoting the whole article first, then 
responding, is no better.  Interspersing comments, as I have done, is 
easy on the eyes and on the mind.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 16 Sep 1999 10:43:56 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Splitting a line and honoring "strings"
Message-Id: <x3yaeqmhq6r.fsf@tigre.matrox.com>


"Lokesh Setia" <nospam@hss.hns.com> writes:

> I have to parse a line whose fields are splitted into spaces,

[snip>

> What I want is to honor the quotes "" and '' withing the user line
> so that the user can embed spaces in the values: like,

Check out perlfaq4:

     How can I split a [character] delimited string except when
     inside [character]? (Comma-separated files)

--Ala



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

Date: Thu, 16 Sep 1999 11:17:22 -0300
From: "Kevin Howe" <khowe@performance-net.com>
Subject: testing data types
Message-Id: <o07E3.154415$5r2.239600@tor-nn1.netcom.ca>

How do you test if a variable is an array, or a hash, or scalar?

ex:

$hash{'Item 1'} = @myArray;
@myArray = qw(one two three);
$hash{'Item 2'} = @myArray;

foreach (keys %hash){
    if ($hash{$_} IS AN ARRAY) {
            # do this
    }
}

Thanks.




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

Date: 16 Sep 1999 08:39:10 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: testing data types
Message-Id: <37e1010e@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    "Kevin Howe" <khowe@performance-net.com> writes:
:How do you test if a variable is an array, or a hash, or scalar?
:
:ex:
:
:$hash{'Item 1'} = @myArray;

That's an error for your purposes.

    man perldata
    man perlref
    man perllol
    man perldsc

--tom



-- 
"War therefore is an act of violence intended to compel our opponent to
 fulfil our will." 
				- Carl von Clausewitz


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

Date: 16 Sep 1999 15:47:21 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: testing data types
Message-Id: <37e102f9_1@newsread3.dircon.co.uk>

Kevin Howe <khowe@performance-net.com> wrote:
> How do you test if a variable is an array, or a hash, or scalar?
> 

ref()

/J\
-- 
"It needs to be said: Tinky Winky is ... an ideal role model for any
child without toes or genitalia" - Paul Rudnick, The Guardian


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

Date: Thu, 16 Sep 1999 09:56:59 -0600
From: Darren Brock <brock@governet.net>
Subject: Thank you
Message-Id: <37E1134B.CB064BC0@governet.net>

Hello
Thanks for the help and I'll try to remember to turn off the attach
v-card.

Thanks again
Darren Brock


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

Date: 16 Sep 1999 14:42:29 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: trimming spaces from a string
Message-Id: <7rqvkl$1ts$1@info2.uah.edu>

In article <MPG.1249a5df7d34dc56989f71@nntp.hpl.hp.com>,
	lr@hpl.hp.com (Larry Rosler) writes:

:       tr/ \n\r\f\t/ /s for $s, $t;

Is there any conforming implementation of isspace() that recognizes a
character outside this set as being whitespace?

: is much more appropriate.

Appropriate?  Appropriate?!  I don't understand. :-)

Greg
-- 
Bigamy is having one wife too many. Monogamy is the same.
    -- Oscar Wilde


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

Date: Thu, 16 Sep 1999 08:19:35 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: trimming spaces from a string
Message-Id: <MPG.124aaa59b4cc13c7989f8c@nntp.hpl.hp.com>

In article <7rqvkl$1ts$1@info2.uah.edu> on 16 Sep 1999 14:42:29 GMT, 
Greg Bacon <gbacon@itsc.uah.edu> says...
> In article <MPG.1249a5df7d34dc56989f71@nntp.hpl.hp.com>,
> 	lr@hpl.hp.com (Larry Rosler) writes:
> 
> :       tr/ \n\r\f\t/ /s for $s, $t;
> 
> Is there any conforming implementation of isspace() that recognizes a
> character outside this set as being whitespace?

The C Standard includes vertical tab '\v', shown as a C char rather than 
a Perl string, because Perl doesn't define it.

> : is much more appropriate.
> 
> Appropriate?  Appropriate?!  I don't understand. :-)

Oh, yes you do.  'Appropriate' as in 'an order of magnitude faster'.
:-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 16 Sep 1999 10:31:02 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: trimming spaces from a string
Message-Id: <x3yd7vjgc7t.fsf@tigre.matrox.com>


lr@hpl.hp.com (Larry Rosler) writes:
> In article <x3ywvtsdq2p.fsf@tigre.matrox.com> on Wed, 15 Sep 1999 
> 13:47:42 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...

> > 	$t =~ s/^\s+|\s+$/g;	# just in case
> 
> Neither of you seems to have read perlfaq4: "How do I strip blank space 
> from the beginning/end of a string?"  It says some rather 
> uncomplimentary things about these approaches.

I know. Once I benchmarked the above approach against the two-step
version:

	$t =~ s/^\s+//;
	$t =~ s/\s+$//;

and, to my surprise, the two-step one is faster. Not much though. So I
usually use the first approach since it's more compact.

> > 	$s =~ s/\s+/ /g;
> > 	$t =~ s/\s+/ /g;
> 
>       tr/ \n\r\f\t/ /s for $s, $t;

That's better. I keep forgetting about the /s modifier in tr///;

> is much more appropriate.  Actually though, the problem statements talks 
> only about spaces, so all those other white-space characters are 
> unnecessary; furthermore it talks only about leading and trailing 
> spaces, so squeezing the interior spaces isn't called for.  The two 
> strings don't match because their interior spaces don't match.

Actually, that was my first thought too. But I looked back at the
original question, and the poster did not say anything about interior
spaces. He just showed an example where the interior spaces were
different, and said that the two string should match. So I assumed
that his algorithm should be independent of leading, trailing and
interior spaces.

Anyway, he has everything ready on the table. Let him choose whatever
he wants.

--Ala



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

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

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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