[12909] in Perl-Users-Digest
Perl-Users Digest, Issue: 319 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 30 23:07:22 1999
Date: Fri, 30 Jul 1999 20:05:08 -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 Fri, 30 Jul 1999 Volume: 9 Number: 319
Today's topics:
64-bit perl on solaris <bills2@technologist.com>
Re: ANNOUNCE: Perl Conference papers <macintsh@cs.bu.edu>
Re: Best way to build a complex data structure (Larry Rosler)
big Oh of sort() func (Ryan Ngi)
Re: big Oh of sort() func (Larry Rosler)
Re: big Oh of sort() func <makkulka@cisco.REMOVETHIS.com>
clearing an already-open file (George)
Code as an argument <neutron@bamboo.verinet.com>
Re: Code as an argument <bwalton@rochester.rr.com>
Convert VAX/VMS Binary floats & doubles to IEEE? <Todd.Ratcliff@jpl.nasa.gov>
Re: ebcdic packed numbers <tchrist@mox.perl.com>
Re: ebcdic packed numbers (Ilya Zakharevich)
flock me! <warish@concentric.net>
Re: flock me! <tchrist@mox.perl.com>
Re: How is perl braindamaged? (was Re: Is LISP dying?) <emschwar@rmi.net>
Re: How to read the submit button as a name or value (brian d foy)
Just Can't, Can't get Net::Telnet to work <Colin@Chaplin.sol.co.uk>
Re: Newbie alert !! (Sam Holden)
print with an inline " <acafounder@crosswinds.net>
Re: print with an inline " <makkulka@cisco.REMOVETHIS.com>
Re: print with an inline " <bwalton@rochester.rr.com>
Re: print with an inline " (Larry Rosler)
Re: Re: How to read the submit button as a name or valu <tchrist@mox.perl.com>
returning to beginning of a file skyfaye@my-deja.com
Re: returning to beginning of a file <bwalton@rochester.rr.com>
Re: running programs from inside perl <qwerty@post.utfors.se>
Re: submit to another form <makkulka@cisco.REMOVETHIS.com>
Re: Trouble shooting please!!! (Larry Rosler)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 30 Jul 1999 18:32:21 -0700
From: Bill S <bills2@technologist.com>
Subject: 64-bit perl on solaris
Message-Id: <37A25225.898E391B@technologist.com>
I've had zero luck trying to compile a 64-bit version of perl 5.005.02
on a solaris 2.6 machine. The version I build seems to recognize
64 bit values, but cannot perform any math operations on them
or print them. It does not understand the printf ("%llx" ) format as
well.
I compiled perl using the -DUSE_LONG_LONG option and
then tried compiling with forced "long long" values in perl.h.
Neither attempt was successful.
I know the stuff works, since I have access to a legacy perl 5.003
build that contains it.
Any ideas on how to enable the 64-bit support?
Where does the processing of "%llx" exist, maybe I can
backtrack from that point. (Looking over the c code for 15
minutes did not reveal where perl processes "printf").
Any help is appreciated.
Please email me at bills@cisco.com.
Thanks.
Bill
------------------------------
Date: 31 Jul 1999 02:58:44 GMT
From: John Siracusa <macintsh@cs.bu.edu>
Subject: Re: ANNOUNCE: Perl Conference papers
Message-Id: <7ntop4$gka$1@news1.bu.edu>
Are the conference talks/groups/tutorials/etc. recorded on video? Are
they transcribed or recorded in any way? If so, are these recordings or
transcriptions made available after the conference (for sale or
published online)?
It seems like a shame for all of this Perl-related coolness to go on "in
private" (i.e. people that can't attend don't get the benefits). It'd
be great if every word spoken at the conference could be transcribed and
put online for free. And video tapes, if reasonably priced, would
probably sell like hot-cakes. Hell, if the agonizingly boring "Computer
Bowl" can make it onto TV via the equally boring "Computer Chronicles"
PBS program, can't the Perl Conference find a way to reach the poor,
unwashed masses?
-----------------+----------------------------------------
John Siracusa | If you only have a hammer, you tend to
macintsh@bu.edu | see every problem as a nail. -- Maslow
------------------------------
Date: Fri, 30 Jul 1999 17:58:10 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Best way to build a complex data structure
Message-Id: <MPG.120be9fc2a0fca96989d7e@nntp.hpl.hp.com>
In article <slrn7q4eef.hek.abigail@alexandra.delanet.com> on 30 Jul 1999
18:49:03 -0500, Abigail <abigail@delanet.com> says...
> kirk@kaybee.org (kirk@kaybee.org) wrote on MMCLIX September MCMXCIII in
> <URL:news:7nsrgq$bt0$1@news-int.gatech.edu>:
> \\
> \\ However, this means that in order to search through and prune out
> \\ certain entries based on certain regular expressions, I would have to do
> \\ something like this:
> \\
> \\ foreach $ThisFile (keys %FileList) {
> \\ if ($ThisFile =~ /regex/) {
> \\ delete $FileList{$ThisFile};
> \\ }
> \\ }
> \\
> \\ This last statement seems that it could be very CPU intensive. The
> \\ other idea I thought of was to store each one like this:
>
> It's not the last statement, it's the 'keys'. Use each().
But the documentation for 'each' says this: "If you add or delete
elements of a hash while you're iterating over it, you may get entries
skipped or duplicated, so don't."
I have been successful deleting entries after the list of keys was
extracted by the 'keys' function (as in the above example). But 'each'
doesn't sound safe based on that documentation (though it worked in my
tests).
One might consider writing the above loop as:
delete @Filelist{grep /regex/ => keys %FileList};
I haven't done a benchmark in a while. Let's see...
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my %hash;
@hash{0 .. 999} = ();
timethese(1 << (shift || 0), {
Cntrl => sub { my %h = %hash },
Each => sub { my %h = %hash;
/[0-5]/ and delete $h{$_} while $_= each %h },
Keys => sub { my %h = %hash; /[0-5]/ and delete $h{$_} for keys %h },
Slice => sub { my %h = %hash; delete @h{grep /[0-5]/ => keys %h} },
});
__END__
Benchmark: timing 1024 iterations of Cntrl, Each, Keys, Slice...
Cntrl: 9 wallclock secs ( 9.31 usr + 0.27 sys = 9.58 CPU)
Each: 30 wallclock secs (29.47 usr + 0.34 sys = 29.81 CPU)
Keys: 22 wallclock secs (21.19 usr + 0.33 sys = 21.52 CPU)
Slice: 20 wallclock secs (19.00 usr + 0.41 sys = 19.41 CPU)
Well, I don't think 'each' beats 'keys' in performance, provided the
list of keys is acceptably short. And the 'slice' is even better than
the loop on keys.
> Of course,
> whether you use a hash or an array, if the list is large, that will
> be a performance hit. You should consider using something like dbm.
Hard to argue with that.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 31 Jul 1999 01:30:34 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: big Oh of sort() func
Message-Id: <37a25104.62031247@news.inet.co.th>
what kind of sort is sort() function ? (selection sort, quick sort !?)
if the input List is a kind of Large will it very slow !?
what's Big-Oh of sort()?
------------------------------
Date: Fri, 30 Jul 1999 19:27:11 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: big Oh of sort() func
Message-Id: <MPG.120bfed59340007b989d80@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <37a25104.62031247@news.inet.co.th> on Sat, 31 Jul 1999
01:30:34 GMT, Ryan Ngi <ryanngi@hotmail.com> says...
> what kind of sort is sort() function ? (selection sort, quick sort !?)
quicksort
> if the input List is a kind of Large will it very slow !?
Yes, for some values of 'kind of' and 'very'.
> what's Big-Oh of sort()?
O(N logN)
You can find more details and the fastest approaches at
http://www.hpl.hp.com/personal/Larry_Rosler/sort/
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 30 Jul 1999 19:30:17 -0700
From: Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com>
Subject: Re: big Oh of sort() func
Message-Id: <37A25FB9.F6BA2640@cisco.REMOVETHIS.com>
While reading an article about Perl Sorting Techniques
and the Schwartzian transform I came across the following
statement -- ( on www.effectiveperl.com )
"The purpose of the Schwartzian Transform is to temporarily cache the
results of expensive key transformations (like -M or split) so that they
are only computed once, not n log n times, for each item being sorted."
This makes me say that the order of Perl's sort is N LOG N.
I can be wrong.
---
Makarand Kulkarni
makarand_kulkarni@usa.REMOVETHIS.net
Ryan Ngi wrote:
>
> what kind of sort is sort() function ? (selection sort, quick sort !?)
>
> if the input List is a kind of Large will it very slow !?
>
> what's Big-Oh of sort()?
------------------------------
Date: Sat, 31 Jul 1999 02:41:36 GMT
From: fred222@mauimail.com (George)
Subject: clearing an already-open file
Message-Id: <fred222-ya023580003007992238530001@news.bellatlantic.net>
Silly little newbie question for the perl folk who know more than I.. when
I have a database file open, read/write, and I'm deleting a line.. I split
it to death, remove the line, then join the results to form a writeable
string that I want to make the file be. My problem is the following: If I
just seek(DAT,0,0) and print the string, there seems to be bits from the
original left over (since my new string is shorter than the old one, as
I've deleted a line, the overlap from the old database remains at the end).
How can I clear the existing data? I don't really want to close the file,
unlink it and make a new file because that would be quite ugly.. I tried
guessing at ways, ie <DAT> = "$newstring" but that didn't seem to work.
I would appreciate greatly any help, and if replies could be emailed to me
also at the following address without the NOTSPAM that would be damn cool:
yurtle@bellatlantic.netNOTSPAM
Thanks & Cheers,
George Henry
--
Just another hacking head >l-d
------------------------------
Date: Sat, 31 Jul 1999 00:53:53 GMT
From: Jack Applin <neutron@bamboo.verinet.com>
Subject: Code as an argument
Message-Id: <BOro3.47$VPg.170532352@news.frii.net>
This works fine, printing "hi\n" three times:
sub many(&$) { &{$_[0]} for 1..$_[1] }
many {print "hi\n"} 3;
If I reverse the order of the arguments to many(), compilation fails:
sub many($&) { &{$_[1]} for 1..$_[0] }
many 3 {print "hi\n"};
Can't use subscript on constant item at ./y line 4, near ""hi\n"}"
Not enough arguments for main::many at ./y line 4, near "};"
Adding a comma to the call doesn't help:
sub many($&) { &{$_[1]} for 1..$_[0] }
many 3, {print "hi\n"};
Type of arg 2 to main::many must be block (not scalar ref
constructor) at ./z line 4, near "};"
Any ideas? Does a code ref as an argument have to be first?
perl -v says: This is perl, version 5.005_03 built for i386-linux
-Jack Applin
neutron@verinet.com
http://www.verinet.com/~neutron/
------------------------------
Date: Fri, 30 Jul 1999 22:29:58 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Code as an argument
Message-Id: <37A25FA6.4593996B@rochester.rr.com>
> ...
> This works fine, printing "hi\n" three times:
>
> sub many(&$) { &{$_[0]} for 1..$_[1] }
> many {print "hi\n"} 3;
>
> If I reverse the order of the arguments to many(), compilation fails:
>
> sub many($&) { &{$_[1]} for 1..$_[0] }
> many 3 {print "hi\n"};
>
> Can't use subscript on constant item at ./y line 4, near ""hi\n"}"
> Not enough arguments for main::many at ./y line 4, near "};"
>
> Adding a comma to the call doesn't help:
>
> sub many($&) { &{$_[1]} for 1..$_[0] }
> many 3, {print "hi\n"};
try:
sub many($&) { &{$_[1]} for 1..$_[0] }
many 3, sub {print "hi\n"};
That works.
------------------------------
Date: Fri, 30 Jul 1999 17:21:11 -0700
From: Todd Ratcliff <Todd.Ratcliff@jpl.nasa.gov>
Subject: Convert VAX/VMS Binary floats & doubles to IEEE?
Message-Id: <37A240B4.D9A42DB5@jpl.nasa.gov>
Hello,
I'm looking for perl modules/libraries/subroutines/etc.
that will let me read/convert binary data created on
a VAX/VMS machine with perl running on an HP/UX machine.
I can use unpack() on the unix box to read the VAX binary
file and correctly convert strings, short integers and long
integers, but, of course, the floats and doubles are another
story.
My searches at CPAN and on the web at large haven't turned
up much but it seems like this sort of thingy should already
exist.
Any info (or pointers to it) would be greatly appreciated.
Many thanks,
Todd
--
__________________________________________________________________
Dr. James Todd Ratcliff Space Geodetic Science & Applications
JET PROPULSION LABORATORY Todd.Ratcliff@jpl.nasa.gov
4800 Oak Grove Dr. MS 238-332 PHONE:(818)354-0204
Pasadena, California 91109-8099 FAX:(818)393-6890
__________________________________________________________________
------------------------------
Date: 30 Jul 1999 18:12:18 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: ebcdic packed numbers
Message-Id: <37a23f62@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
abigail@delanet.com writes:
:_Finite_ or _repeated_ fractions can be. But I challenge you to find 2 bignums
:that form a ratio equal to the square root of 2.
And there are "more" non-algebraic numbers than algebraic ones, since
the algebraic ones would appear to me to be a countable set, but the
non-algebraic ones are not.
--tom
--
sv_magic(sv, Nullsv, 'B', Nullch, 0); /* deep magic */
--Larry Wall, from util.c in the v5.0 perl distribution
------------------------------
Date: 31 Jul 1999 00:14:02 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: ebcdic packed numbers
Message-Id: <7ntf4a$di2$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Abigail
<abigail@delanet.com>],
who wrote in article <slrn7q4d50.hek.abigail@alexandra.delanet.com>:
> _Finite_ or _repeated_ fractions can be. But I challenge you to find 2 bignums
> that form a ratio equal to the square root of 2.
Say, BignumSQRT(2)/1. ;-)
> [Not that's it's impossible to do exact arithmetic on algebraic numbers.
> C-K Yap had an interesting talk on CCCG'92 explaining how to do
> arithmetic on algebraic numbers, using just integers. It's all based on
> the fact that an algebraic number is a root of a polynomial of bounded
> degree, and integer coefficients. But I disgress... ]
Well, Math::Pari module has no problem dealing with algebraic numbers:
perl -MMath::Pari=:DEFAULT,Mod -wle \
' $t = PARIvar("t"); $q = PARIvar("q"); \
$root2 = Mod($t, $t**2 - 2); \
$root3 = Mod($q, $q**2 - 3); \
print "OK" if 24 == (($root2 - $root3)**2 - 5)**2'
OK
However, not that these are "abstract" algebraic numbers, not complex
algebraic numbers. Say, $root2 represents both -sqrt(2) and sqrt(2).
To do calculations with complex algebraic numbers, one needs to keep a
pair of an "abstract" algebraic number (an element of a
finite-dimensional commutative algebra over Q) and a complex
floating-point approximation to this number (a complex number which is
significantly closer to one embedding of the above number into C than
to other embeddings).
PARI has no built-in datatype for such pairs. But since PARI supports
arbitrary-precision (complex) floating-point arithmetic as well, it
should be a quick exercise to write a Perl module which would use
Math::Pari and will make calculations with complex algebraic numbers.
Ilya
P.S. BTW, how hard is it to add a new datatype to PARI nowadays?
------------------------------
Date: 30 Jul 1999 19:22:02 PDT
From: "Warren Bell" <warish@concentric.net>
Subject: flock me!
Message-Id: <7ntmka$moi@chronicle.concentric.net>
open(FILE, "/file.txt");
flock(FILE,2) || print "cannot lock file $!\n";
flock(FILE,8) || print "cannot unlock file $!\n";
close(FILE);
The above code prints me:
cannot lock file Bad file number
What does "Bad file number" mean?
------------------------------
Date: 30 Jul 1999 20:26:13 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: flock me!
Message-Id: <37a25ec5@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
"Warren Bell" <warish@concentric.net> writes:
:open(FILE, "/file.txt");
:flock(FILE,2) || print "cannot lock file $!\n";
:flock(FILE,8) || print "cannot unlock file $!\n";
:close(FILE);
:The above code prints me:
: cannot lock file Bad file number
:What does "Bad file number" mean?
That you didn't open the file.
--tom
--
The secretaries don't understand me. --Rob Pike
------------------------------
Date: 30 Jul 1999 18:21:08 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: How is perl braindamaged? (was Re: Is LISP dying?)
Message-Id: <xkfaesdhdor.fsf@valdemar.col.hp.com>
David Cassell <cassell@mail.cor.epa.gov> writes:
> While I don't vote for bringing language wars here, I don't
> think he's a troll. I've seen other posts by him recently, and
> he can program in Perl. Just because he finds some aspects
> less than appealing doesn't make him evil. Ask Abigail if
> she loves the Perl OO interface. :-)
Well, that was the first one I saw, and when your first post in a
newsgroup is "Hi, I'd like to start a flamewar", well, it doesn't exactly
bode well for the future.
I guess I'll raise my score to mark his posts as "marked read", and see
how that goes.
-=Eric
------------------------------
Date: Fri, 30 Jul 1999 22:44:17 -0400
From: brian@pm.org (brian d foy)
Subject: Re: How to read the submit button as a name or value
Message-Id: <brian-ya02408000R3007992244170001@news.panix.com>
In article <37a2264c@cs.colorado.edu>, tchrist@mox.perl.com (Tom Christiansen) posted:
> 2) It's slower. You're not defining "without the cruft" as *slower*,
> now are you? :-)
> % time perl -MCGI::Request -e 1
> 0.290u 0.040s 0:00.37 89.1%
>
> % time perl -MCGI -e 1
> 0.140u 0.020s 0:00.20 80.0%
well, it compiles more slowly. that's not the whole story, of course.
not that i've ever cared to benchmark them. it doesn't matter to me.
i don't like CGI.pm.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Sat, 31 Jul 1999 01:16:36 +0100
From: "Colin Chaplin" <Colin@Chaplin.sol.co.uk>
Subject: Just Can't, Can't get Net::Telnet to work
Message-Id: <7ntfdk$ot$1@phys-ma.sol.co.uk>
Hi All,
I am doing a small project and I need to telnet to a unix box to zip up a
file so doing it using Perl seemed a good choice, as other parts of this
system are in perl
So I found out about net::telnet and installed that fine, etc
Problem is, even using the supplied examples, I am having little joy.
My first problem was getting it to recognise the command prompt (I was
getting 'timeout waiting for command prompt'). I thought I was being stupid
so changed it to something really simple (I ain't too hot on regexp's) -
that didn't work. Upon further testing I was also getting 'timeout waiting
for password prompt'. It appears to be random which error I get.
The program was trying to telnet the machine it is running on, Redhat Linux
5.2 pretty much as it is out of the box running on a pentium.
I have tried everything I can and still no joy (I got net::ftp working fine
first time)
Am I doing something stupid ? I am sure the regulars in here will jump in
and tell me if I am (Please do :)
Cheers
C.
------------------------------
Date: 31 Jul 1999 02:49:45 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Newbie alert !!
Message-Id: <slrn7q4p2p.nta.sholden@pgrad.cs.usyd.edu.au>
On 30 Jul 1999 17:21:44 GMT, vlad@doom.net <vlad@doom.net> wrote:
>96Vette <cajun@rattler.cajuninc.com> wrote:
>
>> The database definition has been expanded to include five more blank
>> fields at the end of each record. Making the new database example look
>> like this:
>
>> |Mary|601 Elm Street|Nowhere, CA|99999|555-111-2222||||||
>> |Joe|432 Pine Street|Downtown, CA|88888|555-222-3333||||||
>
>
>Since you are new to perl, here's a simple program that will do what you want.
>
>This can easily be written in one line of code. But here's a long version so you
>understand whats going on.
>
>-v
>
>#!/usr/bin/perl -w
>
>open (FILE, "original_db.txt") || die $!;
>open (FILE2, ">new_db.txt") || die $!;
>
>while (<FILE>) {
> chomp;
> print FILE2 "$_|||||\n";
>}
>
>close (FILE);
>close (FILE2);
Which in one line is :
perl -lpi.bak -e '$_.="|||||"'
Much shorter which isn't always a good thing. It does however, use options
that perl programmers should be familiar with. Anytime you see -pi you know
the script is modifying a file line by line (modulo $/). The -l indicates
to me anyway that something is going to be added to the end of the line
hence the removal of the \n. Yes I know you intentionally wrote it
step by step to make it easier to understand.
To be picky though your dies should be die "Unable to open <file> for
<whatever> : $!" makes it much easier to find the error later...
The other way that came to my mind was :
perl -lpi -e '$\="|||||\n"'
But the code should be wrapped in a BEGIN and I couldn't find a command line
option to set $\ to more than a single character.
Well I'm raving so I shall leave now.
--
Sam
I don't want Perl to be beautiful--I want you to write beautiful
programs in Perl.
--Larry Wall
------------------------------
Date: Fri, 30 Jul 1999 21:57:05 -0400
From: "Tom Beauchamp" <acafounder@crosswinds.net>
Subject: print with an inline "
Message-Id: <7ntkma$km6@nnrp1.farm.idt.net>
What would the print statement be to print this line:
<font face="Arial, Helvetica, sans-serif">Arial</font>
I can't figure out how to print the inline quotation marks.
Tom Beauchamp
------------------------------
Date: Fri, 30 Jul 1999 18:52:46 -0700
From: Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com>
Subject: Re: print with an inline "
Message-Id: <37A256EE.FE396DA6@cisco.REMOVETHIS.com>
You have to escape the quotation marks
as follows
print "<font face=\"Arial, Helvetica, sans-serif\">Arial</font>" ;
Regards
Makarand Kulkarni
Tom Beauchamp wrote:
>
> What would the print statement be to print this line:
>
> <font face="Arial, Helvetica, sans-serif">Arial</font>
>
> I can't figure out how to print the inline quotation marks.
>
> Tom Beauchamp
------------------------------
Date: Fri, 30 Jul 1999 22:15:22 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: print with an inline "
Message-Id: <37A25C3A.852DCC4E@rochester.rr.com>
...
> What would the print statement be to print this line:
>
> <font face="Arial, Helvetica, sans-serif">Arial</font>
>
> I can't figure out how to print the inline quotation marks.
...
try
print '<font face="Arial, Helvetica, sans-serif">Arial</font>'."\n";
or
print "<font face=\"Arial, Helvetica, sans-serif\">Arial</font>\n";
or
print <<EOF;
<font face="Arial, Helvetica, sans-serif">Arial</font>
EOF
or ... (there are undoubtedly more ways).
------------------------------
Date: Fri, 30 Jul 1999 19:38:16 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: print with an inline "
Message-Id: <MPG.120c016d2e090a80989d81@nntp.hpl.hp.com>
In article <37A256EE.FE396DA6@cisco.REMOVETHIS.com> on Fri, 30 Jul 1999
18:52:46 -0700, Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com> says,
in the wrong order -- rearranged here for logical thought flow...
> Tom Beauchamp wrote:
> >
> > What would the print statement be to print this line:
> >
> > <font face="Arial, Helvetica, sans-serif">Arial</font>
> >
> > I can't figure out how to print the inline quotation marks.
>
> You have to escape the quotation marks
> as follows
>
> print "<font face=\"Arial, Helvetica, sans-serif\">Arial</font>" ;
No, you don't have too. Perl is much too smart to force you into
unreadability (despite the usual slanders in that vein :-).
In this case, as the string contains nothing needing special
interpretation, single quotes will do fine:
print '<font face="Arial, Helvetica, sans-serif">Arial</font>' ;
When double-quotes are really needed, there is still a better approach.
Read the section "Quote and Quote-like Operators" in perlop, and you
will find the 'qq' operator, which will make life easier and more
pleasant.
print qq{<font face="Arial, Helvetica, sans-serif">Arial</font>\n} ;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 30 Jul 1999 18:09:02 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Re: How to read the submit button as a name or value
Message-Id: <37a23e9e@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, abigail@delanet.com writes:
:While compiling CGI.pm and FileHandle.pm take about the same time on
:my machine, you'll find people that advocate the use of CGI also claim
:FileHandle pulls in thousands of lines and is a waste of resources. ;-)
Filehandle is slower:
% time perl -MFileHandle -e 1
0.200u 0.040s 0:00.37
% time perl -MCGI -e 1
0.140u 0.030s 0:00.23
Moreover, I can *trivially* do everything that Filehandle does without
pulling it in, just by using basic Perl. I can't say as much about the
CGI module, which is several orders of magnitude more functional than
Filehandle (know, I don't know how to quantify that :-), and faster, too.
--tom
--
You want it in one line? Does it have to fit in 80 columns? :-)
--Larry Wall in <7349@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Sat, 31 Jul 1999 02:03:42 GMT
From: skyfaye@my-deja.com
Subject: returning to beginning of a file
Message-Id: <7ntlhq$die$1@nnrp1.deja.com>
I have a file opened for reading. After reaching the end of the file,
can I return to the beginning without closing and opening it again?
Thanks,
Hung
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Fri, 30 Jul 1999 22:21:15 -0400
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: returning to beginning of a file
Message-Id: <37A25D9B.AE707642@rochester.rr.com>
...
> I have a file opened for reading. After reaching the end of the file,
> can I return to the beginning without closing and opening it again?
...
try
seek(FH,0,0);
(see perlfunc for documentation).
------------------------------
Date: Fri, 30 Jul 1999 02:32:09 +0200
From: "Dr. Who" <qwerty@post.utfors.se>
Subject: Re: running programs from inside perl
Message-Id: <37A0F289.72C907E9@post.utfors.se>
olumsbaba@my-deja.com wrote:
> HELP:
> how do I call another program from inside Perl
> e.g
> I have a perl script but inside it I want to run a
> java program [say, java test (where test.class is
> the java class name)]
>
> P.S I am on a UNIX system
>
> marky
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
-
hmm..
system("java","test.class");
------------------------------
Date: Fri, 30 Jul 1999 17:05:35 -0700
From: Makarand Kulkarni <makkulka@cisco.REMOVETHIS.com>
Subject: Re: submit to another form
Message-Id: <37A23DCF.381EB969@cisco.REMOVETHIS.com>
Hi,
This question is not clear.
Are you posting in the sense
that you are trying to use POST method
from a HTML form.
Your reference to "(content -> id=123&page=2 .....)"
makes me feel that you are trying to use
a GET instead to send input to the remote form.
If you are ok with GET method for sending
input to the remote form then you can
do one of the following.
* use a lynx command line option
in the form lynx -source
http://remote-server:port/../form.cgi?id=123&page=2
* Or refer to LWP:UserAgent for other methods
to do the same thing.
Hope this helps.
Regards,
Makarand Kulkarni
makarand_kulkarni@NOSPAM.usa.net
cim wrote:
>
> I have a form and it posts to a perl script
> (content -> id=123&page=2 .....)
>
> the script then processes the form and writes the data.
>
> What I need is that this data (content from the form) is also posted
> to another form on a different server (running similar script).
>
> Anyone. help.
------------------------------
Date: Fri, 30 Jul 1999 18:16:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Trouble shooting please!!!
Message-Id: <MPG.120bee35430e45ce989d7f@nntp.hpl.hp.com>
In article <37a20987@news1.one.net> on 30 Jul 1999 16:22:31 -0400,
Tanvada Jagannadha <jaganna@shell.one.net> says...
> I am stuck with a wierd problem. I'm working on a perl code and i am
> getting an error in the routine given belew:
Oh, much more than that one simple syntax error!
No use of '-w' flag or 'use strict;'.
> open(fpp, "r.txt")
No semicolon; no test for failure to open the file.
No use of upper-case for a filehandle.
> @array = <fpp>;
> foreach $key (keys(%FORM)) {
Use of upper-case for a variable.
> for($n=0; $n<@array; $n++) {
> $temp = substr(@array[$n],0);
Use of array slice instead of scalar (several places).
No-op use of substr.
$temp = $array[$n];
> if($key eq substr($temp,0,8){
So why bother with $temp at all? use 'substr $array[$n], 0, 8'.
> @arr = split(/^/, @array[$n]);
> * for($p=1; $p<@arr; $p++) {
Perhaps you deliberately want to omit the first element of @arr?
> if($FORM{$key} eq @arr[$p]) {
> $score = $score + @arr[$p+1];
> }
Let's hope the match doesn't occur on the last element of @arr.
> $p++;
Incrementing $p twice each time through the loop?
> }
> }
> }
> }
As for the O(N**2) algorithm, David Cassell has pointed you at some
better ways.
> i really couldn't find out what the problem is. Thsi is my first major
> code in perl. Please help me. Thanks in advance.
I hope you have a good book to guide you.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 319
*************************************