[24155] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6349 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 1 00:05:44 2004

Date: Wed, 31 Mar 2004 21:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 31 Mar 2004     Volume: 10 Number: 6349

Today's topics:
    Re: Filehandles Referenced with a Variable (Myron Turner)
    Re: Inline C  on Windows - what am i doing wrong? <tlviewer@yahoo.com>
        Looking for Perl regexp powered Editor (Loup Blanc)
    Re: Looking for Perl regexp powered Editor <jurgenex@hotmail.com>
    Re: Looking for Perl regexp powered Editor <nospam@bigpond.com>
    Re: Looking for Perl regexp powered Editor <postmaster@castleamber.com>
    Re: losing data on socket <emschwar@pobox.com>
    Re: move() sometimes failing with cross-device error? <eric-amick@comcast.net>
    Re: Problems with installing MIME <matthew.garrish@sympatico.ca>
    Re: Problems with installing MIME <postmaster@castleamber.com>
        Ptkdb 1.1091 Available at SourceForge.net (Andrew E Page)
    Re: Ptkdb 1.1091 Available at SourceForge.net <postmaster@castleamber.com>
    Re: Ptkdb 1.1091 Available at SourceForge.net <invalid-email@rochester.rr.com>
    Re: Ptkdb 1.1091 Available at SourceForge.net <postmaster@castleamber.com>
        Python from the command line (was: Choosing Perl/Python (Cameron Laird)
    Re: Spawn child processes - VMS perl 5.6.1 (patrick flaherty)
        Tough (for me) regex case <rob_perkins@hotmail.com>
    Re: Tough (for me) regex case <skuo@mtwhitney.nsc.com>
    Re: Tough (for me) regex case <postmaster@castleamber.com>
    Re: Tough (for me) regex case <rob_perkins@hotmail.com>
    Re: trapping errors <bmb@ginger.libs.uga.edu>
    Re: Very new to perl <auntie_biotic@tbandu.co.uk>
    Re: Very new to perl <segfault@removethis.noao.edu>
    Re: Very new to perl <matthew.garrish@sympatico.ca>
    Re: Very new to perl <noreply@gunnar.cc>
    Re: Very new to perl <tore@aursand.no>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 01 Apr 2004 02:59:36 GMT
From: turnermm@shaw.ca (Myron Turner)
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <406b8347.167013953@news.wp.shawcable.net>

On Sun, 28 Mar 2004 15:52:10 GMT, mturner@ms.umanitoba.ca (Myron
Turner) wrote:

>On Sat, 27 Mar 2004 18:06:44 GMT, Mike Flannigan
><mikeflan@earthlink.net> wrote:
>
>>
>>Myron Turner wrote:
>>
>>> I know this topic has been gone over, but this is based on
>>> "Programming Perl", page 249,  which I've known about but have never
>>> used:
>>>
>>> my %handles;
>>>
>>> for my $file(@names) {
>>>     my $fh;
>>>     $handles{$file} = $fh;
>>> }
>>
>>This confuses me.  It's seems like $fh would not
>>be defined as anything useful, but I'll give it a try.
>>
>>
>
>
>In the above code, because of the my in
>           my $fh
>each time you go through the loop, perl creates a new scalar and
>assigns it to the hash.  In perl you can say:
>      open $fh, "myfile"
>It doesn't have to be 
>                   open FH, "myfile"
>When you extract $fh from the hash and use it in a position requiring
>a filehandle perl goes to the type glob which holds $fh (*fh) and
>fetches the filehandle for you. 
>
>
I was bothered by my tests with this and found that I have to
apologize for a mistatement here.  'my' variables do not have
typeglobs associated with them.   Typeglobs are used only for package
level variables.  

Here is the statement from the perl documentation (perldoc perldata):

All functions that are capable of creating filehandles (open(),
opendir(), pipe(), socketpair(), sysopen(), socket(), and accept())
automatically create an anonymous filehandle if the handle passed to
them is an uninitialized scalar variable. This allows the constructs
such as open(my $fh, ...) and open(local $fh,...) to be used to create
filehandles that will conveniently be closed automatically when the
scope ends, provided there are no other references to them. This
largely eliminates the need for typeglobs when opening filehandles
that must be passed around.


Myron Turner
www.room535.org


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

Date: Thu, 01 Apr 2004 00:17:14 GMT
From: "gnu valued customer" <tlviewer@yahoo.com>
Subject: Re: Inline C  on Windows - what am i doing wrong?
Message-Id: <ecJac.311$KK3.289@nwrddc02.gnilink.net>

Hi Sketchy,

add some minimal headers as shown inline

Here's a sample script to do 3DES encryption
using the CryptoAPI in Perl via Inline_C:
http://mysite.verizon.net/res1ur2j/IL_3DES_Derive.pl.txt

good luck,
msp
"SketchySteve" <nospamplease@no.com> wrote in message
news:KyGac.471$Tq5.405@newsfe3-win.server.ntli.net...
> Hi there,
>
> I have a fairly simple C function which I need to itegrate into a perl
> script. I have decided to use Inline for this task.
>
> First  I needed nmake for Visual Studio 6.0 C++. I found this file here
>
http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
> installed it and set a path variable so it could be found.
>
> After installing Inline and nmake I am still unable to run simple hello
> world c progs or any other type either. I always get this message.
>
> Had problems bootstrapping Inline module 'hello_pl_b1a6'
>
> Can't locate loadable object for module hello_pl_b1a6 in @INC (@INC
> contains: C:\_Inline\lib C:/Perl/lib C:/Perl/site/li
> b .) at C:/Perl/site/lib/Inline.pm line 500
>
>  at C:\hello.pl line 0
> INIT failed--call queue aborted.
>
>
>
> This is a very urgent problem and help would be appreciated greatly. Am
> really wracking my brain to work out what might be going wrong. Could it
be
> that my version of Perl was not compiled with nmake (i'm using 5.8 with
> windows XP)?
>
> Here is the program giving the error message
>
> use Inline C;
>     greet('Ingy');
>     greet(42);
>     __END__
>     __C__
 /* test  */
#define _WIN32_WINNT 0x0400
 #include <stdio.h>
 #include <windows.h>

>     void greet(char* name) {
>       printf("Hello %s!\n", name);
>     }
>
>
> This is from the inline cook book and all other program fail aswell (in
the
> same way).
>
>
> Thanks in advance for your help
>
> Steve
>
>





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

Date: 31 Mar 2004 16:09:40 -0800
From: cedrat50@hotmail.com (Loup Blanc)
Subject: Looking for Perl regexp powered Editor
Message-Id: <9b1ae155.0403311609.321d5a36@posting.google.com>

Hi,
I'm looking for a text editor or a word processor that allows the use
of perl regexp commands. e.g. s/ / / and the like. The more perl
features available, the best it is.
Usually we have to make the script work on the closed text file, this
is what I want to avoid.
Plus, for word processing files, the previous solution won't work
because of the word processor particular coding of the text. So it
would be great to have perl text processing embedded in it.
Let me know if such softs exist, especially for MS Win.

TIA


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

Date: Thu, 01 Apr 2004 00:15:25 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Looking for Perl regexp powered Editor
Message-Id: <xaJac.10686$BE3.9844@nwrddc03.gnilink.net>

Loup Blanc wrote:
> I'm looking for a text editor or a word processor that allows the use
> of perl regexp commands. e.g. s/ / / and the like. The more perl
> features available, the best it is.

It should be fairly simple to write an elisp extension for emacs which calls
Perl on the mini-buffer or the edited text.

jue




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

Date: Thu, 01 Apr 2004 10:22:28 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Looking for Perl regexp powered Editor
Message-Id: <22061727.UXHrqH1ePx@GMT-hosting-and-pickle-farming>

Loup Blanc wrote:

> Hi,
> I'm looking for a text editor or a word processor that allows the use
> of perl regexp commands. e.g. s/ / / and the like. The more perl
> features available, the best it is.
> Usually we have to make the script work on the closed text file, this
> is what I want to avoid.
> Plus, for word processing files, the previous solution won't work
> because of the word processor particular coding of the text. So it
> would be great to have perl text processing embedded in it.
> Let me know if such softs exist, especially for MS Win.
> 
> TIA


If all you want is regular expressions, vi & emacs will do the job.
Available on most platforms.

gtoomey


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

Date: Wed, 31 Mar 2004 18:44:05 -0600
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Looking for Perl regexp powered Editor
Message-Id: <406b6629$0$24357$58c7af7e@news.kabelfoon.nl>

Loup Blanc wrote:

> Hi,
> I'm looking for a text editor or a word processor that allows the use
> of perl regexp commands. e.g. s/ / / and the like. The more perl
> features available, the best it is.

Textpad (http://textpad.com/ ) has IIRC perl compatible regexp. Together 
with macrorecording this is quite powerful.

-- 
John                            personal page:  http://johnbokma.com/

Freelance Perl / Java developer available  -  http://castleamber.com/


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

Date: Wed, 31 Mar 2004 17:51:42 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: losing data on socket
Message-Id: <etoekr8o6zl.fsf@fc.hp.com>

vorxion@knockingshopofthemind.com (Vorxion) writes:
> Yeah, well...you should see the lot I cut out.  There must be about 20
> hashes.  Each tracks an aspect of the client state, the key of each being
> the fd of the connection.

In that case, you probably want to use a hash of hashes instead; it's
much easier.  perldoc perlreftut has some useful tips on how.  Here's
a short example:

my %clientstate;
$clientstate{$fd}{name} = 'bob'
$clientstate{$fd}{customer_id} = 1234;

You can use this to unify all those 20 hashes into one top-level hash
indexed by fd, and then have each of those 20 hashes as a sub-hash
from there.  See perlreftut for a much better explanation.

> Irrelevant when $cli_logfile is actually a package-scoped (main::) variable
> that's used by Getopt::Long.

Right, but nobody who isn't you who is reading that code is going to
remember that by the time they get down to one specific usage far.
This, to me, is the biggest problem with using tons of globals as you
do; it means that this variable can get changed by any of a number of
functions, some of which may or may not get called, depending on
program state, and it's very difficult for someone not intimately
familiar with the code to track down where that value was set from.

> I'm aware of that.  I intentionally suppress that behaviour.  With my error
> codes, it's superfluous, and to a user it looks like a neatly handled
> error, rather than something wrong with the OS (you'd be surprised at how
> thick or just plain inexperienced some users can really be).

The problem most people are having with those error codes is that they
make the code more difficult to read than it needs to be.  If you had
a constants section at the top, where you had something like

use constant { 
  PERMISSIONS_PROBLEM => 10,
  UNKNOWN_USER        => 20,
  YOU_ARE_AN_IDIOT_LOG_OFF_NOW => 30
}

then it's easier for everyone reading it (including yourself, I think
you'll find) to say, "oh, he's calling fl_die because of a user
problem" than it is to track through how many thousands of lines of
your code, see all the places it's used, and guess what it means.
They can also guess that the first parameter is an error code of some
sort, instead of any of a number of other things it could possibly be.
All in all, it's a win.

> I barely use it.  I've been using vi for about 10 years (I was a major
> emacs-a-holic for 4 years before that) and I first learned about the % key
> in vi about 3 weeks ago, I kid you not.
>
> Following the nested braces just isn't an issue for me.  I just see where
> they go.  I rarely have to count, I'm so used to them.

Well, for everyone else it's not so easy.  Which, if you ever want to
have other people help you with your code, is something you may well
want to take into account.

> Well it was hardly intentional.  I was in a hurry to slice, dice, and get
> it up as requested.

The other thing is, and I don't mean this at all antagonistically,
CLPM is not your personal helpdesk.  Now, I'm sure you didn't think
that when you posted the question, but the way you posted, it seemed
that way.  When you say, "look, I don't care about what you are
interested in, you're not solving my problem", you're missing the
point that that isn't necessarily our goal.

We are, as Tassilo points out, all volunteers.  We're here to discuss
interesting bits of Perl.  Many of us have different ideas of what's
interesting, and that's generally to the good, because everybody can't
answer every query.  But we are not under the same time constraints
you are, and most of us would rather concentrate on the most
interesting parts of your code to us.  Such is life on USENET, I'm
afraid.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Wed, 31 Mar 2004 23:30:19 -0500
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: move() sometimes failing with cross-device error?
Message-Id: <ab6n60lh5v810oqns9sihapsthscmdvhv7@4ax.com>

On 30 Mar 2004 07:10:44 -0800, bwooster47@hotmail.com (B Wooster) wrote:

>use File::Copy;     # for move
>...
>  move("$temp_decode_file", "$real_name")
>
>This is copying accross devices, and this code works most of the time, but
>now once in a while I have started getting errors:
>   Invalid cross-device link
>
>But that can't be, since my logs that following succeeded
> move -> /tmp/1 -> /dosdrive/1
> move -> /tmp/2 -> /dosdrive/2
> move -> /tmp/3 -> /dosdrive/3 - FAILED!
>
>Always fails at the same file, any ideas on what else I should look for?

Versions of File::Copy before 2.07 would report "invalid cross-device
link" for move() if both the internal rename call and the attempt to
copy to the destination and unlink the original failed. Upgrading the
module should give you more accurate error messages; I would start
looking for lack of disk space or maybe even permission problems.

-- 
Eric Amick
Columbia, MD


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

Date: Wed, 31 Mar 2004 19:33:49 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Problems with installing MIME
Message-Id: <KrJac.15435$j57.794721@news20.bellglobal.com>


"Helmut Blass" <helmut_blass@tweb.de> wrote in message
news:c4f1go$hn1$04$1@news.t-online.com...
> hi folks,
> I'm working with os win98 and I want to install via PPM
> the MIME-bundle from ActiveState because I need MIME::Parser.
> Unfortunately I am to dump to do this this job :-(. When entering
> ppm> Install MIME  or
> ppm> Install MIME::Parser
>

ppm> install MIME-tools

Matt




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

Date: Wed, 31 Mar 2004 19:02:17 -0600
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Problems with installing MIME
Message-Id: <406b6a81$0$24357$58c7af7e@news.kabelfoon.nl>

Matt Garrish wrote:

> "Helmut Blass" <helmut_blass@tweb.de> wrote in message
> news:c4f1go$hn1$04$1@news.t-online.com...
> 
>>hi folks,
>>I'm working with os win98 and I want to install via PPM
>>the MIME-bundle from ActiveState because I need MIME::Parser.
>>Unfortunately I am to dump to do this this job :-(. When entering
>>ppm> Install MIME  or
>>ppm> Install MIME::Parser
> 
> ppm> install MIME-tools

Also, read the help on search (in ppm).

-- 
John                            personal page:  http://johnbokma.com/

Freelance Perl / Java developer available  -  http://castleamber.com/


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

Date: 31 Mar 2004 17:29:52 -0800
From: aepage@users.sourceforge.net (Andrew E Page)
Subject: Ptkdb 1.1091 Available at SourceForge.net
Message-Id: <617a8128.0403311729.5fa2ffac@posting.google.com>

The latest release of ptkdb is now on sourceforge.net.  

This release corrects problems with the latest releases of perl(5.8.3)
and PerlTk(804.026)


Use the following link to get the distribution file.


http://sourceforge.net/project/showfiles.php?group_id=43854

Please Report bugs through the following link:


http://sourceforge.net/tracker/?group_id=43854&atid=437609


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

Date: Wed, 31 Mar 2004 20:11:32 -0600
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Ptkdb 1.1091 Available at SourceForge.net
Message-Id: <406b7aeb$0$24342$58c7af7e@news.kabelfoon.nl>

Andrew E Page wrote:

> The latest release of ptkdb is now on sourceforge.net.  

What is it?  The page below didnīt give much info either, other that 
itīs perl and tk :-D (but what is db? developers branch?). Maybe a one 
or two line description next time would clear things up :-D.

> http://sourceforge.net/project/showfiles.php?group_id=43854

-- 
John                            personal page:  http://johnbokma.com/

Freelance Perl / Java developer available  -  http://castleamber.com/


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

Date: Thu, 01 Apr 2004 03:31:20 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Ptkdb 1.1091 Available at SourceForge.net
Message-Id: <406B8CA1.8000609@rochester.rr.com>

John Bokma wrote:

> Andrew E Page wrote:
> 
>> The latest release of ptkdb is now on sourceforge.net.  
> 
> 
> What is it?  The page below didnīt give much info either, other that 
> itīs perl and tk :-D (but what is db? developers branch?). Maybe a one 
> or two line description next time would clear things up :-D.
> 
>> http://sourceforge.net/project/showfiles.php?group_id=43854
> 
> 

"db" stands for "debugger".  It is a GUI adaptation of the standard Perl 
debugger.  Quite clever and effective (although I haven't used it in a 
while).

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Wed, 31 Mar 2004 22:00:06 -0600
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Ptkdb 1.1091 Available at SourceForge.net
Message-Id: <406b943c$0$24339$58c7af7e@news.kabelfoon.nl>

Bob Walton wrote:

> "db" stands for "debugger".  It is a GUI adaptation of the standard Perl 
> debugger.  Quite clever and effective (although I haven't used it in a 
> while).

Thanks! To be honest, I can count the number of times I used the Perl 
debugger on one hand :-D.

-- 
John                            personal page:  http://johnbokma.com/

Freelance Perl / Java developer available  -  http://castleamber.com/


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

Date: Thu, 01 Apr 2004 05:03:15 -0000
From: claird@lairds.com (Cameron Laird)
Subject: Python from the command line (was: Choosing Perl/Python for my particular niche)
Message-Id: <106n8kj2t5n7m11@corp.supernews.com>

In article <4069F1FD.601C9079@doe.carleton.ca>,
Fred Ma  <fma@doe.carleton.ca> wrote:
			.
			.
			.
>Perl/sed.  About invoking Perl as part of a simple command in a
>pipeline, I mean that one doesn't even have to write a script for it,
>similar to sed
>
>	Command1 | sed -e Expression1 -e Expression2 ... | Command_N
>
>This might also be possible in Python, in which case so much the better. 
>I'll find out (or someone might answer in a follow-up post).  Thanks
			.
			.
			.
  # python -c "print 3 + 5"
  8
-- 

Cameron Laird <claird@phaseit.net>
Business:  http://www.Phaseit.net


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

Date: 31 Mar 2004 16:44:37 -0800
From: patf@well.com (patrick flaherty)
Subject: Re: Spawn child processes - VMS perl 5.6.1
Message-Id: <87747de.0403311644.26145308@posting.google.com>

pkent <pkent77tea@yahoo.com.tea> wrote in message news:<pkent77tea-2BDB91.18494431032004@pth-usenet-02.plus.net>...
> In article <c4dmmu01i81@drn.newsguy.com>,
>  Patrick Flaherty <Patrick_member@newsguy.com> wrote:
> 
> > VMSNODE>perl test2.pl
> > The Unsupported function fork function is unimplemented at test2.pl line 2.
> > %SYSTEM-F-ABORT, abort
> > VMSNODE>
> > 
> >   Is there any way, under these conditions, to get from here to there?
> 
> The perlvms page that should have come with perl (the perlport page is 
> handy too) says that fork() is not implemented - here's one on-line:
> http://search.cpan.org/~jhi/perl-5.8.0/vms/perlvms.pod
> 
> The relevant part is:
> >>>>>>>>
> fork
> 
> While in principle the fork operator could be implemented via (and with 
> the same rather severe limitations as) the CRTL vfork() routine, and 
> while some internal support to do just that is in place, the 
> implementation has never been completed, making fork currently 
> unavailable. A true kernel fork() is expected in a future version of 
> VMS, and the pseudo-fork based on interpreter threads may be available 
> in a future version of Perl on VMS (see perlfork). In the meantime, use 
> system, backticks, or piped filehandles to create subprocesses.
> 
> <<<<<<<<<<<
> 
> A copy of the perlfork page is:
> http://search.cpan.org/~jhi/perl-5.8.0/pod/perlfork.pod
> 
> That said, there are references to lib$spawn... but I don't know if 
> there's a VMS-specific module for creating processes, in the same way 
> that there is Win32::Process (VMS::Process only seems to do stuff with 
> existing processes)
> 
> P

Thanx P,

  Not encourging but useful information.

  system() is a non-starter because it's synchronous.

  Will look into backticks and piped filehandles.  Um, by piped
filehandles do you mean the -| |- stuff.  I tried this but it only
generated error messages:


VMSNODE>type safepipe.pl

use English;
my $sleep_count = 0;    

do {
    $pid = open(KID_TO_WRITE, "|-");
    unless (defined $pid) {
        warn "cannot fork: $!";
        die "bailing out" if $sleep_count++ > 6;
        sleep 10;
    }
} until defined $pid;    
if ($pid) {  # parent
    print KID_TO_WRITE @some_data;
    close(KID_TO_WRITE) || warn "kid exited $?";
} else {     # child
    ($EUID, $EGID) = ($UID, $GID); # suid progs only
    open (FILE, "> /safe/file")
        || die "can't open /safe/file: $!";
    while (<STDIN>) {
        print FILE; # child's STDIN is parent's KID
    }
    exit;  # don't forget this
}
VMSNODE>perl safepipe.pl
%DCL-W-IVVERB, unrecognized command verb - check validity and spelling
%DCL-W-IVVERB, unrecognized command verb - check validity and spelling
 \$\
 \$\
kid exited 256 at safepipe.pl line 15.
VMSNODE>


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

Date: Thu, 01 Apr 2004 01:17:54 GMT
From: Rob Perkins <rob_perkins@hotmail.com>
Subject: Tough (for me) regex case
Message-Id: <5sqm60lpp2upam99j9lrmjebjakclh1pod@4ax.com>

Hello,

I know I'm not a regular, and I'm new to the arcana of regular
expressions, so I'm a little stuck with two specific cases and I'm
hoping for a genius:

The case I'm most stumped on is an input string like this:

The "quick" brown "fox jumped ""over"" the" lazy dog.

Where what I want to have matched is the quoted strings, except that
paired doublequotes don't count, and I don't want to capture the
quotemarks. In other words, my desired matches are:

<>
quick
fox jumped ""over"" the
</>

If I use: /".+?"/, I get:

<>
"quick"
"fox jumped "
"over"
" the "
</>

 ...which isn't right. If I use /".+"/, I get:

<>
"quick" brown "fox jumped ""over"" the"
</>

 ...which also isn't right. So I don't know how to proceed and get the
match of the strings contained in doublequotes, with the paired
doublequotes escaped, and the matches without the quotes.

How would you do it?

Rob


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

Date: Wed, 31 Mar 2004 17:46:49 -0800
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Tough (for me) regex case
Message-Id: <Pine.GSO.4.21.0403311742510.22366-100000@mtwhitney.nsc.com>

On Thu, 1 Apr 2004, Rob Perkins wrote:

 ...
>
> The case I'm most stumped on is an input string like this:
> 
> The "quick" brown "fox jumped ""over"" the" lazy dog.
> 
> Where what I want to have matched is the quoted strings, except that
> paired doublequotes don't count, and I don't want to capture the
> quotemarks. In other words, my desired matches are:
> 
> <>
> quick
> fox jumped ""over"" the
> </>
> 
> If I use: /".+?"/, I get:
> 
> <>
> "quick"
> "fox jumped "
> "over"
> " the "
> </>
> 
> ...which isn't right. If I use /".+"/, I get:
> 
> <>
> "quick" brown "fox jumped ""over"" the"
> </>
> 
> ...which also isn't right. So I don't know how to proceed and get the
> match of the strings contained in doublequotes, with the paired
> doublequotes escaped, and the matches without the quotes.
> 
> How would you do it?
> 
> Rob




One way to do it is:

$_ = 'The "quick" brown "fox jumped ""over"" the" lazy dog.';

my @matches = m/(?<!")"(?!")(.*?)(?<!")"(?!")/g;


See 'perldoc perlre' for look-ahead and look-behind assertions.

-- 
Hope this helps,
Steven



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

Date: Wed, 31 Mar 2004 20:07:45 -0600
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Tough (for me) regex case
Message-Id: <406b7a08$0$24342$58c7af7e@news.kabelfoon.nl>

Rob Perkins wrote:

> Hello,
> 
> I know I'm not a regular, and I'm new to the arcana of regular
> expressions, so I'm a little stuck with two specific cases and I'm
> hoping for a genius:
> 
> The case I'm most stumped on is an input string like this:
> 
> The "quick" brown "fox jumped ""over"" the" lazy dog.
> 
> Where what I want to have matched is the quoted strings, except that
> paired doublequotes don't count, and I don't want to capture the
> quotemarks. In other words, my desired matches are:

What I do sometimes is:

[1] replace the problem character(s) with something that according to
     the specs, can never occur in the string (e.g. s/.../\000/g; with
     ... the problem char(s), not three dots.
[2] do your thing
[3] undo step 1 (e.g. s/\000/.../g; see remark in step [1] wrt ...)

-- 
John                            personal page:  http://johnbokma.com/

Freelance Perl / Java developer available  -  http://castleamber.com/


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

Date: Thu, 01 Apr 2004 02:55:19 GMT
From: Rob Perkins <rob_perkins@hotmail.com>
Subject: Re: Tough (for me) regex case
Message-Id: <lt0n60d4k4rv7hukaei12s0tsq2p6btc80@4ax.com>

Steven Kuo <skuo@mtwhitney.nsc.com> wrote:

>One way to do it is:
>
>$_ = 'The "quick" brown "fox jumped ""over"" the" lazy dog.';
>
>my @matches = m/(?<!")"(?!")(.*?)(?<!")"(?!")/g;

Thank you very much, and thanks for the perlre reference.

/(?<!")"(?!")(.*?)(?<!")"(?!")/, on my sample string, produces:

<>
"quick"
"fox jumped ""over"" the"
</>

How should I modify the regex to get:
<>
quick
fox jumped ""over"" the
</> 

 ...in other words, without the quotes as first and last characters in
the matches?

Rob


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

Date: Wed, 31 Mar 2004 18:40:45 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: trapping errors
Message-Id: <Pine.A41.4.58.0403311833260.13576@ginger.libs.uga.edu>

On Wed, 31 Mar 2004, Brad Baxter wrote:
> for( @hold_paths ) {
>     if( opendir(DIR, $_) ) {
>         my $file_count = readdir(DIR);
>         push @hold_all, "$_ $file_count\n";
>         closedir DIR || die "can't closedir $_: $!";
>     }
> }
>
Oops, apologies. Make that:

        my $file_count = () = readdir(DIR);

But again, that count will include '.' and '..' as is.

Regards,

Brad


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

Date: Thu, 1 Apr 2004 00:18:12 +0100
From: "auntie_biotic" <auntie_biotic@tbandu.co.uk>
Subject: Re: Very new to perl
Message-Id: <c4fjo1$r9n$1@news6.svr.pol.co.uk>

Thanks for reply John I feel well and truly told off and apolise for
annoying you.

"John Bokma" <postmaster@castleamber.com> wrote in message
news:406b4e60$0$24352$58c7af7e@news.kabelfoon.nl...
> auntie_biotic wrote:
>
> > First of all sorry if this is the wrong place to post this question.
>
> If in doubt, make sure before you post.
>
> > "Internal Server Error
> > The server encountered an internal error or misconfiguration and was
unable
> > to complete your request.
> > Please contact the server administrator, webmaster@tbandu.co.uk and
inform
> > them of the time the error occurred, and anything you might have done
that
> > may have caused the error.
> > More information about this error may be available in the server error
log."
>
> Did you read that last line of useful advice, or just ignored it? If you
>   did check the error_log, as you should have done, why did you not
> include the message?
>
> Did you check the script from the shell? (Using for example PuTTY to
> connect to the server secure?) Where did you get this script?
>
> Also note that many CGI scripts are crap & unsecure. Are you able to
> understand the risks and able to see if your script falls in the c & u
> category?
>
> > 2.    $baseurl = http://your.host.xxx/wwwboard;
> > I changed this to
> >        $baseurl = http://www.tbandu.co.uk/wwwboard;
> >
> > 3.    $cgi_url = http://your.host.xxx/cgi-bin/wwwboard.pl;
> > I changed this to
> >         $cgi_url = http://your.host.xxx/cgi-bin/wwwboard.pl;
>
> Both lines are wrong. Read on Perl scalars and strings for more
> information. Also, copy lines in your posting, donīt type what you think
> was there, I see no change in 3. (except 2 more spaces).
>
> And yes, I think this is a c and maybe even a c & u script :-D.
>
> --
> John                            personal page:  http://johnbokma.com/
>
> Freelance Perl / Java developer available  -  http://castleamber.com/




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

Date: Wed, 31 Mar 2004 16:37:38 -0700
From: Anna Seg <segfault@removethis.noao.edu>
Subject: Re: Very new to perl
Message-Id: <c4fkn8$1qdu$1@noao.edu>

auntie_biotic wrote:
> Thanks for reply John I feel well and truly told off and apolise for
> annoying you.

Auntie, you should not take it personaly.  Also, you should not top-post.

Go ahead and post the real lines of code from the perl script you tried 
to adapt (as John suggested), and the error log messages.

It may be as simple as (note the qutoes) this, but it is hard to without 
the whole picture:

$baseurl = 'http://www.tbandu.co.uk/wwwboard';
$cgi_url = 'http://www.tbandu.co.uk/cgi-bin/wwwboard.pl';

-a-



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

Date: Wed, 31 Mar 2004 18:37:11 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Very new to perl
Message-Id: <DCIac.58881$1A6.1365742@news20.bellglobal.com>


"auntie_biotic" <auntie_biotic@tbandu.co.uk> wrote in message
news:c4fi3r$jea$1@news7.svr.pol.co.uk...
>
> First of all sorry if this is the wrong place to post this question.
>

You can try any Perl group you like, but you're going to get the same
answers. No one is interested in helping you modify code you didn't write
and. from what you've posted. that is most likely crap anyway. If you're
serious about learning Perl, make an effort to find your problem rather than
post urls you think might be wrong. If you're just looking for Perl scripts
and have no interest in learning the language, do the Web a favour and go
here instead: http://nms-cgi.sourceforge.net/

Matt




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

Date: Thu, 01 Apr 2004 02:34:52 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Very new to perl
Message-Id: <c4fo8f$25oi1c$1@ID-184292.news.uni-berlin.de>

auntie_biotic wrote:
> First of all sorry if this is the wrong place to post this
> question.
> 
> I have a message board ...

Why are you asking this same question in more than one group?? Stop
doing so!

> After trying to post a message I receive the following message.
> 
> "Internal Server Error
> ...

The missing quotes have been pointed out in both groups. If correcting
that wouldn't be enough, add this line somewhere in the beginning of
the script:

     use CGI::Carp 'fatalsToBrowser';

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 01 Apr 2004 04:38:19 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Very new to perl
Message-Id: <pan.2004.04.01.00.07.45.1072@aursand.no>

On Wed, 31 Mar 2004 23:52:39 +0100, auntie_biotic wrote:
> "Internal Server Error
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
> Please contact the server administrator, webmaster@tbandu.co.uk and
> inform them of the time the error occurred, and anything you might have
> done that may have caused the error.
> More information about this error may be available in the server error
> log."

Excactly.  More information about your error may be available in the
server's error log.  What does it say?

> 2.    $baseurl = http://your.host.xxx/wwwboard;
>
> I changed this to
>       $baseurl = http://www.tbandu.co.uk/wwwboard;
> 
> 
> 3.    $cgi_url = http://your.host.xxx/cgi-bin/wwwboard.pl;
>
> I changed this to
>       $cgi_url = http://your.host.xxx/cgi-bin/wwwboard.pl;

This isn't Perl.


-- 
Tore Aursand <tore@aursand.no>
"The road to hell is full of good intentions." -- Bruce Dickinson


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 6349
***************************************


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