[21813] in Perl-Users-Digest
Perl-Users Digest, Issue: 4017 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 23 18:05:51 2002
Date: Wed, 23 Oct 2002 15:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 23 Oct 2002 Volume: 10 Number: 4017
Today's topics:
Advice Please <merlin@itwizards.sic>
Re: deleting a file... kill ??? Thanks... <mjcarman@mchsi.com>
Re: Enabling core dumps in child processes <{tony}@realh.co.uk>
Re: Finding words in a string. <usenet@dwall.fastmail.fm>
Re: format to output <krahnj@acm.org>
Re: Grab blob and DBH->quote()??? <zmonteca@zmonteca.com>
Re: negation <alecler@sympatico.ca>
Re: Net::FTP Output <Graham.T.Wood@oracle.com>
Parallel ForkManger - Multiprocessors <cakes@doentreply.com>
Re: Perl bloggers? (Andrew Burton)
Re: Perl bloggers? (Kevin Shay)
Quick way to get the first value? <ihave@noemail.com>
Re: Quick way to get the first value? <twhu@lucent.com>
Re: Quick way to get the first value? <tassilo.parseval@post.rwth-aachen.de>
Re: Quick way to get the first value? <mike_constant@yahoo.com>
Re: Quick way to get the first value? <pinyaj@rpi.edu>
RMI Equivalent in Perl? (Brian)
Re: Running Perl through cron <matt.stoker@motorola.com>
Re: some questions (Malcolm Dew-Jones)
Re: some questions <usenet@dwall.fastmail.fm>
Re: some questions <depesz@depesz.pl>
Using the \n escape code (Beginner question) <fpichette@NOSPAMvideotron.ca>
Re: Using the \n escape code (Beginner question) <mike_constant@yahoo.com>
Re: Using the \n escape code (Beginner question) <nospam@nospam.org>
Re: Using the \n escape code (Beginner question) <Graham.T.Wood@oracle.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 23 Oct 2002 20:13:42 +0100
From: "merlin" <merlin@itwizards.sic>
Subject: Advice Please
Message-Id: <ap6scq$goi$1@news7.svr.pol.co.uk>
Hi
I know nothing about Perl.
I need to change a script so that I only need to input a file name instead
of the full URL.
I have been told that I would need to,
"You'd also need to alter the webbbs_post.pl script, so that instead of (or
better yet, in addition to) "blanking out" URL fields which contain only
the "http://" string, it "blanks out" URL fields which contain only your
defined default string."
How do I "Blank out" the URL fields?
The code I think this refers to is,
$val2 =~ s/([ <>])([\w]+:\/\/[\w\*\+-?&;,#~=\.\/\@]+[\w\/])/$1<A HREF="$2"
TARGET="_blank">$2<\/A>/g;
$val2 =~ s/([ <>])(www\.[\w\*\+-?&;,#~=\.\/\@]+[\w\/])/$1<A
HREF="http:\/\/$2" TARGET="_blank">$2<\/A>/g;
$val2 =~ s/([
<>])([^\s"<>]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?))/$1<A
HREF="mailto:$2">$2<\/A>/g;
}
Any advice appreciated
------------------------------
Date: Wed, 23 Oct 2002 15:00:27 -0500
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: deleting a file... kill ??? Thanks...
Message-Id: <ap6v58$6ps1@onews.collins.rockwell.com>
Jason Baugher wrote:
>
> helgi@decode.is (Helgi Briem) wrote:
>
>> Bart Lateur <bart.lateur@pandora.be> wrote:
>>
>>> Helgi Briem wrote:
>>>
>>>> I still don't really understand why someone decided to call
>>>> it unlink and not rm or delete or remove or something.
>>>
>>> Because on Unix, it is not garanteed to delete a file.
>>
>> So what? If I rm 'foo' and 'foo' is a link to 'bar', I have
>> still deleted foo. The fact that I haven't also deleted bar
>> is irrelevant.
>
> No, you haven't deleted foo. You've removed (or unlinked) the foo
> reference (link) from the directory in which it resides.
In other words, he has deleted foo (the link). You two agree (I think),
though you may not admit it. :)
> The actual file may or may not be deleted by the file system itself,
> depending on whether other references (links) still exist which
> point to the file.
Okay, I think we all understand *what* is happening, so can we please
stop repeating it? Besides, this seems a rather silly argument when
perldoc -f unlink says:
unlink LIST
Deletes a list of files. Returns the number of files
successfully deleted.
I agree with Helgi. If I'm a new programmer in language X and I need to
delete (and I use that word loosely) a file, I'm going to look for a
command called 'delete' or 'remove' or something similar. I'm not going
to think "What's the low-level action taken by the operating system on
which this language was originally designed?"
If we change our definition of "delete" to mean "delete a file link"
instead of just "delete a file" then there's no reason we couldn't
replace unlink() with delete() [1]. It would be a much more natural
keyword, and having "natural language" semantics is certainly part of
Perl's design. (Why else would we have things like 'unless'?)
The use of 'unlink' is, IMHO, an unfortunate artifact.
[1] Expect for the fact that delete is already a keyword, of course,
and I wouldn't favor overloading it.
-mjc
------------------------------
Date: Wed, 23 Oct 2002 20:03:44 GMT
From: Tony Houghton <{tony}@realh.co.uk>
Subject: Re: Enabling core dumps in child processes
Message-Id: <slrnare050.d9h.{tony}@realh.co.uk>
In <slrnardctf.41c.{tony}@realh.co.uk>,
Tony Houghton <{tony}@realh.co.uk> wrote:
> I'm writing a program which is mainly in C, but uses a perl script to
> manipulate some files before and after execution; the perl calls the C
> using system(). The C program needs debugging, but I can't get it to
> dump core when run from the perl script.
Oops, it wasn't because of perl after all, it seems that it's sudo
that's suppressing core dumps. Any idea how to reenable them, or is
there something else I can use instead of sudo?
[perl group removed from followups]
--
TH * http://www.realh.co.uk
------------------------------
Date: Wed, 23 Oct 2002 18:07:38 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Finding words in a string.
Message-Id: <Xns92B08FB5FDA7Bdkwwashere@216.168.3.30>
Yils Kraabe <krikrok.horse@hotmail.com> wrote on 23 Oct 2002:
> I have a string and I want to find words in this string containing, say,
> the letter 'e'. I was wondering what was the 'optimal' way in perl,
> since I am not that used to it. I produced
>
> $string = "Some text with words";
> @string = split /\s+/, $string;
> @mywords = grep { /e/ } @string;
>
> It takes only 3 lines but I wonder if this is efficient to build a
> temporary list @string. Is there another better way to do that?
You could drop the temporary variable and write it as
my $string = "Some text with words";
my @mywords = grep { /e/ } split /\s+/, $string;
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Wed, 23 Oct 2002 20:57:12 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: format to output
Message-Id: <3DB70D36.B560E5D0@acm.org>
[ Please don't top-post. Please trim your posts. ]
Christian Caron wrote:
>
> Thanks for the information. I had a look at printf (but not in depth) and
> found although you specify %15s, if the string contains more than 15
> characters, it will display all of them (maybe I have to use %15c?). I'm
> sure there's a solution to it, I'll just read the documentation.
Use %15.15s if you want no more than 15 characters printed.
John
--
use Perl;
program
fulfillment
------------------------------
Date: 23 Oct 2002 21:32:07 GMT
From: Z Monteca <zmonteca@zmonteca.com>
Subject: Re: Grab blob and DBH->quote()???
Message-Id: <ap74gn$lc0$1@bob.news.rcn.net>
Well, after endless hours of trying to figure this out I resorted to
looking into the system configuration. That was the problem. For some
reason when you have a *.pl file on the server and try and execute it
from the client, the headers are forced to the client someway. That is
why the header appeared with a blob of data appended.
I would still like to hear something on the quote problem. Since I don't
know if the is really necessary I am doing it without quoting the data
blob. It was giving me errors trying to post the blobs with the quoted
test, naturally. So I just didn't feel like parsing out whatever is put
in by using the quote. Laziness prevails.
Cheers,
Z
Z Monteca <zmonteca@zmonteca.com> wrote in
news:ap4no7$kkj$1@bob.news.rcn.net:
> In the below code, I am trying grab a picture (data blob) from MySQL
> DB. The objective of this is to call this from the 'img' tag in a
> form I made. The problem is that I can NOT get this to appear as an
> IMAGE. For some reason only the "Content-Type:
> image/jpeg\n\n$RAW-DATA" comes up. Anyone have a clue what I am doing
> wrong?
>
> Also, in storing this in the DB I use the 'dbh->quote($rawdata)', what
> is the point of using this? Why can't I just insert $rawdata without
> quoting it? If I must use the quote handle before inserting into the
> DB do I have to unquote the quoted $rawdata before trying to use it to
> display it as an image?
>
>
> Thanks in advance....
>
> -Zach
>
>
> ######################################################
> ##
>
> if($I{F}{id}){
> my @blob = sqlSelect('picture', 'static', 'indx=' . $I{F}{id});
> my $data = $blob[0];
>
> if (!$data){
> print "Content-type: text/plain\n\n";
> print "No data found. \n";
> }
> else{
> #while(@blob) {
> print "Content-Type: image/jpeg\n\n";
> print STDOUT $blob[0];
> #}
> #print "Content-type: image/gif\n\n";
> #print "$data";
> }
> }
> else{
> print "Content-type: text/plain\n\n";
> print "Can't access script!\n";
>
> }
> exit(0);
------------------------------
Date: Wed, 23 Oct 2002 14:50:51 -0400
From: Andre <alecler@sympatico.ca>
Subject: Re: negation
Message-Id: <alecler-8455FF.14505123102002@news1.qc.sympatico.ca>
In article <8fec9af1.0210230919.2187e048@posting.google.com>,
rnoory@videotron.ca (R.Noory) wrote:
> My imput is
> stupefy
> qualify
> classify
> affy
>
> I want to create two clusters out of my input
> stupe(fy)
> af(fy)
> qual(ify)
> class(ify)
while (<DATA>) {
s/(i?fy)$/($1)/;
print;
}
__DATA__
stupefy
qualify
classify
affy
HTH,
Andre
------------------------------
Date: Wed, 23 Oct 2002 20:18:54 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Net::FTP Output
Message-Id: <3DB6F61E.7177D024@oracle.com>
Hisham Mohamed wrote:
> Hi all,
>
> I'm using the following script:
>
> use Net::FTP;
> open (STDOUT, ">standardchartered.log") or die "\n\nCould not open
> findmachines.txt input file. Please make sure it exists and \ncontains the
> machine names you're looking for.\n";
>
> $ftp = Net::FTP->new("192.168.35.2", Debug => 1);
> $ftp->login("ftpguest",'guestpassword');
>
> $ftp->get("StandardChartered.txt","c:\\StandardChartered\\StandardChartered.
> txt");
> $ftp->quit;
>
> close STDOUT;
>
> While using the Debug => 1, I get some really informative lines that I'd
> like to pipe into a log file. The above examples work except for the
> re-routing to STDOUT (I get the file, but the log file is empty). Is this
> possible? If so, then how? Any advice would be grearly appreciated.
>
> -Hisham
Being "Debug" information, I'm guessing it is probably printing to STDERR rather
than STDOUT. Try redirecting STDERR and see if that helps.
Graham Wood
------------------------------
Date: Wed, 23 Oct 2002 16:19:18 -0400
From: "cakes99" <cakes@doentreply.com>
Subject: Parallel ForkManger - Multiprocessors
Message-Id: <3db70450$1_1@nopics.sjc>
***** I've searched the documentation and other sources but could not find
an answer.
Will the Parallel ForkManager utilize a system that contains multiple
processors? For instance, I currently am running a program on a machine
with 1 processor. If I were to move the program to a server with 4
processors, would their be a difference in time between the two, due to the
increase in processors?
Thank you,
Matt
------------------------------
Date: 23 Oct 2002 19:24:24 GMT
From: tuglyraisin@aol.commune (Andrew Burton)
Subject: Re: Perl bloggers?
Message-Id: <20021023152424.05649.00016565@mb-fc.aol.com>
Thank you!
Andrew Burton -- tuglyraisin at aol dot com
Felecia Station on Harvestgain
"well, it's software, it can do anything :-)" - Ankh
"A racist alien robot, now that's cutting-edge children's programming, screw
the AIDS puppets." - Derik Smith
------------------------------
Date: 23 Oct 2002 12:26:32 -0700
From: kevin_shay@yahoo.com (Kevin Shay)
Subject: Re: Perl bloggers?
Message-Id: <5550ef1e.0210231126.4b48e181@posting.google.com>
tuglyraisin@aol.commune (Andrew Burton) wrote in message
news:<20021023101355.22841.00005317@mb-md.aol.com>...
> I was curious if anyone knew of a circle of or a single "Perl
> blogger" -- someone in the Perl community who blogs about Perl and
> other technical subjects?
Take a look at the Journals section of the use Perl; site:
http://use.perl.org/search.pl?op=journals
There's also perlblog, an automated service that shows an integrated
listing of new items on the aforementioned journals, Perl Monks, CPAN,
and this very newsgroup:
http://www.nospum.net/perlblog/
--Kevin
------------------------------
Date: Wed, 23 Oct 2002 20:55:32 GMT
From: "TBN" <ihave@noemail.com>
Subject: Quick way to get the first value?
Message-Id: <81Et9.105$EOT8.19660932@news2.randori.com>
If I have a string similar to...
my $test = "asdfh~sdasb~c~daaf~f";
I know that I can split this into an array and then grab the "word" that I
want like so...
@words = split(/~/,$test);
my $firstword = $words[0];
But I'm guessing there's a quicker easier way to grab the first word of a
string than this.
------------------------------
Date: Wed, 23 Oct 2002 17:16:46 -0400
From: "Tulan W. Hu" <twhu@lucent.com>
Subject: Re: Quick way to get the first value?
Message-Id: <ap73k4$no9@netnews.proxy.lucent.com>
Try
$test =~ s/(\w)~(.*)/$1/;
"TBN" <ihave@noemail.com> wrote in message ...
> If I have a string similar to...
>
> my $test = "asdfh~sdasb~c~daaf~f";
>
> I know that I can split this into an array and then grab the "word" that I
> want like so...
>
> @words = split(/~/,$test);
> my $firstword = $words[0];
>
> But I'm guessing there's a quicker easier way to grab the first word of a
> string than this.
>
>
------------------------------
Date: 23 Oct 2002 21:25:48 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Quick way to get the first value?
Message-Id: <ap744s$3bl$1@nets3.rz.RWTH-Aachen.DE>
Also sprach TBN:
> If I have a string similar to...
>
> my $test = "asdfh~sdasb~c~daaf~f";
>
> I know that I can split this into an array and then grab the "word" that I
> want like so...
>
> @words = split(/~/,$test);
> my $firstword = $words[0];
>
> But I'm guessing there's a quicker easier way to grab the first word of a
> string than this.
There are several:
my ($firstword) = split /~/, $test; # impose list context
my ($firstword) = split /~/, $test, 2; # just two fields
my $firstword = (split /~/, $test)[0]; # first element of tmp list
my $firstword = substr $test, 0, index $test, "~";
my ($firstword) = $test =~ /(.*?)~/; # pattern match in list context
and possibly even more.
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Wed, 23 Oct 2002 14:27:18 -0700
From: "Newbie" <mike_constant@yahoo.com>
Subject: Re: Quick way to get the first value?
Message-Id: <ap7477$r4dq1$1@ID-161864.news.dfncis.de>
"TBN" <ihave@noemail.com> wrote in message
news:81Et9.105$EOT8.19660932@news2.randori.com...
> If I have a string similar to...
>
> my $test = "asdfh~sdasb~c~daaf~f";
>
> I know that I can split this into an array and then grab the "word" that I
> want like so...
>
> @words = split(/~/,$test);
> my $firstword = $words[0];
>
> But I'm guessing there's a quicker easier way to grab the first word of a
> string than this.
my $firstword = (split(/~/, $test))[0];
my ($firstword) = $test =~ /(\w+).*/;
but it's not worth it.
------------------------------
Date: Wed, 23 Oct 2002 17:33:56 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Quick way to get the first value?
Message-Id: <Pine.A41.3.96.1021023173308.29506B-100000@cortez.sss.rpi.edu>
On Wed, 23 Oct 2002, TBN wrote:
>If I have a string similar to...
>
>my $test = "asdfh~sdasb~c~daaf~f";
>
>I know that I can split this into an array and then grab the "word" that I
>want like so...
>
>@words = split(/~/,$test);
>my $firstword = $words[0];
my ($first) = $test =~ /([^~]*)/;
my ($first) = $test =~ /(.*?)~/;
my ($first) = split /~/, $test;
my ($first) = split /~/, $test, 2;
--
Jeff "japhy" Pinyan RPI Acacia Brother #734 2002 Acacia Senior Dean
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 23 Oct 2002 15:04:19 -0700
From: lucid1@mediaone.net (Brian)
Subject: RMI Equivalent in Perl?
Message-Id: <961d6f35.0210231404.4c218edc@posting.google.com>
Hi,
I have a perl script executed on an NT machine, and I need to be able
to execute system calls on a unix server as the current user. I do not
want to use RSH. I want to use a more solid method. In Java, there is
RMI which would do the job. I'm wondering if perl has some
equivalent?
Thanks for any info.
------------------------------
Date: Wed, 23 Oct 2002 13:15:10 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: Running Perl through cron
Message-Id: <3DB7034E.9F8C0753@motorola.com>
Tony Curtis wrote:
>
> >> On Tue, 22 Oct 2002 18:40:19 -0700,
> >> Matthew Stoker <matt.stoker@motorola.com> said:
>
> > Which script returns the access denied errors, the Perl
> > script or the rsynch.sh script? I've noticed in Unix
> > that attempting to launch a perl script from a c program
> > gives similar problems. In that case it appears to be
> > due to the shebang (#!/usr/bin/perl) not getting
> > processed correctly. If this is the cause of your
> > problem, a simple workaround is to write a small script
> > file that simply launches the perl script and have the
> > calling program (cron in your case) call the shell
> > script rather than the perl script.
>
> Nonsense. But what are you talking about anyway?
I'm talking about a program I have, written in C (by a co-worker). The
C program launches a user-specified program that performs some
calculations. If I specify a perl script as the user- specified
program, the contents of the script are fed by the C program to the
shell, which obviously cannot understand the perl commands and it
crashes. However, if instead of specifying the perl program directly, I
specify a shell script which does nothing except launch the perl
program, everything works. I suspect that the reason is that running the
shell script, forces the the perl program to be launched from the shell
environment which properly interprets the shebang, launches the perl
interpreter and runs the perl program. I do not claim that every C
program does this, just the program that I have. Nevertheless, its
possible that something similar could be happening with the cron job.
--
/------------------------------------------------------------------\
| Matt Stoker | email: matt.stoker@motorola.com
|
| Motorola, SPS EL722 | Phone: (480)413-2744 |
| 2100 E Elliot Road | Pager: (888)645-8163 |
| Tempe, AZ 85284 | Fax: (480)413-4511 |
|------------------------------------------------------------------|
------------------------------
Date: 23 Oct 2002 11:44:12 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: some questions
Message-Id: <3db6edfc@news.victoria.tc.ca>
AGoodGuyGoneBad (agoodguygonebad@aol.com) wrote:
: 1)If I call this sub several times
: sub Option{
: print "<SELECT NAME=\"$pre\">\n";
: print "<OPTION VALUE = \"\"></OPTION>\n";
: for ($ii=1;$ii<15;$ii++) {
: print "<OPTION VALUE = \"$ii\">$ii</OPTION>\n";
: }
: print "</SELECT>\n";
: }
: is it any quicker to just do
: sub Option{
: print qq~
: <SELECT NAME=\"$pre\">
: <OPTION VALUE = \"\"></OPTION>
note - the " does not need to be escaped because you have
already indicated that ~ is the quote character (qq~).
: <OPTION VALUE =\"1\">1</OPTION>
: <OPTION VALUE =\"2\">2</OPTION>
: <OPTION VALUE =\"3\">3</OPTION>
: <OPTION VALUE =\"4\">4</OPTION>
: <OPTION VALUE =\"5\">5</OPTION>
: <OPTION VALUE =\"6\">6</OPTION>
: <OPTION VALUE =\"7\">7</OPTION>
: <OPTION VALUE =\"8\">8</OPTION>
: <OPTION VALUE =\"9\">9</OPTION>
: <OPTION VALUE =\"10\">10</OPTION>
: <OPTION VALUE =\"11\">11</OPTION>
: <OPTION VALUE =\"12\">12</OPTION>
: <OPTION VALUE =\"13\">13</OPTION>
: <OPTION VALUE =\"14\">14</OPTION>
: </SELECT>
: ~;
: }
I do not think the speed will be much different. Use the one that most
clearly shows what the program is doing, and is easiest for you to work
with. If you use the first, then you might choose to make it more general
by passing the loop count as a parameter.
: 2)
: Option();
: is better (in this case) than
: &Option;
: right ?
Option(); will normally be the correct way to call the function.
These two ways of calling the function do slightly different things.
&function is like an inline macro because it uses its caller's parameters.
Somethimes that is very useful, but not normally what you want.
: 3) to avoid stringification, should this
: print "$Step2<br>\n";
: be something like
: print $Step2."<br>\n";
: or does it really matter ?
The above do not "avoid stringification", they do the opposite, they force
stringification. On the other hand -> print $Step2 , "<br>\n"; <- (note
comma) would not force stringification of $Step2.
It does not appear to matter here, use which ever you find easiest to work
with. Personally, of the above two choices, I would choose
"$Step2<br>\n".
------------------------------
Date: Wed, 23 Oct 2002 18:58:54 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: some questions
Message-Id: <Xns92B098673FCD5dkwwashere@216.168.3.30>
AGoodGuyGoneBad <agoodguygonebad@aol.com> wrote on 23 Oct 2002:
> 1)If I call this sub several times
>
> sub Option{
> print "<SELECT NAME=\"$pre\">\n";
> print "<OPTION VALUE = \"\"></OPTION>\n";
> for ($ii=1;$ii<15;$ii++) {
It's easier and more Perl-ish to write this as
for $ii (1..14) {
Even better would be if you enabled strictures with
use strict;
at the beginning of the program, and wrote it as
for my $ii (1..14) {
# loop stuff here, such as
print qq{<option value="$ii">$ii</option>\n};
}
By using my(), $ii is confined to your for() loop and is not visible
outside it. It probably won't matter in what you're writing now, but in
larger programs you'll want variables to have the smallest possible scope
so you don't have to keep track of numerous global variables that, if
accidentally modified, could break your program.
> print "<OPTION VALUE = \"$ii\">$ii</OPTION>\n";
> }
> print "</SELECT>\n";
> }
>
> is it any quicker to just do
>
> sub Option{
> print qq~
><SELECT NAME=\"$pre\">
><OPTION VALUE = \"\"></OPTION>
><OPTION VALUE =\"1\">1</OPTION>
><OPTION VALUE =\"2\">2</OPTION>
><OPTION VALUE =\"3\">3</OPTION>
><OPTION VALUE =\"4\">4</OPTION>
><OPTION VALUE =\"5\">5</OPTION>
><OPTION VALUE =\"6\">6</OPTION>
><OPTION VALUE =\"7\">7</OPTION>
><OPTION VALUE =\"8\">8</OPTION>
><OPTION VALUE =\"9\">9</OPTION>
><OPTION VALUE =\"10\">10</OPTION>
><OPTION VALUE =\"11\">11</OPTION>
><OPTION VALUE =\"12\">12</OPTION>
><OPTION VALUE =\"13\">13</OPTION>
><OPTION VALUE =\"14\">14</OPTION>
></SELECT>
> ~;
> }
Yecch. I don't care for it myself, but it will work. You don't need to
escape the double-quotes inside qq(), though.
> Option();
> is better (in this case) than
> &Option;
> right ?
Yes. Unless you know what you're doing and have a reason for it, always
use sub_name() and not &sub_name when you call a subroutine. See perlsub
(in the Description section) for more details.
>
> 3) to avoid stringification, should this
> print "$Step2<br>\n";
> be something like
> print $Step2."<br>\n";
> or does it really matter ?
In this case, you probably want it to be a string, so it doesn't matter.
The first of the two is generally preferred because it's easier to read.
If you use CGI.pm, you don't even have to create the Option() subroutine,
and could just write
use CGI qw(:standard);
print popup_menu(-name=>$pre, -values=>[1..14], -default=>'');
or you could use any of several variations to get your <select> menu. See
the CGI.pm docs.
--
David K. Wall - usenet@dwall.fastmail.fm
"Oook."
------------------------------
Date: Wed, 23 Oct 2002 21:04:02 +0200
From: hubert depesz lubaczewski <depesz@depesz.pl>
Subject: Re: some questions
Message-Id: <slrn.pl.ardsl2.4o7.depesz@depeszws.depesz.pl>
AGoodGuyGoneBad wyrzeĽbił(a):
> 1)If I call this sub several times
> is it any quicker to just do
use Benchmark qw(cmpthese);
and check.
but i'd rather go with first sub. the other one (with 15 lines of html)
is just ugly.
> 2)
> Option();
> right ?
right.
> 3) to avoid stringification, should this
> print "$Step2<br>\n";
> be something like
> print $Step2."<br>\n";
> or does it really matter ?
in fact it doesn't matter. of course stringification takes some time,
but when i tested it, the difference was notmeasurable.
depesz
--
hubert depesz lubaczewski http://www.depesz.pl/
------------------------------------------------------------------------
Mój Boże, spraw abym milczał, dopóki się nie upewnię, że naprawdę mam
co¶ do powiedzenia. (c) 1998 depesz
------------------------------
Date: Wed, 23 Oct 2002 14:37:40 -0400
From: "Francois Pichette" <fpichette@NOSPAMvideotron.ca>
Subject: Using the \n escape code (Beginner question)
Message-Id: <T%Bt9.24332$Td.444395@wagner.videotron.net>
I can't seem to be able to write a script that uses the newline escape code
(\n)
When I run the script:
********
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello \n there";
*********
It doesn't create a new line between "Hello" and "there" in my web browser.
When I look at the source the newline appears.
Thanks
------------------------------
Date: Wed, 23 Oct 2002 11:49:05 -0700
From: "Newbie" <mike_constant@yahoo.com>
Subject: Re: Using the \n escape code (Beginner question)
Message-Id: <ap6quj$rvaft$1@ID-161864.news.dfncis.de>
"Francois Pichette" <fpichette@NOSPAMvideotron.ca> wrote in message
news:T%Bt9.24332$Td.444395@wagner.videotron.net...
> I can't seem to be able to write a script that uses the newline escape
code
> (\n)
>
> When I run the script:
>
> ********
> #!/usr/bin/perl
>
> print "Content-type: text/html\n\n";
> print "Hello \n there";
> *********
>
> It doesn't create a new line between "Hello" and "there" in my web
browser.
> When I look at the source the newline appears.
>
> Thanks
To make a newline in html, use <br>
print "Hello <br> there";
------------------------------
Date: Wed, 23 Oct 2002 14:57:30 -0400
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: Using the \n escape code (Beginner question)
Message-Id: <ap6req$3nj8@nrn2.NRCan.gc.ca>
Actually, if you look at the source code generated by the browser (view >
source), you'll see a \n really prints:
Hello
there
but the browser will interpret it as "Hello there". As Newbie said it, you
have to write:
print "Hello<br>there";
for the browser to display:
Hello
there
Good luck!
"Newbie" <mike_constant@yahoo.com> wrote in message
news:ap6quj$rvaft$1@ID-161864.news.dfncis.de...
>
> "Francois Pichette" <fpichette@NOSPAMvideotron.ca> wrote in message
> news:T%Bt9.24332$Td.444395@wagner.videotron.net...
> > I can't seem to be able to write a script that uses the newline escape
> code
> > (\n)
> >
> > When I run the script:
> >
> > ********
> > #!/usr/bin/perl
> >
> > print "Content-type: text/html\n\n";
> > print "Hello \n there";
> > *********
> >
> > It doesn't create a new line between "Hello" and "there" in my web
> browser.
> > When I look at the source the newline appears.
> >
> > Thanks
>
> To make a newline in html, use <br>
>
> print "Hello <br> there";
>
>
------------------------------
Date: Wed, 23 Oct 2002 20:15:13 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Using the \n escape code (Beginner question)
Message-Id: <3DB6F541.3E9E2D28@oracle.com>
Francois Pichette wrote:
> I can't seem to be able to write a script that uses the newline escape code
> (\n)
>
> When I run the script:
>
> ********
> #!/usr/bin/perl
>
> print "Content-type: text/html\n\n";
> print "Hello \n there";
> *********
>
> It doesn't create a new line between "Hello" and "there" in my web browser.
> When I look at the source the newline appears.
>
> Thanks
That's because you've told your browser to use text/html and your newline "\n"
is text/plain. You can either change text/html to text/plain or substitute
your \n for <br> which is a newline in html.
Graham Wood.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4017
***************************************