[8092] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1711 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 23 02:07:58 1998

Date: Thu, 22 Jan 98 23:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 22 Jan 1998     Volume: 8 Number: 1711

Today's topics:
    Re: @ == @, comparing arrays (Abigail)
    Re: [Q] Modifying \n\r on a directory tree of html file (Gabor)
    Re: Can I format emails send using POST, mailto? (David Efflandt)
    Re: DOS: command line wildcards (Gabor)
    Re: Executing another Perl script from inside one. (David Efflandt)
    Re: getting the full path to a perl script !!! (David Efflandt)
    Re: Hashes w/ case-insensitive keys (Tye McQueen)
        Help Setting up CGI.pm (corey andersen hammer)
        hi <luckycom@ica.net>
    Re: How do I get the hostname? (Gabor)
    Re: How does perl do "tail -n" ? (Craig Berry)
    Re: How to print right off the webpage? (David Efflandt)
    Re: I need a man to lick me in to a frenzy!!! (Craig Berry)
    Re: I need a man to lick me in to a frenzy!!! (Craig Berry)
        multi-line substitution (Brendan Macmillan)
    Re: Odd syntax problem <rjk@coos.dartmouth.edu>
    Re: Parsing HTML tag parameters (Zeus Paleologos)
    Re: Parsing HTML tag parameters (Craig Berry)
    Re: Parsing HTML tag parameters (Abigail)
    Re: Parsing HTML tag parameters <rjk@coos.dartmouth.edu>
        Perl-script to binary? (Martin Osmundsvaag)
    Re: source into binary code <rjc@liddell.cstr.ed.ac.uk>
    Re: Trouble with a regex (M.J.T. Guy)
        xs with 3rd party static libs dwatson@netguide.com
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 23 Jan 1998 05:37:22 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: @ == @, comparing arrays
Message-Id: <6a9aai$s93$1@client3.news.psi.net>

Clay Irving (clay@panix.com) wrote on 1605 September 1993 in
<URL: news:6a8hp4$imo@panix.com>:
++   
++   if ( @arrayone == @arraytwo and "@arrayone" eq "@arraytwo") {
++    ....   # arrays are same   
++   

Not!

perl -we '@a1 = ("a b", "c"); @a2 = ("a", "b c");
          print "Equal\n" if @a1 == @a2 && "@a1" eq "@a2"'

prints "Equal" for me. 

Furthermore, beside the problems you have with $" appearing in your
array elements, you need to decide how to deal with multi dimensional
arrays. Should (1, [2, 3]) be considered the same as (1, [2, 3])?
The fragment you give says they are not equal, but is that what you
want?

You can write a recursive function that takes the ref() of the elements
into account, but then what are you going to do with:
@a1 = (sub {1}); @a2 = (sub {1}); ?

As long as you don't have coderefs, you could use Data::Dumper and
compare strings.

Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: 23 Jan 1998 04:28:13 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: [Q] Modifying \n\r on a directory tree of html files to \n files for UNIX
Message-Id: <slrn6cg6na.t21.gabor@vinyl.quickweb.com>

In comp.lang.perl.misc, Ed Avis <epa@datcon.co.uk> wrote :
# On Tue, 20 Jan 1998 05:39:11 GMT, brian@brie.com (Brian Lavender)
# wrote:
# 
# >perl -pi.bak -e 's/\r//' joe.pl
# >
# >(joe.pl.bak will hold the original (DOS) contents)
# >
# >How can I make this so it traverses down a directory tree and modifies
# >all .html files? I could not find a recursive switch in the Camel
# >book. It seems that having the -i.bak switch is a good idea, but how
# >would I get rid of the .bak files once I determine the perl command
# >routine was a success?
# 
# [hmmm... see how much I can annoy people by proposing a solution _not_
# written in Perl]
# 
# From the Bourne Shell (I presume you are using Unix from the nature of
# your problem), try:
# 
# find . -type f -exec perl -pi.bak -e 's/\r//' {} \;

This would change all files, not good.

Should be 

find . -name '*.html' -exec perl -pi -e 's/\cM$//' {} \;

# 
# and
# 
# find . -type f -name \*.bak -exec rm {} \;
# 
# to remove all the *.bak files.
# 
# --
# Ed Avis


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

Date: Fri, 23 Jan 1998 05:38:43 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Can I format emails send using POST, mailto?
Message-Id: <34cd293d.9170343@flood.xnet.com>

Michael O'Sullivan <osullm@cork.cig.mot.com> wrote:

>Hi there,
>
>I operate an electronic helpdesk and want to allow my users to email
>this helpdesk via a web page.
>
>This is easy using POST and mailto in the HTML form but I need to format
>the email so that words like "Priority Urgent" are on the first line.
>Using mailto does something like:
>
>Priority=Urgent
>
>I can do it via a cgi-bin script easily but the mail gets sent from
>"nobody".
>
>How can I send the formatted email as the user who completed the form?
>
>Thanks in advance,
>
>Mike.

Not really perl related.  You may not be able to dupe where it
originates, but you can set From: and Reply-To: headers to make it
easy to reply.  UNIX 'from' may still show 'nobody' since that is who
really sent it.  Typical header using sendmail:

print MAIL <<EOM;
To: $recipient
From: $FORM{username} ($FORM{realname})
Reply-To: $FORM{username} ($FORM{realname})
Subject: $FORM{subject}\n
Below is the result of your feedback form.
EOM

David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

Date: 23 Jan 1998 04:16:29 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: DOS: command line wildcards
Message-Id: <slrn6cg61a.t21.gabor@vinyl.quickweb.com>

In comp.lang.perl.misc, Brendan Macmillan <bren@fangorn.cs.monash.edu.au> wrote :
# Gabor (gabor@vinyl.quickweb.com) wrote:
# : In comp.lang.perl.misc, B Macmillan <bren@fangorn.cs.monash.edu.au> wrote :
# 
# : # 	perl -n test.pl *.dat
# : # but the wildcard does not seem to be expanded into all the matching
# : # filenames! This is a fundamental feature of tools like grep and awk -
# 
# : It's not a feature of the tools.  It's the shell's feature, a real
# : shells's, that is.
# Hmm.. true of the (original) unix tools; but the DOS ports I have of
# these tools do have this feature... I'm using 16 bit DOS 5.0, BTW

Because they expand it themselves.  I recall there was a 'system call'
in dos that grabbed your files and could deal with globs.

#  
# : # how do I get perl to do it?
# : It's the shell that is supposed to expand the wildcard.  In DOS, if I
# : recall correctly, the shell doesn't expand wildcards.  So you have to
# : do it yourself.  
# 
# Sort of goes against the idea of Perl, doesn't it? Quoting from the
# preface of Camel book:

Nope, it doesn't.  Command.com goes against the idea of a shell. :-)

# 
# 	"Perl is different. In a nutshell, Perl is designed to make the
# easy jobs easy, without making the hard jobs impossible."
# 
# OTOH, this was surely talking about the Unix version of Perl, which
# does have access to a real shell.
# 
# -- 
# Brendan Macmillan


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

Date: Fri, 23 Jan 1998 05:21:50 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Executing another Perl script from inside one.
Message-Id: <34cc27c9.8798813@flood.xnet.com>

"Fabiano Vanucci" <vanucci@sp.dglnet.com.br> wrote:

>Can Exec() function execute another script that isn't on the same web site?
>
>I mean....
>
>First, my "post01.pl" that is located at (for example)
>"www.ibm.com/cgi-bin/post01.pl"
>Then, this "post01.pl" has to execute "rec02.pl" at
>"www.compaq.com/cgi-bin/rec02.pl", gets his return value, and process it.
>
>
>Can it be done? How?
>
>
>Thanks,
>
>
>Fabiano Vanucci

I haven't had a chance to install the LWP module which I hear does
these things, but I have some perl scripts or my own module that can
get or post data to a remote URL.  See:
http://www.xnet.com/~efflandt/pub/ under wwwpost.

David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

Date: Fri, 23 Jan 1998 05:13:56 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: getting the full path to a perl script !!!
Message-Id: <34cb2609.8350648@flood.xnet.com>

Mike Renshaw <michaelr@titan.lndn.tensor.pgs.com> wrote:

>Hi all,
>
>does anyone know a shorter way to get the full path name to a perl
>script than, this code..... this is how i do it in csh normally so ive
>just
>converted it to perl.
>
>$var = `cd \`dirname $0\`;pwd`;
>
>I know its not long winded or anything but it looks ugly, dont you agree
>?????
>
>Mike.

use Cwd;	# near the start of script
$dir = cwd();	# anywhere after

Though you want to get this before you do any chdir unless you want to
find out where you are then.


David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

Date: 22 Jan 1998 14:30:21 -0600
From: tyde@medtrodnet.cdom (Tye McQueen)
Subject: Re: Hashes w/ case-insensitive keys
Message-Id: <6a8a8t$p8m@fiinix.metronet.com>
Keywords: from just another new york perl hacker

) "Donnie Hale" <dhale@web.compuserve.com> posted:
) >
) >Unfortunately I'm not the one filling in the hash, so I don't have control
) >over that (in this case it's the Win32::Registry::GetValues method that's
) >doing it). 

Try Tie::Registry.  It gives you a tied hash to the registry that
ignores case in most cases.  The ActiveThing version of Perl doesn't
support it, though.
-
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
       Remove d's from address to reply (sorry for the inconvenience).


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

Date: 23 Jan 1998 04:49:12 GMT
From: c-hammer@students.uiuc.edu (corey andersen hammer)
Subject: Help Setting up CGI.pm
Message-Id: <6a97g8$elf$1@vixen.cso.uiuc.edu>

I'm trying to set up CGI.pm for a project I'm working on
for my research interests in psychology.  Unfortunately, I know next to nothing about PERL.  The CGI.pm webpages at www-genome.wi.mit.edu tell me I need patch 7or universal.pm to make cgi.pm work.  Everything, I find at CPAN is tar or gz 
encoded, and I'm using Win95.  I also can't even find patch 7 to PERL 5.

When I tried to set up cgi.pm by the instructions at genome, it told me to use
"perl makefile.pl" as the command line instructions.  My version of PERL doesn'
t have Makefile.PL.  

I am at a complete loss as to what to do next.  If someone can point me in the 
right direction I would appreciate it.

BTW, my new school's USENET server is not letting me access anything other 
than the university groups, so I'm including my current e-mail address because
I don;t know how to set a reply-to under nn.

Current e-mail:

chammer@shrike.depaul.edu


--
Corey Hammer
c-hammer@uiuc.edu
Visit Corey's Castle at http://www.students.uiuc.edu/~c-hammer


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

Date: Thu, 22 Jan 1998 23:29:18 -0800
From: Alexander Kovalenko <luckycom@ica.net>
Subject: hi
Message-Id: <34C846CE.D200BABB@ica.net>

hey guyz any idea how i can chmod file from my script ?
'cause it seems that just
system ("chmod","660 test.dat");
does not work out... so any ideaz would be appreciated!

--
With best wishes,
Alex.



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

Date: 23 Jan 1998 04:44:25 GMT
From: gabor@vinyl.quickweb.com (Gabor)
Subject: Re: How do I get the hostname?
Message-Id: <slrn6cg7lm.ao.gabor@vinyl.quickweb.com>

In comp.lang.perl.misc, Super-User <root@news.platinum.com> wrote :
# What's the best way to get the hostname of the system I'm running on with perl?
# 
# Thanks,
# Mike

$_= `hostname`;


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

Date: 23 Jan 1998 05:35:48 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How does perl do "tail -n" ?
Message-Id: <6a9a7l$nju$1@marina.cinenet.net>

Michael Wang (mwang@alhena.ibk.ml.com) wrote:
: How do you perl scriptors do the following? 
: 
: #/bin/ksh
: $ if [[ $(wc -l file) > 1000 ]] && {
: $   a=$(tail -100 file)
: $   print -r "$a" > file
: $ }
: 
: I need to control the size of a file within 1000 lines.

Here's a quick version:


#!/usr/bin/perl -w

use strict;

my $numLines = 10;

if (@ARGV > 0 && $ARGV[0] =~ /^-(\d+)/) {
  shift @ARGV;
  $numLines = $1;
}

my @lines = <>;

print @lines[-$numLines .. -1];


---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 23 Jan 1998 04:54:19 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: How to print right off the webpage?
Message-Id: <34ca1c4c.5856504@flood.xnet.com>

jared@frontiernet.net (Jared Evans) wrote:

>
>Is it possible to have this concept (and how to set it up?) on the web:
>
>A resume in HTML with a button at the bottom labelled "PRINT" which when
>clicked on will print out the resume locally in RTF format?
>
>I'm prettty acquainted with perl- but I'm not sure if this was the most
>proper method to use for such a task on the web?

Not really perl related, but it is at the top of your browser called
File/Print. 8-)  There is no way to have a CGI print directly it to a
client's machine (unless you are in control at both ends).  Too many
unknowns (what OS, port, type of printer, format, authorization,
etc.?).

I have printed to my Linux box when logged into a Solaris system using
rlpr, but that would not work from any other host unless specifically
authorized by my local system.  And it wouldn't work in Windoze.


David Efflandt/Elgin, IL USA
efflandt@xnet.com    http://www.xnet.com/~efflandt/


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

Date: 23 Jan 1998 04:21:35 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: I need a man to lick me in to a frenzy!!!
Message-Id: <6a95sf$hij$4@marina.cinenet.net>

John Porter (jdporter@min.net) wrote:
: What section would that be in? 1? 3?  My system doesn't seem
: to have it either.  ;-)

Subject line says it all -- 'man 2', of course.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 23 Jan 1998 04:17:41 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: I need a man to lick me in to a frenzy!!!
Message-Id: <6a95l5$hij$3@marina.cinenet.net>

Mike Stok (mike@stok.co.uk) wrote:
: In article <6a2a08$1s1$1@gaia.ns.utk.edu>,
: Jay Flaherty <fty_no_spam@utk.edu> wrote:
: 
: >while(!($frenzy)) {
: >	lick_me();
: >}
: 
: Might that be clearer as
: 
:   &lick_me until $frenzy;
: 
: Hope this helps,

It's purely a matter of taste, but I'd suggest 

  use strict 'subs';

first...but of course, TMTOWTDI. :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 23 Jan 1998 06:23:50 GMT
From: bren@fangorn.cs.monash.edu.au (Brendan Macmillan)
Subject: multi-line substitution
Message-Id: <6a9d1m$sfq$1@towncrier.cc.monash.edu.au>

I want to match across lines - just like a C-style comment, which can
begin:
	/*
on one line, and end 
	*/
on another.

It seemed to me that some of the options for s/// would do just that -
but I haven't had any luck; eg

	s/\\footnote{([^}]*)}/\[$1\]/		#use options g, s m??
only catches those on a single line. I remember doing this in sed;
but how in perl?

Thanks!!


(Yes, I'm doing a little latex2html messing around)
-- 
Brendan Macmillan


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

Date: Fri, 23 Jan 1998 01:06:22 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Odd syntax problem
Message-Id: <34C8335E.41658334@coos.dartmouth.edu>

Michael King wrote:
> 
> Try this instead:
> $_ = join('/', splice( [ split("/",$_) ], -1, 1)) if (/=/);

Not much of an improvement:

Type of arg 1 to splice must be array (not scalar ref constructor)

> And if you want to be really efficient (and fast) in simply removing the
> trailing stuff
> after the last slash in your line, try this:
> 
> s {/[^/]*?$} {} if /=/;    # remove / and the shortest string of non-/
> characters from the end of $_

Not quite right.

That should not be a non-greedy quantifier.

First, it makes the regex slower.  If there is another character to match
with [^/], you already know the $ is going to fail.  So using a non-greedy
quantifier to force the $ match first is a waste.

Second, there is one case where the assertion I just made is false: when
the string ends in a newline.  With the non-greedy quantifier, the $
matches before the newline, so the final string still has the newline
at the end.  With the normal greedy quantifier, the $ matches after the
newline and all the non-/ characters are indeed removed.

Chipmunk


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

Date: Fri, 23 Jan 1998 03:39:45 GMT
From: rl3s@netcom.com (Zeus Paleologos)
Subject: Re: Parsing HTML tag parameters
Message-Id: <rl3sEn7wu9.992@netcom.com>


In article <6a843g$hgj$2@client3.news.psi.net> on 22 Jan 1998 18:45:04 GMT,
 Abigail (abigail@fnx.com) wrote:
> warn unpack 'u*','5<V%M=65L;$!C:7,N=6%B+F5D=0T*'; (i@non.org) wrote on
> 1605 September 1993 in <URL: news:885487645.28@207.53.5.149>:
> ++ 
> ++ #!/bin/perl
> ++ 
> ++ # If I understand what the original question was,
> ++ # then if:
> ++ 
> ++     $tag = '<img src="pish.gif" alt="hello kitty" width=100>';
> ++ 
> ++ # then, this seems to do what he wants:
> ++ 
> ++     $tag =~ s/\w+?=(".+?"|\w+)/push @params, $&/ges;

> Four cases where this fails:

> <img src = "fooled you">
> <img src=fooled.you>
> <img src='fooled you'>
> <img src="fooled you" ismap>

So?  None of these are what he said he wanted to do.

> Use HTML::Parser saves you lots of problems.

Overkill for this problem when one line of code
will handle the example.

It is not always the case that investing time to
learn a new module ever pays back the expense.
So trumpeting a module for everything is not 
always the best answer when a simpler domain-
specific and easily extensible solution will suffice.

$tag =~ s/\w+?\s*?=\s*?(".+?"|'.+?'|[\.\w]+)|(\w+)/push @params, $&/ges;

which also adds the tag name as the first array element.

Zeus
--
 "specialist:  the high-priced one who get the job done, while 
  generalist:  the 'thinker' who wonders how it could be"  --ZP


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

Date: 23 Jan 1998 04:12:45 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Parsing HTML tag parameters
Message-Id: <6a95bt$hij$2@marina.cinenet.net>

Zeus Paleologos (rl3s@netcom.com) wrote:
: 
: It is not always the case that investing time to
: learn a new module ever pays back the expense.
: So trumpeting a module for everything is not 
: always the best answer when a simpler domain-
: specific and easily extensible solution will suffice.
: 
: $tag =~ s/\w+?\s*?=\s*?(".+?"|'.+?'|[\.\w]+)|(\w+)/push @params, $&/ges;
               ^   ^    ^

Do the marked non-greedy match elements change what is matched, or 
somehow improve match efficiency?  Neither seems to be the case in my 
view, but perhaps I'm missing something.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 23 Jan 1998 05:12:22 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Parsing HTML tag parameters
Message-Id: <6a98rm$rsh$1@client3.news.psi.net>

Zeus Paleologos (rl3s@netcom.com) wrote on 1606 September 1993 in
<URL: news:rl3sEn7wu9.992@netcom.com>:
++ 
++ In article <6a843g$hgj$2@client3.news.psi.net> on 22 Jan 1998 18:45:04 GMT,
++  Abigail (abigail@fnx.com) wrote:
++ 
++ > Use HTML::Parser saves you lots of problems.
++ 
++ Overkill for this problem when one line of code
++ will handle the example.
++ 
++ It is not always the case that investing time to
++ learn a new module ever pays back the expense.
++ So trumpeting a module for everything is not 
++ always the best answer when a simpler domain-
++ specific and easily extensible solution will suffice.
++ 
++ $tag =~ s/\w+?\s*?=\s*?(".+?"|'.+?'|[\.\w]+)|(\w+)/push @params, $&/ges;
++ 

But that's still wrong.

See RFC 1866. 

If you don't know how to parse HTML, please don't say using a module
is overkill.


Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: Fri, 23 Jan 1998 00:49:16 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
Subject: Re: Parsing HTML tag parameters
Message-Id: <34C82F5C.9430363B@coos.dartmouth.edu>

Zeus Paleologos wrote:
> 
>  Abigail (abigail@fnx.com) wrote:
> > warn unpack 'u*','5<V%M=65L;$!C:7,N=6%B+F5D=0T*'; (i@non.org) wrote:
> > ++
> > ++ # If I understand what the original question was,
> > ++ # then if:
> > ++
> > ++     $tag = '<img src="pish.gif" alt="hello kitty" width=100>';
> > ++
> > ++ # then, this seems to do what he wants:
> > ++
> > ++     $tag =~ s/\w+?=(".+?"|\w+)/push @params, $&/ges;
> 
> > Four cases where this fails:
> 
> > <img src = "fooled you">
> > <img src=fooled.you>
> > <img src='fooled you'>
> > <img src="fooled you" ismap>
> 
> So?  None of these are what he said he wanted to do.

That is not a safe assumption to make.  The tag provided by the original
poster was an *example*.  It is quite possible that he will encounter
tags in one of the forms presented by Abigail, or some other form that
breaks the regex solution above.

> > Use HTML::Parser saves you lots of problems.
> 
> Overkill for this problem when one line of code
> will handle the example.

A line of code that just handles the example is not sufficient.  It
should handle all the possible formats of the input.
Like HTML::Parse does.

> It is not always the case that investing time to
> learn a new module ever pays back the expense.
> So trumpeting a module for everything is not
> always the best answer when a simpler domain-
> specific and easily extensible solution will suffice.
> 
> $tag =~ s/\w+?\s*?=\s*?(".+?"|'.+?'|[\.\w]+)|(\w+)/push @params, $&/ges;
> 
> which also adds the tag name as the first array element.

You call that simple?

There are many reasons to use modules, even for domain-specific problems.

First, modules generally do things correctly.  Your regex above does
appear to work with alll five examples presented so far.
But what about this one?
<img src=fooled-you>
Now you have to edit the regex *again*.  Instead of reworking your solution
everytime you find a case where it fails, you could just use HTML::Parse
from the very beginning.

Second, modules are easy to use.  I'd rather just call a routine from
HTML::Parse than remember the above regex, and where all the parentheses
go, and when I want greedy quantifiers and when I don't.

etc...

BTW, $& should be avoided.  It causes a performance penalty on all
regular expressions in the script.

Also, what's the point in munging the original string with a
substitution?

Chipmunk


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

Date: 23 Jan 1998 03:59:00 GMT
From: martino@tor.hb.uib.no (Martin Osmundsvaag)
Subject: Perl-script to binary?
Message-Id: <885527939.898454@ole.uninett.no>

Hi!
How to make a binary exe-file out of a perl script. 
Is there a perl2c program? Where to find info about it?

Thanks in advance..
--
- Martin O.



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

Date: 23 Jan 1998 04:49:02 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: source into binary code
Message-Id: <eyhg1mfaj7l.fsf@liddell.cstr.ed.ac.uk>

In article <34C77B80.574F@min.net>, John Porter (jp) writes:

jp> Orinoco?  Shit creek?  You like those river metaphors ;-)

Well, it was intentional. Don't let on though, I know someone from
Venezuela and I have no wish to end up in hospital:-).

-- 
rjc@cstr.ed.ac.uk			_O_
					 |<



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

Date: 23 Jan 1998 04:43:39 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Trouble with a regex
Message-Id: <6a975r$cc$1@lyra.csx.cam.ac.uk>

Joe Gottman  <joegottman@nospam.worldnet.att.net> wrote:
>Mike Hammernik wrote:
>> 
>> I have a list of ip addresses that I'm trying to pull out the ones that
>> contain a particular range in the last digits.  A list of
>> 192.168.120.101
>> 192.168.116.94
>> 192.168.133.10
>> 192.168.121.30
>> etc
>> 
>> I would like to obtain only the group of ip address that in the last
>> field contain numbers from 01 to 30. expressions thatare like
>> 192\.168\.*\.[01-39] of course match 139 as well as 39. In going through
>> Mastering regex book and my perl books I have been unable to find a way
>> to do this. I've even gone through all my copies of postings in the hope
>> I would find one that asked this question before,
>> Your time and help is greatly appreciated
>>
>
>   This is a difficult regex problem, but it actually is easy if you
>don't confine
>yourself to regular expressions.  Try 
>   if ( ($ip =~ /(\d\d$)/) and ($1 >= 1) and ($1 <= 30) )

That is more or less the answer I would have posted if you hadn't got
there first.

Except that your expression doesn't do what was asked for  -  it will
match numbers like 121 as well.    Instead you want

    if ( ($ip =~ /(\d+$)/) and ($1 >= 1) and ($1 <= 30) )


Mike Guy


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

Date: Thu, 22 Jan 1998 23:51:09 -0600
From: dwatson@netguide.com
To: dwatson@netguide.com
Subject: xs with 3rd party static libs
Message-Id: <885534094.926613505@dejanews.com>

Hello Perl Community,

  I have a C function which uses a 3rd party vendors C libaries.  The
libraries were supplied as a set of static .a files (libfoo.a, libbar.a,
&Etc) and a set of header files (foo.h, bar.h,...).  I must use their API
to do a remote procedure call and get a scalar string result back.

  My Perl is version 5.004_4 on Solaris 2.51 with dynamic linking.  The
Perl executable itself is static.  I believe this is the 'default' from
the configure script.  See below for the output of perl -V.

  I used h2xs to build an XS extention.  I #includ'ed the header files
and the body of my C function in the .xs file.	It compiled and built a
 ..so file, but there were unresolved refferences from the .so file back to
the lib files when I did 'make test'.  It failed during the 'use
ModuleName' part of test reporting:

   'Unresolved symbol foo_func ...'

  I think ld the linker was supplied with information on where to find
the libraries during compile time, but it did not have this information
at run time.  So I moved the libfoo.a files to /usr/local/lib where ld
would be able to find them.  Yes, /usr/local/lib is in my
$LD_LIBRARY_PATH.  It was still unable to resolve the symbols from the
libfoo.a files.

  What is the relationship between .o, .a, and .so files?  It seems to me
that there is some incompatability between the .so extention Perl built
and the .a files.  Is ld smart enough to link object code from .a files
dynamicaly into .so code?

  As a potential work around, I used ar to unpack the .a files into a
bunch of .o object files and added them to Makmaker.PL and rebuilt the
 ..so file.  The linking errors from the .so to the .a library symbols have
gone away!

However, now 'make test' reports at runtime:
   Can't find 'boot_MyName__ModuleName' symbol in
 ../blib/arch/auto/MyName/ModuleName/ModuleName.so

Shouldn't xs build that function for me?  What does bootstrap do?  I
think it makes the C function name visible to Perl.

One very strange thing I see is that xs did not build a ModuleName.c file
out of the .xs file.  I looked in a example I built like this,
Math::Sequence and it had a Sequence.c file with what looked like a macro
-> XS(boot_Math__Sequence).

What has happened here?  Any advice or help with wrapping 3rd party
libraries with XS (or SWIG which I will try next) would be greatly
appreciated.  All I have is object code and headers for the libs.  I want
to create a C wrapper for several functions and have it dynamically link
into Perl.


Dennis

####
% which ld
/usr/ccs/bin/ld

#### Example of my .xs file #### I don't know if I can show you the real
thing because of trade secrets and NDA's, &Etc. ... #include<foo.h>
#include<bar.h> ... char* myfunc (char* val1, char* val2)  char* val1, 
char* val2  CODE:

   char* x, y, result;
   x = foo_func(val1);
   y = bar_func(val2);
   result = foobar_func(x, y, val1, val2);

   RETVAL = result;
   OUTPUT:
   RETVAL


#### Output of perl -V

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration: 
Platform:  osname=solaris, osvers=2.5.1, archname=sun4-solaris 
uname='sunos octopus 5.5.1 generic_103640-12 sun4u sparc sunw,ultra-1 ' 
hint=previous, useposix=true, d_sigaction=define  bincompat3=n
useperlio=undef d_sfio=undef  Compiler:  cc='gcc', optimize='-O',
gccversion=2.7.2.2  cppflags='-I/usr/local/include'  ccflags
='-I/usr/local/include'  stdchar='unsigned char', d_stdstdio=define,
usevfork=false	voidflags=15, castflags=0, d_casti32=define,
d_castneg=define  intsize=4, alignbytes=8, usemymalloc=y,
prototype=define  Linker and Libraries:  ld='gcc', ldflags ='
-L/usr/local/lib'  libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib 
libs=-lsocket -lnsl -lgdbm -ldb -ldl -lm -lc -lcrypt  libc=/lib/libc.so,
so=so  useshrplib=false, libperl=libperl.a  Dynamic Linking: 
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' 
cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Built under solaris
  Compiled at Jan 13 1998 10:15:30
  @INC:
    /usr/local/lib/perl5/sun4-solaris/5.00404
    /usr/local/lib/perl5
    /usr/local/lib/perl5/site_perl/sun4-solaris
    /usr/local/lib/perl5/site_perl
    .

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 1711
**************************************

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