[24237] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6428 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 20 06:05:43 2004

Date: Tue, 20 Apr 2004 03:05:07 -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           Tue, 20 Apr 2004     Volume: 10 Number: 6428

Today's topics:
        5.6 to 5.8 CPAN help <King@ask.for.email.invalid>
    Re: 5.6 to 5.8 CPAN help (Walter Roberson)
    Re: 5.6 to 5.8 CPAN help <King@ask.for.email.invalid>
    Re: 5.6 to 5.8 CPAN help <King@ask.for.email.invalid>
        activeperl + -T option <robin @ infusedlight.net>
    Re: CVS access via PERL <vek@station02.ohout.pharmapartners.nl>
    Re: CVS access via PERL <holgerbiebinger@gmx.de>
    Re: CVS access via PERL <holgerbiebinger@gmx.de>
        Encrypting files (SlimClity)
        help with upload perl <renping.liu@eng.ox.ac.uk>
        Is it possible to 'word wrap' lines just using RegEx? <NewsGroups@US-Webmasters.com>
    Re: Is it possible to 'word wrap' lines just using RegE chris-usenet@roaima.co.uk
    Re: Is it possible to 'word wrap' lines just using RegE (Anno Siegel)
    Re: need Regular Expression to remove all non-numerical (Peter J. Acklam)
    Re: One question <bik.mido@tiscalinet.it>
    Re: pattern matching <krahnj@acm.org>
    Re: Perl is the answer? <georgekinley@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 20 Apr 2004 07:02:02 GMT
From: The King of Pots and Pans <King@ask.for.email.invalid>
Subject: 5.6 to 5.8 CPAN help
Message-Id: <KV3hc.65261$U83.27260@fed1read03>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

I had RH7.2 with Perl 5.6 on my machine. I learned a little about CPAN
a long time ago and remember using it to get modules at one time. I
haven't used it in a long, long, long while.

Since then I have upgraded to RH9, which apparently has Perl 5.8. I
wanted to get the DB_File module the other day and typed "cpan" at my
linux prompt, not remember how exactly to invoke it or how it works.

I get the following error:
[steve@sol 5.8.0]$ cpan
Can't locate CPAN.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .)
at /usr/bin/cpan line 6.
BEGIN failed--compilation aborted at /usr/bin/cpan line 6.

I did a locate on CPAN.pm and got the following:
[steve@sol steve]$ locate CPAN.pm
/var/www/html/perlpods/CPAN.pm.html
/usr/lib/perl5/5.6.0/Bundle/CPAN.pm
/usr/lib/perl5/5.8.0/CPAN.pm.links
/usr/local/lib/perl5/5.6.1/CPAN.pm
[steve@sol steve]$

I am unsure of how to proceed. I went to the cpan website and tried
finding information on how to install cpan, or get it working... but
was unable to find anything to address this issue.

Anyone have any idea what might be going on and what course of action
I should take to get cpan working with 5.8?

I am thinking it probably isn't a good idea just to copy the 5.6 cpan
module into the 5.8 directory and try to use it?

- -- 
The King of Pots and Pans
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAhMy3d/wbFEGfmloRAiv9AJ9xuSmaN6hJGrpP0mp5vhBf9Mh0dACeI0qn
wxTWHoJqWaOq6iGku+UBKus=
=/j4o
-----END PGP SIGNATURE-----


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

Date: 20 Apr 2004 07:14:16 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: 5.6 to 5.8 CPAN help
Message-Id: <c62ik8$msv$1@canopus.cc.umanitoba.ca>

In article <KV3hc.65261$U83.27260@fed1read03>,
The King of Pots and Pans  <King@ask.for.email.invalid> wrote:
:I had RH7.2 with Perl 5.6 on my machine. I learned a little about CPAN
:a long time ago and remember using it to get modules at one time. I
:haven't used it in a long, long, long while.

perl -MCPAN -e shell
-- 
   Any sufficiently advanced bug is indistinguishable from a feature.
   -- Rich Kulawiec


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

Date: Tue, 20 Apr 2004 07:38:13 GMT
From: The King of Pots and Pans <King@ask.for.email.invalid>
Subject: Re: 5.6 to 5.8 CPAN help
Message-Id: <Fr4hc.65265$U83.53371@fed1read03>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On Tue, 20 Apr 2004 at 07:14 GMT, Walter Roberson spoke:
> In article <KV3hc.65261$U83.27260@fed1read03>,
> The King of Pots and Pans  <King@ask.for.email.invalid> wrote:

>:I had RH7.2 with Perl 5.6 on my machine. I learned a little about
>CPAN :a long time ago and remember using it to get modules at one
>time. I :haven't used it in a long, long, long while.

>  perl -MCPAN -e shell

Thanks. As user 'steve' that at least did something. I went through
the setup and finally typed "install Net::FTP" and "install
Bundle::CPAN" as it suggested. During the process I got a bunch of
errors about "you do not have permissions to install this" and a lot
of "not found in @INC path" type stuff.

I tried su'ing to root and running the command above you
suggested. But got the original bad @INC path thing:

[root@sol root]# perl -MCPAN -e shell
Can't locate CPAN.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .).
BEGIN failed--compilation aborted.
[root@sol root]#

Also, in what documentation does one find that "perl -MCPAN -e shell"
kicks off everything? I looked and looked and looked but couldn't find
how to "start it." 

- -- 
The King of Pots and Pans
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAhNUxd/wbFEGfmloRAt84AJ0ZFK953Txd0QoKhyJAHtk7igMGjwCgsi9M
XDjPLzcHleGw/E/um+AVH6A=
=9+I9
-----END PGP SIGNATURE-----


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

Date: Tue, 20 Apr 2004 07:53:07 GMT
From: The King of Pots and Pans <King@ask.for.email.invalid>
Subject: Re: 5.6 to 5.8 CPAN help
Message-Id: <DF4hc.65268$U83.9863@fed1read03>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

On Tue, 20 Apr 2004 at 07:14 GMT, Walter Roberson spoke:

> perl -MCPAN -e shell

When I attempt to install things using the above it installs them in
the perl 5.6 dirs. How do I start using the perl 5.8 and configure
cpan for perl 5.8?

My whole point here is to use cpan to get DB_File because spamassassin
won't let me use the sa-learn program until DB_File module is
installed. I believe I was able to install DB_File using CPAN just
fine, but sa-learn -D still believes it is not installed.

?? 


- -- 
The King of Pots and Pans
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAhNiwd/wbFEGfmloRArkEAJ9c0BWGDf7GidvCiU7FbgNiwNXA9QCfeO4g
xouS2fovtfL6GGhJDaRb0/I=
=GNcU
-----END PGP SIGNATURE-----


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

Date: Mon, 19 Apr 2004 23:41:05 -0700
From: "Robin" <robin @ infusedlight.net>
Subject: activeperl + -T option
Message-Id: <c62hsr$qci$1@reader2.nmix.net>

I am running active perl 8.2.3 Build 809 and I'm wondering why when I turn
on taint mode checking on the #!/usr/bin/perl line whenver I run the script
it gives me an error "Too late for -T option at bbs.pl line 1." and whenever
I run the script with perl -T bbs.pl it works fine....is there any
configuration file I can edit so perl will automatically understand it to be
run with a -T option? I want to run the script with a Perl IDE that I've
downloaded and it gives me this error unless I take out the -T option. Do I
have to take out the -T evertime I run the script with the IDE or is there
something I can do?
Thanks in advance.

--
Regards,
-Robin
--
[ webmaster @ infusedlight.net ]




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

Date: 20 Apr 2004 07:47:14 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: CVS access via PERL
Message-Id: <slrnc89lc2.d1q.vek@station02.ohout.pharmapartners.nl>

On Mon, 19 Apr 2004 18:09:00 +0200,
    Holger Biebinger <holgerbiebinger@gmx.de> wrote:


> Hi NG,
> I would like to access a CVS Server which provides pserverv access. I 
> tried to access via
> cvs [Directory here] login
> After that i get a login prompt. Can I enter my password with PERL? I am 
> a beginner in using the PERL language.
> I would appreciate any help.
>

Why would you do that?  You run the cvs login only once for each server
and you won't need it after that.  Also, if you run cvs via rsh or ssh
you set up rsh or ssh to not require password, in which case you don't
need login either.


Villy


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

Date: Tue, 20 Apr 2004 11:09:04 +0200
From: Holger Biebinger <holgerbiebinger@gmx.de>
Subject: Re: CVS access via PERL
Message-Id: <c62p8p$756nk$1@ID-225521.news.uni-berlin.de>

Hi,

Paul Lalli wrote:

> On Mon, 19 Apr 2004, Holger Biebinger wrote:
> 
> 
>>Ok, let me try to speak Perl. I'm afraid I have quite a bad accent ;-) I
>>have a config file with the CVS access data and i want to connect to the
>>cvs server for a checkout:
>>
>>test.pl
>>#!/usr/bin/perl -w
>>
>># I don't exactly know if I need all those packages
>>use File::Find;
>>use File::Path;
>>use File::Basename;
>>use File::Copy;
>>use File::Spec;
>>use File::DosGlob 'glob'; # TinyPerl only seems to work with DosGlob :-/
>>use FileHandle;
>>use Getopt::Std;
>>use Config;
> 
> 
> The only one I see you using here are File::Basename (for dirname()). I
> would recommend getting rid of the rest (and if the interpreter gives you
> an error, then you know you should add it back. :-) )
> 
> 
Ok you were right. It was the only one needed.

>>%config = (
>>);
>>
>>$scriptbase = dirname($0);
>>$configfile = "$scriptbase/testfile.cfg" unless $configfile;
>>parse_cfg($configfile);
>>
>>my $cvs ="cvs -d
>>:$config{'CVS_RSH'}:$config{'CVS_USERNAME'}"."@"."$config{'CVS_SERVER'}:"."$config{'CVS_DIR'}";
> 
> 
> Gahh.  That looks rather messy.  You might want to take advantage of the
> hashkey property of barewords, not to mention escaping @ characters:
> 
> my $cvs ="cvs -d :$config{CVS_RSH}:$config{CVS_USERNAME}\@$config{CVS_SERVER}:$config{CVS_DIR}";
> 
> Well.  It's mildly better anyway.
> 
Really, its better. Thanks for that hint.

> 
>>my $release = $config{'RELEASE'};
>>my $project = $config{'PROJECT'};
>>my $checkoutdir = $config{'CHECKOUTDIR'};
>>
>>system "$cvs login";
>>#how can I enter the password?
>>system "$cvs co $project";
>>
> 
> 
> Okay. Now I understand.  The simple answer is that you can't, at least not
> like this.  What you're trying to do is called "bidirectional interprocess
> communication".  That is, both getting input from and sending output to a
> process.  This is more complicated than you might imagine.  For more
> details, read:
> perldoc -q pipe
> 
OK. it is not quite easy ;-) It was the humble try of a beginner.

> That documentation will refer you to the IPC::Open2 module.  However,
> since you are trying to do something very specific with your bidirectional
> pipe - something that many people before you have wanted to do - there
> already exists a module specifically for it.  I therefore refer you back
> to the CVS module from CPAN that I posted in my previous message.
> 
I tried it out and it seems to work for my purposes. Great. Next time I 
will first have a look if anyone else has already done the work for me 
;-) Now I know where to search.

Holger



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

Date: Tue, 20 Apr 2004 11:28:22 +0200
From: Holger Biebinger <holgerbiebinger@gmx.de>
Subject: Re: CVS access via PERL
Message-Id: <c62qcu$776oo$1@ID-225521.news.uni-berlin.de>

Hi,

Villy Kruse wrote:

> On Mon, 19 Apr 2004 18:09:00 +0200,
>     Holger Biebinger <holgerbiebinger@gmx.de> wrote:
> 
> 
> 
>>Hi NG,
>>I would like to access a CVS Server which provides pserverv access. I 
>>tried to access via
>>cvs [Directory here] login
>>After that i get a login prompt. Can I enter my password with PERL? I am 
>>a beginner in using the PERL language.
>>I would appreciate any help.
>>
> 
> 
> Why would you do that?  You run the cvs login only once for each server
> and you won't need it after that.  
Oh yeah, that's right. Thanks.

Also, if you run cvs via rsh or ssh
> you set up rsh or ssh to not require password, in which case you don't
> need login either.
> 
The Repository should be accessed via pserver or ssh. ssh can not be 
used without password on that machine. I think the most flexible 
approach is to use the Cvs Module on 
http://search.cpan.org/~rsoliv/Cvs-0.06/lib/Cvs.pm

Thanks,
Holger



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

Date: 20 Apr 2004 02:34:58 -0700
From: slimclity@hotmail.com (SlimClity)
Subject: Encrypting files
Message-Id: <3c209c5f.0404200134.78418af7@posting.google.com>

I'm trying to encrypt file's using the Perl Crypt::Rijndeal module,
see encrypt.pl and decrypt.pl. Because the data must be in blocks of
16 I use "get16". Both scripts work, I can encrypt and decrypt files.
But the decrypted file is corrupt, eg. encrypt word file --> decrypt
--> File is corrupt.

I think this has something to do with the get16, when decrypting I
think I must remove those "\0" which were added (how??).... Or is it
something else??

-- encrypt.pl --
  use Crypt::Rijndael;
  $cipher = new Crypt::Rijndael "1234567890123456",
Crypt::Rijndael::MODE_CBC;
 
  $srcfile = "doc.doc";
  $destfile = "doc.enc";

  #my ($srcfile, $destfile) = @_;
  my $buffer;

  open INF, $srcfile
    or die "\nCan't open $srcfile for reading: $!\n";
  open OUTF, ">$destfile"
    or die "\nCan't open $destfile for writing: $!\n";

  binmode INF;
  binmode OUTF;

  while (
    read (INF, $buffer, 1024)	# read in (up to) 64k chunks, write
    and print OUTF $cipher->encrypt(get16($buffer)) # exit if read or
write fails
  ) {};
  die "Problem copying: $!\n" if $!;

  close OUTF
    or die "Can't close $destfile: $!\n";
  close INF
    or die "Can't close $srcfile: $!\n";

 sub get16 {
        my $data = shift;
        return "\0" x ( 16 - length($data)%16) . $data;
 }
-- end of encrypt.pl --

-- decrypt.pl --
  use Crypt::Rijndael;
  $cipher = new Crypt::Rijndael "1234567890123456",
Crypt::Rijndael::MODE_CBC;
 
  $srcfile = "doc.enc";
  $destfile = "doc-new.doc";

  #my ($srcfile, $destfile) = @_;
  my $buffer;

  open INF, $srcfile
    or die "\nCan't open $srcfile for reading: $!\n";
  open OUTF, ">$destfile"
    or die "\nCan't open $destfile for writing: $!\n";

  binmode INF;
  binmode OUTF;

  while (
    read (INF, $buffer, 65536)	# read in (up to) 64k chunks, write
    and print OUTF $cipher->decrypt($buffer) # exit if read or write
fails
  ) {};
  die "Problem copying: $!\n" if $!;

  close OUTF
    or die "Can't close $destfile: $!\n";
  close INF
    or die "Can't close $srcfile: $!\n";

 sub get16 {
        my $data = shift;
        return "\0" x ( 16 - length($data)%16) . $data;
 }
-- end of decrypt.pl --


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

Date: Tue, 20 Apr 2004 10:53:13 +0100
From: "News sender" <renping.liu@eng.ox.ac.uk>
Subject: help with upload perl
Message-Id: <c62rts$krj$1@news.ox.ac.uk>

Hi there,

I am using CGI and Perl for uploading files. The Perl code is included.

The code works fine on PC and Linux (both run apache 2.0.39). But when I run
the code on Unix (solaris7, also run Apache2.0.39), only the filename is
uploaded, not the contents:

-rw-------   1 nobody   nobody         0 Apr  19 16:10 file1
-rw-------   1 nobody   nobody         0 Apr  19 16:35 file2

You can see the file names are right: file1, file2. But the size of each
file is 0.

The permission of the directory is set as 777:
drwxrwxrwx   2 nobody   nobody          512 Apr  2 15:33 shared

There is no error messages in the Apache log files.

Does anyone see this problem before? Any help is appreciated.

Many thanks.

-----------------------------------------------------------
#!/usr/bin/perl

use CGI;

$query = new CGI;

$filepath = $query->param ('filename');

if ($filepath =~ /([^\/\\]+)$/)
{
 $filename="$1";
print "The file name is: ", $filename, "<br>";
}

else
{
 $filename="$filepath";
}

# check the existence of the file
 if (-e "../htdocs/sharedfiles/$filename")
 {
  print "A file with the same name exists, please rename your file.",
"<br>";
 }
 else
 {
  # open the file and load it
  open (OUTFILE,">../htdocs/sharedfiles/$filename ");
  binmode(OUTFILE);
  while ($bytesread=read($filepath,$buffer,1024)) {
     print OUTFILE $buffer;
  }
  close OUTFILE;
  print "Your file has been successfully uploaded.", "<br>";
 }




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

Date: Tue, 20 Apr 2004 01:33:43 -0500
From: "W. D." <NewsGroups@US-Webmasters.com>
Subject: Is it possible to 'word wrap' lines just using RegEx?
Message-Id: <4084C447.2BBC@US-Webmasters.com>

Hi Folks,

Is there to split a line like the following, *ONLY* using a regular
expression?

The quick brown fox jumped over the lazy sleeping dog.  The rain in
Spain falls mainly on the plain.

to this:

The quick brown fox jumped over the lazy sleeping dog.  The rain 
in Spain falls mainly on the plain.

Thanks for any help you can provide! 



-- 
Start Here to Find It Fast!™ ->
http://www.US-Webmasters.com/best-start-page/
$8.77 Domain Names -> http://domains.us-webmasters.com/


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

Date: Tue, 20 Apr 2004 09:16:38 +0100
From: chris-usenet@roaima.co.uk
Subject: Re: Is it possible to 'word wrap' lines just using RegEx?
Message-Id: <6s2fl1-h33.ln1@moldev.cmagroup.co.uk>

W. D. <NewsGroups@us-webmasters.com> wrote:
> Is there to split a line like the following, *ONLY* using a regular
> expression?

Yes of course.

> The quick brown fox jumped over the lazy sleeping dog.  The rain in
> Spain falls mainly on the plain.

> to this:

> The quick brown fox jumped over the lazy sleeping dog.  The rain 
> in Spain falls mainly on the plain.

There are several different ways to interpret "like the following". I've
chosen to move the word "in" to the start of a new line. I could have
equally chosen to split the line at the Nth character, or the Nth word.

(
    echo 'The quick brown fox jumped over the lazy sleeping dog.  The rain in';
    echo 'Spain falls mainly on the plain.'
) |
    perl -ape 's/\s(in)\n/\n$1 /'


I wonder if Text::Format is what you really want?
Chris


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

Date: 20 Apr 2004 09:39:55 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is it possible to 'word wrap' lines just using RegEx?
Message-Id: <c62r5b$gii$2@mamenchi.zrz.TU-Berlin.DE>

W. D. <NewsGroups@US-Webmasters.com> wrote in comp.lang.perl.misc:
> Hi Folks,
> 
> Is there to split a line like the following, *ONLY* using a regular
> expression?
> 
> The quick brown fox jumped over the lazy sleeping dog.  The rain in
> Spain falls mainly on the plain.
> 
> to this:
> 
> The quick brown fox jumped over the lazy sleeping dog.  The rain 
> in Spain falls mainly on the plain.
> 
> Thanks for any help you can provide! 

Lots of ways, all slightly different.  Since you don't say what you
mean by split, there are too many possibilities to list them all.

Use the module Text::Wrap and be done with.

Anno


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

Date: 20 Apr 2004 07:14:01 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: need Regular Expression to remove all non-numerical
Message-Id: <llkrmdt2.fsf@online.no>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:

> Web Surfer  <raisin@delete-this-trash.mts.net> wrote:
>
> > $string =~ s/\D//g;  # remove all non-numeric chars
> 
>     $string =~ tr/0-9//cd;
> 
> does the same, but faster.

Since no-one else has posted this improved s///-solution, here
goes

    s/\D+//g;

but I am sure tr/// will be faster.

Peter

-- 
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;


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

Date: Tue, 20 Apr 2004 08:41:18 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: One question
Message-Id: <ang9801or83da8khca7ptnpeikqe4t8u4n@4ax.com>

On Mon, 19 Apr 2004 19:00:58 GMT, "edgrsprj" <edgrsprj@ix.netcom.com>
wrote:

>> >of time.  The programs that I was using took as much as 2 hours to do a
>> >single run.  This Perl program does much more in perhaps 20 seconds.  And
>it
>> >is so easy to modify and expand.
>>
>> Fine to know, so what?!?
>>
>
>For it to produce the most helpful results the program I have developed has
>to be run multiple times and the results from each run compared.  That is

OK!

>much easier to do with a program which runs in just 20 seconds versus 2

OK!

>hours.  Also I was generally commenting on the fact that I was finding Perl
>to be useful.

OK! I can understand that: you are commenting on the fact that you
find Perl to be useful well, @{[('many')x1000]} times. WE ALL KNOW
THAT!

OTOH you're answering my own cmt that in turns (i) was pointing out
that you failed (for the n-th time, BTW) to quote properly and give
enough context, (ii) was referring to the fact you said something to
the effect that calling your perl program from console would have
required major hassles in terms of chdir()s et similia IIRC, which is
utter nonsense IMO, etc.


Michele

-- 
# This prints: Just another Perl hacker,
seek DATA,15,0 and  print   q... <DATA>;
__END__


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

Date: Tue, 20 Apr 2004 06:07:40 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: pattern matching
Message-Id: <4084BE03.43F41BEE@acm.org>

Brad Baxter wrote:
> 
> On Mon, 19 Apr 2004, LiHui wrote:
> 
> > Can someone tell me what does this line do ?
> >
> > $line =~ m/^\|\s*\w\S*\s*(?:\|.+?){10,}\|$/o
> >
> > I know that it check to see if the line begin with "|" follow by
> > whitespace, word, nonwhitespace and than I'm lost. What is s*(?:\|.+?)
> 
> Make that "|" followed by optional whitespace, a word character, optional
> nonwhitespace, optional whitespace, ten or more of "these": |x..., and
> ending in "|".
> 
> Also, it's not s*(?:\|.+?), it's \s*(?:\|..+?).  (?:...) are grouping (not
> capturing) parentheses.  They're followed by {10,} so you want 10 or more
> of those groups.  Each group is "|" followed by at least one, possibly
> more, character(s) that match(es) /./ but not "|" (because +? is
> non-greedy).
> 
> Below is an expanded (using /x) version:
> 
> # example line that will match
> my $line = '| abc |0|1|2|3|4|5|6|7|8|9|x|y|z|';
> 
> $line =~ m/^\|\s*\w\S*\s*(?:\|.+?){10,}\|$/o and print "yes\n";
> 
> $line =~ m/
>     ^      # begins with
>     \|     # 'or' bar
>     \s*    # optional whitespace
>     \w     # ONE word character
>     \S*    # optional nonwhitespace
>     \s*    # optional whitespace
>     (?:    # begin the group
>     \|     # 'or' bar
>     .+     # at least one character
>     ?      # make the '+' non-greedy
>     )      # end the group
>     {10,}  # give me 10 or more GROUPS
>     \|     # 'or' bar
>     $      # at the end
>     /ox and print "yes\n";
> 
> I assume you've looked at perldoc perlre.

Also, the /o option is not required as there are no variables in the
regular expression.

perldoc perlop


John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 20 Apr 2004 07:27:16 GMT
From: "George Kinley" <georgekinley@hotmail.com>
Subject: Re: Perl is the answer?
Message-Id: <oh4hc.14373$g4.280371@news2.nokia.com>

I bet, OP Never tried it himself ,
helping him like this will be spoon feeding,
"Andries" <andries@zilz.nl> wrote in message
news:4d3880lph91adlhpds8sv0ndo4btcdb13s@4ax.com...
> Hello there,
>
> I hope someone can help me.
> This is my problem:
> I have a list of thousands and thousands of the next lines:
> ----------------------------------------------------------------------
> <a href="hs80.htm#halveringstijd"target="topic">halveringstijd</a><br>
> <a href="hs80.htm#hartkleppen" target="topic"></a><br>
> <a href="hs80.htm#hartvolume" target="topic"></a><br>
> <a href="hs80.htm#hemoglobine" target="topic"></a><br>
> <a href="hs80.htm#heteroseksueel " target="topic"></a><br>
> <a href="hs80.htm#hijgen" target="topic"></a><br>
> <a href="hs80.htm#histamine" target="topic"></a><br>
> --------------------------------------------------------------------------
------------
> I need to copy the word between the # and " and put it after the > and
> </a>
>
> It can done by hand like the first line but it can be automated with a
> perl script isn't it?
>
> If so I still have a problem can anyone tell me how?
>
>
> TIA
> Andries Meijer




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

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


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