[16477] in Perl-Users-Digest
Perl-Users Digest, Issue: 3889 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 2 18:10:38 2000
Date: Wed, 2 Aug 2000 15:10:27 -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: <965254227-v9-i3889@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 2 Aug 2000 Volume: 9 Number: 3889
Today's topics:
Re: Perl jobs? <jeff@yoak.com>
Re: Perl Module in C - Question. (Greg Bacon)
Perl Web script dlogcher@my-deja.com
Re: Please unconfuse me.... if (<>)... <sumus@aut.dk>
Port access on a Mac <jleane@netDIESPAMcom.ca>
Re: Preserving exit code through END subroutine (Christian Kaufhold)
Re: Preserving exit code through END subroutine <fenkNOfeSPAM@agora.rdrop.com.invalid>
Problem with autovivification in tied hashes. (Vipul Ved Prakash)
Re: quick question on regualr expressions <care227@attglobal.net>
Re: quick question on regualr expressions <tina@streetmail.com>
Re: quick question on regualr expressions <T.Cockle@staffs.ac.uk>
regexp help <abramson@nlm.nih.gov>
Re: Regexp problem - Stripping HTML <jeff@yoak.com>
Re: reinterprete a variable in a variable <tina@streetmail.com>
Re: reinterprete a variable in a variable <mauldin@netstorm.net>
Re: reinterprete a variable in a variable <tina@streetmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 02 Aug 2000 15:22:42 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: Perl jobs?
Message-Id: <8ma00e02uae@news2.newsguy.com>
[ posted and emailed, only posted to existing newsgroups]
In article <kre4os899d2g278fl1i22bfeoj59ipmg0h@4ax.com>, peter
<peterp100@hotmail.com> wrote:
> I'm teaching myself perl and I'm taking a Java class this fall. But, I'm
> thinking about dropping the Java class and concentrating on Perl. Are
> there any jobs out there for perl programmers? When I look in the paper
> everything says "Java and C ++" ???
One of my responsibilities here is hiring compotent Perl programmers and I
can tell you from experience that it is really difficult to find skilled
people. We would literally hire 10 tomorrow if they walked in the door.
As someone hiring in the industry, my best advice is to become a good
programmer. If you like Perl, and choose to focus on it, that's nice. It
is my choice as well. But what is really valauble to most employers I'm
convinced is understanding the art of programming. Understand algorithms.
Get a look at designing different kinds of systems. Try to look at object
oriented programming as well as imperitive programming. If you can see
some functional and logical programming, so much the better. Choose a
platform that makes you happy to work on and learn the tools available so
that you can put various pieces together to solve a problem. A good grasp
of the Unix toolbox places unbelievable power in your hands whatever
language or project you may be working on.
Most of all, have fun. I don't know your context, so it is inappropriate
for me to advise you with respect to learning programming skills as part
of a job search, but if you plan to spend a lot of your time over many
years pushing around 1's and 0's, it should be from love. I've met very
few who were indifferent between writing printer drivers and web
templating systems, but I've known people who like each. Consider trying
different things, learning the basis upon which the whole art depends and
you won't have a hard time finding a job you love that focuses on the
aspects you find most interesting.
Good luck.
Cheers,
Jeff
------------------------------
Date: Wed, 02 Aug 2000 19:02:17 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Perl Module in C - Question.
Message-Id: <sogs1pctdbm64@corp.supernews.com>
In article <9nngosgjrf1b7fk9jg9hcvuunlf7st7gee@4ax.com>,
John Fortin <fortinj@attglobal.net> wrote:
: On Wed, 02 Aug 2000 17:21:21 GMT, gbacon@HiWAAY.net (Greg Bacon)
: wrote:
:
: >All irrelevant. If I tell you to more a file, does that mean you
: >can't use less? The use of man above was as a simple placeholder for
: >the appropriate documentation viewer. Compare the following statements:
:
: except Abigail explicitly mentioned not using a web browser...
She was making a separate point, namely that people tend to jump to
the web without even considering that the information they want could
be on their local machines.
: > Use the appropriate documentation viewer to read manpage.
: >
: > Read man manpage.
:
: However, you are assuming that a user has the backround to translate
: the 2nd to the 1st.
:
: If I did not know what a manpage was ( in its unix context) I may not
: make the connection.
This is a convincing argument on the surface, but, in practice, the
people making the argument are exclusively Microsoft apologists.
Greg
--
I dream of a world where you can buy liquor, cigarettes and firearms at a
drive-through and use them all before you get home. Basically anything that
gets rid of people, but FIRST, BUY MY BOOK!
-- Scott Adams
------------------------------
Date: Wed, 02 Aug 2000 18:30:56 GMT
From: dlogcher@my-deja.com
Subject: Perl Web script
Message-Id: <8m9pd0$6vs$1@nnrp1.deja.com>
I'm looking for a Perl script that will show download times for
a webpage. I need to monitor the download times of a web server
to see if pages are coming down slowly.
--
Dan
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 02 Aug 2000 23:44:39 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: Please unconfuse me.... if (<>)...
Message-Id: <em47z6bc.fsf@macforce.sumus.dk>
Tina Mueller <tina@streetmail.com> writes:
> Keith Calvert Ivey <kcivey@cpcug.org> wrote:
> > Tina Mueller <tina@streetmail.com> wrote:
>
> >>while (<>) {}
> >>is like doing
> >>while ($_ = <>) {}
> >>(the same with for)
>
> > Actually, it's like doing
>
> > while (defined($_ = <>)) {}
>
> uhm, yes, i forgot... =(
No need to apoligize, cos while( $_ = <> ) is _also_ like saying
while ( defined( $_ = <> ) )
while (<>) {}
while ($_ = <>) {}
while (defined($_ = <>)) {}
The three are equivalent.
From perlop:
Anyway, the following lines are equivalent to each
other:
while (defined($_ = <STDIN>)) { print; }
while ($_ = <STDIN>) { print; }
while (<STDIN>) { print; }
for (;<STDIN>;) { print; }
print while defined($_ = <STDIN>);
print while ($_ = <STDIN>);
print while <STDIN>;
--
Jakob Schmidt
http://aut.dk/orqwood
etc.
------------------------------
Date: Wed, 02 Aug 2000 11:20:29 -0700
From: Macb3th Labs <jleane@netDIESPAMcom.ca>
Subject: Port access on a Mac
Message-Id: <020820001120293120%jleane@netDIESPAMcom.ca>
Hi all...
I was wondering if anybody knew of any way to *directly* access the
serial ports on a Mac. I've already used CommConnect, but it's a
little too drool-proof for my intended use. I need the ability to send
one BIT at a time, a la PC parallel port. Or keep one pin high for a
period of time, etc.
I realize the serial ports may not be suited to this, so my second
question is: can I use a Mac SCSI port as parallel port (like on a PC)?
I'd of course need to manipulate each pin directly, bypassing the SCSI
controller...
Thanks for any help you can give me.
j
------------------------------
Date: Wed, 2 Aug 2000 19:54:34 +0200
From: ch-kaufhold@gmx.de (Christian Kaufhold)
Subject: Re: Preserving exit code through END subroutine
Message-Id: <8m9ntl$bds$2@f40-3.zfn.uni-bremen.de>
John Fenk <fenkNOfeSPAM@agora.rdrop.com.invalid> wrote:
> #!/usr/local/bin/perl
> exit 50;
> END { system "ls"; }
>
> exits with return code of 0.
That is because "system" clobbers $?.
> perl 5.005_03 on Solaris if it matters.
>
> Is this a bug or a feature? Is there an easy way of preserving
> the exit code through the END subroutine? I had expected the
> exit code to be 50 unless I had another exit statement in the END
> subroutine.
See perldoc perlvar about $? and END blocks.
Christian
--
sub TIEARRAY { bless \($, = "Just another Perl Hacker") }
sub FETCHSIZE { 2 }
sub FETCH { substr "\n", 0, pop }
sub BEGIN { tie @, => __PACKAGE__; print @, }
------------------------------
Date: Wed, 02 Aug 2000 13:32:08 -0700
From: John Fenk <fenkNOfeSPAM@agora.rdrop.com.invalid>
Subject: Re: Preserving exit code through END subroutine
Message-Id: <0ce0ac6c.03d2ef24@usw-ex0104-025.remarq.com>
Thank you. I had read the fine camel book and it didn't mention
that $? held perl's own exit code - I thought it only held the
results from external commands. I need to check perldoc more
often, but sometimes it is hard to know where to look. Thanks
again.
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: 2 Aug 2000 19:41:53 GMT
From: vipul@shell2.ba.best.com (Vipul Ved Prakash)
Subject: Problem with autovivification in tied hashes.
Message-Id: <slrn8ogubt.lv1.vipul@shell2.ba.best.com>
Hi,
I have run into a problem while handling references in tied hashes. An
assignment to a tied hash that is a reference in lvalue context (created
automatically) is completely opaque inside STORE(). That is, it doesn't
dereference. ref($ref) will determine it's type correctly, but
dereferencing gives an empty structure of type ref($ref). It is obviously
non-empty because assignments succeed and it dereferences fine outside
STORE().
I have tried several round-about things to access these references but
nothing has worked. I didn't find anything pertinent in the documentation
so I thought I'll ask here. Are these special kind of references? (They
claim to be hashrefs). Is there a way I can access/modify the data they
reference?
The following code snippet illustrates this behaviour. The class PHash
provides standard hash semantics with the exception that it dumps (with
Data::Dumper) the value passed to STORE(). %main::h is tied to PHash and
two different forms of reference assignments are used. The value dumped at
first assignment is an empty hash ref, but the assignment is successful.
package PHash;
use Tie::Hash; @ISA=qw(Tie::StdHash);
use Data::Dumper;
sub STORE {
print Dumper $_[2] if ref $_[2];
$_[0]->SUPER::STORE(@_[1..2]);
}
package main;
my %h=(); tie %h, PHash;
print "assignment 1\n";
$h{headers1}->{from} = 'foo@bar.com'; # Automatic Reference opaque in STORE()
print "VALUE: $h{headers1}->{from}\n"; # But accessible outside.
print "\nassignment 2\n";
$h{headers2} = {from => 'foo@bar.com'}; # Works as expected.
print "VALUE: $h{headers2}->{from}\n"; # This too.
# Development environment:
# $ perl -v
# This is perl, version 5.005_03 built for i386-linux
# $ uname -a
# Linux tranceport.vipul.net 2.2.16 #1 Wed Jul 26 09:04:35 PDT 2000 i686 unknown
------------------------------
Date: Wed, 02 Aug 2000 14:25:15 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: quick question on regualr expressions
Message-Id: <3988678B.9BAFC2C4@attglobal.net>
Tim Cockle wrote:
>
>
> This works for most URLs however any complicated one with ? followed by
> data mess the whole thing up!
>
> Basically how do I say look for this string! (that is all characters are
> real characters and metacharacters or alike!)
You answered your own question. Metacharacters have special meanings,
and the ones in your URL are causing problems. Look at the quotemeta
function, and apply it to all your URL's before putting them in the
array.
# perldoc -f quotemeta
HTH
------------------------------
Date: 2 Aug 2000 18:29:29 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: quick question on regualr expressions
Message-Id: <8m9pa9$65hnr$2@ID-24002.news.cis.dfn.de>
hi,
Tim Cockle <T.Cockle@staffs.ac.uk> wrote:
> I have extracted some URLs from a HTML file using TokeParse.
> I now want to go through the file one line at a time looking for the URL
> and so I can mark it.
> eg $_ =~ s/'@orginalURL[$i]'/@changeURL[$i]/;
first you should use
$array[$index] instead of @array[$index].
> This works for most URLs however any complicated one with ? followed by
> data mess the whole thing up!
try out
s/\Q$orginalURL[$i]\E/$changeURL[$i]/;
look for the quotemeta function (that's what
\Q is doing)
perldoc -f quotemeta
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.
------------------------------
Date: Wed, 02 Aug 2000 19:36:40 +0100
From: Tim Cockle <T.Cockle@staffs.ac.uk>
To: news@tinita.de
Subject: Re: quick question on regualr expressions
Message-Id: <39886A38.B6D62823@staffs.ac.uk>
Thank you,
You made a tired head very happy!
Tina Mueller wrote:
> hi,
> Tim Cockle <T.Cockle@staffs.ac.uk> wrote:
>
> > I have extracted some URLs from a HTML file using TokeParse.
>
> > I now want to go through the file one line at a time looking for the URL
> > and so I can mark it.
>
> > eg $_ =~ s/'@orginalURL[$i]'/@changeURL[$i]/;
>
> first you should use
> $array[$index] instead of @array[$index].
>
> > This works for most URLs however any complicated one with ? followed by
> > data mess the whole thing up!
>
> try out
> s/\Q$orginalURL[$i]\E/$changeURL[$i]/;
>
> look for the quotemeta function (that's what
> \Q is doing)
> perldoc -f quotemeta
>
> tina
>
> --
> http://tinita.de \ enter__| |__the___ _ _ ___
> tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
> search & add comments \ \ _,_\ __/\ __/_| /__/ perception
> please no answers via email unless followup is set to poster.
------------------------------
Date: 02 Aug 2000 14:36:25 -0400
From: Myriam Abramson <abramson@nlm.nih.gov>
Subject: regexp help
Message-Id: <t5snsnecie.fsf@etbsun4.nlm.nih.gov>
Hi!
What's a good regexp to grep on an expression that contains newline
characters? For example I would like to print out all lines between
braces like in a bibliography.
Thanks,
--
myriam
Go Proverb:
Make a fist before striking. -- Jay H. Kim.
------------------------------
Date: Wed, 02 Aug 2000 12:27:41 -0800
From: "Jeff Yoak" <jeff@yoak.com>
Subject: Re: Regexp problem - Stripping HTML
Message-Id: <8m9lo904qv@news1.newsguy.com>
In article <8m9bf0$r06$1@nnrp1.deja.com>, mbutt@my-deja.com wrote:
> I am trying to construct a regular expression to strip certain HTML tags
> out of a string.
This question seems to be asked a lot here right now and not answered much
so I'll try briefly. Regular expressions are the wrong tool for dealing
with token type streams such as HTML. There are many fine tools available
for handling things like this on CPAN. Probably you want to deal with
HTML::Parse (or is it HTML::Parser ... don't recall).
> the string $x contains an entire HTML document. I wan to remove the PHP
> tags from it.
Hmmm.... OK. I take it back. I'm not sure what's involved in parsing
non-standard tags with those tools. If you are sure that the tag will
start with '<?php' and will not contain '?>' until the termination of the
tag (I don't know PHP, but this seems safe) , you can use:
$x =~ s/<\?php.*?\?>//g;
The only difference between between this and what you did is the question
mark after the Kleene star. It makes the match non-greedy. Have a look
at that and also at HTML::Parse(r?). They are generally useful.
Cheers,
Jeff
------------------------------
Date: 2 Aug 2000 18:34:39 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: reinterprete a variable in a variable
Message-Id: <8m9pjv$65hnr$3@ID-24002.news.cis.dfn.de>
hi,
Martin Tribius <werbung@htmlfilter.de> wrote:
> $data2 = 'hello $data1 !!'; #can't change this line into doublequotes
> $data1 = 'Martin'; #can't change this line into doublequotes
> $data3 = "".$data2; #thats a try (showed in my book) to get the
> #variable used in $data2
> reinterpreted
> print "\n\n Should say 'hello Martin !!' but it says $data2 \n\n";
> This gives the output:
> Should say 'hello Martin !!' but it says hello $data1 !!
try out:
$data2 =~ s/\$data1/$data1/e;
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.
------------------------------
Date: Wed, 02 Aug 2000 18:43:55 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: reinterprete a variable in a variable
Message-Id: <39886B63.F6186FA2@netstorm.net>
Martin Tribius wrote:
>
> Hi,
>
> got a problem... Here an easy example for it:
>
> $data2 = 'hello $data1 !!'; #can't change this line into doublequotes
> $data1 = 'Martin'; #can't change this line into doublequotes
>
> $data3 = "".$data2; #thats a try (showed in my book) to get the
> #variable used in $data2
> reinterpreted
> print "\n\n Should say 'hello Martin !!' but it says $data2 \n\n";
>
> This gives the output:
> Should say 'hello Martin !!' but it says hello $data1 !!
>
<snip>
I assume you mean that in $data2='hello $data1' $data1 is just a
placeholder or marker for where the actual $data1 should go. It would
be easier to see if the placeholder were name_goes_here, as in $data2 =
'hello name_goes_here'. In which case you would just do:
$data1 = 'Martin';
$data2 = 'hello name_goes_here';
$data2 =~ s/name_goes_here/$data1/;
which in your example would be:
$data2 = 'hello $data1';
$data2 =~ s/\$data1/$data1/;
perldoc perlre
-- Jim
------------------------------
Date: 2 Aug 2000 19:11:46 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: reinterprete a variable in a variable
Message-Id: <8m9rpi$65hnr$5@ID-24002.news.cis.dfn.de>
hi again,
Tina Mueller <tina@streetmail.com> wrote:
> try out:
> $data2 =~ s/\$data1/$data1/e;
eh, I think this should work without the /e modifier,
too, as I saw in the other post.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
please no answers via email unless followup is set to poster.
------------------------------
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 3889
**************************************