[16832] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4244 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 7 00:05:32 2000

Date: Wed, 6 Sep 2000 21:05:11 -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: <968299511-v9-i4244@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 6 Sep 2000     Volume: 9 Number: 4244

Today's topics:
    Re: "dashed" params... schnurmann@my-deja.com
    Re: "dashed" params... schnurmann@my-deja.com
        Bit fields in perl <vandewal@skyblue.com>
        CPU, Memory, HD Load Prediction <jdb@wcoil.com>
        Date Related Issue <lbg-goeff@powerup.com.au>
    Re: Date Related Issue (Maurice E. Jarrell)
    Re: Date Related Issue <bwalton@rochester.rr.com>
    Re: Generate Graphics by Perl (Abigail)
    Re: golf: remove .txt from filenames <wyzelli@yahoo.com>
    Re: golf: remove .txt from filenames <wyzelli@yahoo.com>
    Re: golf: remove .txt from filenames (Abigail)
    Re: golf: remove .txt from filenames <stephenk@cc.gatech.edu>
    Re: golf: remove .txt from filenames <wyzelli@yahoo.com>
    Re: Help needed - regexp (Mark-Jason Dominus)
    Re: Help needed - regexp <rick.delaney@home.com>
    Re: help with a hash? (Daniel Chetlin)
    Re: help with a hash? <christopher_j@uswest.net>
        how could I convert a string to a hex ASCII <lucas@cplhk.com>
    Re: how could I convert a string to a hex ASCII <tony_curtis32@yahoo.com>
    Re: How to get my IP address as a string <jdiadamo@cisco.com>
        HTML subroutines xlr6drone@my-deja.com
    Re: HTML subroutines <stephenk@cc.gatech.edu>
    Re: HTML subroutines <bwalton@rochester.rr.com>
    Re: HTML subroutines news4jim@my-deja.com
    Re: INTERNATIONAL PERL TELECOMMUTING (Abigail)
    Re: Logic Check <s1sims@home.com>
    Re: Logic Check <bwalton@rochester.rr.com>
        Need help with Win32::Console input <randy_734@my-deja.com>
        Newbie SWIG question -- who owns char * return values? (Ron Newman)
    Re: newbie: redirect problem <godzilla@stomp.stomp.tokyo>
    Re: Self-extracting program <bernie@fantasyfarm.com>
        types.h missing from my installation <john@eagleinfosystems.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 07 Sep 2000 02:03:10 GMT
From: schnurmann@my-deja.com
Subject: Re: "dashed" params...
Message-Id: <8p6t0j$48a$1@nnrp1.deja.com>

Yes it does.  Very slick.

In article <m3wvgpv1sk.fsf@franl.andover.net>,
  Francis Litterio <franl-removethis@world.omitthis.std.com> wrote:
> schnurmann@my-deja.com writes:
>
> > Where can I find information on how to support calls like this to my
> > subroutines?
> >
> > $my_obj->a_routine(-param1 => 'value', -param2 => 'another value', -
> > something_else => 10);
>
> The => is just a fat comma.  The above syntax simply passes a list of
> strings to the function.  In the above case, the strings are:
>
> 	'-param1'
> 	'value'
> 	'-param2'
> 	'another value'
> 	'-something_else'
> 	'10'
>
> The called function then takes @_ (the argument list) and initializes
a
> hash with it, like this:
>
> 	my %args = @_;
>
> So that the named args can be accessed like this:
>
> 	$args{-param2}
>
> Hope this helps.
> --
> Francis Litterio
> franl-removethis@world.std.omit-this.com
> PGP public keys available on keyservers.
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 07 Sep 2000 01:58:39 GMT
From: schnurmann@my-deja.com
Subject: Re: "dashed" params...
Message-Id: <8p6so5$3tp$1@nnrp1.deja.com>

I am waning to do more like that is in CGI.pm.

In article <x78zt5l88c.fsf@home.sysarch.com>,
  Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "s" == schnurmann  <schnurmann@my-deja.com> writes:
>
>   s> Where can I find information on how to support calls like this to
my
>   s> subroutines?
>
>   s> $my_obj->a_routine(-param1 => 'value', -param2 => 'another
value', -
>   s> something_else => 10);
>
> just assign all the args to a hash and deal with them then.
>
> sub a_routine {
>
> 	my( $self, %args ) = @_ ;
>
> 	$foo_arg = $args{'-foo'} || $default_foo ;
>
> that works unless you want to be able to pass in a false value to
> $foo_arg. then use:
>
> 	$foo_arg = exists $args{'-foo'} ? $args{'-foo'} : $default_foo ;
>
> uri
>
> --
> Uri Guttman  ---------  uri@sysarch.com  ----------
http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX
Consulting
> The Perl Books Page  -----------
http://www.sysarch.com/cgi-bin/perl_books
> The Best Search Engine on the Net  ----------
http://www.northernlight.com
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 06 Sep 2000 21:27:47 -0500
From: "David E. Vandewalle" <vandewal@skyblue.com>
Subject: Bit fields in perl
Message-Id: <13AD5852E1762059.56CCBEB6EA96D246.128621E87CFADD3F@lp.airnews.net>

Hey,

I need to do something in perl invloving packed binary data that is a little
different
than anything else I have ever done in perl.  Although I have figured out a way
to do it,
it seems like a kludge, and I'm looking for a cleaner method.  

Here's the deal:

I've got a text file full of hex data in 16 bit words.
(it's a dump of a MIL-STD-1553 message buffer ... if anyone cares)

looks kinda like this:
1234 ABCD 1234 ABCD 1234 ABCD 1234 ABCD
1234 ABCD 1234 ABCD 1234 ABCD 1234 ABCD
1234 ABCD 1234 ABCD 1234 ABCD 1234 ABCD
1234 ABCD 1234 ABCD 1234 ABCD 1234

Now, if all of the data were in chunks that were multiples of one word,
I would be ready to rock, but that would be _far_ too easy.

What I've got is multiple fields of various lengths packed into each word. 
Luckily fields
are not allowed to span between words.  Fields can be (and are) any length from 
1 bit to 16 bits.

I have another text file that describes the word number and bit locations of
each
field. (it's actually an ada source module ... if anyone cares)

After reading up on pack/unpack my initial thought at how to attack this was to
read each word as a scalar, unpack into a binary string of 16 ones/zeros, hack
off 
the leading/trailing places I don't need, and then convert back to scalar. Or
something
along those lines.

Is there a simpler, faster, or more elegant way to do this than what I'm
describing?

any and all input is greatly appreciated, and thanks for the time.
/dev

-- 
// David E. Vandewalle          | Meekness : Uncommon patience in planning 
// vandewal @ SPAM-ME-NOT       |            a revenge that is worth while.
//            dhc.net           |  -- Ambrose Bierce


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

Date: 7 Sep 2000 02:53:02 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: CPU, Memory, HD Load Prediction
Message-Id: <8p6vue$5i6$0@206.230.71.39>

I apologize to everyone that found a broken link when they went to download
my recently announced CPU load prediction scripts. I was just made aware of
the problem, and I have fixed the link, along with adding two other simple
scripts.

You can download the CPU load monitoring script from:
http://www.josiah.countystart.com/modules/get.pl?cpu:misc-

Memory load monitor/generalization script from:
http://www.josiah.countystart.com/modules/get.pl?mem:misc-

Hard Disk activity monitor/load generalization script from:
http://www.josiah.countystart.com/modules/get.pl?hd:misc-

Please let me know if there are better ways to do this. I dont claim to have
found the perfect way, just a way that -appears- to work on my system.

--
Josiah Bryan
jdb@wcoil.com
Tel: 937.316.6256





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

Date: Thu, 7 Sep 2000 11:24:00 +1000
From: "GEOFF" <lbg-goeff@powerup.com.au>
Subject: Date Related Issue
Message-Id: <39b6ecd7@grissom>

I am having some problems with a little date related issue.  I know how to
get the date in perl using localtime but I am looking to do something fancy
with it.

I need to compare a date string retrieved from a microsoft access DB via the
DBI modual DBD::ODBC with a current date string retirieved from the
localtime modual.  I must then check if the date string from the database is
7 days older than the current localtime date string I get from localtime. I
can write code to format the strings in the same way and the make a
comparison but I know that would be too sloppy.

Is there some Perl code or OO Perl modual written to take a date comparision
argument and return a yes/no string? or something like that?

eg.  (excuse my ignorance)

$database_date = "2000-01-01"; #or some other format

use DATE_MODUAL;

$date_object = new DATE_MODUAL;

$yes_or_no = $date_object ->function(minus 7days from $database_date);






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

Date: Thu, 07 Sep 2000 02:34:42 GMT
From: mejarrell@worldnet.att.net (Maurice E. Jarrell)
Subject: Re: Date Related Issue
Message-Id: <m3lmx5xn8j.fsf@localhost.localdomain>

"GEOFF" <lbg-goeff@powerup.com.au> writes:


> Is there some Perl code or OO Perl modual written to take a date comparision
> argument and return a yes/no string? or something like that?
> 

The on-line docs are very helpful.  You can search the FAQ's by typing
'perldoc -q date' at the command prompt.  When I did it, the first
result was "How do compare two dates and find the difference?  It
points to two modules from CPAN: Date::Calc and Date::Manip.

Try 'perldoc perl' for a more general intro to these docs.  ( As well
as the FAQ for this group, which has lots more places to look for
help.

HTH,
Mo


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

Date: Thu, 07 Sep 2000 02:47:11 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Date Related Issue
Message-Id: <39B701D4.691AD60C@rochester.rr.com>

GEOFF wrote:
> 
> I am having some problems with a little date related issue.  I know how to
> get the date in perl using localtime but I am looking to do something fancy
> with it.
> 
> I need to compare a date string retrieved from a microsoft access DB via the
> DBI modual DBD::ODBC with a current date string retirieved from the
> localtime modual.  I must then check if the date string from the database is
> 7 days older than the current localtime date string I get from localtime. I
> can write code to format the strings in the same way and the make a
> comparison but I know that would be too sloppy.
> 
> Is there some Perl code or OO Perl modual written to take a date comparision
> argument and return a yes/no string? or something like that?
> 
> eg.  (excuse my ignorance)
> 
> $database_date = "2000-01-01"; #or some other format
> 
> use DATE_MODUAL;
> 
> $date_object = new DATE_MODUAL;
> 
> $yes_or_no = $date_object ->function(minus 7days from $database_date);

Date::Manip and/or Date::Calc should be a big help.
-- 
Bob Walton


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

Date: 07 Sep 2000 02:33:38 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Generate Graphics by Perl
Message-Id: <slrn8rdvi9.pkg.abigail@alexandra.foad.org>

Sean Malloy (srmalloy@home.com) wrote on MMDLXIII September MCMXCIII in
<URL:news:mlldrs8li8to3tmheq45ovfrb7oqp3jvji@4ax.com>:
][ 
][ Bar charts are easy -- cheat.
][ 
][ 1) Create as many NxN GIF images as you have different-colored bars
][    (if they're solid color, you can make them 1x1).
][ 
][ 2) Have your Perl script manipulate its data and produce a table. For
][    each bar in the chart -- either a row or column in the table -- you
][    put an <IMG> tag with the bar image resized to make it the right 
][    size for that bar. For example, if you wanted percentages as
][    horizontal bars ten pixels high, and the space for the bars gave
][    you 400 pixels, then you would have your Perl script compute the
][    percentage, multiply it by four, and use that as the WIDTH 
][    attribute of the <IMG> tag.


That would fail miserably if someone decides to download the image, right?



Abigail
-- 
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
           print+Just (), another (), Perl (), Hacker ();'


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

Date: Thu, 7 Sep 2000 10:21:50 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: golf: remove .txt from filenames
Message-Id: <OXBt5.14$8S.2851@vic.nntp.telstra.net>

>
> Saving 19 strokes:
>
>    ls|perl -ne'/\.txt$/&&rename$_,$`'
>

Won't work very well on Windows as stated by the OP.

Wyzelli




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

Date: Thu, 7 Sep 2000 10:26:14 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: golf: remove .txt from filenames
Message-Id: <Z%Bt5.15$8S.2895@vic.nntp.telstra.net>

"Smylers" <Smylers-usenet@stripey.com> wrote in message
news:2000Sep6.205334.27065@leeds.ac.uk...

> I thought maybe a nasty uncaptured Unix `mv` would help, but since the
> glyph for that clashes with $`, it doesn't:
>
>   perl -e'map{`mv $\`$& $\``if/\.txt$/}<*>'
>   perl -e'map{qx{mv $`$& $`}if/\.txt$/}<*>'

Definitely not on a Windows box (unless a unix toolkit is installed).
The OP said Windows.

Wyzelli




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

Date: 07 Sep 2000 02:30:50 GMT
From: abigail@foad.org (Abigail)
Subject: Re: golf: remove .txt from filenames
Message-Id: <slrn8rdvd1.pkg.abigail@alexandra.foad.org>

Andrew N. McGuire  (anmcguire@ce.mediaone.net) wrote on MMDLXIII
September MCMXCIII in <URL:news:Pine.LNX.4.21.0009061806110.4147-100000@hawk.ce.mediaone.net>:

Trivial save of 2 strokes:

`` perl<CR>
`` map{/\.txt$/;rename$_,$`}<*>

   /\.txt$/,rename$_,$`for<*>

`` C-d
`` 
`` which actually saves 3 strokes on that if my count is correct.
`` (I dont know if that is allowed in golf!!!)

Hmmm " ", "-", "e", "'", "'" vs "<CR>", "<CR>", "^D". That's a difference
of 2, or 1 if you count ^D as two strokes.

`` which does all files (I dont know why I used ?? before, trying to be
`` cute I guess).  Uri's is still the champion, but mine does not use
`` unix commands.  One note, Uri's modification to Abigails post works
`` in Bourne shell variants, but not C shell (tcsh at least). So you
`` may want to qualify that as:

That's scary. What on earth does tcsh do with ls, pipes or perl that
it manages to not work? Are you sure it isn't a bug in your version
of tcsh?

(Note that none of the solutions so far has managed to handle ".foo.txt"
 correctly, or "foo.txt\n" for that matter. Also, the files "..txt" and
 "...txt" cannot be dealt with at all)


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: Wed, 06 Sep 2000 22:50:16 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: golf: remove .txt from filenames
Message-Id: <39B70267.BFB65D97@cc.gatech.edu>

Abigail wrote:

>
> (Note that none of the solutions so far has managed to handle ".foo.txt"
>  correctly, or "foo.txt\n" for that matter. Also, the files "..txt" and
>  "...txt" cannot be dealt with at all)
>

That would probably require replacing <*> with (<*>,<.*>) , an extra 7 keystrokes.  Is it worth
it, for a few (IMO) relatively obscure cases?

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Thu, 7 Sep 2000 12:15:13 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: golf: remove .txt from filenames
Message-Id: <5DDt5.17$8S.3183@vic.nntp.telstra.net>

"Abigail" <abigail@foad.org> wrote in message
news:slrn8rdvd1.pkg.abigail@alexandra.foad.org...
>
> (Note that none of the solutions so far has managed to handle
".foo.txt"
>  correctly, or "foo.txt\n" for that matter. Also, the files "..txt"
and
>  "...txt" cannot be dealt with at all)
>

The only one of those which is a legal filename under Windoze is
".foo.txt".  The rest are not 'creatable' without extreme contortions.

Wyzelli




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

Date: Thu, 07 Sep 2000 03:00:42 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Help needed - regexp
Message-Id: <39b704d9.1ca2$16a@news.op.net>

The benchmark file is at

        http://www.plover.com/~mjd/perl/greedymatch.pl

Sorry for omitting this before.

In article <MPG.142069fc256036a698ad32@nntp.hpl.hp.com>,
Larry Rosler  <lr@hpl.hp.com> wrote:
>What I don't see is how the performance of the two regexes should
>differ.

/(.*?)>/ starts by having .*? match the empty string; then it looks
for a following >.  When it doesn't see one, it backtracks and tries
having .*? match one character; then it looks for a following >.  If
there isn't one, it backtracks again, and so on.  It backtracks at
every step, making .*? a little longer each time, until .*? matches
the right number of characters.  At every step the value in $1 must be
adjusted.

/[^>]*>/ starts by having [^>]* match as many non-'>' characters as
possible.  Then it looks for a following >.  This is guaranteed to
succeed because the [^>]* already ate up the right number of preceding
characters.  So there's no backtracking, it guesses right on the first
try, and drops the right string into $1 immediately.  

>Unlike '.*', '.*?' shouldn't eat up everything then backtrack.  

It backtracks in the other direction: Instead of eating too much at
first and then backing off, it eats too little and then tries more and
more until it gets the right amount.

> This should be exactly the same ...

In the original poster's example, both expressions are correct, but
this is not always the case and there is no way for Perl to know it.
For example:

        "foo>bar>" =~ /^(.*?)>$/;

is not at all the same as 

        "foo>bar>" =~ /^([^>]*)>$/;

The first one matches and the second does not.


The [^>]*> expression runs more quickly because it is more specific;
the .*?> expression is more vague.  There is no way for Perl to be
able to tell when it sees .*?  that even though you *said* '.'  what
you really *meant* was '[^>]'.  The regex can run faster because the
with the [^>]* notation you are giving more specific information to
the compiler.

>'[^>]*', which should stop at the first non-'>' character.
>
>If their performances differ as much as you say, there may be an 
>implementation deficiency (aka optimization opportunity).

That is a nice fantasy, but it is not very likely, because the
compiler would have to read your mind and know what you really meant
instead of what you actually said.

If it makes you happier, I have a prototype of a module which will
lint your regexes so that

        use re 'lint';
        
        /<(.*?)>/;

produces the message

        (.*?)> may be better written as ([^>]*)> at line 3 of foo.pl

among other things.  I will probably release this sometime laster this
fall.

A good rule of thumb, which works 95% of the time, is that all
non-greedy matches are suboptimal.  It is very rare to actually need a
non-greedy match.

I think the character class match is more straightforward also, but
this is matter of taste.



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

Date: Thu, 07 Sep 2000 03:59:48 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Help needed - regexp
Message-Id: <39B71530.40D601DA@home.com>


Mark-Jason Dominus wrote:
> 
> >
> >If their performances differ as much as you say, there may be an
> >implementation deficiency (aka optimization opportunity).
> 
> That is a nice fantasy, but it is not very likely, because the
> compiler would have to read your mind and know what you really meant
> instead of what you actually said.

Actually, it already makes a small attempt at reading your mind by
looking ahead to the next regexp node.  If the next thing to match is a
fixed string (">" in this case), then .*? can quickly jump ahead to it.

Unfortunately, in the case of /<(.*?)>/, the grouping interferes with
this look-ahead (since the next node is CLOSE, rather than EXACT).

Just run this and observe the difference in behaviour:

    use re 'debug';
    "<abc>" =~ /<(.*?)>/;
    "<abc>" =~ /(<.*?>)/;

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Thu, 07 Sep 2000 02:02:20 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: help with a hash?
Message-Id: <MGCt5.1049$p8.89837@news-west.usenetserver.com>

On Wed, 6 Sep 2000 10:21:04 -0700, Christopher M. Jones
<christopher_j@uswest.net> wrote:
>Well, since everyone else gave you the easy ways I might as well give
>you the hard (well not really, but by comparison maybe) way.
>
># assume $file contains the file
>%link = (); while ($file =~
>s{<a.*?href\s*\=\s*\"(.*?)\"\.*?>(.*?)</a>}{}si) { $link{$1} = $2; }
                             ^ did you want to escape that?

  [~] $ perl -nle's{<a.*?href\s*\=\s*"(.*?)"\.*?>(.*?)</a>}{}si && print "$1"'
  <a href="blah" shape="rect">foo</a>
  blah" shape="rect

But even assuming you meant an unescaped dot:

  [~] $ perl -nle's{<a.*?href\s*\=\s*"(.*?)".*?>(.*?)</a>}{}si && print "$1"'
  <a name="oops">don't forget the href="stuff" <strong>here</strong></a>
  stuff

The basic moral of the story is, don't do it this way. There are modules
that solve these problems, and you won't make inevitable mistakes like
this one. I know you posted this just because you could, and you saw the
other posts, and I'm sure you didn't mean to suggest it be done that way
for real. But unfortunately, lots of people read these posts, and they
might look at your REx and think that it's OK to use in production.

HTML::Parser, URI::Find, and friends are what should be used for this
sort of thing.

-dlc




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

Date: Wed, 6 Sep 2000 20:17:10 -0700
From: "Christopher M. Jones" <christopher_j@uswest.net>
Subject: Re: help with a hash?
Message-Id: <zNDt5.1931$Ok5.341074@news.uswest.net>


"Daniel Chetlin" <daniel@chetlin.com> wrote:
> On Wed, 6 Sep 2000 10:21:04 -0700, Christopher M. Jones
> <christopher_j@uswest.net> wrote:
> >Well, since everyone else gave you the easy ways I might as well give
> >you the hard (well not really, but by comparison maybe) way.
> >
> ># assume $file contains the file
> >%link = (); while ($file =~
> >s{<a.*?href\s*\=\s*\"(.*?)\"\.*?>(.*?)</a>}{}si) { $link{$1} = $2; }
>                              ^ did you want to escape that?

No, thanks, good catch.

[snip]

> But even assuming you meant an unescaped dot:
>
>   [~] $ perl -nle's{<a.*?href\s*\=\s*"(.*?)".*?>(.*?)</a>}{}si && print
"$1"'
>   <a name="oops">don't forget the href="stuff" <strong>here</strong></a>
>   stuff

Oooo yeah, that'll cause a problem, my bad.

>
> The basic moral of the story is, don't do it this way. There are modules
> that solve these problems, and you won't make inevitable mistakes like
> this one. I know you posted this just because you could, and you saw the
> other posts, and I'm sure you didn't mean to suggest it be done that way
> for real. But unfortunately, lots of people read these posts, and they
> might look at your REx and think that it's OK to use in production.
>
> HTML::Parser, URI::Find, and friends are what should be used for this
> sort of thing.

Very true, but it's always good to keep the ol' chops in shape.

Let's try this one last time (for the sake of completeness)

=~ s{<a[^>]*?      (?# find <a[anything]href, but don't skip past the >)
 href\s*\=\s*      (?# allow padded whitespace around the =)
 (?:\")?           (?# ", but if it's not there don't)
 ([\w\.\%\@\:\?\&\+\-\=/]+?)   (?# the meat, find something url-ish)
 (?:\")?           (?# ", but if it's not there don't)
 [^>]*?            (?# all the characters past the end of the url to the)
                    (?#  end of the tag, but don't go past the end)
 >                 (?# end of the tag)
 (.*?)             (?# any characters, up to the </a>)
 </a>}             (?# the matching end anchor tag)
 {}six             (?# replace with nothing)


That should do the trick.




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

Date: Thu, 7 Sep 2000 11:14:16 +0800
From: "Lucas Tsoi" <lucas@cplhk.com>
Subject: how could I convert a string to a hex ASCII
Message-Id: <8p7100$8b845@imsp212.netvigator.com>

how could I convert a string to a hex ASCII?

thanks




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

Date: 06 Sep 2000 22:15:38 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: how could I convert a string to a hex ASCII
Message-Id: <87em2wsxid.fsf@limey.hpcc.uh.edu>

>> On Thu, 7 Sep 2000 11:14:16 +0800,
>> "Lucas Tsoi" <lucas@cplhk.com> said:

> how could I convert a string to a hex ASCII?

sorry, that's meaningless.  If you supply some examples
and explanatory commentary, it might be easier to help...

hth
t
-- 
WWNKD?


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

Date: Thu, 7 Sep 2000 00:04:13 -0400
From: "Joe DiAdamo" <jdiadamo@cisco.com>
Subject: Re: How to get my IP address as a string
Message-Id: <968299532.192613@sj-nntpcache-3>

SERVER_ADDR?  Is this new?  Can't find it in any of the CGI references I
have access to...

 ...joe

"Christopher M. Jones" <christopher_j@uswest.net> wrote in message
news:eKvt5.2328$Xq2.193168@news.uswest.net...
>
> "Jonaskuh" <jonaskuh@tell-em-off.com> wrote:
> > If you are talking about just retrieving it when using perl with a
> > webserver, just do the following:
> >
> > $ipstring = $ENV{'REMOTE_ADDR'};
> >
> > That'll do it.
>
> WRONG!!
>
> That is the ip address of the client, what is needed is
>
> $ENV{'SERVER_ADDR'};
>
>
> and,
> $ENV{'HTTP_HOST'};
> will return the full host (+domain) name
>
>
>




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

Date: Thu, 07 Sep 2000 01:14:38 GMT
From: xlr6drone@my-deja.com
Subject: HTML subroutines
Message-Id: <8p6q5g$146$1@nnrp1.deja.com>

Hi,

I am trying to creater a header and footer subroutine and then add
additional html code with perl code in the middle.

I want to use the print <<"label"; shortcut for the HTML instead of
printing it line by line.

When I try to run the script I get an error stating:


Can't find string terminator "HTML code" anywhere before EOF at ../subr/
header_footer.lib line 3.

However I have included the terminator at the end of each of the sub
routines.  Here is the code for the sub routines and code from the main
script:

-----

subroutines:

sub header {
print "Content-type: text/html\n\n";
print <<"HTML code";

<html>

		#(removed html code)

		"HTML code">>;

		}



sub footer {
print <<"HTMLfooter code";


	#(removed html code)


</html>
	HTMLfooter code

	}
1;


main script:
------------

require "../subr/header_footer.lib";

&header;
print "<table><tr><td>test</td></tr></table>";
&footer;

----------
thanks,
Tim


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 06 Sep 2000 22:23:59 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: HTML subroutines
Message-Id: <39B6FC3F.D3253495@cc.gatech.edu>

xlr6drone@my-deja.com wrote:

> Hi,
>
> I am trying to creater a header and footer subroutine and then add
> additional html code with perl code in the middle.
>
> I want to use the print <<"label"; shortcut for the HTML instead of
> printing it line by line.
>
> When I try to run the script I get an error stating:
>
> Can't find string terminator "HTML code" anywhere before EOF at ../subr/
> header_footer.lib line 3.
>
> However I have included the terminator at the end of each of the sub
> routines.  Here is the code for the sub routines and code from the main
> script:
>
> -----
>
> subroutines:
>
> sub header {
> print "Content-type: text/html\n\n";
> print <<"HTML code";
>
> <html>
>
>                 #(removed html code)
>
>                 "HTML code">>;
>
>                 }
>
> sub footer {
> print <<"HTMLfooter code";
>
>         #(removed html code)
>
> </html>
>         HTMLfooter code
>
>         }

Your string terminators should be alone and at the end of the line:
print <<"HTML code";
HTML Text Here ...
HTML code

Details are in perlfaq4 (and probably elsewhere, but I'm not sure where).

--
Stephen Kloder               |   "I say what it occurs to me to say.
stephenk@cc.gatech.edu       |      More I cannot say."
Phone 404-874-6584           |   -- The Man in the Shack
ICQ #65153895                |            be :- think.




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

Date: Thu, 07 Sep 2000 02:44:21 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: HTML subroutines
Message-Id: <39B7012A.272985D8@rochester.rr.com>

xlr6drone@my-deja.com wrote:
 ...
> I am trying to creater a header and footer subroutine and then add
> additional html code with perl code in the middle.
> 
> I want to use the print <<"label"; shortcut for the HTML instead of
> printing it line by line.
> 
> When I try to run the script I get an error stating:
> 
> Can't find string terminator "HTML code" anywhere before EOF at ../subr/
> header_footer.lib line 3.
> 
> However I have included the terminator at the end of each of the sub
> routines.  Here is the code for the sub routines and code from the main
> script:
> 
> -----
> 
> subroutines:
> 
> sub header {
> print "Content-type: text/html\n\n";
> print <<"HTML code";
> 
> <html>
> 
>                 #(removed html code)
> 
>                 "HTML code">>;
> 
>                 }
> 
> sub footer {
> print <<"HTMLfooter code";
> 
>         #(removed html code)
> 
> </html>
>         HTMLfooter code
> 
>         }
> 1;
> 
> main script:
> ------------
> 
> require "../subr/header_footer.lib";
> 
> &header;
> print "<table><tr><td>test</td></tr></table>";
> &footer;
 ...
> Tim
 ...
You need to read up on the syntax for using "here documents".  See:

    perldoc -q "here documents"

Basically, your biggest problem is that the target *must* start in
column 1.
-- 
Bob Walton


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

Date: Thu, 07 Sep 2000 02:53:20 GMT
From: news4jim@my-deja.com
Subject: Re: HTML subroutines
Message-Id: <8p6vur$7i6$1@nnrp1.deja.com>



> sub header {
> print "Content-type: text/html\n\n";
> print <<"HTML code";
>
> <html>
>
> 		#(removed html code)
>
> 		"HTML code">>;

This last line should be:

HTML code

 ... on its own, flush left, no quotes, no brackets, no semicolon.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 07 Sep 2000 02:35:12 GMT
From: abigail@foad.org (Abigail)
Subject: Re: INTERNATIONAL PERL TELECOMMUTING
Message-Id: <slrn8rdvl7.pkg.abigail@alexandra.foad.org>

brian d foy (brian+usenet@smithrenaud.com) wrote on MMDLXIV September
MCMXCIII in <URL:news:brian+usenet-1E109E.20510906092000@news.panix.com>:
)) In article <39b6ccf0$3_2@goliath.newsfeeds.com>, 
)) TelecommutePERL@GlobalWorkInt.com wrote:
)) 
)) > Using a Remote Control software utility called TIMBUKTU,
)) > 2 people can work on the same computer simultaneously.
)) 
)) two programmers at the same time? wow.


Well, you've seen the Windows "natural" keyboards haven't you?
This is the next step.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
#    Two warriors dying
#    beside a stream. A monk.
#    Six pikes swim. An eagle.


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

Date: Thu, 07 Sep 2000 03:06:01 GMT
From: Tuxman <s1sims@home.com>
Subject: Re: Logic Check
Message-Id: <39B70606.98AC5479@home.com>

I am writing a script to convert my phone messages
to *.wav format from vgetty. Serving the files out
on my webserver so I can check my messages from
any computer I happen to be at. Anyway got it
working, except it only converts the first file in
the directory. I want it to loop through my
/var/spool/voice/incoiming  directory and convert
all *.rmd files to *.wav format. My question is
this, does an exec statement when placed in a
foreach loop break the loop? Below is the excerpt
from my script:

# loop through the /var/spool/voice/incoming and
convert

$ext = ".wav";
$msg ="";
$myjoin = "";
$dir = "/var/spool/voice/incoming/";

chdir("$dir") || die "Cannot cd to $dir ($!)";

foreach $msg (<*.rmd>) { # step through the list
of *.rmd files
 $myjoin = "$msg"."$ext"; # concatenate to put an
 .wav ext on the file

# Now lets convert them thar audio files
 exec "rmdtopvf $msg | pvfspeed -s 8000 |
pvftowav>$myjoin";
}

Seems like this should work, can someone enlighten
me? Thank

Tuxman




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

Date: Thu, 07 Sep 2000 03:11:41 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Logic Check
Message-Id: <39B70791.38E3BF59@rochester.rr.com>

Tuxman wrote:
 ...
>                                My question is
> this, does an exec statement when placed in a
> foreach loop break the loop? Below is the excerpt
> from my script:
<script deleted>
> Seems like this should work, can someone enlighten
> me? Thank
> 
> Tuxman

Maybe

   perldoc -f exec

would enlighten you a bit if you would bother to read it.  There it
says, in the first two lines:

            The `exec' function executes a system command *and never
            returns*-- use `system' instead of `exec' if you want it to
-- 
Bob Walton


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

Date: Thu, 07 Sep 2000 04:04:51 GMT
From: Randy <randy_734@my-deja.com>
Subject: Need help with Win32::Console input
Message-Id: <39b710ca.50969796@207.126.101.100>

I'm stuck trying to take either mouse or keyboard input on NT.  If the
user begins typing rather than mousing, I don't want to lose the first
character.

This snippet almost works:

$conI = Win32::Console->new(STD_INPUT_HANDLE);
$m = $conI->Mode ;
$m = ($m | ENABLE_MOUSE_INPUT) ;
$conI->Mode($m) ;
while (1) {
    @k = $conI->Input ;
    if ($k[1] == 1) {               # a key press
        $conI->WriteInput(@k) ; # attempt to put key back in buffer
        last ;
      }
    if ($k[0] == 2 & $k[3]==1) {             # mouse click
        print "Mouse click row $k[2]\a" ;
        # continue in mouse_handler
    }
}
chomp ($infile = <STDIN>) ;

The WriteInput seems to always put a ` (a backtick) in the input
buffer rather than the key pressed.  I've tried using PeekInput
instead of Input but can't seem to get it to see the mouse clicks.

Any suggestions are appreciated.


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

Date: Wed, 06 Sep 2000 20:26:45 -0400
From: rnewman@thecia.net (Ron Newman)
Subject: Newbie SWIG question -- who owns char * return values?
Message-Id: <rnewman-0609002026450001@ppp225-37.thecia.net>

If I use SWIG to provide a Perl 5 interface to the following C function:

  char *greet (char *s) {
    char *s2 = malloc (strlen(s) + 10);
    sprintf (s2, "Hello, %s!", s);
    return s2;
  }

can I be sure that Perl will take 'ownership' of the returned string,
so that I don't have a storage leak?

In other words, can I safely write

   #!/usr/local/bin/perl
   use Hello();
   for (1..9000) {
        print Hello::greet("Ron"), "\n";
   }

and not worry about leaking 9000 strings?

-- 
Ron Newman        rnewman@thecia.net
http://www2.thecia.net/users/rnewman/


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

Date: Wed, 06 Sep 2000 18:54:59 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: newbie: redirect problem
Message-Id: <39B6F573.4D5E0703@stomp.stomp.tokyo>

Chalmers, Susan wrote:
 
> i don't know about everyone else's ideas, but i use:
 
> print "HTTP/1.1 302 Redirected\nLocation: <url goes here>\n\n"
 
> and it works perfectly and quickly.  i have used it as a one-line script
> quite effectively.
 

Well, well. I haven't read this trick in ages.

There is some boring technological trivia related
to this method. If you are running an nph-client,
a non-parsed headers style script, printing a simple
Location: ..etc within an nph-client will not work.
Header format conflicts are created. With this method
you have posted, a redirect / location works just
fine within a nph-client style script. It's a neat
trick when working with your own headers via a 
specialized nph-client, a type of script, which
is rarely used anymore. I believe this style is rare
because so few know how to work with nph-client scripts.

I kinda doubt these Perl 5 Techno-Geeksters have ever
heard of nph scripts much less ever written one. These
nph-client scripts sure beat a regular script for fancy
footwork, tricks and very creative scripts.

I don't know if this oddity applies to all server
types, but it does apply to Apache / Unix style
servers, such as mine.

I am impressed Ms. Chalmers. Few know of this
trick you have posted. You have a bit of smarts.


Godzilla!
-- 
Shazamina Fatima Alabimbo, Internet Mind Reader.
  http://la.znet.com/~callgirl/mindread.cgi


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

Date: Wed, 06 Sep 2000 21:40:34 -0400
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: Self-extracting program
Message-Id: <p8sdrsce1gnd5rki336gkd6o0mkk0tul9m@news.supernews.net>

miko@idocs.com wrote:

} So what do you all think?  Is self-extraction a good idea?

I think self-extraction is a fine idea.  There are the truly-paranoid [who,
I assume, carefully scanned the entirety of the sendmail source code before
they installed the latest version], and to accommodate them I don't see any
reason why your program can't take a '-x' command line that just says
"extract but don't execute"  [and indeed, you could arrange your program so
that when it is run, it could check to see if all of its pieces were
already nearby/installed, and if so skip the explode/install step].  Seems
that that'd make everyone happy, no?  Since the 'extract' part of your
program is readable [before the compressed module data], the
truly-truly-paranoid can even double-check that part to make sure that the
pieces you create in extract mode are the same as the ones you do in
run-for-real mode...

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: Wed, 6 Sep 2000 22:56:13 -0400
From: "John Menke" <john@eagleinfosystems.com>
Subject: types.h missing from my installation
Message-Id: <39b703d0$1_2@news.eclipse.net>

Where can I get this file?




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

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


------------------------------
End of Perl-Users Digest V9 Issue 4244
**************************************


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