[17385] in Perl-Users-Digest
Perl-Users Digest, Issue: 4807 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 4 00:05:55 2000
Date: Fri, 3 Nov 2000 21:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973314308-v9-i4807@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 3 Nov 2000 Volume: 9 Number: 4807
Today's topics:
Re: "chown" of symlink instead of linked file (Martien Verbruggen)
Re: CGI newbie - premature end of script headers??? (Jon Ericson)
Re: CGI newbie - premature end of script headers??? <mtaylorlrim@my-deja.com>
Re: comparing html files (Gwyn Judd)
Re: efficiently passing objects <dale@emmons.dontspamme.com>
Re: Errors from 'make test' while installing 5.6.0 <ehberry@uswest.com>
Re: Form radio/drop down.. <gp@no.thanks>
Re: garbage collecting hashes are slow (Gwyn Judd)
Re: hello world (Gwyn Judd)
Re: how to do a download process? (Chris Fedde)
Re: Mail::Send <yanoff@yahoo.com>
Newbie recursion question <kai_jang@my-deja.com>
Re: Newbie recursion question (Chris Fedde)
Re: Newbie recursion question <harrisr@bignet.net>
Re: Perl Question <yanoff@yahoo.com>
Re: Perl syntax and beyond (was: Re: Perl style and mod (Gwyn Judd)
Re: String manipulation?? <james@NOSPAM.demon.co.uk>
Re: String manipulation?? (Martien Verbruggen)
Re: Timers? (Gwyn Judd)
Re: Unix commands via perl? (Dave)
Re: Unix commands via perl? (Dave)
Re: Unix commands via perl? <ren.maddox@tivoli.com>
Re: Unix commands via perl? (Martien Verbruggen)
Re: Unix commands via perl? <wyzelli@yahoo.com>
Re: values of strings <rick.delaney@home.com>
Re: Zone to host data (Chris Fedde)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 4 Nov 2000 13:49:52 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: "chown" of symlink instead of linked file
Message-Id: <slrn906uag.ac5.mgjv@martien.heliotrope.home>
On Wed, 1 Nov 2000 22:57:44 +0100,
Otto Wyss <otto.wyss@bluewin.ch> wrote:
>
> Anyway since I'm not a very good perl programmer, could anybody tell my
> how I have to change my statements
>
> my (atime, $mtime) = (stat($file))[8,9];
> chown $uid, $gid, $file;
> utime ($atime, $mtime, $file);
>
> so it just changes the owner of the symlink.
I waited a little while to see if anyone else did know, but it looks
like they don't. you already have had answers on how to solve the firts
bit.
AFAIK there is not way to set mtime and atime explicitly on a symlink.
If there are methods to do this, they will be terribly platform
specific. I don't think there is a syscall for it, so Perl won't be able
to do it.
I might be wrong, you could ask in comp.unix.programmer. If there is a
syscall, you can call it from Perl. If there isn't, you're out of luck.
And I still fail to see why you would want to do all of this.
Martien
--
Martien Verbruggen |
Interactive Media Division | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: 4 Nov 2000 00:03:07 GMT
From: Jonathan.L.Ericson@jpl.nasa.gov (Jon Ericson)
Subject: Re: CGI newbie - premature end of script headers???
Message-Id: <8FE1A6DBAJonathanLEricsonjpln@137.78.50.25>
it_likes_you@yahoo.com (Tomas) wrote in
<newscache$tjxg3g$55g$1@news.freegates.be>:
>
>I'm don't do well in CGI. I'm trying to make a form-to-mail cgi, but I
>just grabbed it from several tutorials. The script looks fine, but when
>I run it on a webserver, it says "Premature end of script headers"
>
>Also, I've read that you can print HTML easier when you use "print
><<EndOfHTML" so that you don't have to use the print statement
><<everytime.
>But is the "EndOfHTML" part neccesary or can you use other thing such as
><<errorpage? And can you use EndOfHTML more than once in a script?
perldata has several paragraphs explaining how here-docs work. There is
also a FAQ (in perlfaq4) which discusses potential pitfalls with this
syntax. Please get to know you documentation.
Jon
------------------------------
Date: Sat, 04 Nov 2000 01:16:26 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: CGI newbie - premature end of script headers???
Message-Id: <8tvo15$cao$1@nnrp1.deja.com>
In article <newscache$tjxg3g$55g$1@news.freegates.be>,
"Tomas" <it_likes_you@yahoo.com> wrote:
> Hi,
>
> I'm don't do well in CGI. I'm trying to make a form-to-mail cgi, but
I just
> grabbed it from several tutorials. The script looks fine, but when I
run it
> on a webserver, it says "Premature end of script headers"
>
It sounds like you may have uploaded in binary instead of ascii.
Mark
--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 04 Nov 2000 03:06:44 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: comparing html files
Message-Id: <slrn906va2.fn7.tjla@thislove.dyndns.org>
I was shocked! How could SURAJ MUKATIRA <suraj@purdue.edu>
say such a terrible thing:
> This message is in MIME format. The first part should be readable text,
> while the remaining parts are likely unreadable without MIME-aware tools.
> Send mail to mime@docserver.cac.washington.edu for more info.
ick. Please don't do that. This is a plain text only newsgroup.
>---559023410-851401618-973265371=:18296
>Content-Type: TEXT/PLAIN; charset=US-ASCII
>
>
>Hi,
>
> I have a PERL program that compares >2 html files and puts out
>common features. I am a novice in the PERL programming world and am unable
>to figure out the errors it spits out upon execution.
> If there is anyone out there with the time to go through the
>attached file and help me with it ...i'd appreciate it very much.
No thanks. I suggest what you need to do is cut down your script to the
absolute minimum that still exhibits the behaviour (and runs) and then
post that, as plain text, inside your message.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Marriage is learning about women the hard way.
------------------------------
Date: Fri, 3 Nov 2000 21:43:33 -0600
From: "Dale Emmons" <dale@emmons.dontspamme.com>
Subject: Re: efficiently passing objects
Message-Id: <t071fb5hsiapd9@corp.supernews.com>
> > I'm curious, is code like this efficient? Or is there a better way to do
> it?
>
> You need to narrow this down to a smaller chunk or smaller chunks of code
Thanks for your reply. Perhaps this is a bit simpler:
-----------
my $dbh = DBI->connect("dbi:mysql:$settings{dbName}", $settings{dbUser},
$settings{dbPassword}, {
PrintError => 0,
RaiseError => 1
});
do_sth_with_db( dbh => $dbh, something => $something );
$dbh->disconnect;
sub do_sth_with_db {
my %passed = @_;
my $something = $passed{dbh}->quote( $passed{something} );
$passed{dbh}->do(qq{
DO SOMETHING
WHERE something_else = $something
});
}
-----------
What I'm wondering is, is passing the DBI object into do_sth_with_db() like
I did the most efficient way to do so? Or is there a better way?
Thanks,
Dale
------------------------------
Date: Fri, 03 Nov 2000 23:41:45 GMT
From: Ed Berry <ehberry@uswest.com>
Subject: Re: Errors from 'make test' while installing 5.6.0
Message-Id: <3A034D34.D5C19428@uswest.com>
Anno Siegel wrote:
> Ed Berry <ehberry@uswest.com> wrote in comp.lang.perl.misc:
> >My configuration is:
> >
> >SCO Openserver 5.0.0
> >current Perl is 5.00404
> >upgrading to 5.6.0
> >using cc
> >
> >The errors I am getting in 'make test':
> >
> >lib/socket...........Can't load '../lib/auto/Socket/Socket.so' for
> >module Socket: dynamic linker: ./perl: relocation error: symbol not
> >found: PL_stack_sp at ../lib/XSLoader.pm line 73.
> >at ../lib/Socket.pm line 450
> >Compilation failed in require at lib/socket.t line 14.
> >BEGIN failed--compilation aborted at lib/socket.t line 14.
> >FAILED at test 0
> >
> >This is one of many messages I get when I run 'make test'. 'sh
> >Configure -de' ran OK. 'make' ran fine.
> >
> >The symbol not found is always 'PL_stack_sp' but the can't load messages
> >are different: Glob.so, SysV.so, IO.so...
>
> In 5.6.0 a number of names in the source have been given the prefix
> "PL_" which the predecessors didn't have. While this is generally
> a good thing, modules that refer directly to symbols must get this
> right, meaning that the module must be upgraded to comply with the
> naming convention. Find out if there is a compliant version of
> Socket.pm.
>
> If there isn't, you must supply the flag "_DPERL_POLLUTE" to the
> compiler. Then the old names (without the PL_-prefix) will be
> compiled along with the new ones. This can be done using the right
> incantation when you generate the Makefile via "perl Makefile.PL".
> I think it's "perl Makefile.PL POLLUTE=1".
>
> Anno
Using 'sh Configure -Accflags=-DPERL_POLLUTE' put the flag in but didn't
change the output of the 'make test'. I tried the 'perl Makefile.PL
POLLUTE=1' and got the following message:
'POLLUTE' is not a known MakeMaker parameter name.
Isn't it trying to use the just the files in the Perl distribution? In other
words, it's not looking for any UNIX system files installed on the machine.
------------------------------
Date: Fri, 3 Nov 2000 21:34:02 -0500
From: "Gary P" <gp@no.thanks>
Subject: Re: Form radio/drop down..
Message-Id: <StKM5.13297$GI4.8846@newsfeed.slurp.net>
Here is a site i find useful if you dont have the books:
http://www.aplus.net/CGI.html
using this with the regular if, or while statement works great for me.
"Sangam" <mysangam@my-deja.com> wrote in message
news:8tv6ol$tef$1@nnrp1.deja.com...
> Hi,
> I would like to print radio buttons OR drop down menu on fly from the
> given data. I need some help. I am trying it using HTML::Template
> Where I have defined the format for each one. It doesn't work the way I
> want since in radio buttons, the 'name' goes in each button where as in
> drop down, it goes only once.. ..The selection of the format (drop down
> or radio) comes from the database..
> Any ideas would be helpful
>
> Thanks..
>
>
>
>
>
>
>
>
>
>
> --
> .
> .
> .
> Sangam
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Sat, 04 Nov 2000 02:51:37 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: garbage collecting hashes are slow
Message-Id: <slrn906udm.fn7.tjla@thislove.dyndns.org>
I was shocked! How could Fulko Hew <fulko@wecan.com>
say such a terrible thing:
>Gwyn Judd wrote:
>>
>> I was shocked! How could Fulko Hew <fulko@wecan.com>
>> say such a terrible thing:
>
>I didn't want to say it!
:) Oh by the way, it's considered rude to send someone an emailed reply
and post the same reply to usenet without mentioning that fact.
>> >My app generates and clears a large number of hashes.
>>
>> >If you do the single sets, (on my machine) each set takes about
>> >55 usec. Adding the clear statement ups the loop time to 800 usec.
>>
>> I don't get the same results as you with virtually the same code.
>
>Remember its a sample, and the speed _really_ depends on whats been
>happening before that sample code. Basically I generate a hash that
>has a few thousand items, a few dozen times. Then I generate a few
>hundreds of thousand hashes that contain one or two items. Clearing
>those small hashes sometimes takes a long time, but they are quick if
>I skip that code that created and destroyed the big hashes.
>So go figure?
Beats me. What if you store all the little hashes in an array and just
clear the array instead of clearing them one at a time? Are you sure you
aren't running out of memory (when givin the choice of memory or speed,
Perl tends to throw memory at the problem :) )
>> Can you post the script you use the do the benchmarking?
>
>Unfortunately not. Its propriatary code. It will take me some time
>to build a test case that re-creates the same symptoms without the
>special functionality. If you are interested (privately) I might
>be able to send you the code, but I can't post it "as is".
Well you'd be much better off posting it to usenet. I doubt I'd be able
to find and fix your problem by myself but there are a number of experts
here who probably can. Besides the end of year is coming up so I
probably don't have time. See if you can reduce the problem to an example
that has the behaviour and doesn't give away your proprietary secrets
and post it here?
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
BOFH excuse #390:
Increased sunspot activity.
------------------------------
Date: Sat, 04 Nov 2000 03:07:56 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: hello world
Message-Id: <slrn906vca.fn7.tjla@thislove.dyndns.org>
I was shocked! How could »´ä¸} <nobody@nowhere.net>
say such a terrible thing:
>print "hello world"
print "*plonk*\n";
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
QOTD:
Some people have one of those days. I've had one of those lives.
------------------------------
Date: Fri, 03 Nov 2000 23:33:46 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: how to do a download process?
Message-Id: <uXHM5.163$Bf7.184976896@news.frii.net>
In article <8tvdb4$3lv$1@nnrp1.deja.com>,
Juan Durán <Odeen01@yahoo.com> wrote:
>hi guys,
>does somebody by any chance know how to create a process to download a
>file (actually is an HTML file)?
>i have to give the option to the enduser to click in a link and then
>a "save as" box should appear so the user can save the html file i am
>offering
>
>if somebody can help me, please, i'm stuck in my job because of that
>
>
>thanks a lot!
>
This is not specificly a Perl issue but the easiest way to do it using perl is
to follow the examples in the manual pages for CGI.pm.
Good Luck
chris
--
This space intentionally left blank
------------------------------
Date: Wed, 01 Nov 2000 13:21:14 -0600
From: Scott Yanoff <yanoff@yahoo.com>
To: blaine <lattice@cassandra.intergate.ca>
Subject: Re: Mail::Send
Message-Id: <3A006D2A.1719F307@yahoo.com>
blaine wrote:
>
> I'm trying to use Mail::Send to send email, since I'd like to be at least a
> /little/ more portable than writing to a pipe. However, I'm running into
> problems with setting custom headers.
>
> %headers = (
> to => $to,
> cc => $cc,
> bcc => $bcc,
> subject => $subject,
> );
> $msg->add( 'From', 'my-address@here.com' );
>
> Everything works, the message is sent, and the %headers are set properly.
> Unfortunately, the 'From' header is not set. I've tried using $msg->set(),
> as well as setting other headers (ie, $msg->set( 'X-Myheader', 'Mydata' ) )
> to no avail. Is this a bug in Mail::Send, or am I just doing something wrong?
>
> I've also tried sending mail with /usr/sbin/sendmail, and through a direct tcp
> port 25 connection, both of which succeeded.
Please excuse me, but I haven't used this package before.
However, I'd like to offer suggestions to help.
For your %headers hash, is "from" just not an option here?
Secondly, in your $msg->add, try "From:" instead of "From" and see what
happens.
When you do receive a mail message, who is it "from"?
Lastly, there is the chance that the mail package or programs it calls
do not see you as a trusted user. Often with mail, it will not let you
alter the "from" of an email message unless you are known as a trusted
user.
Just some suggestions, good luck......
-Scott
------------------------------
Date: Fri, 03 Nov 2000 23:11:57 GMT
From: Kai Jang <kai_jang@my-deja.com>
Subject: Newbie recursion question
Message-Id: <8tvgnn$6d6$1@nnrp1.deja.com>
Hi. Long time listner, first time caller. :o)
I was hoping to get a little help. I am new to Perl, and have not
quite gotten everything learned that I need to. Anyway, this is the
problem. I have a program that I am writing that will read through a
directory tree, and display all the files and directorys. I am latter
going to change all file names to lowercase, w/o any special
characters. For now, I will just be happy to get it to print the
complete directory structure. Right now, it reads the files/directorys
from the given directory, but goes no further. My question is how to
get the recursion to work w/o getting the "deep recursion error". I
have read the perldoc's w/ no luck. Any suggestions are greatly
appreaciated. My code is below. Don't laught too hard. It's my first
Perl program. Thanks...
#!/usr/local/bin/perl -w
use File::Find;
print "Enter your starting directory: ";
$dir1 = <stdin>;
chomp ($dir1);
#if ($dir1) {
print "\n Searching $dir1 ... \n";
find(\&showit, $dir1);
print "\n DIRECTORIES in $dir1: \n";
for ($i=0;$i<=$#dirs;$i++) {
print "$dirs[$i] \n";
}
print "\n FILES in $dir1: \n";
for ($j=0;$j<=$#files;$j++) {
print "$files[$j] \n";
}
#### subs ###############
sub showit {
&showit($_[0]);
push (@dirs, $_) if ((-d $_) && ($_ !~m/^\.$/));
push (@files, $_) if (-f $_);
}
-Kai Jang
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 03 Nov 2000 23:30:52 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Newbie recursion question
Message-Id: <MUHM5.162$Bf7.170838528@news.frii.net>
In article <8tvgnn$6d6$1@nnrp1.deja.com>,
Kai Jang <kai_jang@my-deja.com> wrote:
>Hi. Long time listner, first time caller. :o)
>
>sub showit {
> &showit($_[0]);
> push (@dirs, $_) if ((-d $_) && ($_ !~m/^\.$/));
> push (@files, $_) if (-f $_);
>}
The first thing that showit does is call showit. That's what's called
recursion. If I comment that out then it seems to work more like you'd
expect.
good luck
chris
--
This space intentionally left blank
------------------------------
Date: Fri, 3 Nov 2000 20:49:16 -0500
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Newbie recursion question
Message-Id: <t06qnq426m7r01@corp.supernews.com>
Chris Fedde <cfedde@fedde.littleton.co.us> wrote in message
news:MUHM5.162$Bf7.170838528@news.frii.net...
> In article <8tvgnn$6d6$1@nnrp1.deja.com>,
> Kai Jang <kai_jang@my-deja.com> wrote:
> >Hi. Long time listner, first time caller. :o)
> >
> >sub showit {
> > &showit($_[0]);
> > push (@dirs, $_) if ((-d $_) && ($_ !~m/^\.$/));
> > push (@files, $_) if (-f $_);
> >}
A fine example of a loop as defined in the camel glossary.
------------------------------
Date: Wed, 01 Nov 2000 16:43:12 -0600
From: Scott Yanoff <yanoff@yahoo.com>
To: Graeme Turner <graemeturner@blueyonder.co.uk>
Subject: Re: Perl Question
Message-Id: <3A009C80.B7C3A52A@yahoo.com>
Graeme Turner wrote:
>
> Does anyone know how to pass numerous variables into a java applet from a
> perl script (I will be obtaining several values from a mysql database). Once
> the Java applet has finished, how can I get values of the variables inside
> the applet back into a CGI script??
You might consider doing this all in Java and just have it have a
"server" running on your server. The "server" could be written in java
and could service requests from the applet.
Otherwise...
one way to populate an applet with data from a Perl script is to have
the Perl script be a CGI program that generates HTML and part of the
HTML it generates is the reference to your applet. It could then set
parameters as necessary:
#!/usr/bin/perl
print <<EOT;
Content-type: text/html
<HTML>
...
<APPLET.....>
<PARAM NAME="name1" VALUE="value1">
...
</APPLET>
----------------------
That way, your applet gets populated with all the data it needs.
You can have an applet send data back to a Perl script either via an
HTTP call or via a socket. Routines for this exist in various Java
books.
Good luck,
-Scott
------------------------------
Date: Sat, 04 Nov 2000 02:45:19 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl syntax and beyond (was: Re: Perl style and module searches)
Message-Id: <slrn906u1r.fn7.tjla@thislove.dyndns.org>
I was shocked! How could Bart Lateur <bart.lateur@skynet.be>
say such a terrible thing:
>That was not what was originally asked, but a very interesting sidetrack
>anyway.
Oh I dunno, I thought it was what was asked. I guess what I was really
trying to say is that due to the nature of Perl and its size, it's
difficult to really say what the heck Perl "style" really is.
>I must say, that in therory I'm all for orthogonality. But I've grown so
>used to Perl, that I don't even *see* any more in what way it is
>"awkward" when compared to other computer languages. Perl fits pretty
>much like a glove (and that's no a "sperical" one ;-).
Orthogonality is nice because it makes the language smaller. If there is
only a small handful of operators and data types and functions that are
available, then it's simpler to learn the language but the ceiling is
lower. Naturally since they are all Turing complete (or whatever) you
can still do the same things, but that doesn't make doing them any
easier.
>So, I'm curious, for examples in *what* way that Perl deviates from
>normal programming languages, and what makes it more powerful. Regexes
>are one example.
Well lots of langauges have regexes now (tcl, sed, awk etc). What I like
about Perl and what I think makes it different is simply that it doesn't
shrink from adding new features. It's this "big language" feel (kind of
like the "big car" feel only it doesn't have the same 0-60mph figures)
that make it good for people who don't tend to think about things in
orthogonal ways (ie. pretty much anyone). This I think is what
differentiates it from other languages, basically Perl is not afraid of
being difficult to learn all of. This does not make it difficult to
learn Perl because Perl borrows so much from other languages that
basically anyone will find bits in Perl that are familiar. What it does
give you is increased expressiveness so that the more Perl you learn,
the easier it becomes to express the solution to a problem in a familiar
way.
Let me just stop to check that "orthogonal" means what I think it does.
Yup, it seems to. Anyway the cool thing is that since there are so many
different ways to express something in Perl, it doesn't try to restrict
you to the one "right" way of doing it.
I guess this came from how it was originally created, where Larry
basically took all the cool features (regexes, hashes, special
variables, characters to identify variable type etc) from all the
different languages that he liked (aw, sed, shell, C etc) and tied them
together.
>Gwyn, in what way would you like to see Perl go "even further"?
Well how about a linked list data type for a start? I think it would be
useful to have one as a built in type. I know it is possible to create
one using references but the thing about having it as a built in means
it is simpler for everyone to use. Having a linked list type is useful
when you are wanting to add or delete items in the middle of an array.
That is just an example, I am sure there are many other data types and
builtin functions that other languages have and Perl doesn't.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
It is so soon that I am done for, I wonder what I was begun for.
-Epitaph, Cheltenham Churchyard
------------------------------
Date: Fri, 3 Nov 2000 22:39:04 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: String manipulation??
Message-Id: <ant0322041cbfNdQ@oakseed.demon.co.uk>
In article <slrn906cot.ac5.mgjv@martien.heliotrope.home>, Martien Verbruggen
<URL:mailto:mgjv@tradingpost.com.au> wrote:
>
> sub foo
> {
> # Pass on all my work to bar()
> &bar;
> }
Aha, I didn't know that that implicitly passed @_ down as the
parameters of &bar. In fact, I would have expected your &bar to get no
parameters. Can anyone supply a Camel reference for this behaviour?
> One other reason might be to temporarily get rid of the prototype.
Can you give an example of when you would want to
get rid of a prototype?
> But then, I don't like overusing prototypes. I used to think they were
> going to be the next best thing since map, but they get in the way more
> often than they're useful.
Can you give an example of how they could get in the way?
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Sat, 4 Nov 2000 11:04:19 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: String manipulation??
Message-Id: <slrn906kk3.ac5.mgjv@martien.heliotrope.home>
On Fri, 3 Nov 2000 22:39:04 +0000,
James Taylor <james@NOSPAM.demon.co.uk> wrote:
> In article <slrn906cot.ac5.mgjv@martien.heliotrope.home>, Martien Verbruggen
> <URL:mailto:mgjv@tradingpost.com.au> wrote:
> >
> > sub foo
> > {
> > # Pass on all my work to bar()
> > &bar;
> > }
>
> Aha, I didn't know that that implicitly passed @_ down as the
> parameters of &bar. In fact, I would have expected your &bar to get no
> parameters. Can anyone supply a Camel reference for this behaviour?
perlsub
'Subroutines may be called recursively ...'
Camel 2, top of page 112
Camel 3, top of page 222
>
> > One other reason might be to temporarily get rid of the prototype.
>
> Can you give an example of when you would want to
> get rid of a prototype?
#!/usr/local/bin/perl -wl
use strict;
my @array = (1, 2, 3);
sub array
{
return \@array;
}
sub mypush (\@@)
{
my $a_ref = shift;
push @{$a_ref}, @_;
}
&mypush(array, 1, 2, 3);
# Instead of
mypush @{array()}, 1, 2, 3;
I'm sure there are better (there are simpler ones) examples, maybe when
the prototype includes a glob. I didn't say that it is a good idea to do
this, or even that I ever used it. But it is possible,
> > But then, I don't like overusing prototypes. I used to think they were
> > going to be the next best thing since map, but they get in the way more
> > often than they're useful.
>
> Can you give an example of how they could get in the way?
They force a certain context on things. People expect to be able tp
pass arrays, where a list goes. If you force a scalar context on te
first argument, things get unexpectedly odd:
sub foo ($@)
{
my $arg = shift;
print "$arg : @_";
}
my @a = qw(a b c);
foo @a, @a;
__END__
3 : a b c
Now, this is fine as long as it is documented, but the unsuspecting user
could be very, very surprised when they find out that their 'list'
didn't get flattened and passed. There is enough confusion about the
difference between lists and arrays to avoid this. Prototypes shoul,d
only be used for ONE thing, and that is to force a subroutine to act
like one of the builtins. Overuse when you don't need to force an
argument into a certain type is dangerous, and will come back to bite
you, mainly in the form of email of all the users of your code who don't
get what's going on :).
Martien
--
Martien Verbruggen | Since light travels faster than
Interactive Media Division | sound, isn't that why some people
Commercial Dynamics Pty. Ltd. | appear bright until you hear them
NSW, Australia | speak?
------------------------------
Date: Sat, 04 Nov 2000 03:01:58 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Timers?
Message-Id: <slrn906v14.fn7.tjla@thislove.dyndns.org>
I was shocked! How could LostShade <lostshade@home.com>
say such a terrible thing:
>Hello,
> What seems to be a very common theme to this board "I new to Perl"
Well that's nothing new. You have an awful lot of questions in here and
I'm not going to attempt to answer them all. What I suggest you should
do is try and ask only one question per post and keep it all on topic
otherwise people get halfway through and get bored :) To be honest you
don't really explain very well what it is you want to do. You need to be
more specific, explaining exactly what your Perl problem is.
>I saw mention of time() and times(). $^T in an earlyer post all of which
>in my research so far I have found no mention of. Im kinda asking for
>perhaps a little more information on these.
Well there is documentation available on the time() function and the $^T
variable. Have you read those? If so then what didn't you understand?
Actually this seems to be about your only specific Perl question so I
won't answer any of the other stuff. I hope you see what I am trying to
say here.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
You lived with a man who wore white belts? Laura, I'm disappointed in you.
-- Remington Steele
------------------------------
Date: Sat, 04 Nov 2000 00:22:39 GMT
From: dave@;so-.mai (Dave)
Subject: Re: Unix commands via perl?
Message-Id: <3a095638.22498239@news.redhotant.com>
On Thu, 2 Nov 2000 08:24:42 -0500
>On Thu, 02 Nov 2000 11:32:03 GMT, Dave <dave@;so-.mail> wrote:
>
>>Is it possible to use all unix commands via perl ?
>
>
>Yes.
Aha, no answer means not in perl doc yeah? :)
Thanks for your help, i will endeavor to better
your contributions in this ng.
Dave
------------------------------
Date: Sat, 04 Nov 2000 00:23:32 GMT
From: dave@;so-.mai (Dave)
Subject: Re: Unix commands via perl?
Message-Id: <3a0a56d8.22658544@news.redhotant.com>
On 2 Nov 2000 07:36:03 -0700
>In article <3a01504b.8185466@news.redhotant.com>, Dave <dave@;so-.mail> wrote:
>>Is it possible to use all unix commands via perl ?
>>
>>e.g. rm with a switch -
>>
>>rm -s something ?
>
>How many licks does it take to get to the center of a tootsie pop?
>
Hmm.. sounds like yer licked.
Dave
------------------------------
Date: 03 Nov 2000 20:26:14 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Unix commands via perl?
Message-Id: <m3itq4mq0p.fsf@dhcp11-177.support.tivoli.com>
dave@;so-.mai (Dave) writes:
> On Thu, 2 Nov 2000 08:24:42 -0500
>
> >On Thu, 02 Nov 2000 11:32:03 GMT, Dave <dave@;so-.mail> wrote:
> >
> >>Is it possible to use all unix commands via perl ?
> >
> >
> >Yes.
>
> Aha, no answer means not in perl doc yeah? :)
No answer? What do you mean "no answer"? He answered the question
explicitly. You asked if something was possible and he answered that
it was.
Beyond that, the question is really to vague to guess what your
specific concern is. You might be asking any of (or none of):
1. How do I run an external command from within a Perl script?
2. How do I run external commands as if they were built-in to Perl
(like TCL or shell-scripts)?
3. Does Perl auto-magically give me access to UNIX commands on a
non-UNIX system such as Windows NT? (BTW, the answer to this is
"No.")
4. How do I capture the output of external commands?
The point is, you haven't asked a very good question, so you shouldn't
expect a very good answer.
> Thanks for your help, i will endeavor to better
> your contributions in this ng.
Somehow... I have my doubts, but good luck to you on that!
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Sat, 4 Nov 2000 13:52:24 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Unix commands via perl?
Message-Id: <slrn906uf8.ac5.mgjv@martien.heliotrope.home>
On Sat, 04 Nov 2000 00:22:39 GMT,
Dave <dave@;so-.mai> wrote:
> On Thu, 2 Nov 2000 08:24:42 -0500
>
> >On Thu, 02 Nov 2000 11:32:03 GMT, Dave <dave@;so-.mail> wrote:
> >
> >>Is it possible to use all unix commands via perl ?
> >
> >
> >Yes.
>
> Aha, no answer means not in perl doc yeah? :)
You got an answer. A very precise answer to your question. Don't
complain. If you wanted to know something else than this, you should
have asked a different question.
Now that you know it is possible, you are advised to read the Perl
documentation to find out how. It is in there, in multiple places. You
will want to start with the system() function in the perlfunc
documentation.
But, I guarantee you, that if you follow this post up with 'Oh? And how
do I do that?', that you will end up in numerous killfiles. Just read
the manuals.
Martien
--
Martien Verbruggen |
Interactive Media Division | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Sat, 4 Nov 2000 12:57:29 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Unix commands via perl?
Message-Id: <BmLM5.2$V%6.2349@vic.nntp.telstra.net>
"Tom Christiansen" <tchrist@perl.com> wrote in message
news:3a017bd3$1@cs.colorado.edu...
>
> How many licks does it take to get to the center of a tootsie pop?
>
Doesn't the centre keep moving as you lick so you never actually get there?
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Sat, 04 Nov 2000 04:05:46 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: values of strings
Message-Id: <3A038E2D.83E7D188@home.com>
Ren Maddox wrote:
>
> Here is another method that also supplants your split:
>
> printf "%X", $_ for unpack "c*", $string;
print unpack "H*", $string;
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Fri, 03 Nov 2000 23:52:03 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Zone to host data
Message-Id: <DcIM5.164$Bf7.171120128@news.frii.net>
In article <8ttc0h$1fp$1@hermes.nz.eds.com>,
Peter Sundstrom <peter.sundstrom@eds.com> wrote:
>I'm looking to convert zone data to host data, eg:
>
>foo1.foo.com IN A 192.1.1.1
>foo2.foo.com IN A 192.1.1.2
>bar.foo.com IN CNAME foo1.foo.com
>
>would become
>
>192.1.1.1 foo1.foo.com bar.foo.com
>192.1.1.2 foo2.foo.com
>
>I'm unsure which way to approach this. I need to keep the data in the same
>order, so I was thinking of using the Tie::IxHash module and then use
>hostname as the key. Does this seem like a sensible approach?
>
Sounds like a workable approach. Think about how to deal with hosts that
have multiple IP addresses. Think about "round tripping" the data. Can
you get back the same (or equivalent) zone file? What happens to MX records
for example. Is that important?
Just some thoughts
chris
--
This space intentionally left blank
------------------------------
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 4807
**************************************