[15897] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3310 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 10 11:05:22 2000

Date: Sat, 10 Jun 2000 08:05:09 -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: <960649509-v9-i3310@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 10 Jun 2000     Volume: 9 Number: 3310

Today's topics:
    Re: backquote error output <flavell@mail.cern.ch>
    Re: CGI code for downloading <flavell@mail.cern.ch>
    Re: cgi-problem: internet explorer displays web-page -  <brondsem@my-deja.com>
    Re: dividing a string into array..? <dave@vamprod.force9.co.uk>
        DSN-less connection - How To? <tfbiv@SPAMMENOTerols.com>
    Re: Encrypting / decrypting. <bkennedy99@home.com>
    Re: Find and replace! <sweeheng@usa.net>
    Re: Is it possible: Dumping Package Method Names <rootbeer@redcat.com>
    Re: Larry Rosler interview on perl.com! <dan@tuatha.sidhe.org>
    Re: Larry Rosler interview on perl.com! <dan@tuatha.sidhe.org>
    Re: Moving from Unix to NT - sending mail <tfbiv@erols.com>
        obfuscated but useful magic() - for your perlish amusem <sweeheng@usa.net>
    Re: Perl and Novell <jdNOjdSPAM@syncon.ie.invalid>
    Re: Profiling Perl, flock and NT <rootbeer@redcat.com>
        reverse urlizier <reevesg@cableinet.co.ukx>
    Re: sending mails with perl (Robie Basak)
    Re: sorting pointers? <abe@ztreet.demon.nl>
        split using varible length white spaces as field separa <ljames@apollo3.com>
    Re: split using varible length white spaces as field se <rootbeer@redcat.com>
    Re: split using varible length white spaces as field se <ivoz@starmail.com>
    Re: Variables inside strings? <abuse@localhost>
    Re: Variables inside strings? <raphaelp@nr1webresource.com>
    Re: Variables inside strings? <abuse@localhost>
    Re: Variables inside strings? <raphaelp@nr1webresource.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 10 Jun 2000 15:00:48 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: backquote error output
Message-Id: <Pine.GHP.4.21.0006101455280.3434-100000@hpplus03.cern.ch>

On Sat, 10 Jun 2000, jason wrote:

> >On Fri, 9 Jun 2000, Tad McClellan wrote:
> >> \n is commonly called "newline".
> -
> >> ASCII calls it "line feed".

> ASCII is not dependent on the platform ..

I didn't say that it was, and neither did Tad.

> as Tad says - the ASCII CR is 
> always a different character from the ASCII LF

No, Tad said, in effect, that "\n is line feed in ASCII".

perldoc perlport says

  In most operating systems, lines in files are terminated by newlines.  Just
  what is used as a newline may vary from OS to OS.  Unix traditionally uses
  \012, one kind of Windows I/O uses \015\012, and Mac OS uses \015.

and 

  A common misconception in socket programming is that \n eq \012 everywhere.

And what Tad said was IMHO just a re-statement of that "common
misconception".

> Perl treats the LF differently on different platforms replacing it with 
> the appropriate line ending for text on that platform ..

Sorry, I prefer the explanation in perldoc perlport.

> nothing to do  with ASCII

Well, of course Perl also exists on EBCDIC-based platforms.

all the best



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

Date: Sat, 10 Jun 2000 15:49:35 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI code for downloading
Message-Id: <Pine.GHP.4.21.0006072002210.27713-100000@hpplus03.cern.ch>

On Wed, 7 Jun 2000, Stacey Campbell wrote - using somewhat oversized
lines (now reflowed for comfort):

>     I am trying to figure out CGI code that someone else wrote,
> which accepts form data, processes it into the correct path and
> filename for our unix system, and allows the user to download that
> file over the internet. 

Is it clear why there was any need to do that?  All WWW resources are
retrieved by a "downloading" action - a network transaction, typically
by HTTP from a web server; the distinction is whether the user then
views the resource or saves it to file, but, according to the WWW
model, that's their choice, not yours.  See for example

  http://www.htmlhelp.org/faq/html/media.html#download-howto

(currently 5.1) and also the subsequent article (5.2).

As for CGIs in general, I'd have to point you to the newsgroup
comp.infosystems.www.authoring.cgi and the related FAQs, although
there is also some CGI-relevant information in the Perl FAQs. If you
have Perl-language-specific non-WWW/CGI-specific questions then you're
at home here; if the converse is true (as it does seem to be for the
moment) then you should be better off over there.

> The problem is that I have never written
> CGI code for downloading files over the internet, the code is not
> mine, it has all kinds of HTML and perl mixed up all together (he
> didn't use CGI.pm), and I can't decipher it well enough to modify
> it.

I'd venture to suggest that a large percentage of scripts of that
nature would be better tossed out and, after reviewing whether a CGI
script was necessary or appropriate at all, re-written from scratch
based on modules, than worrying over understanding the detail of some
inherited mess.  Especially if its functionality is undocumented both
to the customers and to the maintenance programmer, as is so often the
case with inherited code!

While it's true that any competent programmer should be capable, in
principle, of writing that stuff long-hand -- any competent programmer
would also know better than to re-invent the wheel every time.

>     His code downloads entire groups of files.  

Ah.  Well.  That might, after all, be the reason for using a script,
if it needs to create dynamically-built archive packages for download.
But then again, if there aren't too many different possible archive
packages, it might be preferable to prepare the downloadable archives
ahead of time, and have them available as static - cacheable -
resources.

>     Does anyone have some simple, maybe generic CGI code for
> downloading files from a unix system over the internet? 

I'd say most experienced WWW practitioners write some HTML that says

<a href="http://www.dom/URLpath/to/resource">Foo bar Module version
42</a>

, verifies that their server is configured to send the appropriate
Content-type header for that type of resource, and leaves it at that.

It's only the modern dee-ziners who are determined to involve every
kind of extra technology they can think of - forms, javascript, and
who knows what else, avoiding the basic simplicity that was
designed-into the WWW from the start.

There seems no point keeping a dog (in this case a web server), and
barking yourself (in this case writing extra code to do something that
a web server already does very competently, and much more
efficiently).

If you have some other constraints, like verifying users or charging
them a call-off fee, you'd need to say so, and it might call for a
different kind of implementation.

But, at this point you are, as I said, still very much in the realms
of designing your WWW solution, and a long way from questions of Perl
coding.  So you'd be more at home on c.i.w.a.cgi, in my estimation.

Keep in mind that a CGI script is a potential security vulnerability.  
If you're trying to gain experience and expertise, don't let me
discourage you for a moment!  But if you're looking for a reliable and
resilient production solution, and you are, as you say, a relative
newbie in this field, then there's no harm in having an extra think
about what you're really trying to achieve, in terms of functionality,
rather than just stumbling into (re)writing a CGI-based solution
merely because it was the first and only implementation considered.

good luck - followups set as a precaution - if someone has
Perl-related comments then feel free to override that.



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

Date: Sat, 10 Jun 2000 13:46:25 GMT
From: Dave Brondsema <brondsem@my-deja.com>
Subject: Re: cgi-problem: internet explorer displays web-page - netscape displays source code
Message-Id: <8htgrf$pbk$1@nnrp1.deja.com>

In article <8ht57t$m682@imsp212.netvigator.com>,
  "multiplexor" <abuse@localhost> wrote:
> <tillerbong@my-deja.com>
> > Hello,
> >
> > I wrote a perl script that performs a search in a
> > flat file database and afterwards sends an html
> > page with the search results to the browser. The
> > program works fine.
> >
> > But it displays the html page only in internet
> > explorer. If I call the script from netscape it
> > displays the html source code.
> >
> > In my script I defined the output of the html
> > page as:
> >
> > ####
> > print "Content-Type: text/html\n\n" ;
> >
> > print <<"EOM";
> >
> > <HTML>
> > <HEAD>
> >
> > <TITLE>Suchergebnis</TITLE>
> > ... and so on
> > ####
> >
> >
> > You can have a look at the problem under:
> > http://www.tillmanns.com/agentur/html/test.htm
> >
> > as serch text try: horse
> >
> >
> > Does anybody see where I made the (probably
> > stupid) error?
> >
> > Thanks
> > Christian
>
> My download agent reports the followings:
>
> 2000/06/10 18:31:32   Connect to server ...
> 2000/06/10 18:31:32   Connect to server successfully.
> 2000/06/10 18:31:32   GET http://www.tillmanns.com/agentur/bilddb.pl?
horse
> HTTP/1.1
> 2000/06/10 18:31:32   HOST: www.tillmanns.com
> 2000/06/10 18:31:32   ACCEPT: */*
> 2000/06/10 18:31:32   User-Agent: NetAnts/1.0
> 2000/06/10 18:31:33   HTTP/1.0 200 OK
> 2000/06/10 18:31:33   Date: Sat, 10 Jun 2000 10:23:55 GMT
> 2000/06/10 18:31:33   Server: Apache/1.3.9 (Unix)
> 2000/06/10 18:31:33   bitte suchwort eingeben: Content-type: text/html
> 2000/06/10 18:31:33   Content-Type: text/plain

I found similar results:

HTTP/1.1 200 OK
Date: Sat, 10 Jun 2000 13:42:37 GMT
Server: Apache/1.3.9 (Unix)
bitte suchwort eingeben: Content-type: text/html
Connection: close
Content-Type: text/plain

I used http://www.delorie.com/web/headers.html to view the headers.
It's quite useful.  You want to remove the "Content-Type: text/plain"
header.

BTW, on the results page another form is shown to search again.
However, it has an action to "bilddb.cgi".  I believe you
want "bilddb.pl".

Dave Brondsema


>
>


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


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

Date: Sat, 10 Jun 2000 15:47:52 +0100
From: Dave Arnold <dave@vamprod.force9.co.uk>
Subject: Re: dividing a string into array..?
Message-Id: <93a782cc49%dave@myrddin.caledvwlch.co.uk>

In message <8hrfbk$cvl$1@nnrp1.deja.com>
          happyhippi@my-deja.com wrote:

> Hola!
> 
> I've decided to make a game where a player guesses letters from some
> unknown word and after all tries to guess the whole word. Unfortunately
> it seems to be harder job than I first imagined cause I dunno how to
> show current situation to player; like this:
> 
> the word is "detournement"
> First, the player can see: "____________"
> Player guesses letter "e"
> What she sees next would be: "_e_____e_e__"
> and so on..
> 
> I thought that tr/// -function should solve the problem but according to
> my handbook it doesn't support variables in it. (of course i tried it
> too..)
> Now it came in to my mind that I should divide the word into an array,
> each letter into it's own element; like:
> 
> @array[0] = "d";
> @array[1] = "e";
> @array[2] = "t";
> and so on..
> 
> I don't have an idea how to divide the word, any help..?
> 
> Keep it in your mind that the word to be guessed is a variable..
> otherwise this would be an easy one.. ;)
> 
> The rest of the program is almost finished..
> 
> thank you
Why go to all the trouble of splitting the word when a search and
replace can do it for you?

Here's my quick example:

#!/usr/local/bin/perl
$|=1;
my $word = "guess";
my $guessed = "-"x(length $word);
my $letters = "";
do
{
    print "$guessed ($letters)\n";
    print "Enter letter: ";
    my $input = <STDIN>;
    my $letter = substr($input,0,1);
    if ( $letter =~ /\W|\d/ )
    {
       print "That wasn't a letter!\n";
    }
    elsif ( not index($letters,$letter) )
    {
        print "You already chose that letter!\n";
    }
    else
    {
        $letters .= "$letter";
        ( $guessed = $word ) =~ s/[^$letters]/-/g;
    }
} while ( $guessed ne $word);
print "Congratulations!\nYou guessed the word was $word\n";

Dave.
-- 
No, the fact that it's an infinite loop doesn't mean the program doesn't
work; it just entered a state with which I was previously unfamiliar.
     Calum - Acorna, A.McCaffrey & M.Ball
                   http://www.vamprod.force9.co.uk/


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

Date: Sat, 10 Jun 2000 10:49:52 -0400
From: Tom Bates <tfbiv@SPAMMENOTerols.com>
Subject: DSN-less connection - How To?
Message-Id: <m5l4ks0ju6vun8a8kg1ccs1doaeccr1bt3@4ax.com>

I'm currently using the DBI and DBD-ODBC modules to connect to a
Microsoft Access database on an NT server. Is there a way to set up a
DSN-less connection with DBI? Or a way to specify the filename on the
connection (which can be done in a VB program by specifying extended
attributes)?

Thanks
Tom


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

Date: Sat, 10 Jun 2000 13:40:18 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: Encrypting / decrypting.
Message-Id: <6zr05.246020$Tn4.2228038@news1.rdc2.pa.home.com>

If me trying to open up an honest dialog about the nature of your posts is
'trolling and harassing', then you have a strange definition of those words.
Why don't you respond to my post again and actually read it and consider its
points.  Or, send me a message directly, which is probably best for this
group.  I am not accusing you of anything, I (and most people) just want to
discuss the issue since there is clearly a 'situation' and we should all at
least be able to agree that its bad.

--Ben Kennedy




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

Date: Sat, 10 Jun 2000 19:21:24 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: Re: Find and replace!
Message-Id: <8hteth$9bc$1@clematis.singnet.com.sg>

> Example:
>
> ####
> $message =<<EOF;
> Hi !!name/!! (!!email/!!),
> Thanks for visiting !!site/!!. Hope you enjoyed your stay.
> EOF
>
> $message =~ s/!!(.*?)\/!!/\$$1/g;
> print $message;
> ###
>
> See perlre
>
> Hope this helps

I tried this:
####
my $name  = 'Santa';
my $email = 'santa@north.pole';
my $site  = 'www.green-elves.org';
$message =<<EOF;
Hi !!name/!! (!!email/!!),
Thanks for visiting !!site/!!. Hope you enjoyed your stay.
EOF
$message =~ s/!!(.*?)\/!!/\$$1/g;
print $message;
####

This is what I got:
####
Hi $name ($email),
Thanks for visiting $site. Hope you enjoyed your stay.
####

But the following did work:
####
$name  = 'Santa';
$email = 'santa@north.pole';
$site  = 'www.green-elves.org';
$message =<<EOF;
Hi !!name/!! (!!email/!!),
Thanks for visiting !!site/!!. Hope you enjoyed your stay.
EOF
$message =~ s/!!(.*?)\/!!/${$1}/g;
print $message;
####

Notice the absence of 'my'? Well, if I put it back, it did not work. :(

I am testing it with ActivePerl 5.6




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

Date: Sat, 10 Jun 2000 07:44:46 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Is it possible: Dumping Package Method Names
Message-Id: <Pine.GSO.4.10.10006100743100.10286-100000@user2.teleport.com>

On 10 Jun 2000, Josiah Bryan wrote:

> I need to kow if there is a way to dump the
> method names of a class?

In general, no, since a class may AUTOLOAD any number of new methods upon
demand. But OO-believers will tell you that everything you need to know
should be in the documentation, else the class is still being written. :-)

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 10 Jun 2000 15:00:37 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <pKs05.110113$hT2.431098@news1.rdc1.ct.home.com>

Henry <htp@mac.com> wrote:
> In article <Ek605.107069$hT2.427521@news1.rdc1.ct.home.com>, Dan 
> Sugalski <dan@tuatha.sidhe.org> wrote:

>>>> Perl is in fact already de facto standardized (because of the
>>>> single official source), but the definition is vague and there
>>>> is no corporate clout to support it.  That is why I believe a
>>>> more formal, de jure activity is required.
>>>>
>>>> But the Open Source movemet may be creating a new paradigm for 
>>>> standardization.  We shall see!
>> 
>>> As long there is only one official source there's no need for any
>>> standardization.
>> 
>> That's a common misconception, and one that's not true.

> I'm going to take issue with that.

>> One of the points
>> of standards is to give multiple implementations something to meet. You'd
>> think we didn't need that, but we do because there *are* multiple
>> implementations. Each major version of perl could be reasonably described
>> as an independent implementation.

> Reasonable?  You think it's 'reasonable' to consider that Perl 5.$x is 
> an "independent implementation" of Perl 5.--$x even though 99%+ of the 
> codebase is an exact byte match?

You're making a big assumption here, that I was considering perl 5.005 and
5.6 two major versions, and not looking at perl 4 vs perl 5, or perl 5 vs
topaz. Perl 4 and perl 5 share very little code. Perl 5 and Topaz will
share basically none.

Regardless, while perl 5.005_0x and perl 5.6.0 share a lot of code in
common, it's *quite* a bit less than 99%, and the total amount shared is
irrelevant. A standard defines how the language works. Right now, when
perl converts a float to an integer it truncates, but there's no standard
for that, and without one there's nothing to say that perl 5.8.0 won't
round instead. 

FWIW, each major version of perl sees at least one chunk of the
interpreter given a full overhaul, oftentimes more than one.

> That's one of the most screwed up definitions of "independent 
> implementation" that I have _EVER_ heard.

You don't get out much I see. Give it a few years--even with your
misinterpreting what I was talking about, that was a tame one. :)

> Totally bogus.

Alas not.

>> A standard also gives the *programmer* something to work with. Without a
>> standard you have no guarantees of how a language is supposed to work, so
>> how can you make sure your program does what you think it should?

> Standards don't give programmers something to work with, DOCUMENTATION 
> does!

Ummm... what do you think a standard is, some magic spell woven over the
code? A standard *is* documentation, very formal documentation, of how
something should work. 

> Perl's biggest failing is that since "There Is More Than One Way To Do 
> It" no-one documents _anything_ for fear of being seen as dictatorial, 
> and incurring the wrath of the community.

That turns out not to be the case. In general the perl5-porters folks
don't much worry about the wrath of the community. We know you're all
adults, or can fake it when the situation calls for it, and can cope.

Things don't get documented because it doesn't occur to someone that
something needs documentation, or there's no interest, or we're not ready
to formalize behavior, or we're not sure what something does. Community
wrath doesn't enter in to it.

> This attitude has had a pronounced effect on the documentation, which 
> reads like an arcane language reference and is almost INCOMPREHENSIBLE 
> to a newbie.

Perl's docs are quite good compared to an awful lot of the documentation
out there, free or pay. It's two biggest problems are sheer size (last
time I printed the docset out it was 1500 pages, and that was for perl
5.005_02. It's bigger now) and a somewhat haphazard organization.

> A proliferation of programming guides has attempted to 
> address this issue, but the expectation is that FULL and COMPLETE 
> documentation will ship with the product.  And this simply isn't the 
> case with Perl.

It's not the case with any free programming language that I've come
across. Heck, it's not the case with most major projects period, free or
not free. 

> Dump a standard distribution of Perl in front of a newbie and you'll see 
> their eyes glaze over in a matter of minutes.

Sure. Drop Apache in front of a newbie and watch their eyes glaze over. Or
Fortran, or Unix, or VMS, or most VCRs, or a satellite dish, or the filter
mechanism for an inground pool, or... The list is pretty long, and it's
not exclusive to perl. Drop *anything* moderately complex on a newbie and
you'll see glaze.

Perl's not targeted at, nor designed for, the newbie. That's just
fine--lots of things aren't. That doesn't make it bad in general.

> Make better (more approachable) documentation, and more people will "use 
> Perl;".

There's an awful lot, and folks seem to be doing pretty well with what's 
provided, and there's the llama (or gecko, if that floats your boat) book
for those folks that need a different approach.

> More inertia translates to _functional_stability_.

No, it doesn't. Knowing what the language does gets you functional
stability. A standards doc is a formal definition of what the language
does.

> Functional stability results in industry 
> acceptance.

I could bring up Windows as a counterargument, but some shots are just
*too* easy... :)

> Companies don't really give a flying flock() about whether or not a 
> programming language is ANSI certified

That actually turns out not to be the case in many places. You're also
assuming that I'm talking ANSI standard because Larry did. RFC822 is a
formal standard for e-mail. Adobe's red book (I think--might be the white
one) is a formal standard for postscript. ANSI (or ISO, or whoever)
doesn't need to get involved.

> all they want to know is whether 
> or not the applications they develop _today_ will continue to work 
> _tomorrow_.

And that's what a standard does. Without it there aren't any guarantees,
since those of us who work in perl don't have anything besides past
experience to work with. The closest thing perl's got to a standard is the
test suite that comes with it, and despite its size there are still a lot
of things it doesn't catch.

> You don't need artificial standards to do that, all you need is critical 
> mass.  Approachable documentation, shipped with the standard 
> dstribution, will give us critical mass faster, and more efficiently, 
> than any standard could ever hope.

This is very, *very* wrong. I presume you've never been involved with any
sort of major project used by other people. Formal definitions of
language behavior (which is what a standard *is*) is what gets you
stability. Otherwise you risk breaking things, and perl has definitely
done that in the past. (I think every point release has broken something
somewhere)

				Dan


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

Date: Sat, 10 Jun 2000 15:03:04 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Larry Rosler interview on perl.com!
Message-Id: <IMs05.110114$hT2.431098@news1.rdc1.ct.home.com>

Bart Lateur <bart.lateur@skynet.be> wrote:
> Steven Merritt wrote:

>>since there's little glory in re-writing docs and there is lots of
>>glory in adding new features, I don't see this happening."
>>We're seeing the same thing with some of the stuff going on with the
>>Perl core.

> When was the last time that you saw a new keyword appear in Perl's core?
> The only one for *years* that springs to my mind, is "our". What you're
> more likely to see, is new functionality for old functions, like the
> optional fourth parameter for substr().

5.005 introduced lock(). Broke some stuff, including some of the examples
in the "Writing Apache Modules in Perl and C" book from O'Reilly.

					Dan


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

Date: Sat, 10 Jun 2000 10:45:24 -0400
From: Tom Bates <tfbiv@erols.com>
Subject: Re: Moving from Unix to NT - sending mail
Message-Id: <73l4kssspu1rjfoofob22pl6sjjj3qv6rq@4ax.com>

I've used BLAT with great success.

Tom

On Wed, 07 Jun 2000 21:18:51 GMT, newsmay2000@ordinate.co.uk (Ben
Hambidge) wrote:

>I have to move my CGI script from a Unix web server to a WinNT server.
>I send mail by piping to /usr/lib/sendmail using
>open(MAIL,"|/usr/lib/sendmail $recipient");
>
>What do I need to do to acheive the same effect in Windows?



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

Date: Sat, 10 Jun 2000 23:00:00 +0800
From: "Swee Heng" <sweeheng@usa.net>
Subject: obfuscated but useful magic() - for your perlish amusement
Message-Id: <8htkqj$c64$1@mawar.singnet.com.sg>

Who needs encryption when we can have Perl?

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

sub magic{local$_='Jan1Feb2Mar3Apr4May5Jun6Jul7Aug8Sep9Oct10Nov11Dec12';
my$d=shift;$d=~/^\D+$/?(/$d(\d+)/)[0]:$d=~/^\d+$/?(/(\D+)$d/)[0]:''or'bad'}

printf "%s => %s\n", $_=$ARGV[0], magic($_);
---------------------------------------------------------------------------

A friend asked me how to map months to numbers and vice versa, i.e. Apr =>
4, 12 => Dec. The magic() sub is the shortest I coded. Any challengers? :o)

Swee Heng




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

Date: Sat, 10 Jun 2000 06:03:51 -0700
From: deno <jdNOjdSPAM@syncon.ie.invalid>
Subject: Re: Perl and Novell
Message-Id: <03f6b4b2.0cda75d4@usw-ex0105-036.remarq.com>

http://www.ahs.hist.no/distr/NDSm

* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



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

Date: Sat, 10 Jun 2000 07:42:07 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Profiling Perl, flock and NT
Message-Id: <Pine.GSO.4.10.10006100735120.10286-100000@user2.teleport.com>

On Sat, 10 Jun 2000, Ralf Hoffmann wrote:

> - Does exist any good documentation about perl performance issues
> (despite camel book infos) ?

I don't know what you're asking. But if you're thinking that you want the
highest performance possible from your hardware, forget about Perl. Use
hand-optimized assembler code instead. :-)

> - Is there another way of invoking the profiler option ?
>   perl -d:DProf is not suitable for me, because I have no control of the
> invocation method of perl.

Maybe you can try something like this:

    system($perl, '-d:DProf', @other_args);	# run perl for profiling

But if that won't do it, you're probably trapped in the basement with a
bag over your head, your hands cuffed behind your back, and your shoelaces
tied together. Get yourself free, and then we can talk.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 10 Jun 2000 14:46:21 GMT
From: "red [2]" <reevesg@cableinet.co.ukx>
Subject: reverse urlizier
Message-Id: <1xs05.2$1y5.67@news3.cableinet.net>

thanks a long time ago to you guys i got an url to convert into a link.
now, i need to get it to go the other way around

$post =~ s!(http://[\-~A-Za-z0-9_/\.]+)!<a href=\"$1\">$1</a>!gi;
is what im using to convert http://www.quadmonkey.co.uk/ into
<a href=" etc

but i want to convert
<a href="http://[\-~A-Za-z0-9_/\.]+)">URLNAME</a> into
URLNAME <http://url/>

can you wonderful people help me out again... im not sure how to strip from
the href= to the > , mainly because im not sure how to do it IF there's a "
or not (id like it to be flexible)


thanks in advance.
--

Graham "red" Reeves

uk's Q3 news - - http://www.quadmonkey.co.uk/





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

Date: 10 Jun 2000 13:31:29 GMT
From: rb@localhost.localdomain (Robie Basak)
Subject: Re: sending mails with perl
Message-Id: <slrn8k4gpg.225.rb@localhost.localdomain>

On 10 Jun 2000 11:41:39 +0100, Jonathan Stowe said:
>In comp.lang.perl.misc Stefan T. <stefan.thaler@gmx.net> wrote:
>> hi everybody!
>> 
>> with the following lines of a perl script i can send a mail:verschicken:
>> 
>> -----script-----
>> #!/usr/bin/perl
>> open MAIL,"|mail nothing\@nomail.at ";
>> print MAIL"hello world"; #:-)
>> close MAIL;
>> 
>
>In comp.lang.perl.misc it has been discussed ad nauseam why it is a bad
>idea to use a command line mailer that requires you to supply the recipient
>address on the command line - in the first place you are potentially
>supplying compromising user supplied data to the shell.

However if you're writing a script which mails yourself, the email is
no longer user-supplied but hardcoded into the script and hence safe.

Robie.
-- 


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

Date: Sat, 10 Jun 2000 15:17:55 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: sorting pointers?
Message-Id: <qhf4kskhok1dmk94vob8qm4u5rtds5b6lr@4ax.com>

On Sat, 10 Jun 2000 00:59:04 -0700, mac4@operamail.com (Neil Macneale)
wrote:

> I am new to perl and trying to figure out the sort function.
> 
> I have a list of pointers to lists.
perl has no pointers, but references, "read all about it..."

	perldoc perlref
	perldoc perlreftut

and if you can't get enough:
	perldoc perldsc

They should answer all your questions.

-- 
Good luck,
Abe


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

Date: Sat, 10 Jun 2000 13:22:07 GMT
From: Larry James <ljames@apollo3.com>
Subject: split using varible length white spaces as field separators
Message-Id: <8htfdn$ogd$1@nnrp1.deja.com>

     Can someone advise me how to break up a line using split (or any
other routine) where the separations maybe an inconsistent number of
white spaces.  It there was one space of course it would be:

          @array = split(/ /,$line);

     Thanks in advance for any suggestions or comments.

                                   -- L. James


--
---------------------------
Larry James
ljames@apollo3.com
http://www.apollo3.com/~ljames


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


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

Date: Sat, 10 Jun 2000 07:48:23 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: split using varible length white spaces as field separators
Message-Id: <Pine.GSO.4.10.10006100745550.10286-100000@user2.teleport.com>

On Sat, 10 Jun 2000, Larry James wrote:

>      Can someone advise me how to break up a line using split (or any
> other routine) where the separations maybe an inconsistent number of
> white spaces.  

Do you mean that you want to split on any amount of whitespace? The docs
for split cover that pretty adequately.

Or are you saying that you want to split on N space characters, where N
won't be determined until runtime? You may want unpack, although there are
other ways.

Or do you want something else?

Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 10 Jun 2000 17:54:45 +0300
From: "Ivo Zdravkov" <ivoz@starmail.com>
Subject: Re: split using varible length white spaces as field separators
Message-Id: <3942569a_2@news.nwlink.com>


"Larry James" <ljames@apollo3.com> wrote in message
news:8htfdn$ogd$1@nnrp1.deja.com...
>      Can someone advise me how to break up a line using split (or any
> other routine) where the separations maybe an inconsistent number of
> white spaces.  It there was one space of course it would be:
>
>           @array = split(/ /,$line);
@array = split(/ +/,$line);
    or better
@array = split(/\w+/,$line);
    or best read:
 perldoc perlre   :-)

>
>      Thanks in advance for any suggestions or comments.
>
>                                    -- L. James
>
>
> --
> ---------------------------
> Larry James
> ljames@apollo3.com
> http://www.apollo3.com/~ljames
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Sat, 10 Jun 2000 21:15:24 +0800
From: "multiplexor" <abuse@localhost>
Subject: Re: Variables inside strings?
Message-Id: <8htej4$6ef1@imsp212.netvigator.com>


"Raphael Pirker" <raphaelp@nr1webresource.com> wrote
> Hi,
>
> Well, this adds another problem (not again! :-)
>
> I don't know the names of the variables yet, as each Form-input is going
to
> be different:
>
> foreach $key (keys(%FORM)) {
> $key: $FORM{$key}\n
> }
>
> This is what I use to determine all the variables which is sent through
the
> form.
>
> How can I add those to a hash? Basically I need all form-data inside the
> "details" hash which can then be accessed through the $message string...
>
> Thanks in advance,
>
> Raphael Pirker
> raphaelp@nr1webresource.com
>
> jason <elephant@squirrelgroup.com> wrote in message
> news:MPG.13acc99e2c6451a798971d@news...
> > Raphael Pirker writes ..
> > >#######
> > >## form-input of $message ##
> > ><input type="hidden" name="message" value="Hi !!name/!! (!!email/!!),
> > >Thanks for visiting !!site/!!. Hope you enjoyed your stay.">
> > >## end form-input ##
> > >
> > >
> > >## inside the script ##
> > >$message     = $FORM{message};
> > >$message     =~ s/!!(.*?)\/!!/\$$1/g;
> > >print MAIL "$message"
> > >#######
> > >
> > >This returns:
> > >
> > >Hi $name ($email),
> > >Thanks for visiting $site. Hope you enjoyed your stay.
> > >
> > >Which is just how I wanted it, only I wanted the variables to be
> "parsed".
> > >How do I get Perl to exchange the variables with the values inside the
> > >script? Right now it appears to be a string which has a "\" infront of
> the
> > >"$" sign so it gets printed out as-is...
> >
> > you shouldn't be using symbolic references for this .. you should be
> > using a hash
> >
> > to correct your code so that it stumbles its way to the finish line you
> > take out the escape char .. and put in some {}s so that the $$s get
> > parsed correctly
> >
> >   $message     =~ s/!!(.*?)\/!!/\$$1/g;
> >
> > becomes
> >
> >   $message     =~ s/!!(.*?)\/!!/${$1}/g;
> >
> > but what you should have is
> >
> >   my %details = ( name  => 'some name'
> >                 , email => 'some@email.com'
> >                 , site  => 'some site name'
> >                 );
> >
> >   $message =~ s/!!(.*?)\/!!/$details{$1}/g;
> >
> > it's neater .. easier to read .. nicer .. and less error prone .. and
> > more Perlistic
> >
> > --
> >  jason - elephant@squirrelgroup.com -

The %FORM is already a hash. If you want to use the form data directly, use

$message =~ s/!!(.*?)\/!!/$FORM{$1}/g;

Or you may want to merge %FORM to %details, try the following example:

###
# Merge %a to %b
%a = ("name","Tom", "age","20", "hobby","football");
%b = ("sex","Man");
foreach (keys %a) {
 if ($b{$_} eq '') { $b{$_} = $a{$_}; }
}
foreach (keys %b) {
 print "$_=$b{$_}\n";
}
###


Hope this helps, and please correct me if sth wrong.






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

Date: Sat, 10 Jun 2000 15:54:28 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: Variables inside strings?
Message-Id: <8hth9g$9jp$1@news.online.de>

Hi,

Thanks a lot for your code! It works very well, the only problem is that it
only parses 1 "variable", so let's say I have the string:

Hi !!name/!!,\n I would like to thank you very much for ordering !!order\!!
and hope you have fun with your !!order\!!.\nThey will be shipped to
!!location\!! immediately. In the meantine, please entertain yourself a
little by playing !!hobby\!! or just cruising around !!germany\!!.
\n\nThat's all for now,\n\nBest regards,\nBill Gates\n!!results_link_url\!!

all that comes out is:

Hi Test Person,\n I would like to thank you very much for ordering
!!order\!! and hope you have fun with your !!order\!!.\nThey will be shipped
to !!location\!! immediately. In the meantine, please entertain yourself a
little by playing !!hobby\!! or just cruising around !!location\!!.
\n\nThat's all for now,\n\nBest regards,\nBill Gates\n!!results_link_url\!!

How can I make it go through all of the "variables" inside the above string?

Thanks a lot

Raphael

[snipped]
> The %FORM is already a hash. If you want to use the form data directly,
use
>
> $message =~ s/!!(.*?)\/!!/$FORM{$1}/g;
>
> Or you may want to merge %FORM to %details, try the following example:
>
> ###
> # Merge %a to %b
> %a = ("name","Tom", "age","20", "hobby","football");
> %b = ("sex","Man");
> foreach (keys %a) {
>  if ($b{$_} eq '') { $b{$_} = $a{$_}; }
> }
> foreach (keys %b) {
>  print "$_=$b{$_}\n";
> }
> ###
>
>
> Hope this helps, and please correct me if sth wrong.
>
>
>
>




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

Date: Sat, 10 Jun 2000 22:23:26 +0800
From: "multiplexor" <abuse@localhost>
Subject: Re: Variables inside strings?
Message-Id: <8htiil$4hd9@imsp212.netvigator.com>


"Raphael Pirker" <raphaelp@nr1webresource.com> wrote
> Hi,
>
> Thanks a lot for your code! It works very well, the only problem is that
it
> only parses 1 "variable", so let's say I have the string:
>
> Hi !!name/!!,\n I would like to thank you very much for ordering
!!order\!!
> and hope you have fun with your !!order\!!.\nThey will be shipped to
> !!location\!! immediately. In the meantine, please entertain yourself a
> little by playing !!hobby\!! or just cruising around !!germany\!!.
> \n\nThat's all for now,\n\nBest regards,\nBill
Gates\n!!results_link_url\!!
>
> all that comes out is:
>
> Hi Test Person,\n I would like to thank you very much for ordering
> !!order\!! and hope you have fun with your !!order\!!.\nThey will be
shipped
> to !!location\!! immediately. In the meantine, please entertain yourself a
> little by playing !!hobby\!! or just cruising around !!location\!!.
> \n\nThat's all for now,\n\nBest regards,\nBill
Gates\n!!results_link_url\!!
>
> How can I make it go through all of the "variables" inside the above
string?
>
> Thanks a lot
>
> Raphael

 [snipped]

You typed  "!!order\!!" rather than "!!order/!!", see?





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

Date: Sat, 10 Jun 2000 16:26:00 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: Variables inside strings?
Message-Id: <8htj4c$air$1@news.online.de>

oh shoot! This just doesn't seem to be my day... :-)

[snipped]




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

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


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