[17350] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4772 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 31 06:10:34 2000

Date: Tue, 31 Oct 2000 03:10:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972990618-v9-i4772@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 31 Oct 2000     Volume: 9 Number: 4772

Today's topics:
        Operators for Tied hashes on NBDM_File and GDBM_File, p sajjidm@my-deja.com
        outgoing e-mails <bart@sonik.pl>
    Re: outgoing e-mails (Rafael Garcia-Suarez)
    Re: parsing a majordomo archive file (Clay Irving)
        Q on returning hashes from subroutines <Juergen.Lind@iteratec.de>
    Re: Q on returning hashes from subroutines nobull@mail.com
        read string from kybd <haf@autra.noXX>
    Re: read string from kybd <MiGuenther@lucent.com>
        rename and unlink fail <rkuhn@akicommunications.com>
    Re: rename and unlink fail (Clay Irving)
        reseting the $digit values <celliot@tartarus.uwa.edu.au>
    Re: Session or Sessionless? <bill.kemp@wire2.com>
        share variable between process <wiltam@singnet.com.sg>
        Socket not autoflush-ing? ActiveState 618 on NT (Ran Talbott)
        solution: installing Image::Magick to host as non-root  dtbaker_dejanews@my-deja.com
    Re: solution: installing Image::Magick to host as non-r (Sam Holden)
    Re: Unterminated <> operator? what the heck? oarend@my-deja.com
        urgent regex help <celliot@tartarus.uwa.edu.au>
    Re: urgent regex help <lr@hpl.hp.com>
    Re: urgent regex help <bart.lateur@skynet.be>
    Re: Using 'format' and 'write' multiple times? <streaking_pyro@my-deja.com>
        using regex to insert data <celliot@tartarus.uwa.edu.au>
    Re: using regex to insert data <MiGuenther@lucent.com>
    Re: using regex to insert data (Rafael Garcia-Suarez)
    Re: What about CGI.pm? <bart.lateur@skynet.be>
    Re: What about CGI.pm? <flavell@mail.cern.ch>
    Re: xchat script hassle solved <staeci@yahoo.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 31 Oct 2000 07:31:53 GMT
From: sajjidm@my-deja.com
Subject: Operators for Tied hashes on NBDM_File and GDBM_File, plus DB_File for AIX
Message-Id: <8tlsh9$4v3$1@nnrp1.deja.com>

I normally use the DB_File package for database manipulation and this
works fine for Berkley compatible Unixes.

However, I need to use a database on a non-Berkley compatible UNIX
(AIX). Perl for AIX does not seem to contain DB_File support, so I need
to use the GDBM_File or NDBM_File packages.

However, the "seq" method does not seem to be available in GDBM_File
and NDBM_File pacakages, and the Perl Reference does not seem to contain
any information on what methods, if any, are available or what I can use
instead of "seq".

Does anyone know where I may find detailed information on GDBM_File and
NDBM_File packages including all parameters valid on tie-ing hashes and
the methods available and their parameters.

Also, does anyone know if there is a version of DB_File which will work
on AIX?

Thanks in advance.

Regards,

Sajjid


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 08:33:30 +0100
From: "Bartosz Aninowski" <bart@sonik.pl>
Subject: outgoing e-mails
Message-Id: <8tlsl3$2i5$1@sunsite.icm.edu.pl>

I use RH 6.1 with sendmail.
I wonder if there is possiobilty to make some perl scripts to put copy of
outgoing e-mail to sql database.
Fg. 10 employees send e-mails and I want collect copy of each message in my
sql database in order to monitor history of their work.
Maybe you know aplication like that?
Bart




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

Date: Tue, 31 Oct 2000 08:08:34 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: outgoing e-mails
Message-Id: <slrn8vsvjc.jun.rgarciasuarez@rafael.kazibao.net>

Bartosz Aninowski wrote in comp.lang.perl.misc:
>I use RH 6.1 with sendmail.
>I wonder if there is possiobilty to make some perl scripts to put copy of
>outgoing e-mail to sql database.
>Fg. 10 employees send e-mails and I want collect copy of each message in my
>sql database in order to monitor history of their work.
>Maybe you know aplication like that?

You'll probably get better answers in comp.mail.sendmail. Followups
set.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: 31 Oct 2000 09:59:31 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: parsing a majordomo archive file
Message-Id: <slrn8vt603.84.clay@panix3.panix.com>

On Mon, 30 Oct 2000 21:33:25 GMT, allym@usa.net <allym@usa.net> wrote:

>I'm being lazy here, hoping someone else has invented this wheel
>already.
>
>With a mailing list I am interested in, I can get a monthly archive of
>old posts from the server.  This is one file, typically 2 mb in size,
>with 800 or so messages.  I'm interested in about two years worth of
>data, so 24 mb and 16000 messages or so.  The mailing list is produced
>by majordomo, and I imagine that the archive file I can receive is a
>standard feature of majordomo.
>
>I want a script that will take these monolithic monthly messages and
>parse them, creating web pages on the fly that will allow me to list
>all threads, expand threads to show all the messages, view a message,
>view the next message, skip to the next thread etc.
>
>I only have these archive files; I am just a subscriber to the list.  I
>have found a web site that allows me to send it my archive files and it
>will create the threaded interface; but I want this on my own web
>server on my own network, not on the internet (although I have
>unmetered internet access here in the UK, it's still slow; I have a
>spare machine with acres of disk space waiting for tasks like this, and
>I like to be in control ;-).
>
>Seems that someone else might have done this before; has anyone got any
>pointers as to where to look?

Check http://www.perl.com/reference/query.cgi?mail

-- 
Clay Irving <clay@panix.com>
Advertising copy. Where sentences are replaced by participle phrases. Noun
phrases. And dangling conjunctions.  Bleah. 
- K<bob> 


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

Date: Tue, 31 Oct 2000 09:29:12 +0100
From: =?iso-8859-1?Q?J=FCrgen?= Lind <Juergen.Lind@iteratec.de>
Subject: Q on returning hashes from subroutines
Message-Id: <39FE82D8.D802C24C@iteratec.de>


--------------FBE69C1EEF499AECEB8D7719
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hi,

I have the following situation in my program:

package A;

use strict;
use warnings;

sub new{
 ...
  my %mappings;
  $self->{mappings} = \%mappings;
 ...
}

sub mappings{

  my $self = shift;
  return %{$self->{mappings}};
}

Now, when I try:

 ...
my $shortcut;

foreach $shortcut (sort keys $map->mappings()){
   print "$shortcut => $h{$shortcut}{description}\n";
  }

I get the following error message:

Type of arg 1 to keys must be hash (not subroutine entry) at ...

wheras

my %h = $map->mappings();
my $shortcut;

foreach $shortcut  (sort keys %h){
   print "$shortcut => $h{$shortcut}{description}\n";
  }


works fine... I was trying to figure out how to reformulate the first
solution in order
to avoid the temporary variable but I couldn't find out how to do it...
Any help for me out there?

regards

Jürgen

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

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi,
<p>I have the following situation in my program:
<p><tt>package A;</tt><tt></tt>
<p><tt>use strict;</tt>
<br><tt>use warnings;</tt>
<p><tt>sub new{</tt>
<br><tt>...</tt>
<br><tt>&nbsp; my %mappings;</tt>
<br><tt>&nbsp; $self->{mappings} = \%mappings;</tt>
<br><tt>...</tt>
<br><tt>}</tt><tt></tt>
<p><tt>sub mappings{</tt>
<br><tt>&nbsp;</tt>
<br><tt>&nbsp; my $self = shift;</tt>
<br><tt>&nbsp; return %{$self->{mappings}};</tt>
<br><tt>}</tt>
<p>Now, when I try:<tt></tt>
<p><tt>...</tt>
<br><tt>my $shortcut;</tt><tt></tt>
<p><tt>foreach $shortcut (sort keys $map->mappings()){</tt>
<br><tt>&nbsp;&nbsp; print "$shortcut => $h{$shortcut}{description}\n";</tt>
<br><tt>&nbsp; }</tt><tt></tt>
<p>I get the following error message:
<p><tt>Type of arg 1 to keys must be hash (not subroutine entry) at ...</tt>
<p>wheras<tt></tt>
<p><tt>my %h = $map->mappings();</tt>
<br><tt>my $shortcut;</tt><tt></tt>
<p><tt>foreach $shortcut&nbsp; (sort keys %h){</tt>
<br><tt>&nbsp;&nbsp; print "$shortcut => $h{$shortcut}{description}\n";</tt>
<br><tt>&nbsp; }</tt>
<br><tt></tt>&nbsp;<tt></tt>
<p>works fine... I was trying to figure out how to reformulate the first
solution in order
<br>to avoid the temporary variable but I couldn't find out how to do it...
<br>Any help for me out there?
<p>regards
<p>J&uuml;rgen</html>

--------------FBE69C1EEF499AECEB8D7719--



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

Date: 31 Oct 2000 08:31:47 +0000
From: nobull@mail.com
Subject: Re: Q on returning hashes from subroutines
Message-Id: <u97l6ptk4h.fsf@wcl-l.bham.ac.uk>

Jürgen Lind <Juergen.Lind@iteratec.de> writes:

> Subject: Q on returning hashes from subroutines

perldoc perlsub/"Pass by Reference"

> my %h = $map->mappings();
> foreach $shortcut  (sort keys %h){

> works fine... I was trying to figure out how to reformulate the
> first solution in order to avoid the temporary variable but I
> couldn't find out how to do it...

You can use an anonymous temporary hash:

foreach $shortcut (sort keys %{{$map->mappings()}}){

Of course it would probably be better to modify $map->mappings() to
return a hashref rather than a flattened hash.  For details see the
manual section I refer to above.

> --------------FBE69C1EEF499AECEB8D7719
> Content-Type: text/html; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> 
> <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
> <html>

This is a plain text only newsgroup.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 31 Oct 2000 10:07:48 +0100
From: "P.Eftevik" <haf@autra.noXX>
Subject: read string from kybd
Message-Id: <39FE8BE4.1346E15E@autra.noXX>

I'm looking for a getstr() or something that reads a string  from
keyboard.
getc() takes only single chatacter, and read() seems to want fixed
length.
Is there a trick for me here ?

Any hint appreciated,
Pefte






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

Date: Tue, 31 Oct 2000 10:30:43 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Re: read string from kybd
Message-Id: <8tm3f7$lgh@nntpb.cb.lucent.com>

Have you ever tried  the STDIN Filehandle

 $var = STDIN;
or
$var = <STDIN>;

one of these should work on a Unix box for sure
waits until \n




P.Eftevik wrote in message <39FE8BE4.1346E15E@autra.noXX>...
>I'm looking for a getstr() or something that reads a string  from
>keyboard.
>getc() takes only single chatacter, and read() seems to want fixed
>length.
>Is there a trick for me here ?
>
>Any hint appreciated,
>Pefte
>
>
>
>




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

Date: Tue, 31 Oct 2000 00:27:21 -0500
From: Ryan Kuhn <rkuhn@akicommunications.com>
Subject: rename and unlink fail
Message-Id: <B623C269.5CA%rkuhn@akicommunications.com>

I have a set of files, readable and writeable to every user and I use rename
and unlink with them in my perl cgi script, run by apache. Both of those
functions fail to work, yet I can modify those files and create new ones
within this script.

What else can I do

Thanks
Ryan



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

Date: 31 Oct 2000 10:05:23 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: rename and unlink fail
Message-Id: <slrn8vt6b3.84.clay@panix3.panix.com>

On Tue, 31 Oct 2000 00:27:21 -0500, Ryan Kuhn <rkuhn@akicommunications.com> 
wrote:

>I have a set of files, readable and writeable to every user and I use rename
>and unlink with them in my perl cgi script, run by apache. Both of those
>functions fail to work, yet I can modify those files and create new ones
>within this script.

Readable and writeable by *every* user? -- Does that include nobody?

You don't mention what is the failure -- That might be a clue.

You also fail to mention if the program works correctly from the command
line -- If so, that's an FAQ.

-- 
Clay Irving <clay@panix.com>
As soon as questions of will or decision or reason or choice of action
arise, human science is at a loss. 
- Noam Chomsky 


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

Date: Tue, 31 Oct 2000 17:44:17 +0800
From: "Cam" <celliot@tartarus.uwa.edu.au>
Subject: reseting the $digit values
Message-Id: <39fe94db$0$25568@echo-01.iinet.net.au>

I have a regex inside a loop after another regex outside the loop.
Inside the loop the values of $1....  are the ones from the regex used
before outside the loop.
Can I reset these values or over ride them somehow?

This is what I have

$content =~
/(.*?\\$rtf_key_ref->[15].*?\\$rtf_key_ref->[15].*?\\$rtf_key_ref->[14].*?)(
\\cell.*?\\row.*?)(\\cell.*)/s;
 $beg = $1;
 $mid = $2;
$end = $3;

  for ($i=0;$i<1;$i++)
       {
    $mid =~
/(.*?)(\\cell[\s\\].*?)(\\cell[\s\\].*?)(\\cell[\s\\].*?)(\\cell[\s\\].*?)(\
\cell[\s\\].*)/;
   $temp2 .=
$1.$2.$summary_ref->{'BUF'}[$i][0].$3.$summary_ref->{'BUF'}[$i][1].$4.$summa
ry_ref->{'BUF'}[$i][2].$5.$summary_ref->{'BUF'}[$i][3].$6;
    }

The values in the $1, $2  inside the loop are from the first regex.
What can I do??

--

cheers
cam
-------------------------------





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

Date: Tue, 31 Oct 2000 10:33:58 -0000
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: Session or Sessionless?
Message-Id: <972988769.2536.0.nnrp-03.c3ad6974@news.demon.co.uk>

> Is
>Perl capable of sessions in a browser interface? If so, how?


Surely its a question of server-browser interaction.
Which might get called a CGI question-But java serverlets and mod_perl
aren't CGI ().

Does Java do some sort of magic server-browser interaction that I am not
aware of?

Other than that its the hidden field, query string, or cookie stuff.
(hopefully with most session information in a database)
The mod_perl "eagle" book talks about this, and some of the ideas can be
used in standard perl or be applied to other languages.

>
>This seems to be the biggest issue with the shop's two factions.


Oh for a bit of peace and understanding in the world.  Do you have a barbed
wire line  in the office yet?




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

Date: Tue, 31 Oct 2000 18:51:23 +0800
From: Wilson Tam <wiltam@singnet.com.sg>
Subject: share variable between process
Message-Id: <39FEA42B.3A74F1BE@singnet.com.sg>

Hi,

Does anyone know now to create a variable which can be shared between
different perl process. I have downloaded the IPC-Shareable-0.52 but
can't install on my linux machine running 2.2.15. 'make test' failed.

Or does anyone know how to increase the SHMMAX size on Linux?

Thanks.
Wilson


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

Date: 31 Oct 2000 06:23:48 GMT
From: ran@nuvation.com (Ran Talbott)
Subject: Socket not autoflush-ing? ActiveState 618 on NT
Message-Id: <8tlohk$16j$1@news.mainstreet.net>

Running ActiveState build 618 on NT 4.0 with SP6,  I did a cut-and-paste of 
the "simple client" and "simple server" from the perlipc man page to try 
out socket programming.  I commented out the "Command?" prompt in the 
server so I wouldn't have to modify the client to use sysread.

I can start the server,  and telnet to "localhost 9000" to talk to it (it 
works both with and without the prompt commented out).

If I try to run the simple client,  it connects correctly,  but stalls the 
first time I type in a line of text to send to the server.  By adding a 
couple of print statements before and after it,  I confirmed that the 
client is hung in the print to the socket.

I've tried three different ways of setting autoflush on the socket:

    autoflush $handle 1;
    $handle->autoflush(1);
    select($handle); $| = 1; select(STDOUT);

It made no difference.  I also tried swapping the parent and child roles in 
case there was something odd about the fork() emulation on NT,  to no 
avail.  I tried adding various combinations of CR and LF to the input line 
before sending it.  I even tried changing the print to a send because I'd 
seen warnings about earlier versions of ActiveState not properly supporting 
sockets as filehandles.

If I terminate the client with Ctrl-Break,  the server socket read 
unblocks,  and it sees all the data sent by the client.

If I terminate the server,  the client socket write completes,  and (since 
it's not checking for errors) the client continues normally.

If someone has gotten the samples working on an earlier version of 
ActiveState,  or can suggest a workaround I haven't thought of,  I'd 
greatly appreciate hearing about it.

Thanks,

Ran



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

Date: Tue, 31 Oct 2000 05:40:27 GMT
From: dtbaker_dejanews@my-deja.com
Subject: solution: installing Image::Magick to host as non-root user
Message-Id: <8tlm0b$88$1@nnrp1.deja.com>

First.... many, many thanx to Bob Friesenhahn, Martien Verbruggen et al.
for having the patience to help me thru my personal install hell. In
exchange for all the help. I thought I would post the process I finally
used that worked. I consider my needs "typical" for a webdesigner using
perl, so there must be plenty of people would will benefit by this info.

I needed to do an install of Image::Magick to my remote ISP domain host,
but they didnt want to install it at the root level. So, I had to
install to my webspace. Many modules install easily using perl -MCPAN -e
shell in a telnet window, but Image::Magick is not one of them! You
should NOT attempt to use CPAN for this module, it will only mess you
up. Just read along and follow the steps...

You MUST install ImageMagick before you can use PerlMagick, so dont even
bother trying to install Image::Magick with CPAN. goto
http://www.imagemagick.org  or ftp://ftp.cdrom.com/pub/ImageMagick/ and
download the full deal. something like: ImageMagick-5_2_4_tar.gz

upload the .gz to your webspace, probably under cgi-bin. This example
uses a long path, but it is what I actually had to work with. I uploaded
to my domain at /home/normsgallery/www/admin/cgi-bin

fire up a telnet shell to your domain, and :

        $ cd /home/normsgallery/www/admin/cgi-bin
        $ gzip -d ImageMagick-5_2_4_tar.gz
        $ tar -xof ImageMagick-5_2_4_tar
        $ cd ImageMagick-5.2.4

In the configuration step, I disabled a lot of stuff I know I dont need
in this site. I will only be working with .jp and .gif and wanted a
small install so I used the shared libs, etc, etc. You can review these
settings, but the important one is the --prefix and --without-perl

        $ configure CFLAGS=-O2
--prefix=/home/normsgallery/www/admin/cgi-bin
--without-perl --disable-static --enable-shared --with-modules
--without-magick_plus_plus --without-bzlib --without-dps --without-fpx
--without-hdf --without-lcms --without-jbig --without-png --without-tiff

        $ make
        $ make test
        $ make install

        $ cd PerlMagick
        $ perl Makefile.PL PREFIX=/home/normsgallery/www/admin/cgi-bin
        $ make
        $ make test
        $ make install

then you can cleanup a little:

        $ cd /home/normsgallery/www/admin/cgi-bin
        $ rm ImageMagick-5_2_4_tar

your perl scripts will now need a lines like these to work:

        use lib
"/home/normsgallery/www/admin/cgi-bin/lib/perl5/site_perl/5.005/i386-lin
ux"
;
        use Image::Magick ;

thats it!
- Dan


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 31 Oct 2000 06:42:01 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: solution: installing Image::Magick to host as non-root user
Message-Id: <slrn8vsqdp.710.sholden@pgrad.cs.usyd.edu.au>

On Tue, 31 Oct 2000 05:40:27 GMT,
	dtbaker_dejanews@my-deja.com <dtbaker_dejanews@my-deja.com> wrote:
>
>        $ perl Makefile.PL PREFIX=/home/normsgallery/www/admin/cgi-bin

I suspect it would be wiser to install somewhere other than off your cgi-bin.

PerlMagick could install some executables (I doubt it does, but as a general
principle) which aren't meant to be CGI programs and could open up some
security holes...

Since it's done now, the paranoid part of me would .htaccess (or equivalent)
off the lib/perl5 subdirectory so that the web server won't allow access.


By the way, I for one think it's good when people post as you have.. much better
than the 'solved now don't worry' posts that don't helpt he next person.



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

Date: Tue, 31 Oct 2000 08:30:43 GMT
From: oarend@my-deja.com
Subject: Re: Unterminated <> operator? what the heck?
Message-Id: <8tlvvj$85r$1@nnrp1.deja.com>

Thanks guys,

there were two mistakes:

- one ) missing in the end
- $obj{'jahr'} < $param{'jahr'} should have been $obj... = $param,
otherwise it would have been the exact same comparison twice

Now it works just as it's supposed to!

Oliver


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 15:09:45 +0800
From: "Cam" <celliot@tartarus.uwa.edu.au>
Subject: urgent regex help
Message-Id: <39fe709d$0$25557@echo-01.iinet.net.au>

I have the following problem which I need to solve urgently.  I have tried
it myself and have been stuck for quite a while now.

I am trying to split a string into 3 seperate strings as follows:

first
split just before the first occurance of $var2 after the second occurance of
$var1.

second
split just before the first occurance of $var2 after the first occurance of
$var3.
note that $var2 occurs frequently throughout the string.

third
all the rest

This is what I have tried:

$content =~ /(.*$var1.*$var1.*)($var2.*$var3.*)($var2.*)/s;

but obviously doesn't work

any suggestions please..


--

cheers
cam
-------------------------------




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

Date: Tue, 31 Oct 2000 00:33:24 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: urgent regex help
Message-Id: <MPG.146823afd8f8d6de98ae87@nntp.hpl.hp.com>

In article <39fe709d$0$25557@echo-01.iinet.net.au>, 
celliot@tartarus.uwa.edu.au says...
+ I have the following problem which I need to solve urgently.  I have
+ tried it myself and have been stuck for quite a while now.
+ 
+ I am trying to split a string into 3 seperate strings as follows:
+ 
+ first
+ split just before the first occurance of $var2 after the second
+ occurance of $var1.
+ 
+ second
+ split just before the first occurance of $var2 after the first
+ occurance of $var3.
+ note that $var2 occurs frequently throughout the string.
+ 
+ third
+ all the rest
+ 
+ This is what I have tried:
+ 
+ $content =~ /(.*$var1.*$var1.*)($var2.*$var3.*)($var2.*)/s;
+ 
+ but obviously doesn't work
+ 
+ any suggestions please..

1.  Replace each of your '.*' except the last one by '.*?'.  Read about 
non-greedy matching in perlre.

2.  If any of the substitutions may contain a regex metacharacter, 
surround it by \Q and \E or use quotemeta().

3.  If the substitutions never change during execution, add the /o 
modifier for efficiencty, or use qr// for quoting.

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


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

Date: Tue, 31 Oct 2000 09:04:24 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: urgent regex help
Message-Id: <eh2tvsc62sorn1blllbblilkcp6lq7en53@4ax.com>

Cam wrote:

>This is what I have tried:
>
>$content =~ /(.*$var1.*$var1.*)($var2.*$var3.*)($var2.*)/s;
>
>but obviously doesn't work

Perhaps try nongreedy matching: put a question marks directly after each
star, except for the last one. Oh, and you might want to anchor the
regex. It will return much faster in case of failure.

	$content =~/^(.*?$var1.*?$var1.*?)
	  ($var2.*?$var3.*?)($var2.*)$/sx;

I'v had to split the regex, that's why I use the /x modifier (ignore
whitespace).

And be aware of meta characters: if $var1, $var2 or $var3 contain for
example '.', '+' or '*', then the whole thing won't work. Put a "\Q"
just before each var and "\E" right after it, to fixthat.

	$content =~/^(.*?\Q$var1\E.*?\Q$var1\E.*?)
	  (\Q$var2\E.*?\Q$var3\E.*?)(\Q$var2\E.*)$/sx;

   HTH,
   Bart.


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

Date: Tue, 31 Oct 2000 06:08:14 GMT
From: R.Joseph <streaking_pyro@my-deja.com>
Subject: Re: Using 'format' and 'write' multiple times?
Message-Id: <8tlnkb$1a0$1@nnrp1.deja.com>

In article <slrn8vse45.p9p.tjla@thislove.dyndns.org>,
  tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:
> I was shocked! How could R.Joseph <streaking_pyro@my-deja.com>
> say such a terrible thing:
> >
> >The really odd thing is that I get the output from the while loop -
> >that works just fine, but all I get from the format above it is a
> >single carriage return!  Please help, I can't figure this out!
Thanks!
>
> Stupid question: does $data have anything in it? You don't ever seem
to
> write to it (or $from_file for that matter). It might be a good idea
to
> post the real code.

That was just psuedo-code to show what was happening - if it helps,
PRETEND there is something very very important in thoose varibles that
will get printed.

The real code is much longer than that...I was just trying to show the
general flow and structure of things to see if some nice person could
help me - not make fun of me.

Thanks.

--
R.Joseph


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 31 Oct 2000 17:12:21 +0800
From: "Cam" <celliot@tartarus.uwa.edu.au>
Subject: using regex to insert data
Message-Id: <39fe8d56$0$25562@echo-01.iinet.net.au>

I have another problem, which I am unable to answer.

I need to search a string and each time $var1 occurs, insert an element from
an array in front of it, incrementing the array after each successful
insertion.



--

cheers
cam
-------------------------------





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

Date: Tue, 31 Oct 2000 10:38:26 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Re: using regex to insert data
Message-Id: <8tm3tj$lha@nntpb.cb.lucent.com>

Try
%search =~s/$var/$array[$number].$var/

means replace it with our Array element and itself

Michael


Cam wrote in message <39fe8d56$0$25562@echo-01.iinet.net.au>...
>I have another problem, which I am unable to answer.
>
>I need to search a string and each time $var1 occurs, insert an element
from
>an array in front of it, incrementing the array after each successful
>insertion.
>
>
>
>--
>
>cheers
>cam
>-------------------------------
>
>
>




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

Date: Tue, 31 Oct 2000 09:44:35 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: using regex to insert data
Message-Id: <slrn8vt57e.k65.rgarciasuarez@rafael.kazibao.net>

Cam wrote in comp.lang.perl.misc:
>I have another problem, which I am unable to answer.
>
>I need to search a string and each time $var1 occurs, insert an element from
>an array in front of it, incrementing the array after each successful
>insertion.

If I understand correctly, this solves your problem :
$string is your string, @array is your array (which is left unchanged).

  my $i = 0;
  $string =~ s/($var1)/$array[$i++]$1/g;

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Tue, 31 Oct 2000 09:09:43 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What about CGI.pm?
Message-Id: <k03tvsg00do73jbp98r4srgjj3btlh3cen@4ax.com>

Jeff Zucker wrote:

>  #!/usr/local/bin/perl
>  use Benchmark;
>  Benchmark::timethis( 100,
>     sub { do 'CGI.pm'; my $q=new CGI; print $q->header; }
>  );

That wonb't help much. It will read the module from file ONCE, and
compile/execute it 100 times. After the first time, the file is in a
disk buffer, so loading will be mluch faster. And yes, it's that
*reading from disk* of the 200k source that is much of the overhead.

-- 
	Bart.


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

Date: Tue, 31 Oct 2000 11:20:56 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: What about CGI.pm?
Message-Id: <Pine.GHP.4.21.0010311119440.21195-100000@hpplus03.cern.ch>

On Mon, 30 Oct 2000 fallenang3l@my-deja.com blurted out:

> Thank you for your CONSTRUCTIVE criticism... NOT!!!

Some people just won't be helped.  You realise of course that you're
now in the scorefiles/killfiles of many of the people who could be of
real use to you.

bye.



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

Date: Tue, 31 Oct 2000 08:04:02 GMT
From: "Darrin Mison" <staeci@yahoo.com>
Subject: Re: xchat script hassle solved
Message-Id: <S1vL5.6217$Tq6.58673@news-server.bigpond.net.au>

Nothing wrong with it.  made a mistake earlier and the nick
had a : stick in front of it!!!!  doh!!!!

In article <dkdL5.4490$Tq6.49324@news-server.bigpond.net.au>, "Darrin
Mison" <staeci@yahoo.com> wrote:

> I want a script which will trigger when somoneone types  in a key phrase
> and then sends them a file.
> 
> I can get it to do everything but the file gets queued at my end and
> never even shows its face at the other user's end.
> 
> I assume that there is something wrong with my use of /dcc  but I'm
> damned if I can figure it out.  Help please.
> 
> if ($msg eq "fetch")
>    {
> #    IRC::command("test return ".$nick); # just to test if trigger
> working
>       IRC::command("/dcc send $nick $file");
>    }


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4772
**************************************


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