[19844] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2039 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 31 00:05:36 2001

Date: Tue, 30 Oct 2001 21:05:06 -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: <1004504706-v10-i2039@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 30 Oct 2001     Volume: 10 Number: 2039

Today's topics:
        calling SSI script with perl? <spamfree@go-away.net>
    Re: calling SSI script with perl? (Clinton A. Pierce)
    Re: calling SSI script with perl? (David Efflandt)
    Re: Configuring the Serial Ports (David Efflandt)
    Re: Design questions about fork(), pipe() and sockets (David Efflandt)
        Help Please <sblatz@mailops.com>
    Re: Help Please (Tad McClellan)
    Re: Help Please <wwonko@rdwarf.com>
    Re: Perl from NT OS to Linux/Unix <wwonko@rdwarf.com>
        Perl/CGI Search Script <pneumatus@NOSPAMhotmail.com>
        Searching - CGI <gclark@wavetel.com>
    Re: Security- Upload scripts <spamfree@go-away.net>
    Re: Telnet: get exit status of remotely executed comman (David Efflandt)
    Re: Unsigned 8 bit math (addition and subtraction) (J.B. Moreno)
    Re: Unsigned 8 bit math (addition and subtraction) <mjcarman@home.com>
    Re: Unsigned 8 bit math (addition and subtraction) <bart.lateur@skynet.be>
    Re: Unsigned 8 bit math (addition and subtraction) <wuerz@yahoo.com>
    Re: XML parsing (Tad McClellan)
    Re: XML parsing <bart.lateur@skynet.be>
    Re: XML parsing (Clinton A. Pierce)
    Re: Yet another regexp question <kherlitz@mindcast.com>
    Re: Yet another regexp question <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 30 Oct 2001 23:41:44 GMT
From: "spamfree" <spamfree@go-away.net>
Subject: calling SSI script with perl?
Message-Id: <YUGD7.1740$4x3.153487@news1.cableinet.net>

Hello,
Is it possible to call a server side include script as a "require" or
"include" instead of .shtml
Currently I can use this as part of a perl script...
#!/usr/bin/perl
   print "Content-type: text/html\n\n";
   print "<tt>\n";
   foreach $key (sort keys(%ENV)) {
      print "$key = $ENV{$key}<p>";

   }
#As expected, the above code prints all ENV-(environment variables)

I'm wanting a simple solution to obtain all the SERVER environment
variables,
possibly using <!--#exec cgi="cgi-bin/ALL_ENV.cgi"--> which I currently call
via my browser .shtml

Any thoughts?

--
millside
_____________








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

Date: Wed, 31 Oct 2001 00:23:54 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: calling SSI script with perl?
Message-Id: <uwHD7.212999$K6.104199650@news2>

[Posted and mailed]

In article <YUGD7.1740$4x3.153487@news1.cableinet.net>,
	"spamfree" <spamfree@go-away.net> writes:
> Hello,
> Is it possible to call a server side include script as a "require" or
> "include" instead of .shtml
> Currently I can use this as part of a perl script...
> #!/usr/bin/perl
>    print "Content-type: text/html\n\n";
>    print "<tt>\n";
>    foreach $key (sort keys(%ENV)) {
>       print "$key = $ENV{$key}<p>";
> 
>    }
> #As expected, the above code prints all ENV-(environment variables)
> 
> I'm wanting a simple solution to obtain all the SERVER environment
> variables,
> possibly using <!--#exec cgi="cgi-bin/ALL_ENV.cgi"--> which I currently call
> via my browser .shtml

Why not just (untested):

	#!/usr/bin/perl -w

	use strict;
	use CGI qw(:standard);
	$|=1;
	print header();
	
	print `/home/youruser/cgi-bin/ALL_ENV.cgi`;

To run any-old CGI script that expects to be run as an SSI?  Remember
that the environment won't be EXACTLY the same when you run the script
like this (as opposed to letting it run with an SSI naturally) but 
it'll be close enough for government work.

-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Wed, 31 Oct 2001 03:11:46 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: calling SSI script with perl?
Message-Id: <slrn9tuqvh.731.efflandt@typhoon.xnet.com>

On Tue, 30 Oct 2001 23:41:44 GMT, spamfree <spamfree@go-away.net> wrote:
> Hello,
> Is it possible to call a server side include script as a "require" or
> "include" instead of .shtml

I don't understand the question.  'Include" is .shtml, "require' is a way
to insert one Perl script within another.  CGI output is not currently 
parsed for includes (maybe in apache 2.x)

> I'm wanting a simple solution to obtain all the SERVER environment
> variables,
> possibly using <!--#exec cgi="cgi-bin/ALL_ENV.cgi"--> which I currently call
> via my browser .shtml

Wouldn't it be simpler to use this in your .shtml page (assuming apache):

<pre><!--#printenv --></pre>

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Wed, 31 Oct 2001 03:15:22 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Configuring the Serial Ports
Message-Id: <slrn9tur6a.731.efflandt@typhoon.xnet.com>

On 30 Oct 2001 02:21:50 -0800, Misty <tee_noone@yahoo.com> wrote:
> Hi,
> I need to write to the serial port on a Unix machine but before I do I
> need to set some parameters like the bit rate etc.
> can anyone tell me how to do this.
> I know you write to the serial port you simply open the file and write
> to it, but I am required to set these parameters first.
> Any ideas.

Look for Device::SerialPort on a CPAN mirror.  It is a Unix (Linux) port 
of Win32::SerialPort and comes with sample scripts.

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Wed, 31 Oct 2001 03:28:48 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Design questions about fork(), pipe() and sockets
Message-Id: <slrn9turvf.731.efflandt@typhoon.xnet.com>

On Tue, 30 Oct 2001 13:12:05 +0100, Edwin Günthner <edgue@web.de> wrote:
> I want to implement the following scenario:
> 
> I have program that performs some actions and creates
> log messages. I would like to allow one or more GUI
> applications to display the messages. 
> 
> It should work like an instant messenger system: 
> a GUI connects to the "server" and sees all log 
> messages that are created after the connection 
> is established. 

Wouldn't it be easier to simply have one process write to the log file and 
the other independent processes read and display any changes?

perldoc -q tail

which ends with:
There's also a File::Tail module from CPAN.

> [maybe I should add here that I do not intend to
>  use Threads - the whole thing needs to run in a
>  production system using OS/2 and Perl 5.5]

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Tue, 30 Oct 2001 19:52:10 -0500
From: "Scott Blatz" <sblatz@mailops.com>
Subject: Help Please
Message-Id: <3bdf4ba9_1@excalibur.gbmtech.net>

I have a cgi script I am trying to run that keeps coming back with a 500
error.  In the log it states

[Tue Oct 30 19:48:14 2001] [error] [client 64.210.248.135] Premature end of
script headers: /home/my-site/public_html/cgi-bin/adminpro.cgi
[Tue Oct 30 19:48:14 2001] [error] (2)No such file or directory: exec of
/home/my-site/public_html/cgi-bin/adminpro.cgi failed

I have #! /usr/sbin/perl set correctly, according to my host.
I have the permission set at 755
The whole site has been reset, and still no luck.

Any ideas?
--





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

Date: Wed, 31 Oct 2001 01:06:46 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help Please
Message-Id: <slrn9tuh2f.ig.tadmc@tadmc26.august.net>

Scott Blatz <sblatz@mailops.com> wrote:

>Subject:  Help Please


Please put the subject of your article in the Subject of your article.


>I have a cgi script I am trying to run that keeps coming back with a 500
>error.  

   perldoc -q 500

      "My CGI script runs from the command line but not the
       browser.  (500 Server Error)"


Does it work correctly from the command line?


>[Tue Oct 30 19:48:14 2001] [error] [client 64.210.248.135] Premature end of
>script headers: /home/my-site/public_html/cgi-bin/adminpro.cgi
>[Tue Oct 30 19:48:14 2001] [error] (2)No such file or directory: exec of
>/home/my-site/public_html/cgi-bin/adminpro.cgi failed


Neither of those message were issued by perl (you can tell because
they do not appear in perldiag.pod).


>I have #! /usr/sbin/perl set correctly, according to my host.
>I have the permission set at 755
>The whole site has been reset, and still no luck.
>
>Any ideas?


What is your Perl question?

You appear to be asking a server setup question. Those are best
asked in a newsgroup about such things:

      comp.infosystems.www.authoring.cgi
      comp.infosystems.www.servers.mac
      comp.infosystems.www.servers.misc
      comp.infosystems.www.servers.ms-windows
      comp.infosystems.www.servers.unix


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 31 Oct 2001 04:40:28 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: Help Please
Message-Id: <9rnvbs$1bv$1@holly.rdwarf.com>

Scott Blatz <sblatz@mailops.com> wrote:
: I have a cgi script I am trying to run that keeps coming back with a 500
: error.  In the log it states

: [Tue Oct 30 19:48:14 2001] [error] [client 64.210.248.135] Premature end of
: script headers: /home/my-site/public_html/cgi-bin/adminpro.cgi
: [Tue Oct 30 19:48:14 2001] [error] (2)No such file or directory: exec of
: /home/my-site/public_html/cgi-bin/adminpro.cgi failed

: I have #! /usr/sbin/perl set correctly, according to my host.
: I have the permission set at 755
: The whole site has been reset, and still no luck.

: Any ideas?

Make sure the #! line points to a valid Perl.

Make sure the Perl scripts don't have DOS/Windows line endings.  Use
file(1) or check the file with an editor that'll show it.  VI will show
extra ^M's or vim will say [dos] in the line at the bottom.

This has bitten me repeatedly, and is the second time I've mentioned
it tonight.  Maybe it's common knowledge, but was sure invisible
to me the first time it bit me.
 
If it's not that, then I can't say from here.

Hope it helps.



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

Date: Wed, 31 Oct 2001 04:07:15 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: Perl from NT OS to Linux/Unix
Message-Id: <9rntdj$f8$1@holly.rdwarf.com>

Stuart Gall <stuart@otenet.gr> wrote:
: Have you made the script executable?
: Shell in and do chmod uog+x NAMEOFCGI

This is probably what's causing your problem. Permissions under Unix
are a little different than NT; you might get a "beginning Unix" book
and/or read about the shell a little.  If you understand that, lots
of things will be less confusing and arbitrary.

O'Reilly has one, "Learning the Unix Operating System" which isn't
too bad.  I haven't looked at the 5th edition yet, but I expect
it has important and timely updates.

: I dont think ^M will bother the perl interpreter it should just treat it as
: whitespace.

While the spare ^M's won't likely bother Perl, they may cause you
other problems.

In Unix, you have the #! line:

#! /usr/bin/perl

This tells the OS what interpreter to use on this file; it's how it can
run any random sort of file, be it Perl, a shell script, or an expect
program or what have you.

However, the operating systems tend to be pretty stupid when reading
this line.  If you forget to remove the control-M's, you will get
a very similar error, except it will be, "command not found".

That's because it's trying to run: "/usr/bin/perl^M", which is probably
not what Perl is called on your system.

To make matters worse, many Unix editors notice, "Oh!  DOS text file!"
and just display it correctly - vim in particular - and it becomes
difficult to see that this is happening.  It looks fine in the editor
but dosen't work - command not found.  But the command is there.
Very irritating.  (Yes, I learned this the hard way.)

So, make sure you've got Unix line feeds - IE: You have removed the
^M characters.  There's lots of ways to do this; dos2unix/unix2dos,
recode(1), the -a option on the Unix unzip program, or using ASCII
mode in your FTP client.
 
You can use the file(1) command to see what kind of file it is, if
you have that available on your Unix system.  A Unix text file
will show somethig like:
 
LErickson.txt: ASCII English text
 
Where a Windows/DOS file will show something like:
 
LErickson-win.txt: ASCII English text, with CRLF line terminators

Hope that helps.




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

Date: Tue, 30 Oct 2001 23:03:16 -0000
From: "Matt" <pneumatus@NOSPAMhotmail.com>
Subject: Perl/CGI Search Script
Message-Id: <9rnblg$458$1@plutonium.btinternet.com>

Hi,

I'm looking for a free search script written in perl/cgi. The thing is, I
want one that can handle ? and &'s in urls as the site i need it for is
totally CGI driven.

I hope someone can point me in the right direction.

Pneumatus®




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

Date: Wed, 31 Oct 2001 02:02:48 GMT
From: "Geoff Clark" <gclark@wavetel.com>
Subject: Searching - CGI
Message-Id: <cZID7.9650$tb2.566587@bin2.nnrp.aus1.giganews.com>

Could someone help me with this search I am trying to do.  The code is as
follows.  The problem I am having it is displaying the file to the screen I
want to be able to search on the file.  The file looks like:

010020D6BC56FC  00      10.1.66.12      10.1.64.2       1021684781
voicedhcp
010020D6ACB204  00      10.1.66.13      10.1.64.2       1021903392
voicedhcp
010020D6BC31B4  00      10.1.66.14      10.1.64.2       1022592484
voicedhcp
010020D68CDA8D  00      10.1.66.15      10.1.64.2       1027790024
voicedhcp
010020D69C3B94  00      10.1.66.16      10.1.64.2       1027363889
voicedhcp
010020D6ACB867  00      10.1.66.17      10.1.64.2       1027807714
voicedhcp
010020D6AC5868  00      10.1.66.18      10.1.64.2       1027461402
voicedhcp
010020D68CD088  00      10.1.66.19      10.1.64.2       1026180392
voicedhcp
010020D6A495D0  00      10.1.66.20      10.1.64.2       1024678502
voicedhcp
010020D6AC943A  00      10.1.66.21      10.1.64.2       1025900903
voicedhcp
010020D6BC4E00  00      10.1.66.22      10.1.64.2       1022700185
voicedhcp

You can see the script if you go to http://208.63.123.135/cgi-bin/mac.cgi

Geoff Clark

#!/usr/bin/perl

use CGI qw/:standard/;

print "Content-type:text/html\n\n";
$dest = param ('mac');
print <<EndHTML;

<html><head><title>MAC Address Search Table</title></head>
<body>
<h3>MAC Address Search Table<h3>
<table cellspacing="2" cellpadding="2" border="0">
<form action="mac.cgi" method="post">
<tr align="center" valign="middle">
<td align="left" valign="top"><b>MAC Address:</b></td>
<td>&nbsp;</td>
<td align="left" valign="top"><input type="text" name="mac" size="25"
maxlength="35"></td>
</tr>
<tr><td>&nbsp;</td></tr>
<tr>
<td><input type="submit" name="submit" value="Search"></td>
<td>&nbsp;</td>
<td><input type="Reset"></td>
</tr>
</table>
<pre>
EndHTML

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@lines =`cat 10_1_64_0` ;
@lines= sort @lines;
foreach $lines(@lines){
        $a=substr($lines,0,2);
        if ($a!="00"){
                $lines =~ /([A-Za-z0-9]*)\s(\w*)\s([\d\d.]*)/;
                push (@dhcp,$3." ".$1);
        }
}


$searchstr = $FORM{'mac'};

@results = grep(/$searchstr/i,@dhcp);
$found = 0;
if ($results >= 0) {
        foreach $i (@results) {
                chomp($i);
                ($mac,$ip) = split(/\|/,$i);
                if ($mac =~ $searchstr) {
                        print "$mac ($ip) - $name<br>\n";
                        $found = 1;
                }
        }
} else {
        print "No results found.<p>\n";
}

if ($found == 0) {
        print "No results found.<p>\n";
}

print <<EndHTML2;
</pre>
</body>
</html>
EndHTML2

###Sub Routines Start Here###
sub dienice {
        my ($msg) = @_;
        print "Error\n";
        print $msg;
        exit;
}




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

Date: Wed, 31 Oct 2001 01:06:13 GMT
From: "spamfree" <spamfree@go-away.net>
Subject: Re: Security- Upload scripts
Message-Id: <98ID7.2231$4x3.198873@news1.cableinet.net>

> > Hi,
> > I'm wanting to modify a simple upload script.
> > Any recommended resources/tuts on the many security issues using upload
> > scripts in perl to Unix?
>
> Make sure it starts with:
>
> #!/usr/bin/perl -wT
> use strict;
>
>
Software error:
Insecure dependency in open while running with -T switch
What exactly does this mean and what can I do about it?

--
millside
_____________




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

Date: Wed, 31 Oct 2001 03:53:42 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Telnet: get exit status of remotely executed command
Message-Id: <slrn9tute6.731.efflandt@typhoon.xnet.com>

On 29 Oct 2001, Anand Ramamurthy <anand_ramamurthy@yahoo.com> wrote:
> How can I know the exit status of remotely executed command.
> 
> first I execute
> 
>           $t->cmd("test -x /usr/local/bin/myexe");
> 
> to check if myexe is present & is an executable. Under normal
> circumstances we check for the return status ($?) to be 0.
> But in above how do I know what the exit status was.

Return something if successful:

$t->cmd("test -x /usr/local/bin/myexe && echo 1")
  || print "test failed\n";

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Tue, 30 Oct 2001 18:15:58 -0500
From: planb@newsreaders.com (J.B. Moreno)
Subject: Re: Unsigned 8 bit math (addition and subtraction)
Message-Id: <1f23qvu.zipkngp30q18N%planb@newsreaders.com>

Stuart Gall <stuart@otenet.gr> wrote:

> "J.B. Moreno" <planb@newsreaders.com> wrote in message
> > Is there an easy way to do unsigned one byte addition and 
> > subtraction? I.e. I want 0-1 to equal 255 and 250+7 to equal 1.
> >
> Avoiding an if ?

Yeah, it makes the logic a whole lot clearer.

> $a = ((0-1) % 256)+ 256) %256

That didn't compile for me, but 

$a = (($x-$y) % 256);

and 

$a = (($x+$y) % 256);

does and works just fine.

Thanks.

-- 
JBM
"Your depression will be added to my own" --  Marvin of Borg


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

Date: Tue, 30 Oct 2001 16:39:47 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Unsigned 8 bit math (addition and subtraction)
Message-Id: <3BDF2C33.35AE9FE@home.com>

"J.B. Moreno" wrote:
> 
> Is there an easy way to do unsigned one byte addition and subtraction?
> I.e. I want 0-1 to equal 255 and 250+7 to equal 1.

Do the math then bitwise-and the result with 0xFF to clear all but the
least significant byte:

$x = (0 - 1) & 0xFF;
$y = (250 + 7) & 0xFF;

The parens are for clarity -- you don't need them for precedence.

-mjc


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

Date: Tue, 30 Oct 2001 23:25:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Unsigned 8 bit math (addition and subtraction)
Message-Id: <7ldutto4efovtqk86r7v0j8anq7agc16t7@4ax.com>

J.B. Moreno wrote:

>Is there an easy way to do unsigned one byte addition and subtraction?
>I.e. I want 0-1 to equal 255 and 250+7 to equal 1.

Do (& 255) on the result.

	print +(0-1)&255;
->
	255	

	print +(250+7)&255;
->
	1

-- 
	Bart.


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

Date: 30 Oct 2001 19:14:46 -0500
From: Mona Wuerz <wuerz@yahoo.com>
Subject: Re: Unsigned 8 bit math (addition and subtraction)
Message-Id: <m3pu74r7gp.fsf@DCCMBX01.njitdm.campus.njit.edu>

planb@newsreaders.com (J.B. Moreno) writes:

> Is there an easy way to do unsigned one byte addition and subtraction?
> I.e. I want 0-1 to equal 255 and 250+7 to equal 1.

`$int & 255' has been suggested. I'm fond of calling a byte a byte:

my $byte = ord pack 'C', $int;

-mona


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

Date: Tue, 30 Oct 2001 23:23:56 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: XML parsing
Message-Id: <slrn9tuat6.vsd.tadmc@tadmc26.august.net>

Bart Lateur <bart.lateur@skynet.be> wrote:
>Spike wrote:

>>However, when a large file is encountered the machine runs out of
>>memory.
>>
>>Is there some other way to deal with these XML files rather than the
>>way outlined above? Perhaps a module which deals with the file in a
>>step-wise fashion?
>
>I'm currently facing the same problem.


>Since this can contain up to tens of thousands of records, I'd like to
>process them one at a time. I do prefer a tree-like appoach.


See also XML::Records:

   http://search.cpan.org/doc/EBOHLMAN/XML-Records-0.10/Records.pm


Also also, there is a mailing list specifically for Perl and XML:

   http://listserv.ActiveState.com/mailman/listinfo/perl-xml


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 31 Oct 2001 01:07:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: XML parsing
Message-Id: <sijutt8idl54fsefdso1gls2hlpfr2l5al@4ax.com>

Tad McClellan wrote:

>See also XML::Records:

Now there's a good tip. I've installed that module, I'll play with it in
the morning.

>Also also, there is a mailing list specifically for Perl and XML:
>
>   http://listserv.ActiveState.com/mailman/listinfo/perl-xml

That could be useful. Maybe it's just me, but most of the XML modules
I've tried feel like they want me to put on my socks over my shoes...

-- 
	Bart.


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

Date: Wed, 31 Oct 2001 04:07:34 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: XML parsing
Message-Id: <aOKD7.213273$K6.104503349@news2>

[Posted and mailed]

In article <sijutt8idl54fsefdso1gls2hlpfr2l5al@4ax.com>,
	Bart Lateur <bart.lateur@skynet.be> writes:
> 
> That could be useful. Maybe it's just me, but most of the XML modules
> I've tried feel like they want me to put on my socks over my shoes...
> 

You're not alone in that assessment.  Amen.  Preach on, brother.

Most of the modules in CPAN for dealing with XML make me work very, very 
hard at using the module to deal with my XML.  Lots of documentation that
is outdated, lots of pretty-little-examples dealing with crap I'll never 
see in my job [1], or just being not-quite-ready-for-primetime [2].  
The worst offense of all: making me install lots of prerequisites 
just to use the module.

For chrissakkes:  it's just text processing.  I thought Perl was supposed
to make this stuff easy.

To be honest, I don't give a flying fark about the modules or the feelings 
of their developers.  I want to get my job done.  As a rule, I stick with 
XML::Simple.  If that's not cutting it, I use XML::Parser (I'm comfy with
that in C/expat so it's no big deal in Perl).  If it needs to be all-perl, 
I have a drop-in for XML::Simple that's written all in Perl...

I'm sorry.  I'm ranting.  I'll move on now.



[1] "So what I can have namespaces and Unicode tag names? This all-singing-
all-dancing piece of crap makes parsing 7-bit ASCII XML HARD!"  Is a typical
post-CPAN bitch about XML modules.

[2] The AxKit developers owe me two weeks of my life.  After jumping through
all of the hoops to get it installed, I find out that a major component they
sold me on was based on something that hadn't quite been released from another
package entirely (gnome?).  Bastards.  Ah, well, I'd probably have wasted those
two weeks anyway.  PS: They're STILL not ready for primetime.
-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Tue, 30 Oct 2001 16:16:57 -0800
From: Kirk Herlitz <kherlitz@mindcast.com>
Subject: Re: Yet another regexp question
Message-Id: <3BDF42F9.E16F10F8@mindcast.com>


Here's a brief solution:

my $query = "GRAGG";
my $str = "BAUGHMAN, KINNEY GRAGG, JACK A GRAGG, MARY LEA W";

if ($str =~ /($query, \w+)\s/) {
    print "$1\n";
}

This won't take into account the middle names and middle initials that
appear to be in your data file, though.  It also assumes that there's a
trailing space on each line of the data file.  There's probably a more
complete way to do this, but this should be a good start...

Kirk

Kinney Baughman wrote:
> 
> OK, I give!
> 
> I've been working on this for a couple of hours now.
> 
> I'm trying to work out a regular expression that will do the following:
> 
> 1) I have strings of names in a database.
> 
> For ex., "BAUGHMAN, KINNEY GRAGG, JACK A GRAGG, MARY LEA W".
> 
> 2) Users will search on last names, "Gragg", for example.
> 
> 3) The database will return the string above but ...
> 4) All I want to return is the first occurence of the search term plus the
> next word.
> 
> So in my example above, if someone searches on "GRAGG", then I want to
> return "GRAGG, JACK".
> 
> I've tried grouping and all sorts of techniques but I'm not even getting
> close.
> 
> So how do I do this?
> 
> Thanks.
> --
> +-----------------------------------------------------------------------+
> | Kinney Baughman                          Appalachian State University |
> | Appalachian Regional Development Institute            Boone, NC 28608 |
> | Email:   baughmankr@appstate.edu               Phone:  (828) 262-6523 |
> +-----------------------------------------------------------------------+


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

Date: Wed, 31 Oct 2001 01:03:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Yet another regexp question
Message-Id: <9bjutt0vkghasmsr43uql03u7dasfb0br5@4ax.com>

Kinney Baughman wrote:

>1) I have strings of names in a database.  
>
>For ex., "BAUGHMAN, KINNEY GRAGG, JACK A GRAGG, MARY LEA W".
>
>2) Users will search on last names, "Gragg", for example.
>
>3) The database will return the string above but ...
>4) All I want to return is the first occurence of the search term plus the
>next word.
>
>So in my example above, if someone searches on "GRAGG", then I want to
>return "GRAGG, JACK".

Solution: get your data in order. Even I as a human can't see, at a
glance, what the names are. (Isn't that "JACK A" not plain "JACK"?)

	"BAUGHMAN, KINNEY; GRAGG, JACK A; GRAGG, MARY LEA W"

There. That's a lot easier to tackle. Just split on the semicolons.

-- 
	Bart.


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

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


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