[11506] in Perl-Users-Digest
Perl-Users Digest, Issue: 5106 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 11 00:07:59 1999
Date: Wed, 10 Mar 99 21:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 10 Mar 1999 Volume: 8 Number: 5106
Today's topics:
Re: [HOW TO?] Strip all but certain characters from a s (Larry Rosler)
Re: Adduser for NT? <herys@ctsnet.com>
Re: BigInt: Decimal to Hex <tchrist@mox.perl.com>
Re: BigInt: Decimal to Hex <dagon@halcyon.com>
Book review: PERL 5 Programmers Reference <prochak@my-dejanews.com>
Re: Continue Script After Error? (Larry Rosler)
converting unix perl to win32? (Thrawn5)
Re: Days in Month array <emschwar@mail.uccs.edu>
Re: does perl discourage obfuscated code? (was Re: Perl <Russell_Schulz@locutus.ofB.ORG>
Re: does perl discourage obfuscated code? (was Re: Perl <Russell_Schulz@locutus.ofB.ORG>
FAQ 3.27: Where can I learn about CGI or Web programmin <perlfaq-suggestions@perl.com>
FAQ 3.28: Where can I learn about object-oriented Perl <perlfaq-suggestions@perl.com>
Re: Filecheck-like utility?? <rick.delaney@home.com>
formatting QUERY_STRING <amwalker@gate.net>
Help with basic perl problems. <honky@best.com>
Re: How to find the hostname of the visitors <emschwar@mail.uccs.edu>
Re: Missing CGI Environment Variables <emschwar@mail.uccs.edu>
Re: net sockets <tpot@acsys.anu.edu.au>
Re: Newbie Regularn Expression Help (Larry Rosler)
OT? how do I write a regexp to... <sbeam@beeline.net>
Re: Speed-optimizing regular expressions <uri@ibnets.com>
Re: SSI within CGI <emschwar@mail.uccs.edu>
standard input and standard error <mecks@ust.hk>
Re: Writing to a file <zenin@bawdycaste.org>
Re: Writing to a file <msholund@bigfoot.com>
Re: Writing to a file <msholund@bigfoot.com>
Re: y2k and 4-digit dates (was Re: foreach and while) <Russell_Schulz@locutus.ofB.ORG>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 Mar 1999 00:12:17 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: [HOW TO?] Strip all but certain characters from a string
Message-Id: <MPG.114e77ac31cee903989713@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <7c27f6$dpo@enews2.newsguy.com> on Mon, 8 Mar 1999 22:03:49 -
0500, Jason Hatcher <Jason@InsideMedicine.com >says...
> I am looking for an efficient way to strip a string down to only certain
> characters.
>
> The output is 8 numbers followed by a the letter "S" or a number.
>
> example "4321-8765-S" would return 43218765S
> or "4321 876A5 A S" would return 43218765S
> or "432 1876-58 " would return 432187658
Assume the string is in $_.
First I would strip away all the uninteresting characters:
tr/0-9S//cd; # Delete all characters except digits and S
Then I would check that you have one of your acceptable forms:
unless (/^\d{8}[\dS]$/) { die }
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Mar 1999 23:36:45 -0500
From: "Henry Schlarb" <herys@ctsnet.com>
Subject: Re: Adduser for NT?
Message-Id: <7c7ha6$b7r$1@goblin.uunet.ca>
There is a utility in the NT Resource Kit to do this with the same name.
dragnovich@my-dejanews.com wrote in message
<7c48ch$7ur$1@nnrp1.dejanews.com>...
>Hello I have an application that is programed in perl, one subroutine of it
>is a modified adduser rutine from the Unix adduser command.
>
>But when we try to run it on NT it dont works, well is there any routines
for
>NT to add users (Setup email account) creating a user with username,
>password, Real name, account privilegies, etc...
>
>and/or change users passwords from Perl for NT
>
>is this posible or im dreaming ??
>
>regards!
>------------------------
>Juan Carlos Lopez
>QDesigns President & CEO
>http://www.qdesigns.com
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 10 Mar 1999 18:02:50 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: BigInt: Decimal to Hex
Message-Id: <7c77pk$7qe$1@nntp.Stanford.EDU>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.moderated,
"Jerome O'Neil" <jeromeo@atrieva.com> writes:
:I have been unsuccessful in attempting to convert large decimal integers
:(>20 digits) to their hexadecimal equivalents.
:
:SCO drops core with printf("%x"), and Math::BigInt doesn't support
:conversions. Where else might I look for big_dec2hex conversion code?
Simple Matter Of Programming:
for $n (@ARGV) {
print "$n => 0x", big_dec2hex($n), "\n";
}
sub big_dec2hex {
use Math::BigInt;
my $num = new Math::BigInt shift;
my $str = '';
while ($num > 0) {
my($quo, $rem) = $num->bdiv(16);
$str .= (0 .. 9, 'A'.. 'F')[$rem];
$num = new Math::BigInt $quo; # why aren't they bigints?
}
return scalar reverse $str;
}
Actually, that's a pretty terrible way to do it. It's hard to get slower
than that. :-(
--tom
--
clueless> $SOCK_STREAM = 2
Huh? use Socket or die!
--Tom Christiansen <tchrist@mox.perl.com>
------------------------------
Date: 10 Mar 1999 17:32:47 -0800
From: Mark Rafn <dagon@halcyon.com>
Subject: Re: BigInt: Decimal to Hex
Message-Id: <7c76fv$s51$1@halcyon.com>
"Jerome O'Neil" <jeromeo@atrieva.com> arranged electrons in a pattern like this:
>I have been unsuccessful in attempting to convert large decimal integers
>(>20 digits) to their hexadecimal equivalents.
>
>SCO drops core with printf("%x"), and Math::BigInt doesn't support
>conversions. Where else might I look for big_dec2hex conversion code?
How about:
$i=new Math::BigInt '123456789012345678901234567890';
while ($i > 0) {
($quotient,$remain)=$i->bdiv(16);
$i=new Math::BigInt $quotient;
push(@digits,sprintf("%x",$remain));
}
print reverse(@digits), "\n";
there's probably a better way to do this. In particular, I really
wanted to just do ($i,$remain)=$i->bdiv; instead of putting the value
into $quotient and then copying to $i, but for some reason I was unable
to get it to work.
--
Mark Rafn dagon@halcyon.com <http://www.halcyon.com/dagon/> !G
------------------------------
Date: Thu, 11 Mar 1999 04:31:35 GMT
From: Ed Prochak <prochak@my-dejanews.com>
Subject: Book review: PERL 5 Programmers Reference
Message-Id: <7c7gv7$4be$1@nnrp1.dejanews.com>
The PERL 5 Programmer's Reference
written by R.Allen Wyke and Luke Duncan.
I bought a copy of this book in order to have a more updated
reference. I've made extensive use of the PERL 4 Camel book,
which has that excellent tutorial about Job! I wasn't looking
for a tutorial, just a good accurate reference.
Unfortunately, I had already written my name in the book so I
cannot return it. I began to examine it this week and found it
to be so incomplete and misleading as to be worthless to me.
I just began to browse from the front and the first page describes
bitwise AND (&) and logical AND (&&). If I didn't have experience
with PERL and another good reference (the Camel book), I could be
totally mislead. Here's the description for bitwise AND:
[begin quote]
Usage The & bitwise logical operator performs and returns a
bitwise AND on the arguments passed. A 0 is returned if
the arguments passed are not equal.
Examples [description deleted]
# define 2 numeric variables
$one = 8;
$two = 8;
# print the result, 8, of the & operator
print($one & $two)
[end quote]
Only one example was supplied under the "Examples" heading.
The description seems to imply that if $two was some other value,
the result would be 0. A nice example might have been using
values 12 and 7. And what is a "bitwise logical operator"?
The logical AND (&&) is also given short shrift. NO MENTION IS MADE
THAT && IS A SHORT CIRCUIT OPERATOR. The syntax is listed as
element1 && element2
which isn't wrong but it is misleading. It should say
expresion1 && expression2
and the example again misleads you to believe only elements(variables)
can be tested. The description really blew me away as misleading to
the point of being clearly wrong:
[begin quote]
Usage The && logical operator returns 1 if element2 and element1 exist.
If only one or neither exist, then a NULL is returned. This is
commonly used to verify the existence of variables in your script
as well as to return the second argument based on this existence.
[end quote]
On a positive note, the authors are consistant on the OR operators.
The entries for them are similar to these.
Other problems I found include:
*lack of description between pre and post increment/decrement operators,
*typos a backslash in the division example or the backwards caller example:
caller = ($packageName, $fileName, $line);
*no mention of the difference between the numeric and string comparison
operators.
Now, I would have brought these comments to the publisher or the
authors. Unfortunately, the Publisher, VENTANA, has a web site
(http://www.vmedia.com) that is somehow protected since I get
a "Forbidden..." error there. One author has a web site that
was either down or nonexistant.
The CD did include PERL sources and executables for WinNT.
It listed support for OS/2 and UNIX, but those seem to be only
supported but the sources. (I was hoping for the PERL executable
for OS/2. Well, I'll fire up the compiler soon as I can.)
Well, enough of my opinion. I'd suggest anyone considering buying
this book to think about buying something else.
Ed Prochak
Magic Interface, Ltd.
ORACLE services
440-498-3702
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 9 Mar 1999 20:19:33 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Continue Script After Error?
Message-Id: <MPG.114f92a993e7b6f8989715@nntp.hpl.hp.com>
In article <7c3mfe$h6i$1@pegasus.csx.cam.ac.uk> on 9 Mar 1999 17:41:02
GMT, M.J.T. Guy <mjtg@cus.cam.ac.uk >says...
> Tad McClellan <tadmc@metronet.com> wrote:
> > If you just want to eliminate empty files, you can do that right here:
> >
> > foreach $file (grep -s, sort { -M "$dir_path/$a" <=> -M "$dir_path/$b" }
> > @files) {
>
> You've left out the $dir_path in the -s. And it would be a *tiny*
> amount more efficient to do the grep before the sort (also untested :-):
>
> foreach $file (sort { -M "$dir_path/$a" <=> -M "$dir_path/$b" }
> grep -s "$dir_path/$_", @files) {
Agreed. But if you're worried about efficiency, it would be a whole lot
more efficient to do the relatively very expensive stat on each file
once only -- O(n) times in all -- rather than O(n log n) times. But you
knew that!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 11 Mar 1999 04:34:20 GMT
From: thrawn5@aol.com (Thrawn5)
Subject: converting unix perl to win32?
Message-Id: <19990310233420.29267.00000781@ng109.aol.com>
if I'm writing a perl script for win32 instead of unix what do I put in place
of:
#!/usr/bin/perl
how do I give permissions to a perl script in win32?
------------------------------
Date: 09 Mar 1999 16:12:27 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: Days in Month array
Message-Id: <xkfbti2l0kk.fsf@valdemar.col.hp.com>
Jay Glascoe <jglascoe@giss.nasa.gov> writes:
> isn't it simply
>
> print "leap year\n" if $year % 4 == 0;
No, it's not. Isn't this a FAQ?
-=Eric
------------------------------
Date: Wed, 10 Mar 1999 20:48:18 -0500
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: does perl discourage obfuscated code? (was Re: Perl evangelism)
Message-Id: <19990310.204818.8x0.rnr.w164w@locutus.ofB.ORG>
Jonathan Feinberg <jdf@pobox.com> writes:
> Russell Schulz <Russell_Schulz@locutus.ofB.ORG> makes up some quotes:
>
>> Randal> in fact, I think I'll call him a LIAR! for calling Perl obscure!
unfortunately, that's one I _didn't_ make up.
>> Randal> if he claims it's case-sensitive I'll question his ancestry!
>
> must be a troll.
I was just kidding with that one, but I'd guess being called a troll
is the Usenet equivalent!
thanks. that was really funny.
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Wed, 10 Mar 1999 20:50:01 -0500
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: does perl discourage obfuscated code? (was Re: Perl evangelism)
Message-Id: <19990310.205001.0v1.rnr.w164w@locutus.ofB.ORG>
Jerome O'Neil <jeromeo@atrieva.com> writes:
>>>> I believe it. Perl encourages hard-to-read code. that's just the
>>>> way it is, and if you don't apply a strong discipline when writing
>>>> Perl, you're going to be the proud owner of a ton of [write]-only code.
> I'll state it again, just so you don't misunderstand me. Perl allows
> one to write *more* readable code.
... with extra discipline.
isn't that what I've been saying the whole thread? that your Perl code
can be readable? did I ever say it was impossible to write readable
Perl code? didn't I point out the opposite of that?
hmm. MORE readable. your claim is now that for some tasks, Perl code
is MORE readable than any other possible code.
sure, for some tasks, I'll buy that.
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: 10 Mar 1999 19:16:49 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.27: Where can I learn about CGI or Web programming in Perl?
Message-Id: <36e72791@csnews>
(This excerpt from perlfaq3 - Programming Tools
($Revision: 1.33 $, $Date: 1998/12/29 20:12:12 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq3.html
if your negligent system adminstrator has been remiss in his duties.)
Where can I learn about CGI or Web programming in Perl?
For modules, get the CGI or LWP modules from CPAN. For textbooks,
see the two especially dedicated to web stuff in the question on
books. For problems and questions related to the web, like ``Why
do I get 500 Errors'' or ``Why doesn't it run from the browser
right when it runs fine on the command line'', see these sources:
WWW Security FAQ
http://www.w3.org/Security/Faq/
Web FAQ
http://www.boutell.com/faq/
CGI FAQ
http://www.webthing.com/page.cgi/cgifaq
HTTP Spec
http://www.w3.org/pub/WWW/Protocols/HTTP/
HTML Spec
http://www.w3.org/TR/REC-html40/
http://www.w3.org/pub/WWW/MarkUp/
CGI Spec
http://www.w3.org/CGI/
CGI Security FAQ
http://www.go2net.com/people/paulp/cgi-security/safe-cgi.txt
--
/* This bit of chicanery makes a unary function followed by
a parenthesis into a function with one argument, highest precedence. */
--Larry Wall in toke.c from the perl source code
------------------------------
Date: 10 Mar 1999 21:46:51 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 3.28: Where can I learn about object-oriented Perl programming?
Message-Id: <36e74abb@csnews>
(This excerpt from perlfaq3 - Programming Tools
($Revision: 1.33 $, $Date: 1998/12/29 20:12:12 $)
part of the standard set of documentation included with every
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq3.html
if your negligent system adminstrator has been remiss in his duties.)
Where can I learn about object-oriented Perl programming?
the perltoot manpage is a good place to start, and you can use
the perlobj manpage and the perlbot manpage for reference.
Perltoot didn't come out until the 5.004 release, but you can get
a copy (in pod, html, or postscript) from
http://www.perl.com/CPAN/doc/FMTEYEWTK/ .
--
"If you substitute other kinds of intellectual property into the GNU
manifesto, it quickly becomes absurd." --Cal Keegan
------------------------------
Date: Thu, 11 Mar 1999 02:44:39 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Filecheck-like utility??
Message-Id: <36E72F81.1EE19848@home.com>
[posted & mailed]
Peter Smith wrote:
>
> I need to quickly scan a file for non-alphanumeric and non-space
> characters. Ideally I'd like to spit-out line numbers, and even
> the offending character positions - assuming records are delimited
> by newlines. Basically I'm looking for FILECHK-like ability for
> anyone familiar with this dandy tool. Pretty sure I can gem a
> script out fairly quick, not sure how efficient I could make it
> though.
You won't know if you don't try. This does exactly what you asked for
but I have no idea if it is anything at all like FILECHK, whatever that
is.
#! /usr/bin/perl -w
$" = ',';
while (<>) {
my @positions;
push @positions, pos while /[^\w \n]/g;
next unless @positions;
printf "%5d @positions\n", $.;
}
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 10 Mar 1999 22:43:10 -0500
From: Aaron Walker <amwalker@gate.net>
Subject: formatting QUERY_STRING
Message-Id: <36E73BCE.65598DA1@gate.net>
hello,
I am writing a perl script to assist another perl script.
The first perl script calls the second one by the user clicking on a
link..
example:
first perl script:
... (I skipped the above code, cause it wasn't necessary for my example)
<html><body>
<a href="/cgi-bin/second_script.pl?file=$filename">$filename</a>
...
second perl script:
--begin--
#!/usr/bin/perl
print "Content-type: text/html\n\n";
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;
}
print $FORM{'file'};
--end--
why doesn't the above work? it is the code I usually use when I am
using forms.
It should still work here, too right? since the fact that it came from a
form is irrelevent...
nothing gets printed out when I run the second perl script.
Any ideas?
thanks,
Aaron Walker
------------------------------
Date: Wed, 10 Mar 1999 18:32:41 -0800
From: "David Dodd" <honky@best.com>
Subject: Help with basic perl problems.
Message-Id: <7c7ac4$gf8$1@news2.symantec.com>
Hi,
I am just starting out and can not get my first perl script running. This
is what I have done.
Created a simple form to launch the script...
-------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<BODY>
<FORM ACTION="Test.cgi" METHOD="POST"
ENCTYPE="application/x-www-form-urlencoded">
<P><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit">
</FORM>
</BODY>
</HTML>
-------------------
Create a simple script
-------------------
#!/usr/local/bin/perl
$time=localtime(time);
print "Content-type: text/html\n\n";
print<<end_of_block;
<HTML><HEAD><TITLE>My First CGI Program</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF"> <CENTER><H1>My First CGI Program</H1><CENTER>
<P>
Your host is: $ENV{'REMOTE_HOST'};
<BR> The time is: $time
<P>
This is the end of the program. Like I said, not very useful
but we will be getting to the useful programs soon!
</BODY></HTML>
end_of_block
-------------------------
Set the rights on the .cgi script
chmod 750 Test.cgi
Tried to run the script and I can not figure out how to get it to run. Is
there something I am missing? Please help. I continue to get, document
contains no data.
Thanks,
Dave
p.s. Sorry for the lame question, I am new to perl.
------------------------------
Date: 09 Mar 1999 10:56:18 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: How to find the hostname of the visitors
Message-Id: <xkf678amtrx.fsf@valdemar.col.hp.com>
abigail@fnx.com (Abigail) writes:
> ashishji@hotpop.com (ashishji@hotpop.com) wrote on MMXVI September
> MCMXCIII in <URL:news:7c370v$8s2$1@nnrp1.dejanews.com>:
> -- How could I find the Hostname of the visitors coming to the my site.
>
> Ask them for their business cards, and stop them at the gate if
> that doesn't include their hostname.
It's even easier: simply require that all visitors must be escorted by an
employee. Then, if you want to know the host's name, just call down to
the security desk, and see who signed them in. Low-tech, sure, but you
don't have to use perl for *everything*.
-=Eric
------------------------------
Date: 09 Mar 1999 16:07:57 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: Missing CGI Environment Variables
Message-Id: <xkfemmyl0s2.fsf@valdemar.col.hp.com>
jcasey@workingventures.ca (John Casey) writes:
> I later tried using the same script with Omnicron HTTPd/Perl5.
> PATH_INFO and HTTP_REFERER do not work, but others do. Almost all of
> my path type information does not work.
<snip>
What's your perl question?
-=Eric
------------------------------
Date: 11 Mar 1999 13:37:42 +1100
From: Tim Potter <tpot@acsys.anu.edu.au>
To: gemhound@gemhound.com
Subject: Re: net sockets
Message-Id: <6y6788hhu1.fsf@acronym.anu.edu.au>
gemhound@gemhound.com (Jim and Paula) writes:
> I'm trying to learn internet sockets and having no luck at all. Could
> someone just post or send a small Working example of connecting and
> gettting a domain Name from a Number i.e. translate 12.18.59.111 to
> somebody.com That's all I need to do for a server log analysis
> program I'm working on. Or tell me where a script is that has that.
> If I can get one thing working that I can put in a useful program, I
> think I can go on from there.
I use the following based on the documentation for gethostbyaddr() in
the camel book. I haven't tested it under Win32 though.
# Turn IP address into host name
sub gethost {
use Socket qw(AF_INET);
my $address = @_[0];
my ($a, $b, $c, $d ) = split(/\./, $address);
my $addr = pack( "C4", $a, $b, $c, $d );
my $hostname = gethostbyaddr($addr, AF_INET);
return ($hostname eq '') ? $address : $hostname;
}
Tim.
--
Tim Potter, System Admin/Programmer, Head Bee Guy
Advanced Computational Systems CRC, RSISE Bldg Australian National University,
Canberra 0200, AUSTRALIA Ph: +61 2 62798813 Fax: +61 2 62798602
------------------------------
Date: Tue, 9 Mar 1999 05:04:07 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Newbie Regularn Expression Help
Message-Id: <MPG.114ebc17a69082989714@nntp.hpl.hp.com>
In article <cnaqcvozarg.f8c4i80.pminews@news3.ibm.net> on Tue, 09 Mar
1999 11:01:20 +0000 (GMT), Philip Nelson <pandp@ibm.net.nospam >says...
...
> The output produced for a successful backup reads -
>
> Backup successful. The timestamp for this backup image is : ccyymmddhhmmss
...
> $out = `$backcmd`
Missing a semicolon there.
> if ($out =~ /image is : (\b.\b)/)
> print $1;
if ($out =~ /image is : (\d{14})/)
print $1;
This very specifically requests a string of 14 digits.
`perldoc perlre` for regular expression help.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 10 Mar 1999 22:11:45 -0500
From: SZABO <sbeam@beeline.net>
Subject: OT? how do I write a regexp to...
Message-Id: <36E73470.FB623F95@beeline.net>
match and parse an <A> tag? I would use HTML::Parse or equiv. but this
regexp is destined for a JScript/ASP application (as thus this is not
really a Perl question but I thought this must be the best place to go
for help anyway - I was asked to do this based on my vast expertise in
Perl <cough choke>). I know this is not simple - also need to pull out
the method, domain, port, path, etc. from the href attribute.
If this is too OT I will gladly take my problem elsewhere. Any ideas on
where to take it would be helpful.
Here is what I have so far - thought I would seek help before I spent 2
weeks trying to refine this. Seems to work OK - how I will do it in ASP
without $/ or the $1 series I dont know.
===========================================================================
#!/user/bin/perl -wn
$/ = "\n\n";
while (/<[Aa] (.*?)>(.*?)<\/[Aa]>/sg) {
$attribs = $1;
$tlink = $2;
if ($attribs =~ m/[hH][rR][eE][fF] *=
*"([a-z]+:\/\/)?([a-z0-9\.]+)*(:[0-9]{0,4})?(\/.*?)"/) {
print "method: $1\n" if $1;
print "domain: $2\n" if $2;
print "port: $3\n" if $3;
print "path: $4\n" if $4;
}
else { print "no href!\n"; }
print "attributes: $attribs\n";
print "text: $tlink\n\n";
}
======================================================================
Thanks IA
-S
------------------------------
Date: 11 Mar 1999 04:19:56 +0100
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Speed-optimizing regular expressions
Message-Id: <7md82gr9ur.fsf@glory.besmarter.com>
>>>>> "SM" == Sean McAfee <mcafee@waits.facilities.med.umich.edu> writes:
SM> In article <7mg17dqdcm.fsf@glory.besmarter.com>,
SM> Uri Guttman <uri@ibnets.com> wrote:
>> why not open all the domain log files first, store the handles by a hash
>> indexed by the domain name and write to the file according to the domain
>> in the log line.
SM> This was the first method I thought of, but Joe mentioned that
SM> there were ~250 different domains. I assumed that most operating
SM> systems won't allow this many open files at once. I just tried
SM> opening lots of files on Solaris 2.6, and it balked at opening the
SM> 61st. Hmmm. Now I tried the same test on AIX 4.2, and it
SM> complained about the 1998th. Win95, the 510th.
that is easily fixed on solaris with a ulimit call (IIR). the system
limit is much greater than the default limit. also a handle caching
modification of your code could handle even more that the system by
closing a file and reopening it later when needed. but it is something
to be concerned about if the number of virtual hosts rises to more than
the system limit of open file handles.
uri
--
Uri Guttman Hacking Perl for USite
uri@sysarch.com uri@besmarter.com
------------------------------
Date: 09 Mar 1999 14:09:49 -0700
From: Eric The Read <emschwar@mail.uccs.edu>
Subject: Re: SSI within CGI
Message-Id: <xkfiucal68y.fsf@valdemar.col.hp.com>
Brad Beiter <thespaceport@my-dejanews.com> writes:
> How do i get server side includes to work from within a cgi script? it is in
> perl, if that helps.
But it's still not a perl question. You need to ask this on one of the
comp.infosystems.www.servers.* newsgroups, since that's what they do.
Although I have a feeling you will find out you can't get there from
here.
-=Eric
------------------------------
Date: Thu, 11 Mar 1999 11:16:59 +0800
From: Chim Kin Sang <mecks@ust.hk>
Subject: standard input and standard error
Message-Id: <36E735AB.AEE65367@ust.hk>
Hi,
I am developing some automatical weather forecast system. I have
write a lot of
little program, include C-Shell, C and FORTRAN. I try to put it together
by PERL.
The problem I engaged is that when I am using the command
system. I cannot
put the standard output and standard error into the same file. for
example, C-shell
handle it by something.exe >&! outfile
Can anyone tell me how PERL handle the same thing. I am new to
PERL.
Thanks
Jim
------------------------------
Date: 11 Mar 1999 02:05:38 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Writing to a file
Message-Id: <921118199.65293@thrush.omix.com>
[posted & mailed]
olmert@netvision.net.il wrote:
: I tried to open a file for writing. The unfortunate result is always that
: the entire file is erased,
perldoc -f open
You probably wanted to use <+ (instead of +>)
HTH
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Wed, 10 Mar 1999 21:45:03 -0500
From: "Mark D. Sholund" <msholund@bigfoot.com>
To: olmert@netvision.net.il
Subject: Re: Writing to a file
Message-Id: <36E72E2F.12EC8427@bigfoot.com>
If I understand what you want to do, your code
if (open (BOOK, "+> $bookLocation")) {
@LINES=<BOOK>;
$SIZE=@LINES;
for ($i=0;$i<=$SIZE;$i++) {
$_=$LINES[$i];
if (/begin/) {
print BOOK "This line contains the blues!<P>\n";
}
print $_;
}
close (BOOK);
}
else {
print "error";
}
should have print BOOK; (or print BOOK $_;) otherwise you're just
writing your inserted line to the files each time you find a line
containing "begin" (btw this will also match "beginning" "beginner" etc)
On any account, I think you might be trying to do something that is more
difficult than it has to be. My manual says "if you really want to have
fun, open a file for reading and writing" (+>) I accomplished the same
thing with this code:
open (BOOK, "$bookLocation") || die "error\n";
@LINES = <BOOK>;
$SIZE = $#LINES # $#LINES returns the index of the last element in the
array
close BOOK;
open (BOOK, ">$bookLocation") || die "error\n";
foreach (@LINES)
{
print BOOK "This line contains the blues!<P>\n" if (/\bbegin\b/i);
print BOOK;
}
close BOOK;
This opens the file twice, once for reading each line, then next for
writing out the lines and additionat output. Notice the different
regular expression. This expression will match any case of the word
"begin" and will match onlythe word begin (not beginning, not beginner
etc) and will match when it is followed by punctuation ("begin."
matches).
I hope this was of some help.
--
in accordance with prophecy.
"Computer, install a recursive algorithm."
- Ensign Harry Kim
------------------------------
Date: Wed, 10 Mar 1999 21:51:39 -0500
From: "Mark D. Sholund" <msholund@bigfoot.com>
Subject: Re: Writing to a file
Message-Id: <36E72FBB.B28394CF@bigfoot.com>
I just tried this and it prints error everytime (I am setting $bookLocation to
an existing file). The way he tried to open the file (+>) is the correct way
for reading and writing to the file. Reading and writing to a file at the same
time can get a bit tricky however as this example seems to prove.
Zenin wrote:
> [posted & mailed]
>
> olmert@netvision.net.il wrote:
> : I tried to open a file for writing. The unfortunate result is always that
> : the entire file is erased,
>
> perldoc -f open
>
> You probably wanted to use <+ (instead of +>)
>
> HTH
>
> --
> -Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
> BSD: A psychoactive drug, popular in the 80s, probably developed at UC
> Berkeley or thereabouts. Similar in many ways to the prescription-only
> medication called "System V", but infinitely more useful. (Or, at least,
> more fun.) The full chemical name is "Berkeley Standard Distribution".
--
in accordance with prophecy.
"Computer, install a recursive algorithm."
- Ensign Harry Kim
------------------------------
Date: Wed, 10 Mar 1999 21:11:49 -0500
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: y2k and 4-digit dates (was Re: foreach and while)
Message-Id: <19990310.211149.5f2.rnr.w164w@locutus.ofB.ORG>
Staffan Liljas <staffan@ngb.se> writes:
> But NB: [4 digit years work] is for you.
I forgot to mention: obviously, all these cases where people are having
problems with the 2-digit dates aren't even under consideration. someone
who's trying to discern 5376 BC with 5276 BC wouldn't be writing "'76"
to begin with!
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5106
**************************************