[9553] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3147 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 14 00:07:41 1998

Date: Mon, 13 Jul 98 21:00:35 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 13 Jul 1998     Volume: 8 Number: 3147

Today's topics:
    Re: Dynamic HTML document in new browser window? (brian d foy)
    Re: First meeting of Dallas.pm (brian d foy)
    Re: First meeting of Dallas.pm (Abigail)
        Help with tutorial please... <chris@webfarms.com>
    Re: how to tell execution vs require (M.J.T. Guy)
        HTML <SELECT MULTIPLE> var to Perl script? <dbouska@mindspring.com>
    Re: HTML <SELECT MULTIPLE> var to Perl script? (brian d foy)
    Re: I am an "antispam spammer"? (John Oliver)
    Re: Merging files <rick.delaney@shaw.wave.ca>
    Re: Parsing Perl (Stephen McCamant)
    Re: Perl debugging in emacs - possible? <mpersico@erols.com>
    Re: perl IDE and compiler <mpersico@erols.com>
    Re: Perl OO for dummies [Was: Oh man, DO I love Perl !  <mpersico@erols.com>
    Re: Perl Question (Kelly Hirano)
    Re: Perl Question (brian d foy)
    Re: Reading Directories w/ Perl <maierc@chesco.com>
    Re: Readonly arrays (brian d foy)
    Re: Readonly arrays (brian d foy)
    Re: Recommend me Perl! <tchrist@mox.perl.com>
    Re: Recommend me Perl! (Ronald J Kimball)
    Re: RegExps: Check if string consists of EXACTLY 3 digi <bburlingnews@iname.com>
    Re: RegExps: Check if string consists of EXACTLY 3 digi (Larry Rosler)
    Re: Regular expression matech for ( non-fixed number of (Damian Conway)
    Re: script opening another script (brian d foy)
        unpack <leungwo@ms.com>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 13 Jul 1998 21:28:28 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Dynamic HTML document in new browser window?
Message-Id: <comdog-ya02408000R1307982128280001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35AA7721.D0583168@ikt.de>, Sabine Cremer <sabine@ikt.de> posted:

>I wrote a simple perl application to get an answer from a database.
>Because it is called from a frame too small for the output, I want to
>put the dynamically generated data into a new browser window. How to do
>it??

See the CGI Meta FAQ's section on Working With Frames.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


------------------------------

Date: Mon, 13 Jul 1998 21:23:49 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: First meeting of Dallas.pm
Message-Id: <comdog-ya02408000R1307982123490001@news.panix.com>
Keywords: from just another new york perl hacker

In article <1dc4hze.992d8n1m7o7u4N@bay2-93.quincy.ziplink.net>, rjk@coos.dartmouth.edu (Ronald J Kimball) posted:

>Abigail <abigail@fnx.com> wrote:
>
>> I've tried many times to validate myself after registering on the
>> Perl Mongers webpage. Even after cutting & pasting the password
>> from the emails I get back, it keeps rejecting them as invalid.
>
>I just tried it, and it worked for me.  Are you sure you're entering the
>same email address you used to register?

it's not working for abigail because those entries were deleted.  
abigail should register again if need be (or email me to discuss it
in further detail).

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>
bastard database operator


------------------------------

Date: 14 Jul 1998 03:00:29 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: First meeting of Dallas.pm
Message-Id: <6oehkd$m1i$1@client3.news.psi.net>

brian d foy (comdog@computerdog.com) wrote on MDCCLXXVIII September
MCMXCIII in <URL: news:comdog-ya02408000R1307982123490001@news.panix.com>:
++ In article <1dc4hze.992d8n1m7o7u4N@bay2-93.quincy.ziplink.net>, rjk@coos.dartmouth.edu (Ronald J Kimball) posted:
++ 
++ >Abigail <abigail@fnx.com> wrote:
++ >
++ >> I've tried many times to validate myself after registering on the
++ >> Perl Mongers webpage. Even after cutting & pasting the password
++ >> from the emails I get back, it keeps rejecting them as invalid.
++ >
++ >I just tried it, and it worked for me.  Are you sure you're entering the
++ >same email address you used to register?
++ 
++ it's not working for abigail because those entries were deleted.  
++ abigail should register again if need be (or email me to discuss it
++ in further detail).
++ 


Well, I get an "internal server error" this time - not even
a page complaining about an invalid password.

And the intial email still doesn't list the State.



Oh well. Enough is enough.


Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


------------------------------

Date: Tue, 14 Jul 1998 03:26:16 GMT
From: Christopher Moll <chris@webfarms.com>
Subject: Help with tutorial please...
Message-Id: <35AAB4E8.C590B259@webfarms.com>


--------------11B07B2CF93116553C124237
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Will some kind soul (or rotten bastard will even do ) please show me the
solution to the exercise on this page?   Perl tutorial: File handling
thank you in advance.

--------------11B07B2CF93116553C124237
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Will some kind soul (or rotten bastard will even do ) please show me the
solution to the exercise on this page?&nbsp;&nbsp; <A HREF="http://agora.leeds.ac.uk/Perl/filehandling.html">Perl
tutorial: File handling</A>&nbsp; thank you in advance.</HTML>

--------------11B07B2CF93116553C124237--



------------------------------

Date: 14 Jul 1998 01:00:22 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: how to tell execution vs require
Message-Id: <6oeaj6$115$1@pegasus.csx.cam.ac.uk>

Tom Christiansen  <tchrist@mox.perl.com> wrote:
>In comp.lang.perl.misc, "Race Zyzy" <rsharpe@ncsa.uiuc.edu> writes:
>:I am writing a perl file that I want to be able to be executed
>:standalone as say:
>:    perlfoo.pl
>:or included into another file to use a given fcn say:
>:    require "perlfoo.pl";
>:    ...
>:    &foosub();
>
>Are you sure you want to do that?  Why would you have a library
>file that doubled as a program?  Make a proper module in PerlFoo.pm,
>and then make a program perlfoo that uses it.

While Tom's advice is good, if you *really* want to do this, look
at the "splain" script and the diagnostics.pm module in the standard
Perl distribution.   You'll find they are the same, and illustrate
the technique you want.

Oh, and they are actually written by Tom Christiansen, who clearly
doesn't always follow his own advice.    :-)


Mike Guy


------------------------------

Date: Mon, 13 Jul 1998 20:44:25 -0500
From: Diane Bouska <dbouska@mindspring.com>
Subject: HTML <SELECT MULTIPLE> var to Perl script?
Message-Id: <35AAB7F9.43C4@mindspring.com>

Hi, folks,
Can anybody set me straight on how to get multiple values from an HTML
form field (a list box with the MULTIPLE attribute set on) into a Perl
cgi script?  I'm only getting one of the values selected in the list
box.  I confess I'm new to Perl and haven't had time to really learn
it--I'm just modifying a script that was already written.  Any help will
be greatly appreciated.

The HTML:

  Please select the 3-point critters you identified. <br>
  <SELECT NAME="3pointers" MULTIPLE>
  <OPTION>Stonefly nymph
  <OPTION>Caddisfly larva
  <OPTION>Water Penny
  <OPTION>Riffle Beetle
  <OPTION>Mayfly nymph
  <OPTION>Gilled Snail
  <OPTION>Dobsonfly (Hellgrammite) larva
</SELECT>

The Perl:

   if ($FORM{'3pointers'}) {
      $3pointers = "$FORM{'3pointers'}";
   }

and later:

   print NEWFILE "<b>3 point critters:</b> $3pointers\n";
   print NEWFILE "<br><br>\n";

Thanks,
Diane Bouska


------------------------------

Date: Mon, 13 Jul 1998 22:04:52 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HTML <SELECT MULTIPLE> var to Perl script?
Message-Id: <comdog-ya02408000R1307982204520001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35AAB7F9.43C4@mindspring.com>, Diane Bouska <dbouska@mindspring.com> posted:

>Can anybody set me straight on how to get multiple values from an HTML
>form field (a list box with the MULTIPLE attribute set on) into a Perl
>cgi script?  I'm only getting one of the values selected in the list
>box.  I confess I'm new to Perl and haven't had time to really learn
>it--I'm just modifying a script that was already written.  Any help will
>be greatly appreciated.


sounds like the classic 'roll-your-own' bug.  try something like:

   use CGI;

   my $input = new CGI;

   @multiple_things = $input->param('multiple_thing_name');

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


------------------------------

Date: Tue, 14 Jul 1998 02:01:40 GMT
From: do.not.reply@this.address (John Oliver)
Subject: Re: I am an "antispam spammer"?
Message-Id: <35aabbb2.879906728@news.escnd1.sdca.home.com>

On Mon, 13 Jul 1998 15:37:01 -0400, jordyn@bestweb.net (Jordyn A.
Buchanan) wrote:

>Well, perhaps the reponse isn't material that's really widely useful, so
>it's sent off as an e-mail in order to avoid cluttering the newsgroup.  If
>you don't actually *check* the e-mail address before you send it off, you
>end up with a bounce.  At this point, the person trying to help out
>either:
>
>   a) has wasted his or her effort in composing a reply;
>or
>   b) has to take additional effort to post the reply to the newsgroup
>      or to de-munge
>
>Either way, life becomes more complicated for the person attempting to be
>helpful.
>
>I'm not saying that address-munging doesn't have its place; it's never
>bothered me particularly much.  There are certainly situations in which it
>costs a respondant time and effort, though.

I can see that... heck, I've had a carefully-crafted email reply
bounce off a munged address I didn't notice once or twice.  But
instead of becoming irate at the guy for daring to try to prevent
becoming a spam victim, I felt a little foolish for not noticing and
overcoming the block.  Perhaps this is why some become so incensed by
munging... they got caught, and lashed out.

-- 
If you want to reply to me, do it in the newsgroup... It's 
been too long since I've received anything other than spam 
in my mailbox from posting my address in the newsgroups.


------------------------------

Date: Tue, 14 Jul 1998 01:21:03 GMT
From: Rick Delaney <rick.delaney@shaw.wave.ca>
Subject: Re: Merging files
Message-Id: <35AAB3B6.53F18FB3@shaw.wave.ca>

Bryan Camp wrote:
> 
> Hello,
> 
> I have a simple question about merging data between two files.
> Here are sample lines of data from the two files:
> 
> file1:
> lan_ic:74hc175 520-005 NA SMT
> 
> file2:
> AM27256-2, ADVANCED_MICRO, 520-004
> AM27256-3, ADVANCED_MICRO, 520-005
> 
[matching on the obvious, want:]
> 
> lan_ic:74hc175 520-005 NA SMT ADVANCED_MICRO
> 
> I'm not having any trouble with the comparison part,
> as I've used a couple of "split" statements, but I'm
> having problems appending the 2nd column on to the end of the current
> line, and not to the end of the file.  Can anyone point me in
> the right direction?  Thank you very much.
> 

Next time, post the part of the code that you _are_ having trouble with.
Oh well, here's the whole thing.

#!/usr/local/bin/perl

open(FILE1, 'file1') or die "Can't open file1:  $!\n";
open(FILE2, 'file2') or die "Can't open file2:  $!\n";

while(<FILE1>) {
    chomp;
    ($key) = (split ' ')[1];
    $match{$key} = $_;
}
while(<FILE2>) {
    chomp;# this is important or you will be matching 
          #   something like "520-004" with "520-004\n";
    (undef, $name, $key) = split / *, */;
    print "$match{$key} $name\n" if defined $match{$key};
}

I'm assuming unique keys.
HTH.

-- 
Rick Delaney
rick.delaney@shaw.wave.ca


------------------------------

Date: 14 Jul 1998 03:43:55 GMT
From: stephen@alias-2.pr.mcs.net (Stephen McCamant)
Subject: Re: Parsing Perl
Message-Id: <slrn6qlkuc.d16.stephen@alias-2.pr.mcs.net>

On 13 Jul 1998 22:04:18 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Tom Christiansen 
><tchrist@mox.perl.com>],
>who wrote in article <6odqld$3vu$1@csnews.cs.colorado.edu>:
>> In comp.lang.perl.misc, alias@mcs.com writes:
>>:Yes. Specifically, see the B::Deparse module in recent development versions
>>:(originally by Malcolm, significantly enhanced by me). It generates perl
>>:code, marks up the beginnings and ends of blocks, and uses this to do
>>:rudimentary indentation. Its current idea of `beauty' is pretty simplistic,
>>:but it could be extended to handle lining up parts of expressions, syntax
>>:highlighting, etc.
>> 
>> Does it lose the comments and pods?
>
>It loses almost everything.  It is done after constant folding, so
>some functions may have been already called.

Another important thing lost is BEGIN blocks (and therefore use statements).
If there's really any desire for this, though (or if we want to enforce
decompilability with other backends), it probably wouldn't be too hard get
perl to attach comments and PODs onto the appropriate COPs, and save the
compiled form of BEGIN blocks somewhere. But not for 5.005.

-- 
____________________________________________________________
Stephen McCamant ======== alias@mcs.com (finger for PGP key)


------------------------------

Date: Mon, 13 Jul 1998 22:35:36 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: Jorge Kinoshita <jkinoshi@pcs.usp.br>
Subject: Re: Perl debugging in emacs - possible?
Message-Id: <35AAC3F8.BD3B5D41@erols.com>

I use xemacs 20.4, but the idea should be the same. Try

M-x perldb

Give it the name of the perl script and all the args the script
requires.

Enjoy.


------------------------------

Date: Mon, 13 Jul 1998 22:36:40 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: stlam@yahoo.com
Subject: Re: perl IDE and compiler
Message-Id: <35AAC438.1FE3A2E7@erols.com>

stlam@yahoo.com wrote:

> Is there any Perl compiler for win32/unix?

Xemacs 

:-)


------------------------------

Date: Mon, 13 Jul 1998 22:39:28 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
To: abigail@fnx.com
Subject: Re: Perl OO for dummies [Was: Oh man, DO I love Perl ! (References to things that go out of scope)]
Message-Id: <35AAC4E0.8C9D2CAF@erols.com>

> ++ 5: Again, by convention to, most likely, appease the C++ gods, the
> ++ creation of a new object instance is peformed by putting a function
> ++ 'new' in the package:
> ++
> ++      package MYPACK;
> ++
> ++      sub new {
> ++              my $self = {
> ++                              'foo' => 'default',
> ++                              'bar' => 'default'
> ++                              };
> ++
> ++              bless $self, MYPACK;
> ++              return $self;
> ++      }
> 
> That's bad. Never hard code the package name as second argument
> for bless. Otherwise, you'll be screwed if you subclass the package.
> 
>     sub new {
>         my $proto   =  shift;                 # First argument of new ().
>         my $class   =  ref $proto || $proto;  # Deal with $obj -> new ().
>         my $self    =  { whatever };
>         bless $self => $class;
>     }

Yes, you are right. I was trying to be simple for example's sake, but
that's no excuse to be sloppy. Sorry.
 
> ++ and the user does
> ++
> ++      my $obj = new MYPACK;
> ++      my $obj2 = MYPACK::new();
> 
> Don't do the latter! Because then the package name will not be the
> first argument. Use:
> 
>     my $obj = MYPACK -> new;   # Better.
>     my $obj = new MYPACK;      # Be careful here.
> 
Whoops. You are correct as usual, King Friday.


------------------------------

Date: 13 Jul 1998 18:20:48 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: Perl Question
Message-Id: <6oebpg$i1s@Xenon.Stanford.EDU>

In article <1998071400252800.UAA08644@ladder03.news.aol.com>,
ShearerUK <sheareruk@aol.com> wrote:
>I need help with something.
>
>I am trying to include the statement
><!--#exec cgi="counter.cgi-->
>on a dynamically produced html page
>
>If I use the statement print "<!--#exec cgi="counter.cgi-->"\n;
>where do I have to put the "\" to make it realize it is an ssi call and not a
>comment?

assuming your ssi call is a typo since you're missing a closing ".

well, for one thing, the \n has to be in double-quotes ("\n"). you can get
around any backslashing by using qq() which is the same as double-quotes.

print qq(<!--#exec cgi="counter.cgi"-->\n);
or
print '<!--#exec cgi="counter.cgi"-->', "\n");
or, to answer your question
print "<!--#exec cgi=\"counter.cgi\"-->\n";

i would suggest that you rtfm. `perldoc perlop` see: quote and quote like
characters.

 ... man, i'm starting to get all old and crusty with these questions now.
8^)
-- 
Kelly William Hirano	                    Stanford Athletics:
hirano@cs.stanford.edu	                 http://www.gostanford.com/
hirano@alumni.stanford.org      (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20


------------------------------

Date: Mon, 13 Jul 1998 22:30:23 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl Question
Message-Id: <comdog-ya02408000R1307982230230001@news.panix.com>
Keywords: from just another new york perl hacker

In article <1998071400252800.UAA08644@ladder03.news.aol.com>, sheareruk@aol.com (ShearerUK) posted:

>I need help with something.
>
>I am trying to include the statement
><!--#exec cgi="counter.cgi-->
>on a dynamically produced html page
>
>If I use the statement print "<!--#exec cgi="counter.cgi-->"\n;
>where do I have to put the "\" to make it realize it is an ssi call and not a
>comment?

i'm not sure what your question is:

   * if you want to know how to print that, you can use one of the
   generalized quoting mechanisms so you don't have to escape the
   " characters and such:

      print qq|<!--#exec cgi="counter.cgi"-->\n|;


   * if you are trying to get the server to parse your CGI output,
   you'll have to look at your server documentation.  i don't think
   Apache-like servers do that yet, although i've heard tell of
   other servers that do.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


------------------------------

Date: Tue, 14 Jul 1998 01:47:29 GMT
From: Charles Maier <maierc@chesco.com>
Subject: Re: Reading Directories w/ Perl
Message-Id: <35A9A970.1DFC@chesco.com>

> I just want to be able to feed it a directory name and get the names of the
> files it contains...that's all.  Any help would be appreciated.  Thanks!!
> 
> Marius
> 
>

I think .. If all you want is the FILENAMES.. GLOB() is a simpler
function. 

@fnames = glob("/someplace/i/need/to/see/*.*");

The @fnames array will contain the filenames... but not BARE. (They will
have the path attached)

-- 
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com
(610) 943-2726


------------------------------

Date: Mon, 13 Jul 1998 22:27:13 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Readonly arrays
Message-Id: <comdog-ya02408000R1307982227130001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35AA9AE0.8E90031F@us.oracle.com>, Allen Choy <achoy@us.oracle.com> posted:

>The perlmod page says that one can create scalar constants by doing
>something like this:
>
>*foo = \bar;
>
>Is there an equivalent for arrays?
>
>I've tried things like
>
>*foo = \qw(a b c);
>
>and
>
>*foo = \('a', 'b', 'c');

but those things aren't arrays!  maybe you want to use the constant
module:

   #!/usr/bin/perl

   use constant ARRAY_NAME => qw(just another new york perl hacker);

   print +(ARRAY_NAME)[2,3];

   __END__


HTH :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


------------------------------

Date: Mon, 13 Jul 1998 23:19:51 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Readonly arrays
Message-Id: <comdog-ya02408000R1307982319510001@news.panix.com>
Keywords: from just another new york perl hacker

In article <35AAADC4.85D19663@shaw.wave.ca>, Rick Delaney <rick.delaney@shaw.wave.ca> posted:

>Allen Choy wrote:
>> 
>> The perlmod page says that one can create scalar constants by doing
>> something like this:
>> 
>> *foo = \bar;

>> Is there an equivalent for arrays?


>Sorry, you're out of luck.

not out of look.  see the constant module.

HTH :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


------------------------------

Date: 14 Jul 1998 01:58:43 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Recommend me Perl!
Message-Id: <6oee0j$lv5$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
:Tom Christiansen <tchrist@mox.perl.com> wrote:
:> _Programming Perl_ (Wall, Christiansen, and Schwartz)
:
:You forgot to mention Stephen Potter.

I did?

--tom
-- 
 Timesharing: the use of several people by the computer


------------------------------

Date: Mon, 13 Jul 1998 22:28:12 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Recommend me Perl!
Message-Id: <1dc4mcf.afycj811efzr1N@bay2-93.quincy.ziplink.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:

>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, rjk@coos.dartmouth.edu (Ronald J Kimball) writes:
> :Tom Christiansen <tchrist@mox.perl.com> wrote:
> :> _Programming Perl_ (Wall, Christiansen, and Schwartz)
> :
> :You forgot to mention Stephen Potter.
> 
> I did?

I believe so.

Programming Perl, Second Edition
by Larry Wall, Tom Christiansen, and Randal L. Schwartz, with Stephen
Potter

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Mon, 13 Jul 1998 18:54:48 -0700
From: "Bryan Burlingame" <bburlingnews@iname.com>
Subject: Re: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <6oedq9$9je$1@news.artemis.com>

try if ($ENV{'QUERY_STRING'} =~ /^[0-9]{3}$/)

this will only match a line with exactly three characters on it

In your example code, you are escaping the {}.  This has the effect of
looking for the curly brackets, i.e.  QUERY_STRING = "9{3}" will match,
while QUERY_STRING = "999" will not.

--Bryan


Karsten wrote in message <35AACA77.D9C@alpha.futurenet.co.za>...
>Hi!
>
>I am writing a CGI script which accepts input via QUERY_STRING.
>However, the input is only valid if it consists of EXACTLY 3 DIGITS!  No
>more , no less, no other characters in front, after or in between the
>digits.  Ive tried things such as:
>
>if ($ENV{'QUERY_STRING'} =~ /[0-9]\{3\}/)
>{
>  print "String is valid";
>}
>else
>{
>  print "Invalid input";
>}
>
>which should look for 3 digits as far as i can tell.  But it doesnt
>work.  Ive tried other variations, none of which work (i dont remember
>them right now).  Im clearly missing some important aspect of reg exps.
>
>Please could someone help me get this regexp right?
>Thanks in advance!
>
>Karsten
>karsten@alpha.futurenet.co.za




------------------------------

Date: Mon, 13 Jul 1998 20:27:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <MPG.1014700a29e2719e989737@nntp.hpl.hp.com>

In article <6oedq9$9je$1@news.artemis.com> on Mon, 13 Jul 1998 18:54:48 -
0700, Bryan Burlingame <bburlingnews@iname.com> says...
> try if ($ENV{'QUERY_STRING'} =~ /^[0-9]{3}$/)
> 
> this will only match a line with exactly three characters on it

No.  It will also match a string with three digits followed by a new-line 
character, which the original request ruled out (notice the subject of 
the thread).  See brian d foy's submission for the correct regex.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: 14 Jul 1998 02:31:20 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Regular expression matech for ( non-fixed number of () pairs )?
Message-Id: <6oefto$4mr$1@towncrier.cc.monash.edu.au>

mwang@tech.cicg.ml.com (Michael Wang) writes:

>I want to take out 
>SID_LIST_listener_name=( ...
>                       )
>from the following text. Can perl/shell/sed/awk do this? Or I need to
>resort to lex/yacc? Thanks.

The various "extract_..." subs in Text::Balanced will probably handle this.
Otherwise you could try building a parser with Parse::RecDescent.

Both are available from the CPAN or from
http://www.csse.monash.edu.au/~damian/CPAN

ObDisclaimer: I'm the author of both these packages.

Damian
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 name: Damian Conway                           addr: School of Computer Science
email: damian@csse.monash.edu.au                        and Software Engineering
  web: http://www.cs.monash.edu.au/~damian           Monash University
  fax: +61-3-9905-5146                               Clayton 3168, AUSTRALIA


------------------------------

Date: Mon, 13 Jul 1998 21:30:01 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: script opening another script
Message-Id: <comdog-ya02408000R1307982130010001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6odrt1$r88$1@nnrp1.dejanews.com>, faganb@my-dejanews.com posted:

>I have the following two scripts. The first prints, but the second never
>outputs anything. No error message is printed. What am I doing wrong?


>#!bin/perl
>print "This is a test\n";
>open (SUBPROC, "/u/tct/SuperScripts/hi.pl |") || die "Can't open subproc";

while(<SUBPROC>){

>print $_;

   }

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers Travel Deals! <URL:http://www.pm.org/travel.html>


------------------------------

Date: Tue, 14 Jul 1998 10:21:12 +0800
From: Shan-Leung Woo <leungwo@ms.com>
Subject: unpack
Message-Id: <35AAC098.FB70E1C8@ms.com>

Hello,

I have this piece of code, and I am curious about how to interprete the
behavior of it. Can anyone here help me? 

@a = unpack 'b5', chr 31;
print "$a[0]:$a[1]:\n";

I expect the output to be "1:1:\n" but it's actually "11111::". Why is
that so? Is it because unpack returns a list of one element which is
'11111'? Beside using split // to make it a list of 1's, are there any
other better methods? Actually my problem is that I want to convert a
scalar (int) to a list of bits, but I am too new to perl... :>

Thanks.
-- 
All the best,
Maverick Woo


------------------------------

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 3147
**************************************

home help back first fref pref prev next nref lref last post