[15941] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3354 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 14 11:05:33 2000

Date: Wed, 14 Jun 2000 08:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <960995109-v9-i3354@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 14 Jun 2000     Volume: 9 Number: 3354

Today's topics:
        [Q] clarifications on [@array_name] + some MIME::Lite mitiste@charlie.iit.edu
    Re: A Question? Net::Ping not returning anything? tiny  <tfm@sei.cmu.edu>
        calculating date differences sumera.shaozab@lmco.com
    Re: Dumb question.. How to prompt the user and get the  <mattking@techie.com>
    Re: Easy CGI question <flavell@mail.cern.ch>
    Re: Easy CGI question <dan@tuatha.sidhe.org>
    Re: evaluating expressions <dan@tuatha.sidhe.org>
    Re: Generating an excel page by submitting a form <Peter.Dintelmann@dresdner-bank.com>
    Re: Gif creation on the fly (Steve Harvey)
    Re: How to check browser for Javascript enable? (Eric Bohlman)
    Re: Larry Rosler interview on perl.com! <dan@tuatha.sidhe.org>
        Non echo password <rpearson@quebectel.com>
        NT vs Unix detection <lwaibel@cwia.com>
    Re: NT vs Unix detection (Rafael Garcia-Suarez)
    Re: Opening a file for realtime monitoring <billy@arnis-bsl.com>
        Perl Search |more option <jimmy@blackhole-designs.com>
    Re: perl system call problems, VSS cmd line <p.brouwer@prevalent.nl>
    Re: Phonetic searching - Any Examples? <guy@firstcreative.com>
    Re: Problem with regexp (Rafael Garcia-Suarez)
    Re: Problem with regexp <trevor@trevorsky.com>
    Re: Problem with regexp (Eric Bohlman)
    Re: Problem with regexp <trevor@trevorsky.com>
        Script to calculate a future date? <news@hertell.remove.t_h_i_s.com>
    Re: Script to calculate a future date? <mike.solomon@eps.ltd.uk>
    Re: Threads vs Forks (Greg Bacon)
        trouble installing manpages <lsloan@bigfoot.com>
        Up-to-date Perl for OS/2? <pds@x-datcon.co.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Jun 2000 08:50:32 -0500
From: mitiste@charlie.iit.edu
Subject: [Q] clarifications on [@array_name] + some MIME::Lite
Message-Id: <r03fkssu517jucu8gm6rof03s1obtvipdb@4ax.com>

	I have been trying to debug a problem with an email program,
(using MIME::Lite), and the only thing left for me to check is the
proper creation of a list of recepients. I don't have much knowledge
about Perl, but I thought the following process was fine:
- open a file where all the recipient addresses are listed one/line;
- feed an array with each line, if it matches the proper format, i.e.
while ($line = <MYFILE>)
# ....... other things
	if ($line =~ m/^.*@.*/)
		{
			@recipient = (@recipient,$line);
# ........ other things
- use the array created above, as follows:
	$mime = new MIME::Lite(From => $whatever_sender,
				To => [@recipient],
				Subject => $subject,
				Data => $message);
	MIME::Lite->send('smtp', 'myserver', Timeout=>300);
	$mime->send;

	And here is what's happening: the message goes ONLY to the
first person listed in the @recipient array, all the others never
getting it, but SHOWING UP in the To: list upon email receival by the
first one.
	On the sdame note - I started reading Chapter 4 of Programming
Perl, but I don't think I quite got the grasp of the [@whatever_array]
thing - would anybody care to explain the mechanism of "unrevaling"
the list into the MIME::Lite ... To=> portion? Am I really getting a
comma delimited list the way the MIME::Lite expects it? Can I get rid
of reference in some way?

	TIA,
	Stef

P.S. somebody was kind enough to suggest me some improvements (e.g.
using push, instead of @recipient = (@recipient,$line)), and I
appreciate such advises, but my main focus right now is figuring out
why only the first in a llist gets the message. Thx.





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

Date: Wed, 14 Jun 2000 09:31:48 -0400
From: Ted Marz <tfm@sei.cmu.edu>
Subject: Re: A Question? Net::Ping not returning anything? tiny sample program.
Message-Id: <39478944.A3892BC9@sei.cmu.edu>

I looked into this just last week.  Here's what I found.

It seems (at least on a RedHat 6.2 system with perl 5.5.3 and an
augmented libwww (not from the rpm distribution) that a "dot" notation
ip address does not resolve.

If you look at the source for Net::Ping, you will see that it is trying
to resolve this address using inet_aton(), and for some bizarre reason,
inet_aton is returning undef, rather that a packed ip address structure
containg the "dot" notation address.

I have not yet bothered to figure out why this is so.

If you use a host name, rather that a "dot" notation address, it seems
to work.

You should also be able to convert the "dot" notation address into a
packed IP address, and use the ping_udp, ping_icmp, or ping_tcp
interfaces directly.
I, however, haven't been able to make this work either.

If anyone knows WHY this is happening, I'd love to know.

Ted Marz


Robert Chalmers wrote:
> 
> I'm trying to figure why the following code doesn't return anything?
> No errors, nothing. The ip is the machine it's running on. ??
> Does anyone have any ideaas please?
> thanks
> Robert
> ...................................
> #!/usr/local/bin/perl -w
> $host = '203.1.96.6';
> 
> use Net::Ping;
> 
>     $p = Net::Ping->new();
>     print "$host is alive.\n" if $p->ping($host);
>     $p->close();
> ..................................


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

Date: Wed, 14 Jun 2000 14:11:47 GMT
From: sumera.shaozab@lmco.com
Subject: calculating date differences
Message-Id: <8i83qj$shc$1@nnrp1.deja.com>

Hello,

I am trying to calculate the current date with the date from last week,
last month etc...and find the difference in days.  I looked into the
perl manip:date module but learned that it was not efficient since I
will be calculating thousands of dates.  What do you recommend I should
do?

Sumera


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


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

Date: Wed, 14 Jun 2000 15:41:21 +0200
From: "Matt King" <mattking@techie.com>
Subject: Re: Dumb question.. How to prompt the user and get the input.
Message-Id: <8i827n$d0p$1@news1.transmedia.de>

You mean section 5 of perlfaq8, not section 5 of the FAQ. Anyway, I already
used this. I even posted it above. I _do not_ want to use add-ins/add-ons.
If Perl can't do this nativly, then it's time to reinspect the code. I can't
think of any programming language that does not have the ability to do it
nativly. This is, to me, a MAJOR weekness in Perl (the inability to preform
simple basic tasks). Don't get me wrong, I think Perl is an excelent
language. It's easer to learn, although a bit cryptic at times, then the
other languages. But if it doesn't have the basic functionality that other
languages do, how can one defend it?

So, let me pos this question again, I'll let you wizards answer it. NO, I'M
NOT TROLLING.

Does Perl have a native way to get a single key stroke without the use of
additional modules, like the C getch() routine? This is a simple question,
and I'm only looking for a simple answer. Like: No, Perl can't handle
something as basic as press any key to continue, or press Y/N to answer the
questions. Or, Yes, this is the way you would do it on Active Perl for
Win32, note that it will not work on other platforms.

Is it that hard to answer this question?!

Matt
"Tom Phoenix" <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.10.10006130837500.18837-100000@user2.teleport.com...
> On Tue, 13 Jun 2000, Matt King wrote:
>
> > without using any ad-ins, how can I get a single key stroke with
> > Active Perl on a Windows platform?
>
> Does section five of the FAQ answer your question? Some of the suggested
> ways use add-ons, but no ad-ins! :-)
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
>




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

Date: Wed, 14 Jun 2000 15:13:34 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Easy CGI question
Message-Id: <Pine.GHP.4.21.0006141459000.26251-100000@hpplus03.cern.ch>

On Tue, 13 Jun 2000, Godzilla! wrote:

> Eric Bohlman wrote:

> > Unless the script is running NPH, it's outputting CGI headers, not HTTP
> > headers, and the CGI spec allows bare linefeeds. 

> I can verify what you say to be absolutely correct, Mr. Bohlman.

Oh dear. With friends like this, [...]

> Almost all of my programs are non-parsed header cgi programs.
> Some are standard cgi programs. Regardless, I use bareline
> \n\n for content type, location... Works perfect and, you 
> are precisely and exactly right, nph or not.

In case anyone was misled at a cursory reading, they might want to
re-read that exchange.  Action replay: EB was correct; then the troll
pretended to agree with him by misrepresenting what he had said.

And now I have been trolled too.  But the CGI specifications still say
what they say, irrespective that in some cases wrong coding will still
give the lucky impression of working.

See perldoc perlport (in relation to programming newlines for sockets,
which is quite relevant to what's going on here), and the code in
CGI.pm which computes an appropriate value for $CRLF.

Troll away.

-- 
         "A piece of shh...eer spin" - bbc political commentator 



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

Date: Wed, 14 Jun 2000 14:53:35 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Easy CGI question
Message-Id: <P%M15.471$Zg4.3056@news1.rdc1.ct.home.com>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote:

> I can verify what you say to be absolutely correct, Mr. Bohlman.
> Doesn't matter if you are running straight cgi or nph-cgi.
> Almost all of my programs are non-parsed header cgi programs.
> Some are standard cgi programs. Regardless, I use bareline
> \n\n for content type, location... Works perfect and, you 
> are precisely and exactly right, nph or not.

This is incorrect. The headers sent to the browser from the server must
have carraige return linefeed pairs to be correct, per the HTTP spec and
RFCs. Many browsers are tolerant of this incorrect behaviour because so
many servers to it, but it doesn't make things any more correct.

If your server preprocesses what you send and fixes up the line endings,
great. If the data from your program gets sent out without any
processing, then bare linefeeds are wrong.

This is not, however, a perl issue, so I'll leave it be.

					Dan


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

Date: Wed, 14 Jun 2000 14:58:43 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: evaluating expressions
Message-Id: <D4N15.473$Zg4.3056@news1.rdc1.ct.home.com>

Godzilla! <godzilla@stomp.stomp.tokyo> wrote:
> Your name wrote:
>  
>> The code
>> $w="10+3*x-x**2";
>> $w=~s/x/1/g;
>> print $w;
>  
>> outputs
>> 10+3*1-1**2
>  
>> How to get this calculated to 12 please?

> Mr. Name, change your sequence of events
> and change your syntax. No problem!

Solving a different problem doesn't do this poster any good. The answers
you posted had nothing to do with what was asked.

The correct answer here is to use string eval.

print eval $w;

should do it.

					Dan


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

Date: Wed, 14 Jun 2000 16:51:18 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: Generating an excel page by submitting a form
Message-Id: <8i864f$3sn1@intranews.dresdnerbank.de>

Hi,

>I'd like to place like a button an a html page that when clicked
>generates a excel file. I once did this on an Oracle web server:
>I simply created a form that once submited generated and
>returned a file with a csv extention so that excel and not the
>browser would open it. How can the same thing be done on an IIS
>web server. Any idea is welcome. Thanks.

    same procedure with Perl. Set the appropriate
    content-type (I am not sure but I guess it is
    'Content-type: application/ms-excel') and generate
    your output with tabs (\t) separated.

        print "Content-type: application/ms-excel\n\n";
        print "1\t2\t3\n";
        print "4\t5\t\6";

should do the job in a CGI script. Data handling is a client side
issue (opening Excel, displaying the table). Generating the data
in the appropriate format is a job to be done on the server.

Regards,

    Peter Dintelmann







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

Date: 14 Jun 2000 14:59:31 GMT
From: steveharvey@geocities.com (Steve Harvey)
Subject: Re: Gif creation on the fly
Message-Id: <slrn8kf7ej.bg6.steveharvey@itc001472.usitc.gov>

In article <8i7tvu$nt8$1@nnrp1.deja.com>, phool@my-deja.com wrote:
>How to creat 2d graph using GifGraph perl module? Any other solution for
>plotting 2d graph in perl. I want to write a cgi program which takes
>data from a data file and plot a graph in any image format.


I've done dynamically generated graphs with the Perl::Magick module,
which provides an interface to the ImageMagick utility.

Perl::Magick includes a variety of basic drawing + image manipulation
tools, and it can read & write a variety of file formats.  The
downside is that I found its performance on the slow side for any
complex tasks, and sort of buggy as well (although the line between
"buggy" and "poorly documented" is sometimes a fine one...)

I saw another neat approach recently: a web page which displayed a
dynamically generated bar graph by making each column of the graph a
cell in an HTML table.  The bar itself was actually a GIF of a single
red pixel which was scaled to an appropriate size (i.e. print "<img
src="red.gif" width=50 height=$sales{august}>").  Simple but clever.



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

Date: 14 Jun 2000 14:21:38 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: How to check browser for Javascript enable?
Message-Id: <8i84di$1tr$1@slb6.atl.mindspring.net>

W Kemp (bill.kemp@wire2.com) wrote:
: I guess from this there is a way, but you don't recommend it.
: Where would I find the information on this.
: 
: I know pages shouldn't rely on Javascript, but those who run projects don't
: always agree on this, at least if I could detect if javascript was not
: available I could warn them as to why things weren't working..

I guess those of us who have been trying to tell you the same thing 
haven't been altogether clear.

The main point is that you need to do server-side validation of the form
input *regardless* of whether the user's browser supports JavaScript, for
the simple reason that someone could potentially take your HTML+JS form,
modify it to allow something that it shouldn't, and then submit corrupted
data to your script.  You can *never* completely trust *anything* on the
client side.  This isn't a case where relying on JavaScript winds up
excluding a certain percentage of visitors; it's a case where relying on
JavaScript alone allows people to corrupt your data. 

NOW, once you realize that you have to do server-side validation in all
cases, you can, and probably should, *still* use JavaScript *as a
convenience to the user* to save users with JS enabled from having to make
a round trip to the server if they enter invalid data.  And you don't have
to worry about providing separate JS/non-JS pages.  You simply send out
the same page to all visitors.  Someone who makes a mistake with JS
enabled will have it caught before the form is submitted.  Someone who
makes a mistake with JS disabled will have it caught server-side when he
submits the form.  And someone who maliciously hacks the form will also
have it caught when he submits it. 



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

Date: Wed, 14 Jun 2000 14:44:40 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <sTM15.469$Zg4.3056@news1.rdc1.ct.home.com>

Drew Simonis <care227@attglobal.net> wrote:
> Henry wrote:
>> 
>> And I reply (again) that it's the _lack_ of approachable documentation
>> (documentation that newbies can comprehend) that ships with the standard
>> distribution that's got my goat.
>> 

> I am failing to see this point.  I appologize if my thick headedness 
> comes into play, but I count myself among the newbies.  I am a 
> programmer by hobby only.  I am not an educated programmer (my degrees
> are in political science and foreign policy) or a professional one.
> I just _like_ Perl.  I am that neophyte you speak of, and I have 
> found the majority of the documents to be _very_ approachable.  

Like all documentation, the stuff in the perl kit is written in the style
the authors find comfortable. If that style works for you then you're in
great shape, and things come easy. If it's a style that doesn't work for
you, then you'll end up fighting the docs all the way. Perl's no different
in this regard than any other programming language, though it does suffer
from the problem of being significantly different than many other
languages, so past experience is less help.

No matter how the docs are written there'll be a group of people they
don't work for, and there's no real way around that short of including the
same tutorial material in a number of different styles. (Which then has
the issue of confusing folks, plus having to find people that write
differently...)

This really is more the provenance of book publishers and trainers, since
they've got the cash on-hand to develop tutorial materials in different
styles. The core distribution should include a full set of reference
material (which it does, sort of, though lots of fuzzy areas remain) with
any tutorial stuff being considered a bit of a bonus.

					Dan


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

Date: Wed, 14 Jun 2000 10:49:07 -0400
From: "Russel Pearson" <rpearson@quebectel.com>
Subject: Non echo password
Message-Id: <KZM15.20399$NS6.278284@news.globetrotter.net>

Is there a way to be able to get password from STDIN without echoing it ?

Thanks in advance




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

Date: Wed, 14 Jun 2000 06:37:57 PDT
From: Larry R. Waibel <lwaibel@cwia.com>
Subject: NT vs Unix detection
Message-Id: <VA.00000036.0c88e0c7@cwia.com>

I've got some scripts that I want to be able to run on either NT or HP-UX.  
What's the general/accepted/best way for a Perl script to determine which OS 
it's running under?  Thanks!



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

Date: Wed, 14 Jun 2000 14:18:07 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: NT vs Unix detection
Message-Id: <slrn8kf589.7cp.garcia_suarez@rafael.kazibao.net>

Larry R. Waibel wrote in comp.lang.perl.misc:
>I've got some scripts that I want to be able to run on either NT or HP-UX.  
>What's the general/accepted/best way for a Perl script to determine which OS 
>it's running under?  Thanks!

Use the $^O variable (and see perlvar).

-- 
Rafael Garcia-Suarez


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

Date: Wed, 14 Jun 2000 14:34:04 GMT
From: Ilja Tabachnik <billy@arnis-bsl.com>
Subject: Re: Opening a file for realtime monitoring
Message-Id: <8i854r$thc$1@nnrp1.deja.com>

In article <3947747F.AF682DB6@epicrealm.com>,
  Paul Eckert <peckert@epicrealm.com> wrote:
> Dear Peter:
> Try this:
> #!/usr/local/bin/perl -w
>
> $fn = "test.log";
> open INF, "tail -f $fn |" or die "Couldn't fork() tail process...:
$!";
> while (<INF>) {
>    # do something with line
>    print;
> }
> close (INF);
>

IMHO it could be better not to start en external 'tail'
but just use File::Tail module.

Ilja.


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


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

Date: Wed, 14 Jun 2000 14:22:33 GMT
From: Jimmy Humphrey <jimmy@blackhole-designs.com>
Subject: Perl Search |more option
Message-Id: <394795A7.576EBCED@blackhole-designs.com>


I was wondering what might be a good way to sort search listings by the
first "10" or something to that degree when returning a large amount of
listings.  Should I just print out my first 10, and then have the
program remember to next time just print out 11-21 or something to that
degree? Or is there a perl, or CGI.pm way of stacking such information
without having to query a database each time?

This would work kinda like "ls |more" in unix.  I created something
where you do a for i; loop, but I was thinking there must be an easier
way.

Jimmy

-- 
Jimmy Humphrey <jimmy@blackhole-designs.com>
Web Designer - Black Hole Designs - http://www.blackhole-designs.com


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

Date: Wed, 14 Jun 2000 15:55:07 +0200
From: "Pieter Brouwer" <p.brouwer@prevalent.nl>
To: comp.software.config-mgmt,microsoft.public.visual.sourcesafe,comp.lang.perl.misc
Subject: Re: perl system call problems, VSS cmd line
Message-Id: <PRVL5992AD47B@prevalent.nl>

Hi,

The "\" is a special character in perl. Therefore, when you construct a
string in Perl using:

"E:\Progra~1\VSS\Win32\ss Add tiny.pm -Y -C"

you end up with:

"E:Progra~1VSSWin32ss Add tiny.pm -Y -C"

And that's most probably not a valid path.

test it with:

>perl -e "print \"E:\Progra~1\VSS\Win32\ss Add tiny.pm -Y -C\";"

E:Progra~1VSSWin32ss Add tiny.pm -Y -C


HTH

Pieter Brouwer

<invinfo@my-deja.com> schreef in berichtnieuws
8i5hmd$1io$1@nnrp1.deja.com...
> I am working in a WinNT environment.
>
> I am trying to replicate our Project directory structure ( tree ) in
> VSS,
> but I only need to store the .pm files.
> There are 200 subdirectories that have .pm files.
> The whole tree is 100 MB, the .pm's use 8 MB.
> Using the VSS cmd line  ( ss ... )
> I have tried the -R feature but it only works on projects ( get, etc. )
>
> I have tried some command line / cmd line VSS commands. ( ss Add *.pm )
>
> I have successfully run some scripts with system call.
> i.e.
> system "dir *.pm";
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> But just about at wits end trying to find my problem.
> Most of the script runs fine up until this line
> system "E:\Progra~1\VSS\Win32\ss Add tiny.pm -Y -C";
>
> Although I think this should work, I have tried numerous Variations:
> Program Files vs  Progra~1
> Upper/lower case on  VSS and Win32
> with or without  "E:" - I am on that drive.
> ( Full path/file qualification shouldn't hurt )
>
> using the following:
> $cmd = "....";
> system $cmd; or system "$cmd";
>
> trying to add  *.pm I don't think the * needs to be \*
>
>
> Any Suggestions ?  Clues ?  Am I doing something Foolish ?
> Suggestions welcome ( Thanks in advance )
>
> invinfo@enteract.com  (708) 524-1922
> rkattke@nar.com (312) 329-8696
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.



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

Date: Wed, 14 Jun 2000 15:56:09 +0100
From: "Guy Fraser" <guy@firstcreative.com>
Subject: Re: Phonetic searching - Any Examples?
Message-Id: <8i86eb$k2u$1@plutonium.compulink.co.uk>

Aha!  >penny drops<

> The other group would be a hash of lists in which each key would be a
> soundex and the value would be a list of terms that hash to the same
> soundex.

Regards,

Guy.




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

Date: Wed, 14 Jun 2000 14:23:25 GMT
From: garcia_suarez@hotmail.com (Rafael Garcia-Suarez)
Subject: Re: Problem with regexp
Message-Id: <slrn8kf5i7.7cp.garcia_suarez@rafael.kazibao.net>

Antti-Jussi Korjonen wrote in comp.lang.perl.misc:
[...]
>
>my $string1 = "first test\nsecond test\nthird [test]\nfourth test";
>my $string2 = "first test\nsecond test\nthird [test]\nfourth test";
>
>my $temp1 = "first test\nsecond test\nthird [test]";
>my $temp2 = "first test\nsecond test\nthird"; ^
>                                              |
>$string1 =~ s/$temp1//;                       |
>                                              |
># why doesn't this match [test] ---------------

because [test] in a regexp means "match any of the 't', 'e' or 's'
character". This is equivalent to [est]. If you want to match '[' or ']'
in a regexp, you should escape it with a backslash.
  my $temp1 = "first test\nsecond test\nthird \[test\]";

-- 
Rafael Garcia-Suarez


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

Date: Wed, 14 Jun 2000 07:34:55 -0700
From: "Trevor Sky Garside" <trevor@trevorsky.com>
Subject: Re: Problem with regexp
Message-Id: <CIM15.102$%Q.6973@nntp1.onemain.com>

"Antti-Jussi Korjonen" <Antti-Jussi.Korjonen@sonera.com> wrote in message
news:39478019.36DBBB19@sonera.com...
>
> $temp1 should be extracted from $string1 so that all that remains
> is '\nfourth test'. doesn't work.
>
> code:
>
> my $string1 = "first test\nsecond test\nthird [test]\nfourth test";
> my $string2 = "first test\nsecond test\nthird [test]\nfourth test";
>
> my $temp1 = "first test\nsecond test\nthird [test]";
> my $temp2 = "first test\nsecond test\nthird"; ^
>                                               |
> $string1 =~ s/$temp1//;                       |
>                                               |
> # why doesn't this match [test] ---------------
> # switches won't help, what
>
> $string2 =~ s/$temp2//;
>
> print "string1=$string1\n\ntemp1=$temp1\n";
> print "\nstring2=$string2\n\ntemp2=$temp2\n";
>
[Snip Diagnostics]

The problem is in $temp1.  Since you are going to interpolate that string
into a substitution, you need to make sure that the substitution is not
going to interpret any part of the string in a special way.  Specifically,
you need to escape the brackets.  Look at this version of your script:

#!/usr/bin/perl -w

use strict;

my $string1 = "first test\nsecond test\nthird [test]\nfourth test";
my $string2 = "first test\nsecond test\nthird [test]\nfourth test";

my $temp1 = "first test\nsecond test\nthird \\[test\\]";
my $temp2 = "first test\nsecond test\nthird";

$string1 =~ s/$temp1//;

# why doesn't this match [test]
# switches won't help, what

$string2 =~ s/$temp2//;

print "string1=$string1\n\ntemp1=$temp1\n";
print "\nstring2=$string2\n\ntemp2=$temp2\n";

See how I forced there to be a \ in front of both bracket characters?

I should mention that I'm pretty sure there's a function available to turn a
string into something usable as part of a regular expression, but I can't
remember what that is, or how it is used.  Anyhow, for this example, adding
the escape character seems to fix things.

--Trevor




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

Date: 14 Jun 2000 14:33:47 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Problem with regexp
Message-Id: <8i854b$1tr$2@slb6.atl.mindspring.net>

Antti-Jussi Korjonen (Antti-Jussi.Korjonen@sonera.com) wrote:
: $temp1 should be extracted from $string1 so that all that remains
: is '\nfourth test'. doesn't work.
: 
: code:
: 
: my $string1 = "first test\nsecond test\nthird [test]\nfourth test";
: my $string2 = "first test\nsecond test\nthird [test]\nfourth test";
: 
: my $temp1 = "first test\nsecond test\nthird [test]";
: my $temp2 = "first test\nsecond test\nthird"; ^
:                                               |
: $string1 =~ s/$temp1//;                       |
:                                               |
: # why doesn't this match [test] ---------------

Square brackets have a special meaning in regular expressions.  What you 
have in the square brackets matches only a t, e, or s immediately 
following the space after "third."

If you need to do a regex match against a variable pattern that's 
supposed to be treated as literal text, you'll need to tell the regex 
engine to treat it that way; the easiest way to do that in your case is 
to stick a \Q right before $temp1 in the regex part of your substitution.



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

Date: Wed, 14 Jun 2000 07:36:39 -0700
From: "Trevor Sky Garside" <trevor@trevorsky.com>
Subject: Re: Problem with regexp
Message-Id: <eKM15.104$%Q.7654@nntp1.onemain.com>

"Rafael Garcia-Suarez" <garcia_suarez@hotmail.com> wrote in message
news:slrn8kf5i7.7cp.garcia_suarez@rafael.kazibao.net...
> Antti-Jussi Korjonen wrote in comp.lang.perl.misc:
> [...]
> >
> >my $string1 = "first test\nsecond test\nthird [test]\nfourth test";
> >my $string2 = "first test\nsecond test\nthird [test]\nfourth test";
> >
> >my $temp1 = "first test\nsecond test\nthird [test]";
> >my $temp2 = "first test\nsecond test\nthird"; ^
> >                                              |
> >$string1 =~ s/$temp1//;                       |
> >                                              |
> ># why doesn't this match [test] ---------------
>
> because [test] in a regexp means "match any of the 't', 'e' or 's'
> character". This is equivalent to [est]. If you want to match '[' or ']'
> in a regexp, you should escape it with a backslash.
>   my $temp1 = "first test\nsecond test\nthird \[test\]";

Close - but you'll need to double that backslash so it stays in the string.

--Trevor




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

Date: Wed, 14 Jun 2000 16:34:53 +0300
From: "René Hertell" <news@hertell.remove.t_h_i_s.com>
Subject: Script to calculate a future date?
Message-Id: <8i81lr$obd$1@tron.sci.fi>

Hi!
I'm new to perl, and I would need help with calculating a future date.
e.g.
14.06.2000 + 14 would return 28.06.2000
28.06.2000 + 4 would return 02.07.2000
28.12.2000 + 4 would return 01.01.2001

can someone help me with this, e.g. if you know where I could find a ready
script for this purpose

regards, René




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

Date: Wed, 14 Jun 2000 15:17:27 +0100
From: "mike solomon" <mike.solomon@eps.ltd.uk>
Subject: Re: Script to calculate a future date?
Message-Id: <8i84bm$4a7ib$1@fu-berlin.de>

try using module Date:Manip

this allows you to do all sorts of date manipulation


Regards

Mike Solomon



René Hertell <news@hertell.remove.t_h_i_s.com> wrote in message
news:8i81lr$obd$1@tron.sci.fi...
> Hi!
> I'm new to perl, and I would need help with calculating a future date.
> e.g.
> 14.06.2000 + 14 would return 28.06.2000
> 28.06.2000 + 4 would return 02.07.2000
> 28.12.2000 + 4 would return 01.01.2001
>
> can someone help me with this, e.g. if you know where I could find a ready
> script for this purpose
>
> regards, René
>




>




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

Date: Wed, 14 Jun 2000 14:00:25 GMT
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Threads vs Forks
Message-Id: <skf3vprlis417@corp.supernews.com>

In article <UfJ15.188$n32.4023@news6-win.server.ntlworld.com>,
    Rich Robinson <rich@claripoint.com> wrote:

: Assuming threading in Perl is stable, what would be the advantages of
: spawning numerous forks to do little jobs (database access/updates), over
: spawning numerous threads to do the same?  Would there be any advantage?

Think of it in terms of different security policies: should the default
policy for access to your data be to grant or deny access?  When you
use fork(), access is denied by default.  When you use threads, access
is granted by default.  Many people like multiprogramming (i.e., using
fork()) for the same reasons that people like, say, database
constraints: you have to work very hard to shoot yourself in the foot.

Greg
-- 
It's too bad she won't live!  But then again, who does?
    -- Gaff


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

Date: Wed, 14 Jun 2000 10:34:25 -0400
From: Lance E Sloan <lsloan@bigfoot.com>
Subject: trouble installing manpages
Message-Id: <394797F1.AB7B2822@umich.edu>

I'm using a Sun Ultra 10 with Solaris 2.6 and it's an AFS client.
I built Perl 5.6.0 with little problem and most of the install worked,
too.  However, when it came to installing the manpages, all
heck broke loose.  That is, when make ran "./perl installman",
that script apparently started a find, beginning with /.  The
find went into /afs, naturally, which went extremely slow and
I got lots of errors about "afs: Lost contact
with volume location server ##.##.##.## in cell some.domain".

Why is the installman script doing a find anyway?  The install
finally finished a few hours later, but that's ridiculous!  I can't
easily turn off AFS, because that's where my home directory
is.

Any suggestions?

I'd appreciate it if responses could be emailed to me as well as
posted to this newsgroup.

Thanks!





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

Date: Wed, 14 Jun 2000 15:12:20 +0100
From: "Paul D.Smith" <pds@x-datcon.co.uk>
Subject: Up-to-date Perl for OS/2?
Message-Id: <8i83sd$3k0$1@soap.pipex.net>

Anyone know of a source for such a thing?  Only binaries required.

Thanks,
Paul DS.

--
Please remove the "x-" if replying to sender.




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

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


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