[23405] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5623 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 6 14:07:21 2003

Date: Mon, 6 Oct 2003 11:05:14 -0700 (PDT)
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, 6 Oct 2003     Volume: 10 Number: 5623

Today's topics:
    Re: A couple of matching questions. (Roy Johnson)
    Re: EBCDIC-ASCII Conversation (James Willmore)
    Re: fastest count of instances in string? (Roy Johnson)
        get() function - troubles with pdf and zip files. (Marco)
    Re: get() function - troubles with pdf and zip files. <mbudash@sonic.net>
        How replace ing2004 to ing-2004 ? please help <avril@ece.fr>
    Re: How replace ing2004 to ing-2004 ? please help <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: How replace ing2004 to ing-2004 ? please help <ak+usenet@freeshell.org>
    Re: How replace ing2004 to ing-2004 ? please help <josef.moellers@fujitsu-siemens.com>
    Re: How replace ing2004 to ing-2004 ? please help <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: How replace ing2004 to ing-2004 ? please help <HelgiBriem_1@hotmail.com>
    Re: How replace ing2004 to ing-2004 ? please help <josef.moellers@fujitsu-siemens.com>
    Re: How replace ing2004 to ing-2004 ? please help <avril@ece.fr>
    Re: Looking for a search engine submit script (James Willmore)
    Re: LWP:UserAgent not working ??? (Gaurav)
    Re: pattern matching <nospam@peng.nl>
        Perl::Inline compiling problems (Brian K. Michalk)
    Re: Perl::Inline compiling problems (Brian K. Michalk)
    Re: regex with nots in it (Randal L. Schwartz)
    Re: regex with nots in it <pinyaj@rpi.edu>
    Re: Strange behaviour with '\r' character [[ sorry my o <xx087@freenet.carleton.ca>
    Re: Strange behaviour with '\r' character [[ sorry my o (i5513)
    Re: Strange behaviour with '\r' character (Tad McClellan)
    Re: two regexs <perl@my-header.org>
    Re: two regexs (Tad McClellan)
    Re: Unexpected alteration of array's content nobull@mail.com
    Re: Writing your own Presentation Tool (James Willmore)
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 6 Oct 2003 08:26:32 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: A couple of matching questions.
Message-Id: <3ee08638.0310060726.62e09091@posting.google.com>

agoodguygonebad@aol.com (AGoodGuyGoneBad) wrote in message news:<20031004190204.15275.00000173@mb-m23.aol.com>...
> Q1.

I'm a bit late to the party, but I've got a tidy solution to Q1
(included below, with testing program).

#!perl
use strict;
use warnings;

my @strings = qw (aaagggcebbb cfbbcaaacee ebccaaaggge);

for (@strings) {
    my $groupref = grouped($_);
    if (defined $groupref) {
        print "String $_ succeeded with group lengths ",
            join(',', @$groupref), "\n";
    }
    else {
        print "String $_ failed.\n";
    }
}

sub grouped {
    my $str = shift;

    my %seen = ();
    my @lengths = ();
    while ($str =~ /(.)\1*/g) {
        return undef if ($seen{$1}++);
        push @lengths, length($&);
    }
    return [@lengths];
}


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

Date: 6 Oct 2003 07:23:54 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: EBCDIC-ASCII Conversation
Message-Id: <e0160815.0310060623.6ff0bacb@posting.google.com>

"Reinhard Burgmann" <r.burgmann@gmx.net> wrote in message news:<3f814a95$0$18772$91cee783@newsreader02.highway.telekom.at>...
> Hello,
> 
> I have to convert a EBCDIC-File into an ASCII-Code in perl. Unfortunately
> part's of the files are in packed format I have to do this in perl. I think
> a solution with two arrays is possible but maybe somebody has a better idea?
> 
> Thanks in advance
> 
> Reinhard

Convert::EBCDIC 
(http://search.cpan.org/~cxl/Convert-EBCDIC-0.06/lib/Convert/EBCDIC.pm)

Encode::EBCDIC
(http://search.cpan.org/~dankogai/Encode-1.98/EBCDIC/EBCDIC.pm)

HTH

Jim


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

Date: 6 Oct 2003 07:06:39 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: fastest count of instances in string?
Message-Id: <3ee08638.0310060606.65ff3a11@posting.google.com>

"John W. Krahn" <krahnj@acm.org> wrote in message news:<3F80DE17.E890C1CB@acm.org>...
> Ahh, but it does change values.  It just changes them to the same thing
> that they were before.

You have an unusual notion of the definition of "change".
Nevertheless, the behavior is exactly the same, regardless of whether
you specify the replacement list, so why specify it?


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

Date: 6 Oct 2003 08:57:49 -0700
From: ver_for@yahoo.it (Marco)
Subject: get() function - troubles with pdf and zip files.
Message-Id: <da63f24c.0310060757.4a1f3a15@posting.google.com>

Hi,

I try to download some pdf or zip from interet with a perl scripts.

I use the following function.

I open file on my computer called FIC then

$file = get("http://dddddd.zip");
print FIC $file;

The file is downloded but it cannot be read, while when I do the same
process with txt or html it works pefectly.

Do you have any idea of how can I solve this problem?

Thanks,

Marco


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

Date: Mon, 06 Oct 2003 16:06:36 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: get() function - troubles with pdf and zip files.
Message-Id: <mbudash-3863B8.09063706102003@typhoon.sonic.net>

In article <da63f24c.0310060757.4a1f3a15@posting.google.com>,
 ver_for@yahoo.it (Marco) wrote:

> Hi,
> 
> I try to download some pdf or zip from interet with a perl scripts.
> 
> I use the following function.
> 
> I open file on my computer called FIC then
> 
> $file = get("http://dddddd.zip");
> print FIC $file;
> 
> The file is downloded but it cannot be read, while when I do the same
> process with txt or html it works pefectly.
> 
> Do you have any idea of how can I solve this problem?
> 
> Thanks,
> 
> Marco

perldoc -f binmode

-- 
Michael Budash


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

Date: Mon, 6 Oct 2003 15:23:44 +0200
From: "François" <avril@ece.fr>
Subject: How replace ing2004 to ing-2004 ? please help
Message-Id: <blrqe4$i6a$1@s1.read.news.oleane.net>

I want to replace an expression abc1234 to abc-1234 how can i do
I 've tried

s/......./$1$2$3-$4$5$6$7/ but it dont work.

Please help ?

Thanks a lot




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

Date: Mon, 6 Oct 2003 13:31:47 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: How replace ing2004 to ing-2004 ? please help
Message-Id: <Xns940C9DD1AA478elhber1lidotechnet@62.89.127.66>

"François" <avril@ece.fr> wrote in news:blrqe4$i6a$1
@s1.read.news.oleane.net:

> I want to replace an expression abc1234 to abc-1234 how can i do
> I 've tried
> 
> s/......./$1$2$3-$4$5$6$7/ but it dont work.
> 
> Please help ?


  s/(\D+)(\d+)/$1-$2/


Cheers,
Bernard


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

Date: Mon, 6 Oct 2003 13:34:15 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: How replace ing2004 to ing-2004 ? please help
Message-Id: <slrnbo2rq2.kb6.ak+usenet@sdf.lonestar.org>

In article <blrqe4$i6a$1@s1.read.news.oleane.net>, François wrote:
> I want to replace an expression abc1234 to abc-1234 how can i do
> I 've tried
> 
> s/......./$1$2$3-$4$5$6$7/ but it dont work.


s/(\w{3})(\d{4})/$1-$2/


-- 
Andreas Kähäri


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

Date: Mon, 06 Oct 2003 15:38:17 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: How replace ing2004 to ing-2004 ? please help
Message-Id: <3F817049.78AAB87D@fujitsu-siemens.com>

Bernard El-Hagin wrote:
> =

> "Fran=E7ois" <avril@ece.fr> wrote in news:blrqe4$i6a$1
> @s1.read.news.oleane.net:
> =

> > I want to replace an expression abc1234 to abc-1234 how can i do
> > I 've tried
> >
> > s/......./$1$2$3-$4$5$6$7/ but it dont work.
> >
> > Please help ?
> =

>   s/(\D+)(\d+)/$1-$2/

TMTOWTDI

I'd use
s/(\D{3})(\d{4})/$1-$2/

It's a little more robust when the abc1234 is not the only thing on a
line.

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Mon, 6 Oct 2003 13:38:45 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: How replace ing2004 to ing-2004 ? please help
Message-Id: <Xns940C9EFF9DFFEelhber1lidotechnet@62.89.127.66>

Josef Möllers <josef.moellers@fujitsu-siemens.com> wrote in 
news:3F817049.78AAB87D@fujitsu-siemens.com:

> Bernard El-Hagin wrote:
>> 
> 
>> "François" <avril@ece.fr> wrote in news:blrqe4$i6a$1
>> @s1.read.news.oleane.net:
>> 
> 
>> > I want to replace an expression abc1234 to abc-1234 how can i do
>> > I 've tried
>> >
>> > s/......./$1$2$3-$4$5$6$7/ but it dont work.
>> >
>> > Please help ?
>> 
> 
>>   s/(\D+)(\d+)/$1-$2/
> 
> TMTOWTDI
> 
> I'd use
> s/(\D{3})(\d{4})/$1-$2/
> 
> It's a little more robust when the abc1234 is not the only thing on a
> line.


s/abc1234/abc-1234/  is even more robust. ;-)


That's the problem with general specifications of problems.


Cheers,
Bernard


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

Date: Mon, 06 Oct 2003 13:42:21 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: How replace ing2004 to ing-2004 ? please help
Message-Id: <qhr2ovs5126khlmiuhdbr6ua098npr8q7j@4ax.com>

On Mon, 6 Oct 2003 15:23:44 +0200, "François" <avril@ece.fr> wrote:

>I want to replace an expression abc1234 to abc-1234 how can i do
>I 've tried
>
>s/......./$1$2$3-$4$5$6$7/ but it dont work.

I presume the format is originally 
3 letters 4 numbers?

If so:

s/(^[a-z]{3})(\d{4})$/$1-$2/;



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

Date: Mon, 06 Oct 2003 15:44:56 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: How replace ing2004 to ing-2004 ? please help
Message-Id: <3F8171D8.72CBD0C6@fujitsu-siemens.com>

Bernard El-Hagin wrote:
> =

> Josef M=F6llers <josef.moellers@fujitsu-siemens.com> wrote in
> news:3F817049.78AAB87D@fujitsu-siemens.com:
> =

> > Bernard El-Hagin wrote:
> >>
> >
> >> "Fran=E7ois" <avril@ece.fr> wrote in news:blrqe4$i6a$1
> >> @s1.read.news.oleane.net:
> >>
> >
> >> > I want to replace an expression abc1234 to abc-1234 how can i do
> >> > I 've tried
> >> >
> >> > s/......./$1$2$3-$4$5$6$7/ but it dont work.
> >> >
> >> > Please help ?
> >>
> >
> >>   s/(\D+)(\d+)/$1-$2/
> >
> > TMTOWTDI
> >
> > I'd use
> > s/(\D{3})(\d{4})/$1-$2/
> >
> > It's a little more robust when the abc1234 is not the only thing on a=

> > line.
> =

> s/abc1234/abc-1234/  is even more robust. ;-)

Why didn't I think of that B-{)))

> That's the problem with general specifications of problems.

Yes, you're right.
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Mon, 6 Oct 2003 15:56:25 +0200
From: "François" <avril@ece.fr>
Subject: Re: How replace ing2004 to ing-2004 ? please help
Message-Id: <blrsa9$k1i$1@s1.read.news.oleane.net>

thanks that work

"Helgi Briem" <HelgiBriem_1@hotmail.com> a écrit dans le message de
news:qhr2ovs5126khlmiuhdbr6ua098npr8q7j@4ax.com...
> On Mon, 6 Oct 2003 15:23:44 +0200, "François" <avril@ece.fr> wrote:
>
> >I want to replace an expression abc1234 to abc-1234 how can i do
> >I 've tried
> >
> >s/......./$1$2$3-$4$5$6$7/ but it dont work.
>
> I presume the format is originally
> 3 letters 4 numbers?
>
> If so:
>
> s/(^[a-z]{3})(\d{4})$/$1-$2/;
>




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

Date: 6 Oct 2003 07:25:40 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: Looking for a search engine submit script
Message-Id: <e0160815.0310060625.4bb1a7c@posting.google.com>

"Public Interest" <ir@microsoft.com> wrote in message news:<bF8gb.166115$0v4.12560844@bgtnsc04-news.ops.worldnet.att.net>...
> The most recent ones I can find online is as out of date as 2001. What I am
> looking for is something like http://www.addpro.com/submit30.htm
> 
> But even this most recent "free tool" has 3-4 out of date links.
> 
> I remember on http://www.jimworld.com/tools/ there was a free tool, but he
> took it out of his website and he never released the source code.
> 
> Basically, anyone who kept track of url submiting syntax on different search
> engines can write a Perl or HTML tools easily...

There are a few different methods you could use if you were to write your own.

Pre-made scripts/applications _may_ be available at http://freshmeat.net

HTH

Jim


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

Date: 6 Oct 2003 10:09:28 -0700
From: bansal2425@hotmail.com (Gaurav)
Subject: Re: LWP:UserAgent not working ???
Message-Id: <42983cb.0310060909.53d1ec8a@posting.google.com>

wherrera@lynxview.com (Bill) wrote in message news:<239ce42f.0310041247.37cb4656@posting.google.com>...
> bansal2425@hotmail.com (Gaurav) wrote in message news:<42983cb.0310040647.240bb225@posting.google.com>...
> > wherrera@lynxview.com (Bill) wrote in message news:<239ce42f.0310030946.66fedbec@posting.google.com>...
> > > bansal2425@hotmail.com (Gaurav) wrote in message news:<42983cb.0310030625.fa12d98@posting.google.com>...
>  
> > 
> > 
> > I tried perl -e "use LWP::UserAgent;" on my server and i got the
> > following message. It seems like module doesnt exist.
> > **********************************
> > gbansal@ernie:~> perl -e "use LWP::UserAgent;"
> > Can't locate LWP/UserAgent.pm in @INC (@INC contains:
> > /usr/perl5/5.00503/sun4-so
> > laris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris
> > /usr/perl5/site
> > _perl/5.005 .) at -e line 1.
> > BEGIN failed--compilation aborted at -e line 1.
> > ***************************************
> > 
> > How can i add the module ? I am a user on a school server.
> > 
> > Gaurav
> 
> Simplest, have your sysadmin do it.
> 
> However, I've installed user directory CPAN modules via HTTP/CGI
> before, so I know it's possible to install them yourself, as long as
> you can create directories on your server somewhere.
> 
> See if you can run CPAN from the Command line:
> 
> $> perl -e "use CPAN; CPAN::shell(); "
> 
> If so, read the documentation for CPAN to set up installation to one
> of your directories. Then add a
> use INC 'mydir';
> 
> to your programs. The documentation for CPAN has this:
> 
> -------------------------------------------------------------------------
> 
> How do I manually install a module in a private/non-standard
> directory?
> You need to set PREFIX and LIB when you run the Makefile.PL. LIB is
> where the module files will go and PREFIX is the stub directory for
> everything else. For example:
> 
> 
>   foo@barbell$ perl Makefile.PL LIB=/home/foobar/mylib
> PREFIX=/home/foobar/mylib
> Read more about this in the ExtUtils::MakeMaker documentation.
> 
> 
> --------------------------------------------------------------------------------
> 
> How do I use a module installed in a private/non-standard directory?
> There are several ways to use modules installed in private
> directories:
> 
> foo@barbell$ setenv PERL5LIB /path/to/module sets the environment
> variable PERL5LIB.
> use lib qw(/path/to/module); used at the top of your script tells perl
> where to find your module.
> foo@barbell$ perl -I/path/to/module 
> All of these will append /path/to/module to @INC. You should keep in
> mind that having private/non-standard libraries may cause problems if
> you wish to have portable code.
> 
> ----------------------------------------------

where can i find just the module needed for LWP::UserAgent to work. Do
i need more modules or just that one particular module ?

thanx.


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

Date: Mon, 6 Oct 2003 17:21:24 +0100
From: "Lex" <nospam@peng.nl>
Subject: Re: pattern matching
Message-Id: <dJggb.24$iy3.14442@news-reader.eresmas.com>


"Bob Walton" <invalid-email@rochester.rr.com> wrote in message
news:3F80C08B.2070501@rochester.rr.com...

>
> Then you'll have to figure out how to "make a link".

Bob your code is great.

However, I still have a question.

My code now looks like this:

<code>
open (DB, "<$db_file_name_abc") or &cgierr("error in search. unable to open
database: $db_file_name_abc.\nReason: $!");
 if ($db_use_flock) { flock(DB, 1); }

my %xref;
my %meaning;
while ( <DB> ) {
     chomp;
     my($id, $word, $plural, $synonym,$cat,$text) = split /\|/;
     @xref{($word, $plural, $synonym, $text)} = ($id)x4;
     $meaning{$id}=$meaning;
}

foreach my $id(keys %meaning){
     foreach my $word ( $rec{'Text'} =~ /\S+/g ) {
my $newword = "<a
href=\"$db_dir_url/db.cgi?db=abc&uid=$db_uid&ID=$xref{$word}&mh=1&ww=1&view_
records=1\" class=\"abclink\" ONMOUSEOVER=\"popup('...','#C6CBDE')\";
ONMOUSEOUT=\"kill()\">$word</a>";
$rec{'Text'} =~ s|\b$word\b|$newword|gs if exists $xref{$word};
 }
}

close DB;
</code>

The links works now as well while using another database (where $rec{'Text'}
is in).
The only thing I don't know how to do (and I've tried lots...) is how, where
you see " popup('...', ", the three dots, how to get there the original
$text field that goes with this link. So, where $xref{$word} is now the ID
of the record that has to be shown, I'd like the ... to be the original text
field...

Any ideas?

Thanks a lot.

Lex




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

Date: 6 Oct 2003 07:16:58 -0700
From: michalk@awpi.com (Brian K. Michalk)
Subject: Perl::Inline compiling problems
Message-Id: <c30723e3.0310060616.78cbc24e@posting.google.com>

I posted this over in perl.inline, but there's not much traffic there.

I've been porting some time critical code over to C, making C
libraries for reuse in Perl and C.  Pure C compiles, and Perl syntax
compiles, but something's going wrong with autoload, I think.

At this point I'm just confused, and my code looks more like spagetti
than normal.

When I step it through the debugger, it halts at the line where I
call C_sn, which is a C subroutine embedded in the perl code.

With the message:
Can't locate auto/calc_texture/C_sn.al in @INC (@INC contains:
/mnt/bigun/ideraid/samba/functions/develop/bin/_Inline/lib .
/mnt/bigun/ideraid/samba/functions/develop/bin
/usr/lib/perl5/i386-linux 
/usr/lib/perl5 
/usr/lib/perl5/site_perl/i386-linux 
/usr/lib/perl5/site_perl) at calc_texture.pm line 109

I looked, and there is no file: C_sn.al.  Any suggestions?

package calc_texture;
$VERSION = '1.00';
use lib qw(
          .
          /mnt/bigun/ideraid/samba/functions/develop/bin
          );
use strict;
use base ("base_time");
use Inline  C => 'DATA',
            NAME => 'calc_texture',
            LIBS => '-L/mnt/bigun/ideraid/samba/functions/develop/texture
-lnnsn',
            ;
 ...code snip...
sub get_sn_stats {  # do all the filtering and return statistics
  my $self = shift;
  my $indata = \@_;     # indata is a reference to the input array
  my @data_filt;         
  my @data_stats;       
  my @data_deglitched;
  my @data_rawsub;

 ... initialization of vars snipped ...

  C_sn(1|2|4,
       $indata,
       \@data_stats,
       \@data_deglitched,
       \@data_rawsub,
       \@data_filt,
       );
  print join(',', @data_stats);
}
1;
__DATA__
__C__
#include "/mnt/bigun/ideraid/samba/functions/develop/texture/nnsn.h"
#define CP_ARY      1
#define CP_STATS    2
#define FUNC_STATS  4
#define FUNC_NORM   8

// set up glue to convert from PERL to C
int C_sn(int mode, 
          SV *inref, 
          AV *statsout,
          SV *outref1) {
  Inline_Stack_Vars;
  int i;
  int *bigary, *indata;
  float *statary;
  int err;                   // result from processing
  int aryelts;
  float tfloat;
  int sn;
  AV *pinref, *statsoutref, *poutref1;     // pointer to SV arrays
  SV** sv_ptr;              // pointer to move data from one type to
another
  texture_stats stats;     // texture statistics

// convert from Perl Scalar Values to something C knows

  bigary      = (int *) malloc(insize*sizeof(int));
  indata      = (int *) malloc(insize*sizeof(int));   
  statary     = (float *) malloc(STAT_ELEMENTS*sizeof(float));
  pinref      = (AV*) SvRV(inref); 
  statsoutref = (AV*) SvRV(statsout);
  poutref1    = (AV*) SvRV(outref1);
  av_clear(poutref1);

  // copy to local
  for (i=0; i<insize; i++) { sv_ptr = av_fetch(pinref,i,0); indata[i]
= SvNV(*sv_ptr); }
  
  err = process_for_stats(zx, 
                          &stats,
                          indata,
                          bigary, 
                          subary, 
                          filtary);
 ... copy back to outputs vars snipped...

  return(s);
}


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

Date: 6 Oct 2003 10:43:31 -0700
From: michalk@awpi.com (Brian K. Michalk)
Subject: Re: Perl::Inline compiling problems
Message-Id: <c30723e3.0310060943.9097fd6@posting.google.com>

michalk@awpi.com (Brian K. Michalk) wrote in message news:<c30723e3.0310060616.78cbc24e@posting.google.com>...
> I posted this over in perl.inline, but there's not much traffic there.
> 

Replying to myself here, I want to say that I've managed to resolve
most of the issues.  I still have some problems though.  When I
compile the C to test my code, I use the following command:

gcc -lm -o testnnlibs testnnlibs.c 110in1outa.c nnsn.c

This pulls in code from two other libraries, and magically makes the
executable.  It works.

I have yet to find a way to tell Inline::C how to pull in my other
source files.


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

Date: Mon, 06 Oct 2003 16:31:48 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: regex with nots in it
Message-Id: <0ce9f07b6d84a63975d581f87830cea7@news.teranews.com>

>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:

>> /Perl.*(?!PHP)/

Anno> No, your "wild cards" make short shrift with the look-ahead.  Even if
Anno> there is a "PHP" after "Perl", it is always possible for ".*" to match
Anno> enough of the following string to make any "PHP" disappear, so the
Anno> negative look-ahead succeeds (doesn't see PHP).  Take the ".*" into
Anno> the lookahead:

Anno>     /Perl(.*?!PHP)/

Right, it's the difference between:

        Can I find Perl, followed by some number of characters,
        followed by something that isn't PHP?

versus

        Can I find Perl, followed immediately by something that isn't
        "some number of characters followed by PHP"?

Logic can be tough some times.  Luckily, Regex are precise, and do
exactly what you tell them. :)

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Mon, 6 Oct 2003 12:37:23 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: regex with nots in it
Message-Id: <Pine.SGI.3.96.1031006123635.15228A-100000@vcmr-64.server.rpi.edu>

On Mon, 6 Oct 2003, Randal L. Schwartz wrote:

>>>>>> "Anno" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
>
>>> /Perl.*(?!PHP)/
>
>Anno>     /Perl(.*?!PHP)/
>
>Right, it's the difference between:
>
>        Can I find Perl, followed by some number of characters,
>        followed by something that isn't PHP?
>
>versus
>
>        Can I find Perl, followed immediately by something that isn't
>        "some number of characters followed by PHP"?

Uhhh, except that Anno misplaced the '?!' in that regex.  It should be

  /Perl(?!.*PHP)/

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 6 Oct 2003 14:04:20 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Strange behaviour with '\r' character [[ sorry my other post was wrong typed ]]
Message-Id: <slrnbo2tk5.jb8.xx087@smeagol.ncf.ca>

i5513 <i5513@hotmail.com> wrote:
>    if ($FORM{"text"} =~ /\r/)
>    {
>      print "Hey! It is here! <BR> ";
>    }
>    if ($FORM{"text"} =~ /^(\s|\n)*$/)
>    {
>      print "Now it isn't here!";
>    }
>  
>  Well, When I execute (on Windows) this script with one simple return
>  on textarea. It gives me next result:
>  Hey! It is here!
>  Now it isn't here!
>  
>  What does Perl do with '\r' character?

\s (whitespace) contains \r


-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: 6 Oct 2003 10:40:49 -0700
From: i5513@hotmail.com (i5513)
Subject: Re: Strange behaviour with '\r' character [[ sorry my other post was wrong typed ]]
Message-Id: <a657ec02.0310060940.160cbd9a@posting.google.com>

Glenn Jackman <xx087@freenet.carleton.ca> wrote in message news:<slrnbo2tk5.jb8.xx087@smeagol.ncf.ca>...
> i5513 <i5513@hotmail.com> wrote:
> >    if ($FORM{"text"} =~ /\r/)
> >    {
> >      print "Hey! It is here! <BR> ";
> >    }
> >    if ($FORM{"text"} =~ /^(\s|\n)*$/)
> >    {
> >      print "Now it isn't here!";
> >    }
> >  
> >  Well, When I execute (on Windows) this script with one simple return
> >  on textarea. It gives me next result:
> >  Hey! It is here!
> >  Now it isn't here!
> >  
> >  What does Perl do with '\r' character?
> 
> \s (whitespace) contains \r

Thanks you! I have read on perlre:
\s	Match a whitespace character
But I didn't know '\r' was whitespace (I thinked about \s was( |\t)).


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

Date: Mon, 6 Oct 2003 08:51:38 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Strange behaviour with '\r' character
Message-Id: <slrnbo2sra.gec.tadmc@magna.augustmail.com>

i5513 <i5513@hotmail.com> wrote:

> Hi!. I don't understand ...


It would be easier for us to help you if you actually said
what it is that you don't understand...


> (After get parameters)


You should use the CGI.pm module for that.


> if ($FORM{"text"} =~ /^(\s|\n|\r)*$/) 
                             ^^ ^^
                             ^^ ^^ this part will *never* match


These will match exactly the same as the above:

   if ($FORM{"text"} =~ /^\s*$/)

   if ($FORM{"text"} =~ /^[\r\n\t\f ]*$/)



>   if ($FORM{"text"} =~ /^(\s|\n)*$/)
>   {
>     print "Now it isn't here!";
>   }


I'll guess that you do not understand why this condition is true?

It is true because \s matches a carriage return.

If you want to check that there is no carriage return, then write
an expression that checks that there is no carriage return:

     if ($FORM{"text"} !~ /^\r*$/)
                       ^^
                       ^^ note

or

     unless ($FORM{"text"} =~ /^\r*$/)


> with one simple return
> on textarea. 


Saying it in Perl is always better than trying to say it in English.

You say that sentence in Perl like this:

   my %FORM = ( text => "\r\n" );
or
   $FORM{text} = "\r\n";


Have you seen the Posting Guidelines that are posted here frequently?


> It gives me next result:
> Hey! It is here!
> Now it isn't here!


Those are the expected results.

You neglected to tell us what it was that _you_ were expecting.


> What does Perl do with '\r' character?


Nothing.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 06 Oct 2003 17:01:48 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: two regexs
Message-Id: <l7v2ov8bp775mrtulreb26qc3t9o8oo0k5@4ax.com>

X-Ftn-To: Greg Bacon 

gbacon@hiwaay.net (Greg Bacon) wrote:
>: everything between quotes OR match all consecutive non white chars". Since I
>: need this to parse html forms, I ended up with,
>: 
>:   my $atr = qr/(?:["'](.*?)["']|([^>\s]+))/;
>: 
>: And here is the reinvented wheel with some known limitations(it doesn't
>: support group of checkboxes with same names).
>
>Is there a reason you're not using CGI.pm or another CGI module
>from the CPAN that doesn't have this limitation?

Afaik CGI.pm, can't deal with predefined forms, and solutions from cpan seem
bloated. :!



-- 
Matija


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

Date: Mon, 6 Oct 2003 10:19:07 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: two regexs
Message-Id: <slrnbo31vb.gj8.tadmc@magna.augustmail.com>

Matija Papec <perl@my-header.org> wrote:

> Afaik CGI.pm, can't deal with predefined forms


What is a "predefined form" ?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 6 Oct 2003 09:33:42 -0700
From: nobull@mail.com
Subject: Re: Unexpected alteration of array's content
Message-Id: <4dafc536.0310060833.2cc22a48@posting.google.com>

rjohnson@shell.com (Roy Johnson) wrote in message news:<3ee08638.0310041405.34a8e888@posting.google.com>...
> Brian McCauley <nobull@mail.com> wrote in message news:<u9oewydvo3.fsf@wcl-l.bham.ac.uk>...
> > 
> >   for my $line (grep 1, @lines){
> > 
> > Then @lines _is_ still modified.
> 
> This was new to me.

I guessed that because you didn't think the map() trick had a high
"blink factor".
 
> Then I'm sorry to inform you that the idiom you prefer is still going
> to cause a WTF moment for the casual reader. At least with a simple
> assignment, it is intuitively obvious that something is being copied.
>  
> > Not once you get used to it (I certainly blinked at the map example).
> 
> There is no reason for @{[@ar]} to become a familiar idiom. It doesn't
> do anything that is often going to be necessary. It's not difficult to
> decipher, but it still takes a blink.

Well _I_ encounter it often enough that I wanted a way to avoid the
ugliness of the explicit copy.

I was even moved to asked a question here
(<u98ytk6yc9.fsf@wcl-l.bham.ac.uk>).
http://groups.google.com/groups?threadm=u9brye1qw2.fsf%40wcl-l.bham.ac.uk

This is something I rarely do!

> > Please see other current thread about why local $_ can do strange
> > things.
> 
> I will do that, if I can find it.

Actually it's an interesting sub-thread of a rather less interesting
thread over in clp.moderated.

Unless you have MJD massively scored up [ doesn't everyone? :-) ] you
could easily have missed it.  It starts at:

From: Mark Jason Dominus <mjd@plover.com>
Newsgroups: comp.lang.perl.moderated
Subject: Re: bug or gotcha?
Date: Mon, 29 Sep 2003 18:16:53 -0400
Message-ID: <20030929221654.22084.qmail@plover.com>


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

Date: 6 Oct 2003 07:28:26 -0700
From: jwillmore@cyberia.com (James Willmore)
Subject: Re: Writing your own Presentation Tool
Message-Id: <e0160815.0310060628.3bc08c26@posting.google.com>

shlomif@vipe.technion.ac.il (Shlomi Fish) wrote in message news:<deca99a9.0310060148.664cb219@posting.google.com>...
> Hi all!
> 
> I know that in Israel alone, at least 5 people (Gabor Szabo, Reuven
> Lerner, Shlomo Yona, Alon Altman and I) wrote their own presentation
> tools in Perl, at least one (Nadav Har'El) wrote one in zsh, and at
> least one wrote it in Python.
> 
> Did any of you also rolled their own presentation tool instead of
> using something that you found on the Net?
> 
> Regards,
> 
> 	Shlomi Fish

Huh?  Not sure where the question/statement is related to Perl.  I'm
also thinking you need to define "presentation tool" a little better. 
You mean like M$ PowerPoint(tm)?

Jim


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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.  

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


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