[8179] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1797 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 3 12:08:00 1998

Date: Tue, 3 Feb 98 09:00:22 -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, 3 Feb 1998     Volume: 8 Number: 1797

Today's topics:
        Academic Assistance in Programming Languages <tutoraid@mail.excite.com>
        Email Perl script on NT alpha server d2dcleh@fre.fsu.umd.edu
    Re: Error with analysis of system () return value on Pe <jdporter@min.net>
    Re: goto & with variable routine $sub in SUPER - is thi <jdporter@min.net>
    Re: Help writing to log file and redirecting user (Richard Bellavance)
    Re: Help! ~ operator doesn't work! (Richard Bellavance)
    Re: Help:  Testing a CGI script locally/Path to browser <camerond@mail.uca.edu>
        Including a newline in replacement text <erik@peak.mrc.montana.edu>
        Install ques: perl modules on RH Linux ldavis@iago.reston.ans.net
    Re: Inverse of a regex <scottj@mthcsc.wfu.edu>
        keyboard input without carriage return (Michael Russo)
    Re: keyboard input without carriage return (Honza Pazdziora)
        keyboard INPUT (Michael Russo)
    Re: LOW LEVEL PERL HELP (Andrew M. Langmead)
    Re: multi-line regexp help needed (Andrew M. Langmead)
        Need help with editing @INC (SLSorrels)
        opendir/rewinddir problem on NT <asupcsi@cyberramp.net>
        Perl and Excel ? <lwest@imaginet.fr>
    Re: print a integer with two decimal places <barnett@houston.Geco-Prakla.slb.com>
        recreating sed with perl michael_moore@idx.com
    Re: recursive regex? (Chip Salzenberg)
    Re: RegEx anchors? \@ ? (Jim Allenspach)
    Re: RegEx anchors? \@ ? <dboorstein@shopcfn.com>
    Re: Regex From Hell? <scottj@mthcsc.wfu.edu>
    Re: Regex From Hell? (Tom Grydeland)
        Time measurements <hussain_imran@jpmorgan.com>
    Re: White Hats and Black (John Moreno)
    Re: Win32 CGI compiler ? <rsgdata@worldnet.fr>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 03 Feb 98 09:49:16 -0500
From: Academic Assistance Access <tutoraid@mail.excite.com>
Subject: Academic Assistance in Programming Languages
Message-Id: <8bf5.8a1c.19a@AAA>


Academic Assistance Access is a free tutoring service on the Web
designed to offer assistance in Programming Languages for  post
secondary students. If you are looking for answers to your Programming
Languages questions, our team of professionals can help you make the
grade!!!

Please, do not ask questions by replying to this message. For assistance
you should first subscribe to the following address:

http://www.tutoraid.org/

George Richards
Academic Assistance Access



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

Date: 3 Feb 1998 16:23:51 GMT
From: d2dcleh@fre.fsu.umd.edu
Subject: Email Perl script on NT alpha server
Message-Id: <6b7gan$9ht$1@hecate.umd.edu>

I currently created a form through html and I am using a perl script to email 
the form.  The problem is when I send the form nothing happens, I just get the 
reponse back through the netscape browser saying that the form was sent.  
Everyone I have talked to so far has been running forms from a unix server.  We 
have a NT alpha server and I was wondering if maybe the perl script is 
different on a Unix server compared to a NT alpha server.  I would greatly 
appreciate any suggestions on how to email the form, or maybe something that 
may need configured on the NT server.   Thanks...


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

Date: Tue, 03 Feb 1998 09:59:19 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Error with analysis of system () return value on Perl book page 230
Message-Id: <34D730C7.5D6D@min.net>

Michael Wang wrote:
> 
> John Porter  <jdporter@min.net> wrote:
> >Michael Wang wrote:
> >>
> >>   I believe the example analyzing the return value of system()
> >> on Perl book page 230 is wrong.
> >
> >I certainly don't blame you for being confused.  But you're wrong.
> 
> John,
> 
> I certainly don't blame you for being confused. But what you said
> below is in complete agreement as what I posted, which is in
> disagreement with Perl book page 230. Thanks.

Touche.

The problem (bug) is in the code on page 230.  The line that says
'elsif ($rc > 0x80) {'  , that should be 0x100, not 0x80.

I'm surprised this is not in the Camel book errata list.

I also believe that this test and brach should be reversed, in the
sense that the upper byte should only be meaningful if the lower
byte is zero. In other words, that line should be

	elseif ( ($rc&0xFF) == 0 ) {

thanks
John Porter


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

Date: Tue, 03 Feb 1998 09:44:03 -0500
From: John Porter <jdporter@min.net>
Subject: Re: goto & with variable routine $sub in SUPER - is this right?
Message-Id: <34D72D33.69A8@min.net>

Peter Scott wrote:
> 
> So I want to jump to the method named $AUTOLOAD in my superclass, passing
> whatever arguments I currently have.  I wound up with the eval line in:
> 
> sub AUTOLOAD {
>     my $self = shift;
>     $AUTOLOAD =~ s,.*::,,;
>     return if $AUTOLOAD eq "DESTROY";
>     eval "goto &\$self->SUPER::$AUTOLOAD" unless exists $ATTRS{$AUTOLOAD};
>     $self->{$AUTOLOAD} = shift if @_;
>     return $self->{$AUTOLOAD};
> }

Sorry, ugly is what you get with Perl.

What you've got here looks OK to me, except for the goto. I couldn't get
it
to work.  This line worked for me:

	eval "\$self->SUPER::$AUTOLOAD" . . .

hth,
John Porter


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

Date: 3 Feb 1998 10:07:45 -0500
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: Help writing to log file and redirecting user
Message-Id: <6b7bs1$pnv@ocean.CAM.ORG>

In article <34d72a93.633601540@news.mindspring.com>,
Bob <miadesigns@thetriangle.com> wrote:
>Hi,
>
>What I'm trying to accomplish is similar to a guest book script. Here
>are the details:
>

First off, your problem has nothing do to with Perl.  You don't seem to
understand the Common Gateway Interface works.  I suggest you read up on it.
(lurking in comp.infosystems.www.* might be a good idea)  But I'll answer your
question anyway...

[details snipped]

># Get the input
>read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>
># Split the name-value pairs
>@pairs = split(/&/, $buffer);
>
>foreach $pair (@pairs) {
>   ($name, $value) = split(/=/, $pair);
>
>   # Un-Webify plus signs and %-encoding
>   $value =~ tr/+/ /;
>   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>   $value =~ s/<!--(.|\n)*-->//g;
>   $value =~ s/<([^>]|\n)*>//g;   
>
>   $FORM{$name} = $value;
>} 

ObPerl: You really should use CGI.pm to do this.

>
>print "Content-Type: text/html\n\n";
>

Don't send a Content-type header if you want to redirect !!!

>   # If lockfile exist, then someone is already writing to the file
>   if (-e "add.filelock") {
>      # We'll take a 1 second nap
>      sleep(5);
>   }

You do realize this is not safe ?  What if two requests come in a the same
time ?  Consult the Perl FAQ for better locking ideas (http://www.perl.com).

>## print "Content-type: text/html\n\n";
>open (PAGE, "$page") || die "Couldn't open $page";
>while (<PAGE>) {print;}
>## print "Location: $page\n\n\n";

You only need 2 newlines after the Location header.

Good luck,
Richard.
-- 
Richard Bellavance -- charlot@cam.org -- http://www.cam.org/~charlot/
    "All along this path I tread  /  My heart betrays my weary head
     With nothing but my love to save / From the cradle to the grave"
                                 (Eric Clapton, "From the cradle")


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

Date: 3 Feb 1998 09:53:17 -0500
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: Help! ~ operator doesn't work!
Message-Id: <6b7b0t$p77@ocean.CAM.ORG>

In article <34D72978.7C64ADF2@mycroft.cmhnet.org>,
Sean Gilley  <sgilley@netexp.net> wrote:
>I've been having problems with tests failing. Yesterday we finally
>tracked at least quite a few of the problems down to the ~ operator.
>In experimenting with the bop.t test, we found that this statement:
>
>	printf("%x\n", ~0xdead);
>
>returned the value 7FFFFFFF.  Further, replacing "0xdead" with "1",
>"111", and "111111", all yielded the result "7FFFFFFF".
>

On my Perl, the following:

#! /usr/local/bin/perl -w
use strict;

printf("%x\n", ~0xdead);
printf("%x\n", ~1);
printf("%x\n", ~111);
printf("%x\n", ~111111);


Outputs this:

ffff2152
fffffffe
ffffff90
fffe4df8

Which version of Perl are you running ?

Richard.
-- 
Richard Bellavance -- charlot@cam.org -- http://www.cam.org/~charlot/
    "All along this path I tread  /  My heart betrays my weary head
     With nothing but my love to save / From the cradle to the grave"
                                 (Eric Clapton, "From the cradle")


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

Date: Tue, 03 Feb 1998 09:12:26 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: Linda Starr <lgstarr@primenet.com>
Subject: Re: Help:  Testing a CGI script locally/Path to browser
Message-Id: <34D733DA.3EBD7E0@mail.uca.edu>

[copy mailed to recipient]

Linda Starr wrote:
> 
> What is the path (action = "......../cgi-bin/mydoc.pl") to the browser
> if
> I am testing CGI scripts locally in WIN 95 and a Mac

Time Out! This is really a FMM (frequently made mistake), it seems to
show up *at least* once a day on this group, worded slightly differently
in this case.

Actually it's 2 FMM's: (1) It's not a perl question, but that's not what
I'm going to address here, and:

(2) A CGI script doesn't go to the *browser*, it has to be run from a
web *server* (or the command line, but that's a little less convenient).
The path to the *server* is what you need, http://www.foo.bar

Now, to anticipate the next question, how do you get server software
(free)? Go someplace like tucows (http://www.tucows.com). People have
recommended things like omnihttpd, O'Reilly's website, apache, sambar, a
bunch of others, pick one which works on your machines (I use NS
Fasttrack, because it's free for edu institutions, and I like it). Set
up your server, point your browser to http://localhost, and go.

HTH,

Cameron Dorey
camerond@mail.uca.edu


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

Date: Tue, 03 Feb 1998 10:21:42 -0600
From: Erik <erik@peak.mrc.montana.edu>
Subject: Including a newline in replacement text
Message-Id: <886522240.1735065607@dejanews.com>

I am trying to replace strings with other strings,
sometimes with a newline in the middle of it.
Perl does not seem to want to interpret the \n
in the middle of the replacement text. Here's the code:

$from=^Description:
$To=Identification Information:\n\tCitation:\n\t\tTitle:

	$line=~ s/$from/$to/egi;
	print NEW "$line";

Its supposed to look like this after replacement:

old:
Description:

new:
Identification Information:
	Citation:
		Title:

but it comes out like this:
Identification Information:\n\tCitation:\n\t\tTitle:

It seems to interpret the left side fine (the ^ is
correctly interprete) but not on the right side, any help?

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 03 Feb 1998 10:54:03 -0500
From: ldavis@iago.reston.ans.net
Subject: Install ques: perl modules on RH Linux
Message-Id: <ru4t2gfzvo.fsf@iago.reston.ans.net>

I was trying to install some modules last night, and
I found that the Makefile.PL created a makefile with 
install dirs of /var/tmp/perl-root...

where is Makefile.PL getting this information?  I 
really have my stuff installed in /usr/lib/perl5.  I know
I can edit my Makefile manually, but I want to know the
cause.

All help is appreciated.

Thanks,
Lynch
-- 
____________________________________________________________________________

ANS Communications                                  Software Engineer
1875 Campus Commons Dr.                             ldavis@reston.ans.net
Suite 220,  Reston VA 22091                         (703) 758-6622
____________________________________________________________________________


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

Date: Tue, 03 Feb 1998 10:42:30 -0500
From: Kevin Scott <scottj@mthcsc.wfu.edu>
Subject: Re: Inverse of a regex
Message-Id: <34D73AE6.EEC69542@mthcsc.wfu.edu>

Doug wrote:

[snip]
> I want to get the opposite and the following doesn't work...why ?
> 
> $line =~ s/!(\<.*?\>)//g;
>
> I think that probably just trying to inverse a regex won't work. 
[snip]

This doesn't work because ! is not an 'inverse' operator in Perl regular
expressions.  I don't even think that inverse would be the appropriate
term for what you're looking for.  Consider the following Perl:

	$line =~ s/^.*?(\<.*\>).*$/$1/;

This will replace everything in $line with the sub-string enclosed by
the outermost pair of angle brackets in $line, including the brackets
themselves.  

This is far from being the only way to do this, so experiment.

Good luck.

-- 
******  Kevin Scott
********  Department of Mathematics & Computer Science
********  Wake Forest University
******  scottj@mthcsc.wfu.edu


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

Date: 3 Feb 98 15:08:19 GMT
From: russo02@sunserv.eelab.newpaltz.edu (Michael Russo)
Subject: keyboard input without carriage return
Message-Id: <34d732e3.0@npnews.newpaltz.edu>
Keywords:  keyboard input 

Does anyone have any clue on how to process input from the keyboard without
having to hit the carriage return. getc and read just don't seem to cut the
mustard.


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

Date: Tue, 3 Feb 1998 15:39:05 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: keyboard input without carriage return
Message-Id: <adelton.886520345@aisa.fi.muni.cz>
Keywords: keyboard input 

russo02@sunserv.eelab.newpaltz.edu (Michael Russo) writes:

> Does anyone have any clue on how to process input from the keyboard without
> having to hit the carriage return. getc and read just don't seem to cut the
> mustard.

How about Term::ReadKey?

Hope this helps,

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 3 Feb 98 15:19:22 GMT
From: russo02@sunserv.eelab.newpaltz.edu (Michael Russo)
Subject: keyboard INPUT
Message-Id: <34d7357a.0@npnews.newpaltz.edu>
Keywords: keyboard input 

Does anybody have any insight on how to process keyboard input without
having to wait for the '\n' (carriage return, in the vernacular)?  Getc and
read STDIN aren't cutting it.




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

Date: Tue, 3 Feb 1998 16:37:03 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: LOW LEVEL PERL HELP
Message-Id: <EntA5r.ACq@world.std.com>

Pablo Hortal <mcai3ph2@ist4.co.umist.ac.uk> writes:

>I have to write a simple Perl script to communicate
>with a Printed Circuit Board, through a simple serial
>link (RS232 link).

>I have been advised to use ioctls.
>Has anyone have a bit of info. about this ioctls stuff?

You're probably best off looking at the termios man page (although it
will be the C library man page, you'll have to figure out how it
applies to the corresponding perl functions.) Then look at the
POSIX::Termios module for how to use those functions in perl.

You might also take a look at the book "Advanced Unix Programming" by
WR Stevens. (Again it would be in C, not perl.)
-- 
Andrew Langmead


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

Date: Tue, 3 Feb 1998 15:34:17 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: multi-line regexp help needed
Message-Id: <Ent795.1D7@world.std.com>

"Hugh J. Blair" <blairhj@intnet.net> writes:

>Help !  I'm a perl newbie so this could make or break my perl career.

A good perl tutorial book might be the one purchase to make or break
your perl career.

>I'm trying to extract multi-line block of text from a very large file.
>I can specify the begin pattern and the end pattern. The variation is a
>string in the middle.

If the file is very large, you might be best off searching for the
beginning and ending pattern separately, and grabbing all the lines in
the middle.

#!/usr/bin/perl -w


while(defined($line = <>)) {
  push @found, $line while /^start/ .. /^end/;
}

print @found;

or more verbosely as:

#!/usr/bin/perl -w

$start_matching = 0;
while(defined($line = <>)) {
  if($line =~ /^start/) {
     $start_matching = 1;
  }
  push @found, $line if $start_matching;
  if($line =~ /^end/) {
     $start_matching = 0;
  }
}

If you are exaggerating when you describe the file as "very large",
you might just want to slurp the entire file into memory and extract
it with a single regular expression match.

{
 local($/) = undef;
 $data = <>;
}

($found) = ($data =~ /^start(.*?)^end/ms);
-- 
Andrew Langmead


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

Date: 3 Feb 1998 16:50:30 GMT
From: slsorrels@aol.com (SLSorrels)
Subject: Need help with editing @INC
Message-Id: <19980203165000.LAA01151@ladder03.news.aol.com>

I downloaded a module for Internet stuff... like FTP... I ran the "install.bat"
to let it make the appropriate Registry modifications and drop the files where
they need to go...  (yes... I'm using Perl on Win95  :-))

BUT...  when I try to run my tiny little perl program, I get an error message
saying "Can't load 'c:\Perl\lib/auto/win32/internet/internet.pll' for Module
Win32::Internet..........."

I can see "internet.pll" in that path but can't figure out why Perl thinks it's
not there...  someone suggested I edit the @INC and push the info...

How do I push the info? I know about the "push function" but am unsure of the
proper syntax to use...

Anyone???  hheeelllppp  :-)

-SLSorrels


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

Date: 3 Feb 1998 15:03:45 GMT
From: "Clay Isaacs" <asupcsi@cyberramp.net>
Subject: opendir/rewinddir problem on NT
Message-Id: <01bd30b5$434d5fc0$671415ac@fusat36_124>

Question: When the opendir command is issued, can you re-read the directory
without first closing and then re-opening the handle and have any new files
added picked up? I have tried using rewinddir as shown in the code below
but I still recieve no files after issuing the readdir command. The snippet
below does not pick up the file created after the opendir command.

Thanks,

Clay

#### per 5.004_02 WindowsNT 4.0 SVCPK  3

$some_dir = '\\\\trft_srvdal006\\data\\batch\\bt\\ToPage\\';
opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";

$pgf = ">\\\\trft_srvdal006\\data\\batch\\bt\\ToPage\\test.pgr";

if (! open(FH, $pgf)) {
	print "\nCould not create file $pgf\n";
	exit 1;
}
print FH "3973742,Test\n";
close(FH);

sleep(10);
rewinddir(DIR);
@files = readdir(DIR);
shift @files;
shift @files;

foreach $x (@files) {
	print "File entries = $x\n";
}
closedir(DIR);
exit 0;


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

Date: Tue, 03 Feb 1998 16:29:22 +0100
From: Leo West <lwest@imaginet.fr>
Subject: Perl and Excel ?
Message-Id: <34D737D2.9489A0CB@imaginet.fr>

Does anybody know about a module or any process to read a .XLS (Excel
file) from a Perl script ?

Sorry if this question is a common one, but i am quite new to Perl under
Windows OS ..

Thanks,

Leo


--
____________________________________________________________

                                  Leo West lwest@imaginet.fr
                             Developpement Base de donnees / Web
                                      IMAGINET DESIGN
____________________________________________________________




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

Date: Tue, 03 Feb 1998 08:38:28 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: print a integer with two decimal places
Message-Id: <34D72BE4.72413D90@houston.Geco-Prakla.slb.com>

Richard Wilde wrote:
> 
> I wonder if  any one could help me:
> 
> I need to output an integer to two decimal places.
> i.e.
> 
> $total=4
> print $total; #this would print 4. I would need it to print 4.00
> 
> $total=6.5;
Well, except for the fact that 6.5 is not an integer, and neither would
4.00 or 6.50 be one.  (By definition integers are whole numbers only,
with no fractional part, and no decimal point.)  Perhaps you want a
floating point value?

> print $total; #this would print 6.5. I would need it to print 6.50
> 

How about printf ("%2.2f", $variable);   ?


HTH.

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Tue, 03 Feb 1998 16:34:38 GMT
From: michael_moore@idx.com
Subject: recreating sed with perl
Message-Id: <34d746ae.11427785@news.idx.com>

Hi.  I'm looking to recreate the Unix sed functionallity in perl on a
win32 system.  Before I reinvent the whell, I was wondering if anyone
else has already done this and if they'd be willing to share the code
with me.

Thanks,
Mike


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

Date: Tue, 03 Feb 1998 15:33:59 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: recursive regex?
Message-Id: <6b7dgo$r4u$1@cyprus.atlantic.net>

According to Richard Caley <spt@cstr.ed.ac.uk>:
>In article <6b59qk$ori$1@cyprus.atlantic.net>, Chip Salzenberg (cs) writes:
>cs> Actually, just such a thing is under active design work even as we
>cs> type at each other here.  Probably won't be in 5.005, but you might
>cs> expect to see it in 5.006.
>
>Could I put in a vote for a readable syntax. extending the current
>regex syntax is getting silly. Something verbose and understandable
>would be a godsend.

Well, the current syntax _will_ be extended.  There has been discussion
of a verbose equivalent to all of the RE line noise, but nothing has
come of it yet.  A concrete proposal that includes all of the current
RE language would be a good start.
-- 
Chip Salzenberg               - a.k.a. -                <chip@pobox.com>
 "Boy, is it ever dark."  "I hope they don't get a moonburn."  // MST3K
           ->  Ask me about Perl training and consulting  <-
    Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: 3 Feb 1998 09:09:52 -0600
From: jima@REMOVE.ME.mcs.com (Jim Allenspach)
Subject: Re: RegEx anchors? \@ ?
Message-Id: <6b7c00$lf8$1@Mercury.mcs.net>

>firstname lastname user@host
>singlname user@host
>user@host
><user@host>
>alot of silly info user@host some more info

> I want to grab ONLY the user @ host info but I cant seem to get it. Can
>I anchor on the @ sign in an expression? Ie: (\w+\@\w+) to give
>word@word?

	Sure can:

	$line = 'test data user@host test';
	if ($line =~ /(\w+)@(\w+)/) {
		print "user $1 at host $2\n";
	}

Note that, if these user@host data are going to be full e-mail addresses, a
simple regex might not catch all possible addresses. The Perl FAQ has a
thing or two to say about this. Hope this helps...
jma

--
jima at mcs dot com
Chicago, IL                     Perl programmers do it
http://www.streams.com/jima/      with one hump.


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

Date: Tue, 03 Feb 1998 10:06:33 -0500
From: Dan Boorstein <dboorstein@shopcfn.com>
Subject: Re: RegEx anchors? \@ ?
Message-Id: <34D73279.4E819BBC@shopcfn.com>

Nicholas Brenckle wrote:
> 
*cut*
> firstname lastname user@host
> singlname user@host
> user@host
> <user@host>
> alot of silly info user@host some more info
> 
>  I want to grab ONLY the user @ host info but I cant seem to get it. Can
> I anchor on the @ sign in an expression? Ie: (\w+\@\w+) to give
> word@word?

yes, you can do that. it worked fine for me with the following: 

while (<DATA>)  {
  /(\w+\@\w+)/ and print "$1\n";
}

__END__
firstname lastname user@host
singlname user@host
user@host
<user@host>


maybe you were having problems elsewhere in your test. if you post
your code i can be more helpful. be warned though, an email address
may contain characters which do not match \w. a custom character class
may be more appropriate.

--

dan boorstein


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

Date: Tue, 03 Feb 1998 09:47:24 -0500
From: Kevin Scott <scottj@mthcsc.wfu.edu>
Subject: Re: Regex From Hell?
Message-Id: <34D72DFC.AFFB7B0E@mthcsc.wfu.edu>

Alexis Huxley wrote:
[snip]
> Now suppose that I want to allow any number of any of the characters to be
> repeated after their current positions. So that, for instance, 'azazaz' could
> become 'aaaaaaaazazazzzzzzzzz'. I expected that I could put round brackets
> around each square bracketed term (meaning "remember this") and then put
> '\1*' and '\2*' after each of them (meaning "followed by any number of the
> remembered character") giving:
> 
>         perl -ne 'print if (/^(([abc])\1*([xyz])\2*){3}$/)'
> 
> But that fails with 'aazaazaaz' which I believe it should pass. Interestingly
> 'azaazaaaz' passes. What's going on?
[snip]

Your expression needs to be

	/^(([abc])\2*([xyz])\3*){3}$/

to work.  Remember that \1 is the string matching the first expression
enclosed in parentheses.

Good luck.

-- 
******  Kevin Scott
********  Department of Mathematics & Computer Science
********  Wake Forest University
******  scottj@mthcsc.wfu.edu


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

Date: 3 Feb 1998 16:36:52 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Regex From Hell?
Message-Id: <slrn6deht3.ppa.Tom.Grydeland@mitra.phys.uit.no>

On 03 Feb 1998 12:49:44 GMT,
Alexis Huxley <alexis@danae.demon.co.uk> wrote:
> Hi
> 
> Now suppose that I want to allow any number of any of the characters to be
> repeated after their current positions. So that, for instance, 'azazaz' could
> become 'aaaaaaaazazazzzzzzzzz'. I expected that I could put round brackets
> around each square bracketed term (meaning "remember this") and then put
> '\1*' and '\2*' after each of them (meaning "followed by any number of the
> remembered character")

You don't need backreferences for that.  There's the + modifier.

However, if you use [abc]+, you'll get any number of a's *or* b's *or*
c's, which I don't think is what you want.

> 
> 	perl -ne 'print if (/^(([abc])\1*([xyz])\2*){3}$/)'
> 
> But that fails with 'aazaazaaz' which I believe it should pass. Interestingly
> 'azaazaaaz' passes. What's going on?

This has been answered by several others.

> As an extension of the same problem, it is my understanding that the
> '\1' thing means "match what the first bracketed thing matched". Is
> there any way to make it mean "match *anything* that the first
> bracketed regex *could* have matched" ?

No.

> What I mean is that if the above regex worked 
> as expected then I would then expect 'aazbbzccz' to fail [...]

Correct.

> Obviously I could use:
> 
> 	perl -ne 'print if
> 	(/^([abc])\1*([xyz])\2*([abc])\3*([xyz])\4*([abc])\5*([xyz])\6*$/)'
> 
> but I simplified the '{3}' for this article; the original was '{3,}'.


Mattias Lvnnqvist was close, but (a|b|c) matches the same as [abc],
albeit more slowly.  What you want is this:

#!/usr/bin/perl -nw

print if
/^                 # beginning of line
  (?:              # grouping only
    (?:a+|b+|c+)   # one or more a's OR one or more b's OR one or more c's
    (?:x+|y+|z+)   # one or more x's OR one or more y's OR one or more z's
  ) {3,}           # three or more times
  $                # and nothing more
/x                 # /x so I can comment it like this

__END__

See?  That didn't require a single backreference.  I think it should be
reasonably fast too.  No extensive backtracking.

Embedding it (in compact form) in a test script:

#!/usr/bin/perl -w

@abc = qw/ a b c x y z /;

for (1 .. 1000) {
    $x = "";
    for (1 .. rand(20)) {
        $x .= $abc[rand(@abc)] x rand(4);
    }
    print "$x\n" if $x =~ /^(?:(?:a+|b+|c+)(?:x+|y+|z+)){3,}$/;
}

__END__

produces sample output:

cccczbbyyazaaxxx
ccczzzaaazzbbbxxxxccx
cxxaaazaxx
ccccczzbbxxbzzby
czbbxxxxcccxccxx
byyybbbxccyy
bbbxxaaazaaz
aaazccczzzccczzz
ccyaaxxazz

demonstrating matches of both three and four repetitions.

HTH,

> Alexis

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Tue, 03 Feb 1998 16:29:06 +0000
From: Imran Hussain <hussain_imran@jpmorgan.com>
Subject: Time measurements
Message-Id: <34D745D2.5729@jpmorgan.com>

Hi,

I need to extract and mathematically (subtract) manipulate times from a 
text file which are stored as:

27/01/98 23:45:06	#i.e: date & time 

28/01/98 14:20:41 


Is there a straight forward way in Perl of finding the difference in 
minutes and perhaps converting to hours.

I can't simply operate on the times as they are because they often span 
over several days.

Any help appreciated.

Imran.


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

Date: Tue, 3 Feb 1998 11:17:27 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: White Hats and Black
Message-Id: <1d3vg7d.wgzhtsajhbryN@roxboro0-049.dyn.interpath.net>

soren a. <sorentin@plsdontspam.sprynet.com> wrote:

> In response to an article in which Tom Christiansen <tchrist@mox.perl.com>
> wrote the following:
> 
> [CC: to T. C. as a courtesy]
> 
> >         __White Hats and Black__
> 
> >         Thursday, 22 January 1998
> >             Tom Christiansen
> >             tchrist@perl.com
> 
> Not to be just another lame "me too'er" ...  but this was brilliant,
> wonderful, important commentary and I, as a relative newcomer to the Free
> Software Universe, applaud it, and Netscape, enthusiastically. It not only
> directs attention to the culture of gift-giving but to the "culture of hope"
> vs. that of "stale cynicism."
> 
> Tom, i would like to refer to this essay/article on my webpage; do you have
> this published on the WWW as a fixed stable URL? One that i can link to?

Personally I prefer to use AltaVista for stuff like this, give it a day
or two for them to get it in and then try this:

<http://ww2.altavista.digital.com/cgi-bin/news?id@6ae5l4$smk$1@csnews.cs
 .colorado.edu>

-- 
John Moreno


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

Date: Tue, 03 Feb 1998 16:39:41 -0500
From: rsgdata <rsgdata@worldnet.fr>
Subject: Re: Win32 CGI compiler ?
Message-Id: <34D78E9D.4F3C@worldnet.fr>

Richard Bellavance wrote:
> 
> In article <34D7721D.6B99@worldnet.fr>, rsgdata  <rsgdata@worldnet.fr> wrote:
> >
> >I want to make an hybrid CDROM with Internet explorer and some
> >cgi-scripts. But I want to protect my scripts on the CDROM because they
> >are in editable ASCII.
> >
> >Can I compile my CGI scripts in Win32 .exe or in java ?
> >
> >If not, how can I protect my sources (binary encryption or other ?)
> >
> 
> Well, since they're on a CD-ROM, nobody will be able to delete or edit them,
> so they are quite well protected, aren't they ?    :-)
> 
> Richard, who couldn't resist.
> 
> [serious hint: look on DejaNews for a recent thread on this matter]
> --
> Richard Bellavance -- charlot@cam.org -- http://www.cam.org/~charlot/
>     "All along this path I tread  /  My heart betrays my weary head
>      With nothing but my love to save / From the cradle to the grave"
>                                  (Eric Clapton, "From the cradle")

But everyone can read the source...

In France, your answer is called : "une riponse de charlot" :-)

        Christophe.


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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