[11605] in Perl-Users-Digest
Perl-Users Digest, Issue: 5205 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 23 08:07:44 1999
Date: Tue, 23 Mar 99 05:01:03 -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 Tue, 23 Mar 1999 Volume: 8 Number: 5205
Today's topics:
Re: [HELP PLS] Reg Exp for "a number" (Bart Lateur)
Activeperl and NT wstation <allantud@ozemail.com.au>
Re: Activeperl and NT wstation c4jgurney@my-dejanews.com
Checking Directories contents.. <horizon@internetexpress.com.au>
Re: choping off whitespace (Larry Rosler)
Encryption Problem <webmaster@unicorn-soft.com>
Re: Encryption Problem (Jonathan Stowe)
Help me : SEBDEMAIL scripts <root@uoavs.smb.mv.ru>
help with loops <c-denman@dircon.co.uk>
Help: subroutine call in 'dochere' string? <soli@pc-szoftver.mgx.hu>
Re: Help: subroutine call in 'dochere' string? (Jonathan Stowe)
Re: HTML in email <Philip.Newton@datenrevision.de>
HTTP:Request. POST method adding HTTP/1.0 to headerr <plf58@leland.Stanford.EDU>
Re: Need username in Perl script <imagee@image-engineering.co.uk>
Re: Need username in Perl script (Steve Grantz)
Re: Odd/Even (Larry Rosler)
Re: Perl WIN32 - How to return a DOS ErrorLevel? <Philip.Newton@datenrevision.de>
Re: Possible values for $^O? <Philip.Newton@datenrevision.de>
Re: Possible values for $^O? <Philip.Newton@datenrevision.de>
Re: Possible values for $^O? (Jonathan Stowe)
Re: RAD or WYSIWIG for Perl ??? (Jonathan Stowe)
REGEX <luke@chipcity.com.au>
Re: REGEX (Bart Lateur)
Re: retrieve the first hyperlink from an html file (Jonathan Stowe)
Re: Sending to multiple recipients via Sendmail (Jonathan Stowe)
Re: STDOUT buffering (Bart Lateur)
use B <The Perl Compiler> problem <mike@nordlink.ru>
View CGI source <lemmen@support.nl>
Re: View CGI source (Jonathan Stowe)
Re: Where to start with Perl (Bart Lateur)
Re: Where to start with Perl (Bart Lateur)
Re: WIN 95 - How to run c4jgurney@my-dejanews.com
Re: WIN 95 - How to run <seannln@bit-net.com>
Win32::NetResource ()
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 23 Mar 1999 08:54:01 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: [HELP PLS] Reg Exp for "a number"
Message-Id: <36f84a67.1615014@news.skynet.be>
sergei_klimov@my-dejanews.com wrote:
> I have been trying to invent a generalized RegExp for "a number" but
>failed. I believe there exists a RegExp that I need but I cannot find it or
>work it out myself. Please, help.
Let's see:
$numberpattern = '[+-]?(?:\d+\.?\d*|\d*\.\d+)(?:[eE][+-]?\d+)?';
This requires at least one digit left of the (optional) "E" part. "1.2",
"1.", ".1", "123" are all acceptable, but "." is not.
Try this on your data with:
if (/^$numberpattern$/o) {
print "Yeehaw! Number found: $_\n";
} else {
print "'$_' isn't a number\n";
}
or
while (/($numberpattern)/g) {
print "Number: $1\n";
}
You can get rid of excess spaces using { tr/ //d; }.
Bart.
------------------------------
Date: Tue, 23 Mar 1999 16:16:22 +0800
From: "Allan Tudehope" <allantud@ozemail.com.au>
Subject: Activeperl and NT wstation
Message-Id: <36f74d9c.0@news.highway1.com.au>
Apologies if this has come up before, but I cannot find a suitable answer
for my problem.
I have NT4 workstation using the Peer Web Server and have just installed
Activeperl. I have followed the installation docs closely and can get perl
scripts to run in a DOS window. But I cannot seem to get the same script to
run by calling it from a HTML page using PWS. My browser will try to connect
to the PWS but nothing happens. If I open the HTML page through MS Explorer,
the script will run in the DOS window, but if I open the same HTML page
through the PWS nothing happens when I call the script (with a form using
the POST method).
I just know it's something simple, but I'm too simple to figure this one
out!
Thanks
--
Allan Tudehope
------------------------------
Date: Tue, 23 Mar 1999 12:23:14 GMT
From: c4jgurney@my-dejanews.com
Subject: Re: Activeperl and NT wstation
Message-Id: <7d813c$mvn$1@nnrp1.dejanews.com>
In article <36f74d9c.0@news.highway1.com.au>,
"Allan Tudehope" <allantud@ozemail.com.au> wrote:
> I have NT4 workstation using the Peer Web Server and have just installed
> Activeperl. I have followed the installation docs closely and can get perl
> scripts to run in a DOS window. But I cannot seem to get the same script to
> run by calling it from a HTML page using PWS.
Allan,
Run through the following checklist.
1) The perl script is in the cgi-bin directory 2) PWS has the cgi-bin
directory set up correctly 3a) The shebang line has the correct path to perl
(I don't know about PWS but some win32 servers do require this to be set) 3b)
NT has the correct file association for .pl files (I don't know about PWS but
some win32 servers do require this to be set - AS build 509 didn't do this
correctly on my NT box C:\Perl\bin\Perl.exe "%1" %*) 4) read perlfaq9 "My CGI
script runs from the command line but not the browser. (500 Server Error)"
Regards,
Jeremy Gurney
SAS Programmer | Proteus Molecular Design Ltd.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 23 Mar 1999 22:44:48 +1100
From: Mick <horizon@internetexpress.com.au>
Subject: Checking Directories contents..
Message-Id: <36F77EB0.916E3A7C@internetexpress.com.au>
Hi...is there a simple way to check if a directory contains any files?
I've tried -
while ( $entry = readdir( DIR ) ) {
$type = ( -d "$user_path$p_month\\$entry" ) ? "dir" :
"file";
if($type eq "file"){
push (@files, $entry);
}
}
closedir(DIR);
if (@files eq 0){
print "<B><CENTER>Directory doesn't contain any data
files</B></CENTER><BR>";
etc...
Which doesn't work (It picks up . and .. I think)....The problem is this
does work in DOS? why?
Thanks in advance,
Mick
--
----------------------------------------------------------------
HORIZON Software Solutions
Visit Site - http://www.deakin.edu.au/~bellears/horizon/index.html
e-mail - mailto:horizon@internetexpress.com.au
----------------------------------------------------------------
------------------------------
Date: Mon, 22 Mar 1999 23:51:01 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: choping off whitespace
Message-Id: <MPG.1160e7c480ba712c9897aa@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <36f725be$0$204@nntp1.ba.best.com> on 23 Mar 1999 05:25:18
GMT, J. David Eisenberg <nessus@shell5.ba.best.com >says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> : In article <slrn7fe4l3.pvb.morpheus@teleute.rpglink.com> on 22 Mar 1999
> : 20:03:47 +0800, Steve Lamb <morpheus@no-spam.calweb.com >says...
> :> On 23 Mar 1999 03:40:07 GMT, Damon61 <damon61@aol.com> wrote:
> :> >Can someone please tell me how to chop off the leading and trailing
> :> >whitespace of a string. It seems so simple, but i'm having trouble. Any
> :> >help is greatly appreciated.
> :>
> :> $string =~ s/^\s*//;
> :> $string =~ s/\s*$//;
> :>
> :> Just a guess.
>
> : That works, and is almost right. But why answer with a guess? For such
> : a Frequently Asked Question, the definitive answer in in the Perl FAQ.
>
> Interesting comment: "That works, and is almost right." If it
> works, then it _is_ right. It may not be the most efficient way
> to do it, but it's straightforward to read and understand. I had
> been under the impression that there's usually more than one
> way to do something in perl.
Thank you for taking the bait!
There Is indeed usually More Than One Way To Do something in Perl. All
of the ways may work, but some will be more 'right' than others. As you
intuited, the difference is efficiency.
If one way works but takes 'forever' to finish, that way is *wrong*. In
this case, the difference is 'only' a factor of 6 or so, so it is
'almost right'.
> However, I stand corrected, and shall seek out the perl faq
> so that I may find out the one way, the only way,
> the "right" way to do it. <grin>
For comparison, I threw in another -- even less right -- way, derided in
the FAQ ('Bad'); also another one-liner (often posted) that isn't so
good either ('Or').
#!/usr/local/bin/perl -w
use Benchmark;
my $s = 'x' x 50;
timethese(1 << (shift || 0), {
Bad => sub { $s =~ s/^\s*(.*?)\s*$/$1/ },
Or => sub { $s =~ s/^\s+|\s+$//g },
Plus => sub { $s =~ s/^\s+//; $s =~ s/\s+$//; },
Star => sub { $s =~ s/^\s*//; $s =~ s/\s*$//; },
});
__END__
Benchmark: timing 65536 iterations of Bad, Or, Plus, Star...
Bad: 9 wallclock secs ( 8.96 usr + 0.00 sys = 8.96 CPU)
Or: 6 wallclock secs ( 6.64 usr + 0.00 sys = 6.64 CPU)
Plus: 1 wallclock secs ( 0.93 usr + 0.00 sys = 0.93 CPU)
Star: 6 wallclock secs ( 5.72 usr + 0.00 sys = 5.72 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Mar 1999 03:08:33 -0600
From: "Tobias C. Wilhelm" <webmaster@unicorn-soft.com>
Subject: Encryption Problem
Message-Id: <36F75A11.9994E8D0@unicorn-soft.com>
I'm in the middle of setting up a store front for one of our customers
and it turns out that they can not use PGP since their offices are
located overseas. Is there any other options, such as 40-bit encryption
that work nicely in a CGI script and are easy to be decrypted using NC
or IE ???
Any help is appreciated ...
Tobias C. Wilhelm
--
****************************************
* Tobias C. Wilhelm *
* CEO / Vice President *
* webmaster@unicorn-soft.com *
****************************************
* Unicorn Software Development Inc. *
* *
* Visit Our Website *
* http://www.unicorn-soft.com *
****************************************
------------------------------
Date: Tue, 23 Mar 1999 11:44:04 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Encryption Problem
Message-Id: <36f77e2c.10214488@news.dircon.co.uk>
On Tue, 23 Mar 1999 03:08:33 -0600, "Tobias C. Wilhelm"
<webmaster@unicorn-soft.com> wrote:
>I'm in the middle of setting up a store front for one of our customers
>and it turns out that they can not use PGP since their offices are
>located overseas.
Why does that stop them from using PGP ?
> Is there any other options, such as 40-bit encryption
>that work nicely in a CGI script and are easy to be decrypted using NC
>or IE ???
I would ask on a crypto or CGI group - this isnt really a Perl
Question.
/J\
------------------------------
Date: Tue, 23 Mar 99 10:02:06 +0300
From: "System Administrator" <root@uoavs.smb.mv.ru>
Subject: Help me : SEBDEMAIL scripts
Message-Id: <ABhhpzsymE@uoavs.smb.mv.ru>
Hi !
I need simple working script SENDMAIL .
or I've got any , but its don't working
on my PC-server
SY ,
Andrew
------------------------------
Date: Tue, 23 Mar 1999 10:59:38 -0800
From: "Chris Denman" <c-denman@dircon.co.uk>
Subject: help with loops
Message-Id: <7d7s76$ipb$1@news5.svr.pol.co.uk>
I have a program which gets into a loop. There are many parts to this
program, so it is hard to find out which sub has the loop.
Is there any way of finding out where a program has got into a loop. I have
the perl DK and the debugger, but the debugger gets into a loop also. I
have not found a way to stop the debugger and get the line number that it is
at.
I could manually work through the code, but I have a deadline to stick to.
Cheers for any help,
Chris D
------------------------------
Date: Tue, 23 Mar 1999 09:06:47 +0100
From: soli <soli@pc-szoftver.mgx.hu>
Subject: Help: subroutine call in 'dochere' string?
Message-Id: <36F74B97.489D5CF5@pc-szoftver.mgx.hu>
Hi All,
I'd like to know how can I call a subroutine from within a
"document here" string?
The following does not work:
sub UserName() {
...
return "john";
}
$str1 = <<__ENDSTR__;
fgfdgfdgdf
&UserName()
ghghghg
__ENDSTR__
[if you have answer, please reply to my address,too]
thanks in advance,
SOLI
------------------------------
Date: Tue, 23 Mar 1999 11:30:30 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Help: subroutine call in 'dochere' string?
Message-Id: <36f779fb.9140913@news.dircon.co.uk>
On Tue, 23 Mar 1999 09:06:47 +0100, soli <soli@pc-szoftver.mgx.hu>
wrote:
>Hi All,
>
>I'd like to know how can I call a subroutine from within a
>"document here" string?
>
>The following does not work:
>
>sub UserName() {
> ...
> return "john";
>}
>
>$str1 = <<__ENDSTR__;
>fgfdgfdgdf
>&UserName()
>ghghghg
>__ENDSTR__
>
Yes, thats the way it is I'm afraid - the here doc behaves just like a
double quoted string and expressions such as functions are not
expanded in the same way as vaiables are - what you will have to do is
put in the rather nasty looking:
@{[&UserName()]}
instead or copy the value of the function to a string before the here
doc.
/J\
------------------------------
Date: Tue, 23 Mar 1999 10:05:34 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: HTML in email
Message-Id: <36F7595E.601409B4@datenrevision.de>
Karen J. Cravens wrote:
>
> "Brian" brian@removethisnet-weaver.com wrote in
> <7d3tcg$cgi$1@winter.news.rcn.net>:
>
> > print MAIL "From: $in{'author'}\n";
> > print MAIL "Subject: Article Submission\n\n";
> > print MAIL "Content-Type: \"text/html;\"\n\n";
>
> You'll also want to add the header:
> Mime-Version: 1.0
You will probably also want to use a here-doc for this:
print MAIL <<"EOMAIL";
From:
Subject:
bla
bla bla
etc.
EOMAIL
Saves you having to type "print MAIL" and "\n" over and over again, and
also keeps you from having to escape the quotation marks.
------------------------------
Date: Mon, 22 Mar 1999 23:52:56 -0800
From: Peter Leo Feng <plf58@leland.Stanford.EDU>
Subject: HTTP:Request. POST method adding HTTP/1.0 to headerr
Message-Id: <Pine.GSO.3.96.990322235047.12821A-100000@saga0.Stanford.EDU>
This is my first POST. literally.
I'm writing a web client, and I would like to really manipulate my
requests with POST instead of a general GET which appears in all the
books...
I am using HTTP::Request Module.
The error I am getting after making the request is 501 Protocol
scheme '' is not supported. I believe this is due to the lack of a
HTTP/1.0 following the POST <path> statement. I've printed out my
header, and I think this is what the error is. I'm not really sure
how I could add the string "HTTP/1.0" to the HTTP::Request end of the URL$
Strangely, GET method works just fine without this extra HTTP/1.0.
Things I've already tried:
1.altering the number of spaces in the content,
2.appending HTTP/1.0 to the $url.
I really don't want to use sockets....
THIS IS MY CODE
$ua = new LWP::UserAgent;
$url="www.perl.com/cgi-bin/email-grabber/grabber";
$request= new HTTP::Request("POST",$url);
$url="www.perl.com/cgi-bin/email-grabber/grabber";
$request= new HTTP::Request("POST",$url);
$request->header('Accept'=>'text/html');
$request->header('Content-type'=>'text/html');
$request->header('Content-length'=> 2);
$content=<<Cont;
NAME="emailaddr" VALUE="plf58\@sbh.com"
Cont
$request->content($content);
print $request->as_string();
my $response=$ua->request($request);
OPEN AND PRINT TO A FILE...
------------------------------
Date: Tue, 23 Mar 1999 11:18:38 +0000
From: Richard Watkins <imagee@image-engineering.co.uk>
To: John Dilley <john@dilley.com>
Subject: Re: Need username in Perl script
Message-Id: <36F7788E.45FE7F63@image-engineering.co.uk>
> I have a PERL script inside a private directory protected with a .htaccess
> file. I would like the script to use the login name of the user accessing that
> directory. A test sample of all $env didn't show anything of real use. One web
> page I found mentioned REMOTE_USER, but this does not appear in my list. Is
> there a way to get the htaccess login name from within my script?
>From my "Special Edition Using CGI" book:
REMOTE_USER - If AUTH_TYPE is set, this variable contains the user name
provided by the user and validated by the server.
AUTH_TYPE - If the server supports basic authentication and if the
script is protected, this variable provides the authentication type. The
information is protocol and server specific. An example AUTH_TYPE is
BASIC.
Might be worth speaking to your host and enquiring about AUTH_TYPE.
Richard.
--
Image Engineering - Constructing your web presence.
http://www.image-engineering.co.uk
5, Mayfly Close, Chatteris, Cambs, PE16 6PF
Tel: 01354 696390 Mobile: 0966 389110
email: richard@image-engineering.co.uk
------------------------------
Date: Tue, 23 Mar 1999 09:30:18 GMT
From: sgrantz@visi.com (Steve Grantz)
Subject: Re: Need username in Perl script
Message-Id: <KaJJ2.1013$rP1.47512@ptah.visi.com>
John Dilley (john@deletethisdilley.com) wrote:
: I have a PERL script inside a private directory protected with a .htaccess
: file. I would like the script to use the login name of the user accessing that
: directory. A test sample of all $env didn't show anything of real use. One web
: page I found mentioned REMOTE_USER, but this does not appear in my list. Is
: there a way to get the htaccess login name from within my script?
If you use the CGI module, the method remote_user() should do the trick.
More information in perldoc CGI.
: I hate to ask, but could you please reply in email as well as to the group? My
: ISP's news server is going down as often as $PresidentialIntern and missing
: major chunks of mail....
And that request comes up as often as $PresidentialPhallus.
--
More of Steve Grantz's Blather at 2 * McQ != McQ
http://www.visi.com/~sgrantz 0.5 * McQ == McQ
------------------------------
Date: Tue, 23 Mar 1999 00:03:53 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Odd/Even
Message-Id: <MPG.1160eac437e94b479897ab@nntp.hpl.hp.com>
In article <1dp3gkr.na65rqq8sztsN@p57.block2.tc3.state.ma.tiac.com> on
Tue, 23 Mar 1999 01:18:52 -0500, Ronald J Kimball
<rjk@linguist.dartmouth.edu >says...
> Gabriel Richards <grichard@uci.edu> wrote:
>
> > if ($counter = [an odd number]) {do x}
>
> if ($counter & 1) {do x}
That may be 'high-school' level (because it deals with binary
representations).
if ($counter % 2) {do x}
is 'elementary-school' level (because it deals with arithmetic).
The '&' is perhaps 5% faster, though.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 23 Mar 1999 09:30:08 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Perl WIN32 - How to return a DOS ErrorLevel?
Message-Id: <36F75110.F969E89E@datenrevision.de>
Brian Moore wrote:
>
> I know it seems simple, but having gone through the PERL for Win32 docs, I
> find nothing about returning the most basic of Windows cmd values, the
> ERRORLEVEL.
ERRORLEVEL is just DOS's name for the return value of the last program
executed. So if you want an ERRORLEVEL of -- say -- 2, just arrange for
Perl to return this value: use
exit 2;
as the last line of your script.
> I'm trying to use my Perl script within an existing (and complicated) DOS
> batch program, and have the batch program make decisions based on the Perl
> script results. So I want the Perl script to return a DOS ERROLEVEL (this
> is the only way I know to reference results within a cmd shell, without
> having to write a file). Any help is appreciated...
Alternatively, you could think about rewriting your batch program in
Perl at some point.
Cheers,
Philip
------------------------------
Date: Tue, 23 Mar 1999 09:09:42 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Possible values for $^O?
Message-Id: <36F74C46.235805BB@datenrevision.de>
Bart Lateur wrote:
>
> Philip Newton wrote:
>
> >Does $^O differentiate between e.g.
> >Win95, Win98, WinNT, and Win2000?
>
> I think that $^O depends entirely on the Perl port, and NOT on the OS
> itself.
>
> For example, Ilya's OS/2 port says it's "os2", even when run on DOS. It
> looks like the Activestate port says "MSWin32", no matter what platform.
In theory, all Perl ports can be built by fetching the CPAN source, no?
So there must be some file in the distribution which detects the host
operating system and tweaks some settings (is this the "hints" file?)
So somewhere in the distribution, I assume there must be a file (or
several files) which contain these values. Perhaps someone know which
of the 2^n files in stable.tar.gz (or whatever) contain(s) the strings?
At home, I use ActivePerl and didn't bother to fetch the source, so I
can't tell from there.
Cheers,
Philip
------------------------------
Date: Tue, 23 Mar 1999 09:06:16 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: Possible values for $^O?
Message-Id: <36F74B78.BEA614D6@datenrevision.de>
Jonathan Stowe wrote:
>
> P:\>uname -a
> MS-DOS DESKTOP8 7 10 pc
Where'd you get uname for DOS from?
Thanks a lot for your answers, though.
Cheers,
Philip
------------------------------
Date: Tue, 23 Mar 1999 09:19:00 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Possible values for $^O?
Message-Id: <36f75c71.1577698@news.dircon.co.uk>
On Tue, 23 Mar 1999 09:06:16 +0100, Philip Newton
<Philip.Newton@datenrevision.de> wrote:
>Jonathan Stowe wrote:
>>
>> P:\>uname -a
>> MS-DOS DESKTOP8 7 10 pc
>
>Where'd you get uname for DOS from?
>
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/
/J\
------------------------------
Date: Tue, 23 Mar 1999 11:37:50 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: RAD or WYSIWIG for Perl ???
Message-Id: <36f77cf5.9903247@news.dircon.co.uk>
On Mon, 22 Mar 1999 17:26:36 -0700, "Ty! Boyack"
<ty@cnr.colostate.edu> wrote:
>Jonathan Stowe wrote:
>>
>> On Wed, 17 Mar 1999 01:29:57 -0500 Steve Davis wrote:
>> >
>> > I want a GUI that will help me assemble the code.. there are dozens of apps
>> > out there to help me produce java apps but nothing for Perl which surprises
>> > me.
>> >
>
>I've only tinkered with these (I personally prefer a text editor
>myself), but you might search for SpecTCL/SpecPerl for building
>GUI's. It's probably not as seemless as a full IDE you might
>go out and buy, but it fits right in everyone's price range :-)
>
I think I'll stick with vim if thats alright with you
/J\
------------------------------
Date: Tue, 23 Mar 1999 18:19:18 +1030
From: "Luke" <luke@chipcity.com.au>
Subject: REGEX
Message-Id: <36f746ca.0@news.camtech.net.au>
Hi,
I have a problem, maybe someone can help me with.
I have attached a program.
I have explained my problem in the comments,
Can anyone explain?
Luke
#!/usr/bin/perl
# This program is to test out some things
# To illustrate my problem
# The "work" file could consist of the following lines:
###################
# take photos
# photos
###################
open(WORK, "work");
while(<WORK>) {
# if I use this line it doesn't give me any result:
if(/(ph)\b|\b\1/) {
# if I use this line it does:
# if(/ph\b|\bph/1) {
# why?
s/ /XXXXXX/g;
print "$_";
}
}
close(WORK);
------------------------------
Date: Tue, 23 Mar 1999 11:31:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: REGEX
Message-Id: <36fa7b24.6278421@news.skynet.be>
Luke wrote:
>I have a problem, maybe someone can help me with.
This is a repost. I gave an answer in the original thread.
Bart.
------------------------------
Date: Tue, 23 Mar 1999 11:34:27 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: retrieve the first hyperlink from an html file
Message-Id: <36f77c0d.9671423@news.dircon.co.uk>
On Tue, 23 Mar 1999 04:41:56 GMT, brz@hotmail.com wrote:
>Can someone show me how to retrieve the first hyperlink in an html file?
>
Use the module HTML::LinkExtor and get the first one off the list
returned.
/J\
------------------------------
Date: Tue, 23 Mar 1999 09:05:19 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Sending to multiple recipients via Sendmail
Message-Id: <36f758a5.605675@news.dircon.co.uk>
On Mon, 22 Mar 1999 22:53:48 -0700, Martin Foster
<mfoster@spots.ab.ca> wrote:
> The reason I sated
>Localhost, was simple, Glen had mentioned he had access to sendmail, so
>I assumed (though I agree it should of not been assumed) that he had
>direct access trough telnet et cetera.
>
Except of course that sendmail might not be running as a daemon on the
machine :
tom.dircon.net# telnet localhost 25
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
tom.dircon.net# /usr/lib/sendmail -t
To: jns@pigment.dircon.net
Subject: Test
Test
.
Often for security reasons - if there is no reason for sendmail to be
running as a daemon then it wont be. So no SMTP connection is
possible.
/J\
------------------------------
Date: Tue, 23 Mar 1999 11:30:56 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: STDOUT buffering
Message-Id: <36f97ab5.6167198@news.skynet.be>
Trevor wrote:
>what I'm seeing is that STDOUT from program.exe is coming out
>bunched. So it would appear that perl is buffering STDOUT.
>How can I tell perl not to do this?
$| = 1;
Bart.
------------------------------
Date: 23 Mar 1999 15:28:17 +0300
From: Michael Kichanov <mike@nordlink.ru>
Subject: use B <The Perl Compiler> problem
Message-Id: <199903231228.PAA13233@mix.nordlink.ru>
I am build perl-5.005_02 on P90 running bsdos 3.1
It works fine but when i'm tried to use module B (The Perl Compiler)
included in core perl distribution I got the folowing error message:
---
Can't load '/usr/local/packages/perl/lib/5.00502/i386-bsdos/auto/B/B.o' for module B: can't resolve undefined symbols: Inappropriate file type or format at /usr/local/packages/perl/lib/5.00502/i386-bsdos/DynaLoader.pm line 168.
at - line 0
BEGIN failed--compilation aborted.
---
Other modules of perl core that uses dynamic loading
such as DB_File, IPC::SysV, Opcode, etc works properly.
What's the matter? Enlighten me please.
Thanx in advance,
mike
------------------------------
Date: Tue, 23 Mar 1999 11:26:04 +0100
From: "Marcel Lemmen" <lemmen@support.nl>
Subject: View CGI source
Message-Id: <7d7q4d$853$1@news.news-service.com>
Hi,
I've seen a CGI script which I want to use, but I can't find the source
anywhere.
Is there a possibility to view the CGI source straight from a page?
Thnx in Advance.
------------------------------
Date: Tue, 23 Mar 1999 11:41:46 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: View CGI source
Message-Id: <36f77dce.10119692@news.dircon.co.uk>
On Tue, 23 Mar 1999 11:26:04 +0100, "Marcel Lemmen"
<lemmen@support.nl> wrote:
>Hi,
>
>I've seen a CGI script which I want to use, but I can't find the source
>anywhere.
>Is there a possibility to view the CGI source straight from a page?
>
No chance whatsoever unless the server is running an unpatched version
of IIS3.0
/J\
------------------------------
Date: Tue, 23 Mar 1999 09:43:31 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Where to start with Perl
Message-Id: <36fa5a2e.5650958@news.skynet.be>
Luke wrote:
>I have a problem, maybe someone can help me with.
># if I use this line it doesn't give me any result:
> if(/(ph)\b|\b\1/) {
The vertical bar indicates alternatives. The left side is tested first.
If that fails, the right side is tested. But, in taht case, the lefts
side must have failed so \1 is nothing. Therefore you cannot use this
syntax to test for "\b(ph)" (parentheses added to split the different
parts).
HTH,
Bart.
------------------------------
Date: Tue, 23 Mar 1999 09:43:13 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Where to start with Perl
Message-Id: <36fc6201.7633806@news.skynet.be>
[mailed and posted]
Ed Wolfe wrote:
>@names=("Muriel","Gavin","Susanne","Sarah","Anna","Paul","Trish","Simon");
>
>for ($x=0; $x <= $#names; $x++) {
> print "$names[$x]\n";
>}
>
>$x has the value of 0 and there's an end of line semicolon. But then it
>says lesser than equals the array "names" then increment 0 one time??
>Then print the name Muriel??
Your problem appears not to be with the arrays, but with the for()
syntax. You seem to completely misunderstand it. It may not be the most
obvious syntax devisable, anyway.
The syntax is:
for(INIT; TEST; INCREMENT) { BLOCK }
and it's C's slightly more versatile version of the BASIC
FOR var = FIRST TO LAST STEP STEPSIZE
INIT: set VAR to FIRST
INCREMENT: add STEPSIZE to var
TEST: check if var is not larger than LAST
INIT, TEST and INCREMENT *must* be one statement,/expression. No
embedded semicolons, although you may use a " do { statements } "
construct.
It is equivalent to this code:
INIT;
while (TEST) {
BLOCK
} continue {
INCREMENT;
}
So:
- Do INIT once, before entering the loop
- Do the TEST every time, and repeat the loop only as long as this test
succeeds (evaluates to a true value)
- Do the code in the BLOCK every time
- After that is done, do the INCREMENT code (every time)
- Repeat the TEST, etc.
So the code you quote works much like:
@names=("Muriel","Gavin","Susanne","Sarah","Anna","Paul","Trish","Simon");
$x=0;
while($x <= $#names) {
print "$names[$x]\n";
} continue {
$x++;
}
This demo version will show you what is executed, and when.
for(do { print STDERR "INIT\n"; $x=0 };
do { print STDERR "TEST\n"; $x <= $#names };
do { print STDERR "INCREMENT\n"; $x++ })
{
print STDERR "BLOCK\n";
print "$names[$x]\n";
}
You'll see something like:
INIT
TEST
BLOCK
INCREMENT
TEST
BLOCK
INCREMENT
TEST
BLOCK
...
possibly intermingled with the normal output.
HTH,
Bart.
------------------------------
Date: Tue, 23 Mar 1999 09:07:50 GMT
From: c4jgurney@my-dejanews.com
Subject: Re: WIN 95 - How to run
Message-Id: <7d7ll2$e44$1@nnrp1.dejanews.com>
In article <36f6b808.5820508@news.zrz.tu-berlin.de>,
kissqfjg@sp.zrz.tu-berlin.de (velocity) wrote:
> Can somebody rescue me ? Or can somebody send a good side with FAQ
> where somebody answered my questions ?
>
The documentation that installs as part of the ActiveState distribution should
be a good place to start - You'll find a section on web programming in the
Active perl FAQ. Also good reading is the CGI.pm documentation also part of
same.
Somebody posted this URL for a free perl & CGI course (sorry I forget who
posted this - please stand up and take a bow).
http://www.free-ed.net/fr03/lfc/course%20030207_01/index.html
And when you're ready to test it all then D Turley's CGI testing page might
prove useful.
http://www.binary.net/dturley/cgi_testing.html
Regards,
Jeremy Gurney
SAS Programmer | Proteus Molecular Design Ltd.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 23 Mar 1999 06:41:23 -0500
From: Sean Phillips <seannln@bit-net.com>
To: velocity <kissqfjg@sp.zrz.tu-berlin.de>
Subject: Re: WIN 95 - How to run
Message-Id: <36F77DE3.4A8FCD2F@bit-net.com>
Did you try running "perl -v yourscript.pl"?
Also look into a module called CGI.pm by Lincoln Stein. This seems to
be the cornerstone of Perl CGI scripts.
Finally, goto www.perl.com - most things perl can be found there.
- Sean
velocity wrote:
> Hey Folks,
>
> I tried to begin programming in Perl because I want to develop some
> scripts to make my web - page more interesting.
>
> I 'm working with Win 95 b and because of that I downloaded
>
> 1. perl5.00402-bindist04-bc
> 2. Active Perl Win 32
> 3. Dcom 95
>
> But I do not understand how to test my scrips with the extensions like
>
> .cgi or .pl . Do I have to write a html or something like that ? Can
> somebody rescue me ? Or can somebody send a good side with FAQ
> where somebody answered my questions ?
>
> Thank you very much
>
> Henner
>
> kissqfjg@sp.zrz.tu-berlin.de
------------------------------
Date: 22 Mar 1999 22:51:01 GMT
From: rob@locutus.ucr.edu ()
Subject: Win32::NetResource
Message-Id: <7d6hgl$25f$1@pravda.ucr.edu>
I have been trying to use the Win32::NetResource module in perl to dynamically
map network printers in a logon script. I'm guessing that the AddConnection
function is the way to go, but I can't seem to make it work. It wants a
\%NETRESOURCE hash passed ot it, and a dwtype, both of which are moot for my
needs.
Basically all it should need to know is the UNC path to the printer itself,
i.e. "\\MACHINE\printer". Right now I'm using the kix32 function:
addprinterconnection to map these printers, but I want to do it all in perl
without relying on kix. The addprinterconnection function in kix does not
make you anchor the printer to a Local LP port, it just adds it in as a network
printer.
Has anyone been able to make this work? If so, please help... Thanks!!
--Robert
------------------------------
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 5205
**************************************