[13691] in Perl-Users-Digest
Perl-Users Digest, Issue: 1101 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 17 15:05:41 1999
Date: Sun, 17 Oct 1999 12:05:09 -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: <940187109-v9-i1101@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 17 Oct 1999 Volume: 9 Number: 1101
Today's topics:
Re: DNS provisoning scripts (Kragen Sitaker)
Re: email RegExp problem (Abigail)
Re: file protection (Kragen Sitaker)
Re: I am a newbie and need help! <golf@tfz.net>
Re: Is there an easy Perl equivalent to SSIs including <gellyfish@gellyfish.com>
Re: Need help with seek/sysseek <dheera@usa.net>
Re: Newbie Question (Kragen Sitaker)
Re: Perl script taking regex as argument? <rhomberg@ife.ee.ethz.ch>
Re: Perl4->Perl5 Migration (John M. Gamble)
Re: Public apololgy <uri@sysarch.com>
Re: qr operator the $_ <ltl@rgsun40.viasystems.com>
Re: qr operator the $_ <ltl@rgsun40.viasystems.com>
Re: qr operator the $_ (Ilya Zakharevich)
Re: Range checking <jeffp@crusoe.net>
Re: retrieve url from hypertext <dheera@usa.net>
Re: smallest hardware for perl development ? <uri@sysarch.com>
Re: THANKS FOR ALL THE HELP <kstephan@my-deja.com>
Re: THANKS FOR ALL THE HELP (Michael Budash)
Re: THANKS FOR ALL THE HELP (Matthew Bafford)
Re: THANKS FOR ALL THE HELP <rhomberg@ife.ee.ethz.ch>
Unicode bracket matching (was Re: qr operator the $_) (Kragen Sitaker)
Re: Unicode bracket matching (was Re: qr operator the $ (Ilya Zakharevich)
Re: Uses of # <rhomberg@ife.ee.ethz.ch>
Re: Uses of # (Kragen Sitaker)
Re: Win32::ODBC connect to Intersolv Informix <gellyfish@gellyfish.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 17 Oct 1999 18:51:45 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: DNS provisoning scripts
Message-Id: <5VoO3.12472$E_1.689060@typ11.nn.bcandid.com>
In article <uhnO3.17226$gm.217941@news1.rdc2.on.home.com>,
Gopi Balasingam <gopib@home.com> wrote:
>I was wondering if any one had any automatic DNS provisioning scripts ? I
>would like to automate the creation of domains to a nameserver via default
>provisioning scripts that update the DNS configuration file with the
>required parameters.
In 1997 I wrote some code to automatically update domains in a
nameserver db file, in response to requests from the network. It's at
http://pobox.com/~kragen/sw/dyndns.html.
Rather than try to parse the DNS database file myself, I write the
state of the database to a very simple file, and use the following
three routines.
# This takes a domain and a host-state database and writes it to a file.
sub writedbfile {
my ($setup, $database) = @_;
my $dbfile = $setup->{dbfile};
my $tempfile = "$dbfile.tmp.$$";
open DBFILE, ">$tempfile" or do {
logmsg "Cannot open $tempfile for write";
return; # fooey
};
print DBFILE "; Autogenerated ", scalar localtime, "\n";
print DBFILE <<SOA_end;
;
; DNS data file, from version Toy-3 of Kragen's dynamic DNS server
; 'relocatable', in that everything is relative to the specified origin.
;
\@ IN SOA $setup->{origin} $setup->{person} (
69 ; serial number is currently not kept track of
0 ; secondaries not supported; see above
0 ; retry; same
0 ; same
0 ; TTL of zero; do not cache!
)
IN NS $setup->{nameserver}
;
; Dynamic host entries follow
;
SOA_end
local $_;
my $record;
my $attribute;
for (sort keys %$database) {
$record = $database->{$_};
for $attribute (sort keys %$record) {
$attribute eq "A" and do {
print DBFILE "$_ IN A $record->{A}\n";
next;
};
$attribute eq "CNAME" and do {
print DBFILE "$_ IN CNAME $record->{CNAME}\n";
next;
};
logmsg "Weird attribute $attribute on $_";
}
}
close DBFILE;
rename ($tempfile,$dbfile) or logmsg "Can't rename", $tempfile, $dbfile;
return;
}
# Read a checkpoint file, if it exists.
sub readstatefile {
my @xxx;
my ($filename) = @_;
my %rv = ();
return %rv if ( ! -f $filename);
open STATEFILE, $filename or do {
logmsg "Can't open statefile", $filename;
return %rv;
};
local $_;
while (<STATEFILE>) {
chomp;
@xxx = split;
if (@xxx == 3) {
$rv{$xxx[0]}->{$xxx[1]} = $xxx[2];
} else {
logmsg "Can't understand in statefile", $_;
}
}
close STATEFILE;
return %rv;
}
sub writestatefile {
my ($setup, $state) = @_;
my $statefile = $setup->{statefile};
my $tempfile = "$statefile.tmp.$$";
open STATEFILE, ">$tempfile" or do {
logmsg "Can't open statefile $tempfile for write";
return; # shoot
};
my ($host, $attribute);
foreach $host (keys %$state) {
foreach $attribute (keys %{$state->{$host}}) {
print STATEFILE "$host $attribute $state->{$host}->{$attribute}\n";
}
}
close STATEFILE;
rename ($tempfile,$statefile)
or logmsg "Can't rename statefile", $tempfile, $statefile;
}
The main flow of my program was like this:
(read configuration data, like %hosts, %state, %passwords, %setup)
setupserver \%setup;
while (acceptconn) {
talk_to_client \%hosts, \%state, \%passwords and do {
writestatefile \%setup, \%state;
writedbfile \%setup, \%state;
sighup_named;
};
close CLIENT_SOCKET;
}
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 17 Oct 1999 12:12:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: email RegExp problem
Message-Id: <slrn80k0rv.q8s.abigail@alexandra.delanet.com>
MTW (suaai@csv.warwick.ac.uk) wrote on MMCCXXXVIII September MCMXCIII in
<URL:news:Pine.GSO.4.10.9910171631170.29805-100000@mimosa.csv.warwick.ac.uk>:
``
`` I know - but I'm doing some code to be used internally at this university.
`` I already _know_ that the email addresses that I'll be finding will end
`` ".warwick.ac.uk", but I need to extract John.Smith@dcs from
`` John.Smith@dcs.warwick.ac.uk, where the whole From: line that I'm
`` processing will be
``
`` Johnny Boy! <John.Smith@dcs.warwick.ac.uk>, or indeed
`` j.c.smith@dcs.war . . .
The problem is unclear. 'Johnny Boy! <John.Smith@dcs.warwick.ac.uk>'
*is* a valid address:
$ perl -MRFC::RFC822::Address -wle 'print "Valid" if
RFC::RFC822::Address::valid
(q {Johnny Boy! <John.Smith@dcs.warwick.ac.uk>})'
Valid
$
Of course, if you start making assumptions, why not assume the
parts you are interested in are inside the angle brackets?
Then the parsing is easy.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 17 Oct 1999 18:24:45 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: file protection
Message-Id: <NvoO3.12441$E_1.687827@typ11.nn.bcandid.com>
In article <7uct1k$mev$1@oak.prod.itd.earthlink.net>,
Blair Heuer <ab@cd.com> wrote:
>On Unix systems, I know that the flock() can be used to protect a file from
>corruption, but how do you prevent this on a Windows system in perl? For
>instance, if I were writing to my programs pref file from the administration
>script, and someone was reading that file, wouldn't that corrupt it? If it
>gets corrupt the whole system will go screwy. So, in summary, my question
>is: How do I protect files with perl on Windows systems?
My system doesn't have any trouble. It has windows; I run xterm in
most of them.
If you're talking about Microsoft Windows, it depends. NT, flock();
other, give up.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Sun, 17 Oct 1999 13:11:41 -0400
From: "Jim" <golf@tfz.net>
Subject: Re: I am a newbie and need help!
Message-Id: <7ud033$42g$1@bgtnsc02.worldnet.att.net>
hey i have virutalave.net hosting the site with the CGI. It says "internal
server error" and says "the page cannot be displayed". someone please help!
Jim wrote in message <7ucl9o$s6m$1@bgtnsc02.worldnet.att.net>...
>Hi, i have been upload this script
>
>#!/usr/bin/perl
>
>
>
>print "Content-type: text/html\n\n";
>print "<HTML><BODY BGCOLOR=\"#000000\"></BODY></HTML>";
>
>to virtualave.net
>
>I am uploading just to see if I can get it to work, but I am gettin an
>internal 500 error. Whats wrong with it?
>
>
------------------------------
Date: 17 Oct 1999 18:14:47 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Is there an easy Perl equivalent to SSIs including some HTML ?
Message-Id: <7ud3mn$59g$1@gellyfish.btinternet.com>
On Thu, 14 Oct 1999 06:13:35 GMT Stuart Wright wrote:
> On 12 Oct 1999 06:03:45 GMT, efflandt@xnet.com (David Efflandt) wrote:
>
>
>>>
>>>#---------------------------------------------
>>>#code snippet:
>>>#
>>>sub include_this_file {
>>> my $include_file = @_; # get the name of the file
>>> open (INCLUDE, "$include_file") or print "couldn't open $include_file,
>>>error: $!\n";
>>> while (<INCLUDE>) {print;} # read each line from the file and print
>>>it.
>>
>>Or instead of the above while loop, simply print the whole file at once:
>> print <INCLUDE>;
>>
>>> close (INCLUDE); # be nice and close the file yourself,
>>> #even though perl will eventually do it for
>>>you
>>>}
>
> After an hour, I gave up trying to get the above to work.
> For a start I get server 500 error if I declare the $include_file
> variable with 'my' infront of it.
Ooh looks like your server got an ancient Perl on it - I would consult
with the admin to see if there is Perl 5 - if not they would be
advised to upgrade forthwith ...
> Also I get the same error if I put 'or print...' after the open.
That a Perl 4 problem as well (my,or and a bunch of other stuff were
introduced with Perl 5 ).
> And I'm not sure how to specify the relative url of the file to
> include on a virtual server. Should a fixed URL specifying
> http://www.... etc work ?
No you will most likely have to determine the absolute filsystem path
on the system - /usr/www/virtual/blah/filename.txt for example - this
might be complicated if the server is running chroot. Again I would
consult with the server admin as this is something that we cannot determine.
You *cannot* supply a URL to open() - whilst a URL may have some
similarities to a filepath they are largely dissimilar - open() can
only operate on files that are on the exist on the local filesystem or
those that appear to be through some network file sharing mechanism
such as NFS or Samba.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sun, 17 Oct 1999 18:35:58 GMT
From: Dheera <dheera@usa.net>
Subject: Re: Need help with seek/sysseek
Message-Id: <7ud4ue$7bq$1@nnrp1.deja.com>
In your first program - I don't believe there is any way to seek a
handle that has been assigned to a pipe... try opening a file instead!
In both of your programs, you're using the "+>>" mode to open. Use "+>"
instead since you're doing random access, not an append. So rewrite
your open's like this:
open FILE,"+>seektest2.txt";
Also consider using the sysopen command instead of open, if you're only
using sys* commands...
Hope this helps,
Dheera
In article <7u9t3a$90a$1@nnrp1.deja.com>,
Shawn Collenburg <greynite@mindspring.com> wrote:
> Could anyone tell me why the following program does not work? It fails
> on just about every PERL it's been tested on save one.
>
> Thanks,
> Shawn
> ---------------- cut here ------------------
> # Check to see if running as a web script
> if ( exists $ENV{'LOCAL_ADDR'} ) {
> print "Content-type: text/html\n\n";
> print "<TITLE>Seektest.pl</TITLE><HEAD><H2>Seektest.pl</H2></HEAD>";
> print "<BODY><HR>";
> $cgi = "<P>";
> }
>
> print "PERL v. $]\n$cgi";
> print "\$^X = $^X\n\n$cgi";
>
> if ( open(FILE,"|which perl.exe") ) {
> while (<FILE>) {
> print "$_$cgi";
> }
> }
>
> unlink "seektest1.txt";
> open FILE,"+>>seektest1.txt";
>
> print "Seek 1 rc=".seek(FILE, 0, 0)."\n$cgi";
> print FILE "12345\n\n";
>
> print "Seek 2 rc=".seek(FILE, 2, 0)."\n$cgi";
> print FILE "=12";
>
> seek FILE, 0, 0;
> $line = <FILE>;
> chomp $line;
>
> close FILE;
>
> print "Seek(3) = $line;";
> if ( $line == "12=12" ) {
> print " Success!\n\n$cgi";
> } else {
> print " FAIL \n\n$cgi";
> }
> #############################################3
> unlink "seektest2.txt";
> open FILE,"+>>seektest2.txt";
>
> print "Sysseek 1 rc=".sysseek(FILE, 0, 0)."\n$cgi";
> syswrite FILE, "12345\n\n", 5+2*length($/), 0;
>
> print "Sysseek 2 rc=".sysseek(FILE, 2, 0)."\n$cgi";
> syswrite FILE, "=12", 3, 0;
>
> sysseek FILE, 0, 0;
> sysread FILE, $line, 6, 0;
> chomp $line;
>
> close FILE;
>
> print "SysSeek(2) = $line;";
> if ( $line == "12=12" ) {
> print " Success!\n\n$cgi";
> } else {
> print " FAIL \n\n$cgi";
> }
>
> unlink "seektest3.txt";
> open FILE,"+>>seektest3.txt";
> print "Using binmode rc=".binmode(FILE)."\n$cgi";
>
> print "Binmode Seek 1 rc=".seek(FILE, 0, 0)."\n$cgi";
> print FILE "12345\n\n";
>
> print "Seek 2 rc=".seek(FILE, 2, 0)."\n$cgi";
> print FILE "=12";
>
> seek FILE, 0, 0;
> $line = <FILE>;
> chomp $line;
>
> close FILE;
>
> print "Seek(3) = $line;";
> if ( $line == "12=12" ) {
> print " Success!\n\n$cgi";
> } else {
> print " FAIL \n\n$cgi";
> }
>
> unlink "seektest4.txt";
> open FILE,"+>>seektest4.txt";
> print "Using binmode rc=".binmode(FILE)."\n$cgi";
>
> print "Sysseek 1 rc=".sysseek(FILE, 0, 0)."\n$cgi";
> syswrite FILE, "12345\n\n", 5+2*length($/), 0;
>
> print "Sysseek 2 rc=".sysseek(FILE, 2, 0)."\n$cgi";
> syswrite FILE, "=12", 3, 0;
>
> sysseek FILE, 0, 0;
> sysread FILE, $line, 6, 0;
> chomp $line;
>
> close FILE;
>
> print "SysSeek(2) = $line;";
> if ( $line == "12=12" ) {
> print " Success!\n\n$cgi";
> } else {
> print " FAIL \n\n$cgi";
> }
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 17 Oct 1999 18:22:49 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Newbie Question
Message-Id: <ZtoO3.12440$E_1.639494@typ11.nn.bcandid.com>
In article <7u9q8v$a4o$1@gxsn.com>,
Martin Elliott <martin@mert.globalnet.co.uk> wrote:
>Thanks a lot for the help, I've installed Perl and so can write my scripts
>ok, but the CGI scripts are going to be difficult to test.
If you use CGI.pm, they will be easy to test.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Sun, 17 Oct 1999 19:05:57 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Perl script taking regex as argument?
Message-Id: <380A01F5.1D084A11@ife.ee.ethz.ch>
Gregory Stoll wrote:
>
> Hi all! I'm trying to write a little Perl script (haven't used Perl for
> very long), and I'd like to have it take a filename and a regex as
> arguments. The problem is, perl tries to interpret the regex as a file
> and complains when it can't find it. Is there some way to take a regex?
> (a reference to a perldoc is just fine - as a sidenote, is there any way
> to view all the perldoc files available?) I'm running perl 5.005 on a
> Linux box...Thanks for your help! :-)
Perl doesn't do anything to your arguments unless you tell it to do so
(e.g. by using @ARGV or <> or -p or -n)
Manipulate @ARGV before starting normal processing.
Here's an example grep using -n. Needs regexp as first argument and
prints matching lines from the given files (or stdin)
perl -ne'BEGIN{$re = shift @ARGV} print if /$re/' <perl regex>
<filelist>
- Alex
------------------------------
Date: 17 Oct 1999 18:14:41 GMT
From: jgamble@ripco.com (John M. Gamble)
Subject: Re: Perl4->Perl5 Migration
Message-Id: <7ud3mh$4i0$1@gail.ripco.com>
In article <Pine.LNX.4.10.9910140948310.1492-100000@cc569157-a.warn1.mi.home.com>,
Daniel W. Burke <dwb1@home.com> wrote:
>
>Hello,
>
>We are finally in the process of migrating a large number
>of perl scripts from perl4 (oraperl), to perl5. So far
>there has not been any major issues for us to work through,
>the first step has just been to get everything to WORK like
>we expect it to, and it's gone pretty well.
>
>The next step we plan to do is seriously cleanup the code
>(total of 10 different programmers have worked on it, no
>more then 2 at a time have ever worked together, so it's a
>mess!), and convert the library files to modules, then
>eventually we want to move to mod_perl.
>
>I'm curious to hear anyone elses comments/experiences in
>doing the same thing, i.e. things to watch out for, or very
>good resources to check out.
>
>I've read plenty about the things you have to do to get mod_perl
>to work right for you, but not a lot about perl4->5 migration,
>or converting large amounts of interdependant files to modules.
>
>Can you believe that all this code was developed without -w?!?!!!
>
Well, as another poster has already pointed out, *use* that
-w and "use strict".
However i would recommend doing that one step at a time. Put
the -w in first, fix all the warnings, then put in "use strict".
Otherwise it gets pretty overwhelming.
Watch out for anyone on your team who cheats and, instead of
fixing those messages by declaring their variables in their subs
with my(), just slaps a "use vars" line on the top of the script.
In vi, the command 1,$s/local/my/ was a good starting point for
me - of course, i wasn't doing anything special with local()
in my perl4 scripts; you might want to check yours first.
And, no matter how good your libraries are, there is probably a
better module already posted on CPAN - in my case, the Date::
modules replaced everything i had written myself.
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
--
Pursuant to US Code, Title 47, Chapter 5, Subchapter II, '227,
any and all unsolicited commercial E-mail sent to this address
is subject to a download and archival fee in the amount of $500
US. E-mailing denotes acceptance of these terms.
------------------------------
Date: 17 Oct 1999 13:25:58 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Public apololgy
Message-Id: <x7vh85gaqg.fsf@home.sysarch.com>
>>>>> "A" == Abigail <abigail@delanet.com> writes:
A> Brandon (pooka@cygnus.ucdavis.edu) wrote on MMCCXXXVIII September
A> MCMXCIII in <URL:news:3809524E.82A184B2@cygnus.ucdavis.edu>:
A> ^^ So I offer my apologies to ^^ Abigail, who behaved with class
A> when faced with an erroneous claim, ^^ which is more than I can say
A> for most others, and myself.
A> Oh, dear! You're ruining my reputation.
don't worry, i will write your email address on various bathroom stalls.
wan't some tricky perl, email abigail@delanet.com
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
------------------------------
Date: 17 Oct 1999 18:07:22 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: qr operator the $_
Message-Id: <7ud38q$ant$2@rguxd.viasystems.com>
Oops. Spoke too soon. :-( Maybe there is a little magic in
the qr{} operator after all.
$_ = 'have some text';
##my $compiled_re = '(?-xism:some(?{print "too true"}))';
## Above gives an error about eval-group not allowed at runtime
## when I attempt to use it as a compiled re.
my $compiled_re = qr'some(?{print "too true"})';
# This one works of course
print "true\n" if $_ =~ $compiled_re;
The funny thing is that if I examine them in the debugger
they look identical.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: 17 Oct 1999 17:53:40 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: qr operator the $_
Message-Id: <7ud2f4$ant$1@rguxd.viasystems.com>
Kragen Sitaker <kragen@dnaco.net> wrote:
:>In article <7uacns$i26$1@charm.magnus.acs.ohio-state.edu>,
:>Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
:>>To put credit where it belongs: IIRC, phrase "quoting operator" in
:>>context of compilation of regular expressions belongs to Larry. He
:>>was objecting to my reuse of `study' as an operator to compile a REx:
:>>
:>> $compiled_REx = study /REx/;
:>>
:>>was how the initial implementation looked like. It was later that I
:>>realized that an introduction of (?foo-bar:REx) and of transparent
:>>stringification of $compiled_REx allow one to remove *all* the magic
:>>altogether. The motto became
:>>
:>> "It may be compiled, but this is an implementation detail." ;-)
:>So, in fact, it really *does* compile the regex behind the scenes, and
:>the compiled regex gets used if I say $var =~ $compiled_REx or
:>/$compiled_REx/, but not if I say /foo$compiled_REx/?
It would seem that at this stage of perl, the REx compiler is
so simple that I can write my own already compiled regular
expressions as strings. So now I have yet another way to
implement the m// operator. :-)
use re 'debug';
$_ = 'have some text';
my $compiled_re = '(?-xism:some)';
print "true\n" if $_ =~ $compiled_re;
__END__
I eagerly await the day when the documentation says that qr{}
compiles *and optimizes* regular expressions. Until that day, it is
hard to get excited about the compilation magic of qr{}. ;-)
Don't take this as a knock on it though. It is actually quite
elegant to store the parsed, checked and "compiled" input for
the re engine as a string. It is way cool that you did not need
to add another data type. Simplicity is almost always cool.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
Date: 17 Oct 1999 18:26:59 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: qr operator the $_
Message-Id: <7ud4dj$fpg$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to lt lindley
<lee.lindley@bigfoot.com>],
who wrote in article <7ud38q$ant$2@rguxd.viasystems.com>:
> Oops. Spoke too soon. :-( Maybe there is a little magic in
> the qr{} operator after all.
>
> $_ = 'have some text';
> ##my $compiled_re = '(?-xism:some(?{print "too true"}))';
> ## Above gives an error about eval-group not allowed at runtime
> ## when I attempt to use it as a compiled re.
>
> my $compiled_re = qr'some(?{print "too true"})';
> # This one works of course
>
> print "true\n" if $_ =~ $compiled_re;
>
> The funny thing is that if I examine them in the debugger
> they look identical.
Try C<ref>. ;-)
Ilya
------------------------------
Date: Sun, 17 Oct 1999 13:48:41 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Range checking
Message-Id: <Pine.GSO.4.10.9910171347160.14462-100000@crusoe.crusoe.net>
[posted & mailed]
On Oct 18, Henry Penninkilampi blah blah blah:
> $min < $x <= $max
>
> if (($min < $x) and ($x <= $max))
That's basically it, man. The Python programming language can handle
cascading comparisons (like a < b < c > d). But Perl can't. Oh well.
--
MIDN 4/C PINYAN, USNR, NROTCURPI
jeff pinyan japhy@pobox.com
perl stuff japhy+perl@pobox.com
CPAN ID: PINYAN http://www.perl.com/CPAN/authors/id/P/PI/PINYAN
------------------------------
Date: Sun, 17 Oct 1999 18:23:38 GMT
From: Dheera <dheera@usa.net>
Subject: Re: retrieve url from hypertext
Message-Id: <7ud474$6v8$1@nnrp1.deja.com>
I do not know how to use the CGI::Parser module, but some time before,
I did write this code ($text contains the full text of the HTML page).
$text=~s/[\r\n]//g;
$text=~s/.*?<\s*A.*?HREF=\"*(.*?)\"*[> \n]/$1::/ig;
@links=split(/::/,$text);
pop @links;
After executing, @links will contain a list of URL's found in $text.
However, it does not fix-up relative links. Hope this works...
Dheera
In article <7ubd12$60f$1@nnrp1.deja.com>,
Howard Sun <hxshxs@my-deja.com> wrote:
> In article <7u9cg3$vmm$1@nnrp1.deja.com>,
> Howard Sun <hxshxs@my-deja.com> wrote:
> > just started learning Perl. not sure how to do the following,
> >
> > extract all URLs within the hypertext.
> >
> > if I use
> > if(/<a href="?.*"?>/) {
> > $link = $&;
> > }
> >
> > it can only display <a href="http://......"> part, not the real url.
> > real URL maynot start with http or end with html.
>
> now I can get first URL by
> if($line=~/<a href=\"?(.*?)\"?>/i)
> {
> push (@link, "$1");
> print @link, "\n";
> }
>
> But how do I get the second url on the same line $_ ? how to do the
loop
> here?
>
> if you know how to do this by CGI::Parser module, please let me know.
> thanks.
> >
> > also it stops at the first occurance.
> >
> > Thanks for your help.
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 Oct 1999 13:23:16 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: smallest hardware for perl development ?
Message-Id: <x7yad1gauz.fsf@home.sysarch.com>
>>>>> "WR" == Web Research <webresearch@indy-soft.com> writes:
>> smallest hardware for perl development ?
WR> a newbie brain.
core dump (bus error)
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
------------------------------
Date: Sun, 17 Oct 1999 16:57:31 GMT
From: kstephan <kstephan@my-deja.com>
Subject: Re: THANKS FOR ALL THE HELP
Message-Id: <7ucv5o$3rd$1@nnrp1.deja.com>
Reading through the threads, I noticed the line
$thisyear = $year + 1900;
What happens on 1 January 2000???
Sorry if this is a dumb question!!
Thanks, In advance for a "heads up".
Ken S
Escondido, CA
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$thisyear = $year + 1900;
$mon++;
In article <38077D52.3A88D30F@compumix.com>,
Mark Bakker <mark@compumix.com> wrote:
> Thank You All!
>
> Mark Bakker wrote:
>
> > I want to set the time in YYYY-MM-DD HH:MM:SS format in a string,
> > how do I do this? I can't Use print "%04d-%02d etc... because I do
not print
> > this string but I have to put It in a MySQL database...
> >
> > Please help..
>
> With kind regards, Mark Bakker
>
> Mark Bakker
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 17 Oct 1999 10:55:02 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: THANKS FOR ALL THE HELP
Message-Id: <mbudash-1710991055020001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <7ucv5o$3rd$1@nnrp1.deja.com>, kstephan <kstephan@my-deja.com> wrote:
>
>Reading through the threads, I noticed the line
>
>$thisyear = $year + 1900;
>
>What happens on 1 January 2000???
>
>Sorry if this is a dumb question!!
>
>Thanks, In advance for a "heads up".
>
>Ken S
>Escondido, CA
>
>($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
>$thisyear = $year + 1900;
>$mon++;
>
>
it still works. (sounds like you were thinking that $year is a 2-digit
number, when it's actually an offset from 1900...)
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sun, 17 Oct 1999 18:11:53 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: THANKS FOR ALL THE HELP
Message-Id: <slrn80k231.2pj.*@dragons.duesouth.net>
On Sun, 17 Oct 1999 16:57:31 GMT, kstephan <kstephan@my-deja.com> was
attempting to recharge the laptop battery by typing:
: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
: $thisyear = $year + 1900;
:
: What happens on 1 January 2000???
Exactly what you want!!!
: Sorry if this is a dumb question!!
It is, I'm sorry to say!! The information is in the documentation under
localtime!!
: Ken S
--Matthew
--
Remember, question marks and exclamation marks are on
the endangered characters list. Please refrain from
using them excessively or where not required, lest we
loose them forever.
------------------------------
Date: Sun, 17 Oct 1999 20:39:12 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: THANKS FOR ALL THE HELP
Message-Id: <380A17D0.62A2EB61@ife.ee.ethz.ch>
Matthew Bafford wrote:
> : What happens on 1 January 2000???
>
> Exactly what you want!!!
Wow!! can I write a wishlist of what I want to happen then?
- Alex
------------------------------
Date: Sun, 17 Oct 1999 17:07:11 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Unicode bracket matching (was Re: qr operator the $_)
Message-Id: <3nnO3.12338$E_1.676537@typ11.nn.bcandid.com>
In article <7ucu7b$esr$1@charm.magnus.acs.ohio-state.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Kragen Sitaker
>who wrote in article <NwlO3.11934$E_1.655839@typ11.nn.bcandid.com>:
>> It would be nifty if you could use the Japanese corner quote characters
>> in Unicode Perl to do a qr without having to say "qr"
>
>Even with my user-defined-operators patch you cannot introduce new
>quoting operators
I was thinking it should be a normal part of Perl, not a user-defined
thing.
>> BTW, the various quoting operators that use > to match <, ) to match (,
>> and so forth -- do they recognize the various Unicode brackets, like
>> the lenticular and tortoise-shell brackets? There's probably a more
>> appropriate place to ask, right?
>
>There are 4 such guys, {}, [], (), <>. I think keeping this list
>short has some advantages.
Definitely agreed. There are a few dozen pairs of brackets in Unicode,
and some things that are somewhat unclear; also, there are things that
look like brackets but really aren't (like the mathematical "much
greater than" and "much less than"), and then there are "presentation
forms" of brackets. (For example, there is a "fullwidth" copy of
ASCII; should a normal ( match a fullwidth )? There are "vertical
presentation forms" for a number of the brackets; should a normal (
match a vertical )?)
And then there are quotes. The corner brackets Friedl uses for his
regexes in his book are traditionally used as quotes in Japanese, and I
think they should match each other. But how about the (traditional
Western non-ASCII 6-shaped and 9-shaped) left quotes and right quotes?
Should we match them with each other? Should we match them with ASCII
`'? If we match left quotes with right quotes, should we match the
ornamental dingbat quotes with each other too?
So if we match all the pairs of brackets, we'll end up with a set of
brackets nobody can quite remember. ("I forget. Does ideographic
double prime left quote match itself or ideographic double prime right
quote when used as a quote delimiter?") Furthermore, whether we do or
not, Unicode's extremely unfortunate choice to have lots of pairs of
identical or almost-identical characters with no relation to one
another will make it hard to tell whether things really match or not by
looking at them.
On the other hand, if we don't match all the pairs of brackets, we're
going to end up with even more code that looks like it should work, but
doesn't. Things like qq(a b c) where the () happen to be fullwidth ()
instead of normal ().
I guess editors are going to have to worry about this too.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 17 Oct 1999 17:29:27 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Unicode bracket matching (was Re: qr operator the $_)
Message-Id: <7ud11n$fam$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Kragen Sitaker
<kragen@dnaco.net>],
who wrote in article <3nnO3.12338$E_1.676537@typ11.nn.bcandid.com>:
> And then there are quotes. The corner brackets Friedl uses for his
> regexes in his book are traditionally used as quotes in Japanese, and I
> think they should match each other. But how about the (traditional
> Western non-ASCII 6-shaped and 9-shaped) left quotes and right quotes?
> Should we match them with each other? Should we match them with ASCII
> `'? If we match left quotes with right quotes, should we match the
> ornamental dingbat quotes with each other too?
I do not think this discussion belongs here. I CC'ed my previous mail
to p5p, please redirect your remarks there.
> On the other hand, if we don't match all the pairs of brackets, we're
> going to end up with even more code that looks like it should work, but
> doesn't. Things like qq(a b c) where the () happen to be fullwidth ()
> instead of normal ().
"code that looks like it should work, but doesn't"? What do you mean?
Code is just a sequence of charges on chips or on hard disks. It does
not look like anything: a typical Perl program may be less than
wavelength of visible light. ;-)
So what you are discussing are programs to provide a visual
representation of your code. Then the answer is simple: just use
CPerl, and you will not be confused about what matches and what not.
Ilya
------------------------------
Date: Sun, 17 Oct 1999 20:08:51 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Uses of #
Message-Id: <380A10B3.6E14467@ife.ee.ethz.ch>
Kragen Sitaker wrote:
> You want to parse Perl. Only perl can parse Perl, my friend.
So Perl must have been there from the beginning.
The orig perl parser cannot have been written with lex and yacc ;-)
- Alex
------------------------------
Date: Sun, 17 Oct 1999 18:18:10 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Uses of #
Message-Id: <CpoO3.12434$E_1.686533@typ11.nn.bcandid.com>
In article <380A10B3.6E14467@ife.ee.ethz.ch>,
Alex Rhomberg <rhomberg@ife.ee.ethz.ch> wrote:
>Kragen Sitaker wrote:
>> You want to parse Perl. Only perl can parse Perl, my friend.
>
>So Perl must have been there from the beginning.
>The orig perl parser cannot have been written with lex and yacc ;-)
There are two Perl parsers, perl4 and perl5, and they parse slightly
different languages. I think the budding perl6 probably parses still
another language. And the parsing of the language is very difficult;
lex and yacc don't cut it by themselves. In particular, lexical
analysis depends on quote characters, which fall out of the parse tree,
and parsing depends on prototypes.
So writing your own Perl parser will be hard, and it is likely that it
will disagree with perl on how some code is written.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 17 Oct 1999 17:51:48 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Win32::ODBC connect to Intersolv Informix
Message-Id: <7ud2bk$59a$1@gellyfish.btinternet.com>
On Mon, 11 Oct 1999 15:30:26 +0200 Ing. Thoralf Bihlo wrote:
> Iīve got a problem connecting to the Intersolv driver via ODBC.
>
> Iīve got a Windows Internet Information Server installed.
> Iīve a System DSN with an Intersolv Informix driver - Version 3.x
>
> In a Perl CGI- Script i want to open a database and select something.
> When i access the script in a DOS-Shell it works. But when I access the
> script via a html-Browser (Netscape, but I think any would do this) I
> canīt access the database.
>
I think that you'll find that this is actually a problem with the server
configuration - the usr (IUSR_<whatever>) that the web server runs as
probably doesnt have permission to use a network connection to contact
the Informix server - you should configure things so that this user
has these permissions - if you are unsure as to how to do this then
you should ask in a group about NT servers.
> Iīm developing under WindowsNT with ActiveState Perl 5.0
> I tried to get the DBI::Informix module but I couldnīt find a ready
> compiled module for WinNT.
> Does anyone have it compiled?
>
Er for Linux & SCO yes. If you are using Activestate then you can
compile one for yourself if you have MS VC++ and the Informix Client
SDK (which is a free download from <http://www.intraware.com>) -
unfortunately you cant even compile your own Perl with cygwin32 or
whatever and then build DBD::Informix with that because the Informix
ESQL/C for windows appears to require a Microsoft or Borland compiler ;-{
You might try asking in comp.databases.informix though ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
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 1101
**************************************