[15660] in Perl-Users-Digest
Perl-Users Digest, Issue: 3073 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 17 06:05:28 2000
Date: Wed, 17 May 2000 03: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: <958557909-v9-i3073@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 17 May 2000 Volume: 9 Number: 3073
Today's topics:
Re: [Hash] Is the key always double-quoted? (Villy Kruse)
Re: Accurate IP return? <gellyfish@gellyfish.com>
Re: Accurate IP return? <gellyfish@gellyfish.com>
Re: Camel T-Shirt <sue@pennine.com>
Re: Camel T-Shirt <gellyfish@gellyfish.com>
Re: Camel T-Shirt <gellyfish@gellyfish.com>
Re: counter <gellyfish@gellyfish.com>
Re: counting leading spaces <michael.schlueter@philips.com>
Re: determining existence of object method <kenneth.lee@alfacomtech.com>
Re: Guestbook... Kinda? <none>
Inserting data with ADO from PerlScript <aahz@gol.com>
my cgi script <amcguigan@pinesoft.co.uk>
Re: my cgi script <webmaster@linkworm.com>
Re: neo: require doesn't work ninuzzo@my-deja.com
packing problem <donalo@credo.ie>
Passing variables to O/S command itsaw@my-deja.com
Re: Perl code editors? (Norbert Gruener)
Re: perl compiler ? <pinin@xchain.com>
Re: perl on OS390 <sb@muccpu1.muc.sdm.de>
Re: RE Question <xah@xahlee.org>
Re: regex mind bender (for me) (Andrew Johnson)
Re: xs: getting a char* into my Perl script <uackermann@orga.com>
Re: zen and the art of trolling [OT] <xah@xahlee.org>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 May 2000 07:57:08 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: [Hash] Is the key always double-quoted?
Message-Id: <slrn8i4k6i.ug8.vek@pharmnl.ohout.pharmapartners.nl>
On Tue, 16 May 2000 09:55:36 -0700, Tom Phoenix <rootbeer@redcat.com> wrote:
>On 16 May 2000, Villy Kruse wrote:
>
>> Would it be correct to interpret 01 as a octal number and not a
>> bareword that would be treated as a string between {} or before => ?
>
>Good question. Let's see:
>
> $ perl -MO=Deparse -e '$hash{01} = [ 01=>01 ];'
> -e syntax OK
> $hash{1} = [1, 1];
>
Or maybe try these example:
$ perl -we ' print 0123 . "\n";'
83
$ perl -we ' print 0123 , "\n";'
83
$ perl -we ' print 0123 => "\n";'
83
perl -we ' print x0123 , "\n";'
No comma allowed after filehandle at -e line 1.
$perl -we ' print x0123 => "\n";'
x0123
>> It looks like a number, therefore it is a number, or is this wrong?
>
>I'd have to say that, based upon the evidence, you're right. Of course,
>this is as it should be; only barewords (alphanumerics and underscores,
>not starting with a digit) should be quoted as hash keys or to the left of
>the big arrow.
>
Is that, or should it be, documented as proper Perl hebaviour? so no one
would think this is a bug or try to "fix" it.
Villy
------------------------------
Date: 16 May 2000 22:02:18 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Accurate IP return?
Message-Id: <8fsd0q$1ad$1@orpheus.gellyfish.com>
On Tue, 16 May 2000 20:01:06 +0100 [TNN]G.Bloke wrote:
>
> "Abigail" <abigail@foad.org> wrote in message
> news:slrn8i307a.p3i.abigail@ucan.foad.org...
>> ++ Is there a reliable method to return a users IP address?
>>
>> No. It's not even well defined. IP addresses aren't associated with
>> users - IP addresses are associated with interfaces.
> <SNIP>
>
> Now you are just being picky....can't anyone on this NG be sensible? Please
> grow up...
>
> I want to establish the IP address given by the ISP to a user when they log
> on. I WOULD LIKE to know if this can be done with PERL. Forget why I want to
> know....just give me a good answer.
>
> Perldoc states something like this for remote_host :
> "Returns either the hostname or the IP address of the system that requested
> the page."
>
> Unfortunatly this runs into problems when the page is fetched by the ISP's
> cache and not directly by the user.
>
Precisely. This is what people are trying to tell you. In the case of a
cache, proxy, firewall, network address translating router or any of the
other multitude of means by which the actual IP address of a host might
be concealed from you *there is absolutely no way you can determine the
real IP address* from an HTTP transaction in a CGI program. All you
get is $ENV{REMOTE_HOST} and if that is not the real IP then it is tough.
I would ask in comp.infosystems.www.authoring.cgi about what you really
want to do and maybe someone will come up with a solution that doesnt
depend upon the IP address.
/J\
--
If something is to hard to do, then it's not worth doing. You just stick
that guitar in the closet next to your shortwave radio, your karate
outfit and your unicycle and we'll go inside and watch TV.
--
fortune oscar homer
------------------------------
Date: Wed, 17 May 2000 09:25:36 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Accurate IP return?
Message-Id: <kAtU4.1615$Kc1.225205@news.dircon.co.uk>
On 16 May 2000 22:02:18 +0100, Jonathan Stowe Wrote:
>
> Precisely. This is what people are trying to tell you. In the case of a
> cache, proxy, firewall, network address translating router or any of the
> other multitude of means by which the actual IP address of a host might
> be concealed from you *there is absolutely no way you can determine the
> real IP address* from an HTTP transaction in a CGI program. All you
> get is $ENV{REMOTE_HOST} and if that is not the real IP then it is tough.
I think I could have put that better.
In the case of a cache, proxy, firewall, network address translating
router or any of the other multitude of means by which the actual IP
address of a host might be concealed from you the address that you get in
$ENV{REMOTE_HOST} *is* the address of the host that requested the page
as far as the HTTP server is concerned: that it might not be the IP of
the machine on which the browser which ultimately initiated the request
is running is immaterial as whatever goes on between that machine and
the device that is talking to your server is their private business -
for all you know it might not even have an IP address at all.
/J\
------------------------------
Date: 17 May 2000 01:13:06 -0700
From: Sue Spence <sue@pennine.com>
Subject: Re: Camel T-Shirt
Message-Id: <8ftkai$10lv@drn.newsguy.com>
In article <3921B4D1.447E83F6@attglobal.net>, Drew says...
>
>
>
>brian d foy wrote:
>
>> if you don't mind wearing a Perl Mongers shirt, we sell them through
>> www.geekstuff.com, Camel and all. to get an O'Reilly shirt, you
>> probably have to go to the Perl Conference. :)
>
>From Websters:
Which Websters? There are a number of them.
>
>monger \Mon"ger\, v. t. To deal in; to make merchandise of; to
>traffic in; -- used chiefly of discreditable traffic.
>
>=(
Not that the definition you posted above bothers me at all, but perhaps you
should consult a slightly more comprehensive dictionary. The negative
connotation of -monger is usually given as a secondary meaning. I live in a
rather quiet part of rural England, and in the nearest town an ironmongers
('hardware store') is still in business.
------------------------------
Date: Wed, 17 May 2000 09:09:00 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Camel T-Shirt
Message-Id: <MktU4.1614$Kc1.225205@news.dircon.co.uk>
On Tue, 16 May 2000 13:10:24 -0500, spurcell Wrote:
> Hello,
> I just signed up for some of Tom's classes and would like to get a Camel
> T-Shirt to take up to Boulder.
> I can't seem to find them anywhere, I went to O'Reilly and to Perl.com Does
> anyone out there know where to get one?
ORA sent me one a couple of weeks ago - I have no Idea why though - its kind
of sandy colour with 'Perl - The open source advantage' and camels.
/J\
------------------------------
Date: Wed, 17 May 2000 09:46:25 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Camel T-Shirt
Message-Id: <RTtU4.1618$Kc1.225205@news.dircon.co.uk>
On 17 May 2000 01:13:06 -0700, Sue Spence Wrote:
> In article <3921B4D1.447E83F6@attglobal.net>, Drew says...
>>
>>
>>
>>brian d foy wrote:
>>
>>> if you don't mind wearing a Perl Mongers shirt, we sell them through
>>> www.geekstuff.com, Camel and all. to get an O'Reilly shirt, you
>>> probably have to go to the Perl Conference. :)
>>
>>From Websters:
>
> Which Websters? There are a number of them.
>
>>
>>monger \Mon"ger\, v. t. To deal in; to make merchandise of; to
>>traffic in; -- used chiefly of discreditable traffic.
>>
>>=(
>
> Not that the definition you posted above bothers me at all, but perhaps you
> should consult a slightly more comprehensive dictionary. The negative
> connotation of -monger is usually given as a secondary meaning. I live in a
> rather quiet part of rural England, and in the nearest town an ironmongers
> ('hardware store') is still in business.
And 'fishmongers' everywhere. In some parts of London you might have still:
cos·ter·mon·ger (kstr-mnggr, -mng-)
n. Chiefly British
One who sells fruit, vegetables, fish, or other goods from a cart,
barrow, or stand in the streets.
/J\
------------------------------
Date: 16 May 2000 21:37:32 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: counter
Message-Id: <8fsbic$s8g$1@orpheus.gellyfish.com>
On 16 May 2000 00:46:40 GMT Abigail wrote:
> On Mon,
> 15 May 2000 22:05:36 +0200, Christian Winter <thepoet1@arcormail.de> wrote:
> ++
> ++ sleep 1 until (flock HIT, LOCK_EX);
>
> This is strange. Unless told otherwise, flock() will block untill
> it has the lock - or a failure occurs. The only time flock() will
> return false on a blocking call, is when the flock() fails because
> of an error condition; not because it has to wait for a lock. Blindly
> sleeping a second and retrying isn't good.
The description of flock(2) on my system doesnt indicate that should
return EAGAIN which would suggest that there is never any point in
retrying unless one used FLOCK_NB and got EWOULDBLOCK.
/J\
--
I want to share something with you: The three little sentences that will
get you through life. Number 1: Cover for me. Number 2: Oh, good idea,
Boss! Number 3: It was like that when I got here.
--
fortune oscar homer
------------------------------
Date: Wed, 17 May 2000 10:17:23 +0200
From: "Michael Schlueter" <michael.schlueter@philips.com>
Subject: Re: counting leading spaces
Message-Id: <8ftgis$dji$1@porthos.nl.uu.net>
Hi Brian,
You could try:
use strict;
my $t=" some text";
$t=~m/^(\s+)/; # puts leading whitespaces into $1, if any
my $l=$1; # $1 will go out of scope
my $indent = length $l; # what you requested
or shorter:
my $indent=length $1 if $t=~m/^(\s+)/;
I wonder if you need to distinguish " some text" from " \t \tsome text" ?
Both will have the same number of leading whitespaces.
Michael Schlueter
------------------------------
Date: Wed, 17 May 2000 16:29:56 +0800
From: Kenneth Lee <kenneth.lee@alfacomtech.com>
To: Uri Guttman <uri@sysarch.com>
Subject: Re: determining existence of object method
Message-Id: <39225884.24710162@alfacomtech.com>
Oops...seems like I should go through perltoot manpages once again.
Thanks.
Uri Guttman wrote:
>
> >>>>> "KL" == Kenneth Lee <kenneth.lee@alfacomtech.com> writes:
>
> KL> i want to test whether an object can invoke an arbitrary method.
> KL> defined() (or exists() in 5.6.0) only works for class methods, but not
> KL> object ones.
>
> use the can method which every package inherits.
>
> and comp.lang.perl is a dead group. tell your isp to drop it.
>
> 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: Wed, 17 May 2000 04:44:38 -0500
From: "Al" <none>
Subject: Re: Guestbook... Kinda?
Message-Id: <si4qkqe98ta53@corp.supernews.com>
Hi Kevin
If you would like to hire me to write the program for you please let me
know. If I was you I would cut out the e-mail part of your ideal. E-mails do
get lost, and for your idea to work, the form would have to be e-mail 2
times. One time to get the form and one time to OK the form. There are also
a host of other problems in doing it that way. The better way is to store
the filled in form on your site. When you OK the review, just click a button
and have it display on your site.
al@alaweb.com
www.web-site-builder.com
AL
Kevin Ostrowski wrote in message <#qHIGU2v$GA.230@cpmsnbbsa03>...
>Does anyone know of a script that does this?
>
>A user fills out a form, lets say it is a concert review...
>I need it to be saved as HTML, but not posted live as the content needs to
>be approved first.
>Ideally I would like to have the content emaild to me with a choice to
>approve or decline the message,
>it also needs to be able to have the look custumized...
>
>The reason this is so despertally needed is as of now hundred's of reviews
>need to be manually coppied and pasted into HTML files every day, and it's
>making me go insane!!!!!!!!! Please help
>
>
>Kevin Ostrowski
>
>
>
>
------------------------------
Date: Wed, 17 May 2000 09:14:47 GMT
From: "Chris Williams" <aahz@gol.com>
Subject: Inserting data with ADO from PerlScript
Message-Id: <bqtU4.1698$uL2.114946@nnrp.gol.com>
How can I insert data into a database with PerlScript? (I'm going to buy
the book, but figure I might as well find out as quick as I can.) And more
specifically how does one use now() and inserting dates, or reading those
back out in certain formats (ie. using "May" instead of "5"?)
------------------------------
Date: Wed, 17 May 2000 09:35:05 +0100
From: Andrew McGuigan <amcguigan@pinesoft.co.uk>
Subject: my cgi script
Message-Id: <392259B9.72051130@pinesoft.co.uk>
All is going well so far with my web Form. I just need the code that
collects the information on the Form and sends it to the server. That’s
all for the moment.
Thanks
Andrew
------------------------------
Date: Wed, 17 May 2000 02:55:54 -0700
From: "LinkWorm Software, Inc." <webmaster@linkworm.com>
Subject: Re: my cgi script
Message-Id: <39226CAA.C968A76C@linkworm.com>
Andrew McGuigan wrote:
>
> All is going well so far with my web Form. I just need the code that
> collects the information on the Form and sends it to the server. That’s
> all for the moment.
>
> Thanks
>
> Andrew
Huh? Try alt.perl.cgi.scripts.i.want.i.want.so.gimme
--
Regards,
Tim Greer: tech@linkworm.com | LinkWorm Software http://www.linkworm.com
Tel: 530 247-1749. Programming, CGI, Perl, C/C++, ASP, SQL, more. Design
Web Server & Network Administration, Security, Consulting, Installations
Configuration. Unix/Linux/FreeBSD & NT. Apache, IIS, TCP/IP, LAN/WAN/WWW
------------------------------
Date: Wed, 17 May 2000 07:28:56 GMT
From: ninuzzo@my-deja.com
Subject: Re: neo: require doesn't work
Message-Id: <8fthnc$bc1$1@nnrp1.deja.com>
this is an auto-replay :}
i discovered myself what was the problem:
every external files must have an instruction "1;" (or 2;, etc..)
outside of subroutines.
So i added 1; in read_input.pl outside my parse routine and it works.
this page has an explanation of many compiler errors:
http://www.helpdesk.vuurwerk.nl/docs/perl/pod/perldiag.html
bye, Antonio (alias "ninuzzo")
> I have a subroutine read_input to parse out CGI query strings.
> This returns an associative array which contains the pairs
(name,value).
> It is fine, but every time i have to paste its code into the script.
>
> To avoid this i decided to put read_input in a separate file
> (read_input.pl), and i added this line in a script:
>
> require 'read_input.pl';
>
> but it doesn't work, i get this error:
>
> read-input.pl did not return a true value at ./test.pl line 3.
>
> thanx, Ninuzzo
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 17 May 2000 09:53:07 +0100
From: "O'Mahony, Donal" <donalo@credo.ie>
Subject: packing problem
Message-Id: <8427475C51D5D211A0DC00062B000D8F1BF9E6@tampa.credo.ie>
I am having a problem with sending a message from a perl script via a
fifo to another process. The other process is written in C and reads the
message in to the following structure :
typedef struct
{
int RequestCode;
char RTDir[PATH_MAX + 1];
char UserId[USER_ID_LEN + 1];
char BatchNo[BATCH_NO_LEN + 1];
int SeqNo;
int NumBatches;
pid_t Pid;
time_t TimeStamp;
}
PATH_MAX is 1024
USER_ID_LEN is 8
BATCH_NO_LEN is 7
pid_t and time_t are effectively longs.
My perl script packs the message as follows :
$ReqCode = 1;
$SeqNo = 0;
$NumBatches = 1;
$F7Pid = 0;
$FRTPmsg = pack "ia1024xa8xa7xiill", $ReqCode, $RTDir, $SiteID,
$BatchNo,
$SeqNo, $NumBatches, $F7Pid, $TimeStamp, "\n";
The C program reads it ok except that $NumBatches is read as 65536. If I
change $SeqNo to 1 it is also read as 65536.
The $ReqCode is read ok as 1.
Any idea why this is ?
For legacy reasons the C structure cannot be changed. The C program that
reads it and the perl script can be changed.
Thanks,
Donal O'Mahony
------------------------------
Date: Wed, 17 May 2000 08:12:25 GMT
From: itsaw@my-deja.com
Subject: Passing variables to O/S command
Message-Id: <8ftk8v$eai$1@nnrp1.deja.com>
I have problem regarding backticks . Part of the code that i wrote is
here :
$var = '111111';
`useradd -u 500 -d /home/user -p $var username`;
The problem is i want to pass the value's of the $var into the command
, but this code that i wrote doesn't seems to work . The reason i am
doing this is that $var is not a constant and it changes according to
user's input . So i have no choice but to insert a variable into the
command eventhough putting the string directly into the command will
solve the problem . Can anyone please advice on how to work around this
problem .
Thanks in advance .
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 May 2000 09:13:39 GMT
From: nog@Mpa-Garching.MPG.DE (Norbert Gruener)
Subject: Re: Perl code editors?
Message-Id: <8ftns3$2k88$1@kiosk.rzg.mpg.de>
In article <8fsgli$6ks$1@nnrp1.deja.com>,
Daniel Pfeiffer <occitan@esperanto.org> writes:
> My choice is Emacs, which has two major modes for Perl. The standard
> Perl mode is helpful, but fails miserably on Perl oddities like $#array
> doesn't start a comment and m!'! or s'a'b' doesn't start a string, but
> q( does. The alternative CPerl mode has an almost excellent grip on
> these though! That gives you neat syntactical highlighting with various
> text attributes and correct indentation.
>
> My iPerl minor mode mode for editing bits of Perl dispersed in any
> document (see signature below) gives you the choice of these two modes.
I am interested in your iPerl minor mode. But the give URL is not
working (anymore) :-(
All I get is the the following error message:
IMPORTANT NOTICE!
All the registered redirects are no longer on this server. This is the reason we
had to re-launch our redirect service. We are sorry about this situation and
hope you will re-register your free beamto-redirect again with us.
Any help would be appreciated.
Best Regards,
Norbert Gruener
--
+------------------------------------------------------------------+
| Norbert E. Gruener E-mail: nog@MPA-Garching.MPG.DE |
| MPI fuer Astrophysik PGP encrypted mail preferred |
| WWW: http://www.MPA-Garching.MPG.DE/~nog/ |
| PGPprint(RSA): 66 64 C0 D0 6F 1A 16 02 C2 C6 37 83 3A 5F 88 9B |
| PGPprint(DH): EBBF 02ED 1B91 39C3 5FB9 4D2F 9478 E224 334C 34CD |
+------------------------------------------------------------------+
------------------------------
Date: Wed, 17 May 2000 10:21:24 +0300
From: pinin <pinin@xchain.com>
Subject: Re: perl compiler ?
Message-Id: <39224873.2B37CC32@xchain.com>
avishay ashkenazi wrote:
> Does anyone knows where can I get a free stable PERL compiler and it's
> man pages ?
Hi Avishay,
Did you try 'perlcc'?
Pinkhas
------------------------------
Date: 17 May 2000 07:24:52 GMT
From: Steffen Beyer <sb@muccpu1.muc.sdm.de>
Subject: Re: perl on OS390
Message-Id: <8fthg4$okn$1@solti3.sdm.de>
In article <Pine.GSO.4.10.10005160658290.25459-100000@user2.teleport.com>, Tom Phoenix <rootbeer@redcat.com> wrote:
> On 16 May 2000, Steffen Beyer corrected me:
>> >> Does anybody know what is the last supported version of perl for OS390
>> >> platform ?
>> >> If it's not 5.6.0, it should be. :-)
>>
>> Tom, you should know better!
>> Perl 5.6 is deliberately incompatible with any EBCDIC ports
>> due to support for Unicode. Both strands of development are supposed
>> to be re-unified in a later release.
> I hadn't heard that. Thanks for the info!
You didn't read "perldoc perldelta", did you? :-)
To quote:
OS390 (OpenEdition MVS)
Support for this EBCDIC platform has not been renewed in
this release. There are difficulties in reconciling
Perl's standardization on UTF-8 as its internal represen-
tation for characters with the EBCDIC character set,
because the two are incompatible.
It is unclear whether future versions will renew support
for this platform, but the possibility exists.
Best regards,
--
Steffen Beyer <sb@engelschall.com>
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: Wed, 17 May 2000 02:41:22 -0700
From: Xah <xah@xahlee.org>
Subject: Re: RE Question
Message-Id: <B547B752.9D0C%xah@xahlee.org>
Uri Guttman,
Uri Guttman <uri@sysarch.com> wrote
> this is fancy coding?
>
> split( /,(?! )/, $line ) ;
No, it's mumble jumble very much preferred by fancily-clad yokel like
yourself. Godzilla is just too diffident to point that out.
Godzilla's suggestion:
> Replace comma/space with a special character.
> Perform a split.
> Replace the comma/space.
for the question:
>I want to parse lines like this:
>"Some text with comma, bad bad",33,44,55
>by commas, but not by commas followed by a space.
is actually quite elegant and effective.
The reason that Perl folks of beady eyes cannot see it, is because Perl/unix
are habitually addicted to backwater 7-bits ISO 646:1991 character set. That
regex obfuscation tickles them at heart too. Clarity would be the bane of
Perl.
Uri Guttman:
> too complex for you, eh purlmoron? try learning some actual perl regex
> stuff for a change.
"Wipe your gloss with knowledge" -- James Joyce
and try to see beyond your perl-perl-land. -- Xah
PS Godzilla's solution does not necessarily require an 8 bit character.
About the half-assed Unicode support in 5.6, it's like XML forced shit down
their throat: swallow or die!
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
> From: Uri Guttman <uri@sysarch.com>
> Organization: Sysarch, Inc.
> Newsgroups: comp.lang.perl.misc
> Date: Tue, 02 May 2000 18:06:28 GMT
> Subject: Re: RE Question
------------------------------
Date: Wed, 17 May 2000 07:12:27 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: regex mind bender (for me)
Message-Id: <vDrU4.14029$95.197239@news1.rdc1.mb.home.com>
In article <8ft1dm$137i$1@onlink3.onlink.net>,
Jonah <nomail@nomail.com> wrote:
> This seems simple enough but I can't
> solve it.
>
> I'm getting a value from a $q->textfield
> and I need to check if it contains *only* spaces.
>
> not empty, but if it has 1 or more spaces and nothing else in it.
>
> my $var = $q->param('mytextfield');
> print "yay" if $var =~ /\s+/;
anchor your pattern to the start and end of the string:
print "yay" if $var =~ /^\s+$/;
or, if you really mean space characters and not just any
whitespace (tabs, newlines,...)
print "yay" if $var =~ /^ +\z/;
or use a negative character class:
print "yay" unless $var =~ /[^ ]/;
please see: perldoc perlre
regards,
andrew
--
Andrew L. Johnson http://members.home.net/andrew-johnson/epwp.html
Some people, when confronted with a problem, think 'I know,
I'll use regular expressions.' Now they have two problems.
-- Jamie Zawinski, on comp.lang.emacs
------------------------------
Date: Wed, 17 May 2000 09:34:12 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: xs: getting a char* into my Perl script
Message-Id: <39224B74.A3E16EB2@orga.com>
Ilya Zakharevich wrote:
Thanks for replying :-)
> Just use
>
> char *
> get_name()
>
> That's all. If you actually need to put 1 in front, make a Perl wrapper.
This is what I tried first, but it did not work. It gives me back
something that looks like an adress to me (0xd0b81208). I did look in
the typemap-file which has a line as
char * T_PV
I thought this should tell the xs-compiler how to handle it right.
> But here are several points:
>
> sizeof(char[30]) // Just do not do this
> name = malloc(???) immediately followed by name = ??? // Likewise
>
> I do not think you want to program XS with so much knowledge of C.
You are right. I do not *want* to, I have to. I have to test some
functions in a C-Library and tried to get a bit familiar with xs, which
caused more trouble than I could think of.
> But anyway, here is the thing I would try:
>
> SV *
> get_name()
> PPCODE:
> char *name = get_name();
> EXTEND(sp,2);
> PUSHs(&Perl_sv_yes);
> PUSHs(sv_2mortal(newSVpv(name, 0)));
>
> (with an optimization to push 1).
This one did not work for me either. First, I had to replace
'&Perl_sv_yes' with 'sv_2mortal(newSViv(1))' (forgot to include
something?) because he did not know that function and after that it gave
me something similar as the code above (just longer).
What works is, if I hard-code a string instead of the name-variable in
the PUSHs statement
e.g. PUSHs(sv_2mortal(newSVpv("abc", 0)));
so I tried to the string where 'name' is pointing at to 'char []' but
screwed up with that because of my unability of writing any code in C.
:-(
I do not know if this gives any more hints, what my problem is (besides
unability to write C-code :-) ).
Bye, Ulrich
--
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925
mailto:uackermann@orga.com
------------------------------
Date: Wed, 17 May 2000 01:07:23 -0700
From: Xah <xah@xahlee.org>
Subject: Re: zen and the art of trolling [OT]
Message-Id: <B547A14B.9CF0%xah@xahlee.org>
Dear Paul:
This is a technical newsgroup.
Please shove your asinine moralization back in your ass.
I get so tired of this fucking class of shit droppers who don't spent time
to think about the nature of things and consequences but bloat their
righteous ego and promptly rush forward to demonstrate their stupidity in
sincereness as if the world care about their contribution to noise.
Tell your class of Perl cronies to shut their fucking beer-holes, and you
will immediately save 80% of the most worthless posts in this group.
Fly over to comp.lang.perl.moderated, see if they want you there.
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
> From: Paul Eckert <peckert@epicrealm.com>
> Organization: EpicRealm
> Newsgroups: comp.lang.perl.misc
> Date: Tue, 16 May 2000 11:32:07 GMT
> Subject: Re: zen and the art of trolling [OT]
>
> Dear Godzilla:
> This is a technical newsgroup.
> Please confine yourself to technical subjects.
> --
> Paul Eckert
> Sr. Software Engineer
> Epicrealm Inc.
> 1651 N. Glenville Dr., Suite 212
> Richardson, TX 75081
> (972) 479-0135 x300
> peckert@epicrealm.com
------------------------------
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 3073
**************************************