[22184] in Perl-Users-Digest
Perl-Users Digest, Issue: 4405 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 15 00:05:54 2003
Date: Tue, 14 Jan 2003 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)
Perl-Users Digest Tue, 14 Jan 2003 Volume: 10 Number: 4405
Today's topics:
A Regular Problem (Stephen Adam)
Re: A Regular Problem <jkeen@concentric.net>
Re: A Regular Problem (Sam Holden)
Re: ActiveState's perlapp (Andrew Allaire)
Re: command-line args style flags from a file (Kevin Newman)
Debugging help <foo@bar.baz>
Re: Flushing the Output Stream <jurgenex@hotmail.com>
Re: How to delete leading&trailing spaces&tabs at once? <jurgenex@hotmail.com>
Re: How to delete leading&trailing spaces&tabs at once? <eric.schwartz@hp.com>
Re: How to delete leading&trailing spaces&tabs at once? <jurgenex@hotmail.com>
HTML::Table conflict? noone@anon.com
Re: HTML::Table conflict? <jurgenex@hotmail.com>
Re: Image::Magick for Activestate 5.8.0 (Win32) (Jay Tilton)
Re: My, our, etc. <goldbb2@earthlink.net>
Re: Need Help (Jay Tilton)
Re: Need to address myself <jurgenex@hotmail.com>
Re: newbie: chapter 4 exercise Llama book (Ed Kastenmeier)
Re: newbie: chapter 4 exercise Llama book <eriz00@yahoo.com>
Re: Perl command line processing, Windows/dos style ? <pkent77tea@yahoo.com.tea>
Re: poe and fork <troc@netrus.net>
Re: Question about high performance spidering in perl <goldbb2@earthlink.net>
Re: return value of backticks under DOS <wksmith@optonline.net>
save and run bytocode (Barry)
Re: The "default thing" <goldbb2@earthlink.net>
unpack usage <noone@nowhere.com>
Re: unpack usage <goldbb2@earthlink.net>
Re: Using Mail::MAiler to send attachment <junk_nntp@hoopajoo.net>
Re: Variable naming convention <jurgenex@hotmail.com>
Re: what's the similar functionality to the '#include' <pkent77tea@yahoo.com.tea>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Jan 2003 19:21:03 -0800
From: 00056312@brookes.ac.uk (Stephen Adam)
Subject: A Regular Problem
Message-Id: <945bf980.0301141921.61f2384c@posting.google.com>
Hi guys and girls,
I'm looking for a way of using a regular expresion to find the nth
instance (or first if thats easier) of a string in an array and return
it's position in that array. Here is the vague pseudocode:
$position = (@array =~ m/<P class=g>/);
Were $position does NOT hold a boolean value of if the string exists
in the array but instead holds the value of its position.
Thanks for your help
Steve
------------------------------
Date: 15 Jan 2003 03:35:44 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: A Regular Problem
Message-Id: <b02kug$ojf@dispatch.concentric.net>
"Stephen Adam" <00056312@brookes.ac.uk> wrote in message
news:945bf980.0301141921.61f2384c@posting.google.com...
> Hi guys and girls,
>
> I'm looking for a way of using a regular expresion to find the nth
> instance (or first if thats easier) of a string in an array and return
> it's position in that array. Here is the vague pseudocode:
>
Finding the first instance should be easy with Perl's 'index' function:
perldoc -f index
------------------------------
Date: 15 Jan 2003 03:47:26 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: A Regular Problem
Message-Id: <slrnb29mee.kg2.sholden@flexal.cs.usyd.edu.au>
On 14 Jan 2003 19:21:03 -0800, Stephen Adam <00056312@brookes.ac.uk> wrote:
> Hi guys and girls,
>
> I'm looking for a way of using a regular expresion to find the nth
> instance (or first if thats easier) of a string in an array and return
> it's position in that array. Here is the vague pseudocode:
>
> $position = (@array =~ m/<P class=g>/);
>
> Were $position does NOT hold a boolean value of if the string exists
> in the array but instead holds the value of its position.
perlfaq4: How do I find the first array element for which a condition is true?
You are allowed to check the documentation, before posting.
--
Sam Holden
------------------------------
Date: 14 Jan 2003 15:38:03 -0800
From: Andrew.Allaire@na.teleatlas.com (Andrew Allaire)
Subject: Re: ActiveState's perlapp
Message-Id: <6bdb91de.0301141538.325011ea@posting.google.com>
I beleive its about the pm vs PM and dll vs DLL extensions. Ofcoarse
windows doesn't care about case in file names like some other
operating systems do. I have gotten similar messages using perlApp and
ignore them unless its my own module complaining.
------------------------------
Date: 14 Jan 2003 19:22:38 -0800
From: knewman00@earthlink.net (Kevin Newman)
Subject: Re: command-line args style flags from a file
Message-Id: <4c8e4398.0301141922.574e7cf0@posting.google.com>
"Harald H.-J. Bongartz" <bongie@gmx.net> wrote in message news:<1067493.27ZDSdSMKy@nyoga.dubu.de>...
> Kevin Newman wrote:
>
> > "Harald H.-J. Bongartz" <bongie@gmx.net> wrote in message
> > news:<1601609.3xdfVSxWaW@nyoga.dubu.de>...
> >> getopts('...F:', \%Options); # get command line options
> >> if ($Options{F}) { # there is a "-F do_flags.txt"
> >> open (OPTFILE, "<$Options{F}")
> >> or die "cannot open option file: $!";
> >> while (<OPTFILE>) {
> >> my %LocalOptions = %Options; # inherit global options
> >> @ARGV = split;
> >> getopts(..., \%LocalOptions); # analyze one line of options
> >> do_something_with_options (\%LocalOptions);
> >> }
> >> close OPTFILE;
> >> } else {
> do_something_with_options (\%Options);
> >> }
> >>
> >> (untested)
> >>
> >> Of course, when using this trivial method you won't get the quoting
> >> capabilities of the shell, i.e. your do_flags.txt should not contain
> >> -c -o "Output File With Blanks.o"
> >> or something like that.
> >>
> >
> > I like this too (see the reply to Ben Morrow). BTW, can you describe
> > a non trivial method to handle filenames with spaces?
>
> Tad gave an answer on that one already.
>
> > Also, what is
> > inherit global options?
>
> In the while loop, I use a local hash %LocalOptions to parse the options
> from OPTFILE, but before I initialize it with the global options, i.e.
> those options the script was started with. Ben does this using
> my %all_opts = (%cmd_opts, %file_opts);
> but the result will be the same (options not mentioned in the current
> line of OPTFILE but defined in %LocalOptions will retain their value
> even after getopts()). Of course, these %LocalOptions must be
> re-initialized on every loop cycle, or it would accumulate all options
> from all lines...
I thought that was the intent...
Thanks,
kln
------------------------------
Date: Tue, 14 Jan 2003 17:35:15 +0000
From: "vineyard" <foo@bar.baz>
Subject: Debugging help
Message-Id: <pan.2003.01.14.17.35.14.668069@bar.baz>
I am trying to debug a problem with a perl script running on Solaris 8
(with perl 5.8, not the Sun version). The script runs as a daemon. A
master copy of the script forks off other copies, which then perform
a variety of tasks before ending. Periodically, I'll take a look at the
process table and notice that a bunch of the forked copies
have hung. Typically, if I do a truss, the copy will say that it's
reading.
What makes this difficult to debug is that the hung copies may be doing
one of a wide variety of things. Basically, each copy pulls instance
information from a database, builds an object and then runs an object
method based on the instance information. I am trying to figure out what
exactly which method the script is hanging on, as well as the parameters
used.
The condensed version is like this:
use strict;
my $params = get_info();
my $obj = new Obj(%$params);
my $method = $params->{"method"};
$obj->$method;
I'd give more, but it's fairly complex and I'm reasonably certain that
it's hanging within the methods (based on previous debugging--i.e.,
it runs fine for extended periods of time with the same method). I had a
similar problem before, which I believe was related to an IO::Socket
timeout problem.
I'm having trouble identifying where they're hanging. I have it logging, but
unfortunately the only clue it doesn't write after they're hanging. I have
a wrapper around the main loop so that if it crashes I'll know about it,
but it is a real pain to figure out what's going on when it just hangs.
So: can anyone suggest a better debugging strategy? Ideally, I'd like to
send it a signal and have it dump out the method and all the parameters. I
am trying something like this to at least get the method name:
use strict;
my $i = 0;
my $method = '';
while (1) {
$i++;
run_method($i);
}
}
sub run_method {
$method = shift;
print "Running method $method\n";
$SIG{'HUP'} = \&dump_it;
sleep 1;
}
sub dump_it {
die "DUMPING METHOD: $method\n";
}
But that doesn't work unless I put $method in the global scope, which I
don't think I want to do (and would also require the parameters to be
global), and I can't pass dump_it() any parameters without it running
right there and then (which is, ah, inconvenient).
Replies to the group, please, so Google will preserve my stupidity for
posterity.
------------------------------
Date: Wed, 15 Jan 2003 02:02:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Flushing the Output Stream
Message-Id: <Bi3V9.29435$%V.2533@nwrddc02.gnilink.net>
Chucky wrote:
> This was very amusing.
>
> If you are going to waste bandwidth, at least post the answer. What do
> you think newsgroups are for, actually finding a question or problem
> that is absolutely not covered in any of the hundreds of books or
> FAQ's? No. It is for quick dialogs between persons that share common
> interests.
Right! It is for dialogs and discussions about shared interests.
You seem to confuse dialogs and discussions with a helpdesk.
> Since I develop in 5 different languages on a daily basis I was
> looking for a quick answer from someone whi is not as rusty as I am
The fastest possible answer you will get from the documentation that is
sitting on your very own local harddrive. No need to launch a Newsreader, no
need to formulate and to type a question, no need to wait for a reply.
Anyway, you don't seem to know much about how Usenet works if you expect a
quick answer. An assumption that is confirmed by your TOFU style, too.
> Take your negativeness elsewhere and grow up.
Learn manners.
Until then: *PLONK*
jue
------------------------------
Date: Wed, 15 Jan 2003 02:05:15 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <vl3V9.650$be.327@nwrddc03.gnilink.net>
ZZT wrote:
[see subject]
>
> didn't work really reliable. Is there a better way?
Tell me, are you generating your Usenet posts by quoting the questions from
the FAQs?
Pretty much anything you asked so far (and there were many questions) are
FAQs. Do you ever check them before posting?
jue
------------------------------
Date: 14 Jan 2003 19:43:55 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <eto8yxnxhck.fsf@wormtongue.emschwar>
"Jürgen Exner" <jurgenex@hotmail.com> writes:
> ZZT wrote:
> [see subject]
> >
> > didn't work really reliable. Is there a better way?
>
> Tell me, are you generating your Usenet posts by quoting the questions from
> the FAQs?
> Pretty much anything you asked so far (and there were many questions) are
> FAQs. Do you ever check them before posting?
The obvious searches:
perldoc -q leading
perldoc -q trailing
perldoc -q spaces
perldoc -q trim
all came up empty or incorrect on my 5.8 install. It couldn't hurt to
point the OP to the FAQ in question.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Wed, 15 Jan 2003 03:58:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <105V9.30266$%V.16786@nwrddc02.gnilink.net>
Eric Schwartz wrote:
> "Jürgen Exner" <jurgenex@hotmail.com> writes:
>> ZZT wrote:
>> [see subject]
>>>
>>> didn't work really reliable. Is there a better way?
>>
>> Tell me, are you generating your Usenet posts by quoting the
>> questions from the FAQs?
>> Pretty much anything you asked so far (and there were many
>> questions) are FAQs. Do you ever check them before posting?
>
> The obvious searches:
>
> perldoc -q leading
> perldoc -q trailing
> perldoc -q spaces
> perldoc -q trim
>
> all came up empty or incorrect on my 5.8 install. It couldn't hurt to
> point the OP to the FAQ in question.
perldoc -q beginning
perldoc -q end
perldoc -q blank
perldoc -q space
perldoc -q strip
It's not so much that he missed this one. It's more that the vast majority
of ZZTs postings are FAQs.
jue
------------------------------
Date: 14 Jan 2003 20:46:20 -0700
From: noone@anon.com
Subject: HTML::Table conflict?
Message-Id: <3e24d98c@news.nucleus.com>
I have a problem where if I add the line "use HTML::Table" to my code
it won't render (in IE); if I remove the line it works.
NOTE: No methods in Table.pm are actually called -- "use HTML::Table"
is the ONLY difference.
Here's the relevant code:
#!/usr/bin/perl -w
#
use CGI qw(:standard);
use DBI;
use HTML::Table;
[snip]
This is version 1.17 of Table.pm.
I've tried different orderings for the modules -- same result. If I
run the script from the command line it produces the same (valid)
HTML output in either case.
I've run other scripts using only HTML::Table and they work fine.
Anyone have any idea what's going on? Thanks.
------------------------------
Date: Wed, 15 Jan 2003 04:18:47 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: HTML::Table conflict?
Message-Id: <Hi5V9.55166$uL2.49999@nwrddc01.gnilink.net>
noone@anon.com wrote:
[...]
> If I
> run the script from the command line it produces the same (valid)
> HTML output in either case.
Then in all likelyhood you don't have a Perl problem.
> I've run other scripts using only HTML::Table and they work fine.
>
> Anyone have any idea what's going on? Thanks.
What does the error log of your CGI server say?
I wonder if HTML:Table is installed....
jue
------------------------------
Date: Wed, 15 Jan 2003 00:03:39 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Image::Magick for Activestate 5.8.0 (Win32)
Message-Id: <3e24a4a8.1889239@news.erols.com>
Eric McDaniel <ericm@I_HATE_SPAM@vertical.com> wrote:
: It's actually not the installation of ImageMagick binaries that is the
: problem, but the Image-Magick.ppd. When I run "ppm install Image-
: Magick.ppd", the response I get is:
:
: Error: no suitable installation target found for package Image-Magick.
:
: I am able to install other packages with ppm, so I assume this message
: indicates that the Image-Magick.ppd I have is only for 5.6.0
Or that the ppd is not found at all.
Give it an absolute path, e.g.
ppm install c:\ImageMagick\PerlMagick\Image-Magick.ppd
------------------------------
Date: Tue, 14 Jan 2003 19:44:11 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: My, our, etc.
Message-Id: <3E24AEDB.91E145C0@earthlink.net>
Jim Agnew wrote:
>
> Benjamin Goldberg wrote:
[snip code which did my $entry = .... $entry ....]
> > Change to either:
> >
> > my $entry = $frame -> Entry(
> > -validatecommand => \&valid_routine,
> > -invalidcommand => [ sub {
> > print "invalid entry, try again\n";
> > shift() -> focus;}, Ev('W') ]
> > ) -> pack ();
> >
> > Or:
> >
> > my $entry; $entry = $frame -> Entry(
> > -validatecommand => \&valid_routine,
> > -invalidcommand => sub {
> > print "invalid entry, try again\n";
> > $entry -> focus;},
> > ) -> pack ();
> >
> > (The first form is prefferred, since it avoids a circular reference
> > loop, which could hinder later garbage collection).
> >
> > [both code pieces are untested]
> >
>
> how would that cause a circular reference? I'd think the second form
> would be "cleaner"..??
The $entry variable contains an Entry object which contains a reference
to an anonymous sub which in turn contains a reference to the $entry
variable (which contains the Entry object which ...).
As to how this is a circular reference... the shape of a triangle
approches that of a circle, as the value of 3 approaches infinity.
And the second form is cleaner for two reasons: 1/ it avoids the
circular reference, and 2/ it avoids the need to declare $entry in a
seperate statement, before assigning to it.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Wed, 15 Jan 2003 04:06:08 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Need Help
Message-Id: <3e24d0c8.5784829@news.erols.com>
Dr P Singh <psinghp@emirates.net.ae> wrote:
: Subject: Need Help
That's a perfectly abysmal choice for the subject line. Except in a
most broadly generic sense, it's not what the article is about.
I had noticed this article earlier, but I deferred replying. Then I
couldn't find it again because the subject has nothing to do with
anything. Found it again only by accident.
: Hi every one. I took this code snippet from active perl(5.8) and ran it with
: little modification. I have two problem with this code.
:
: (1) I get this warning message "Constant Subroutine emptyenum redefined at
: c:/site/lib/win32/ole/constant.pm line 65535. I get a lot of this message.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
That feels so very wrong.
Are the Perl site libraries really hanging off c:\ like that?
I'm familiar with Win32::OLE::Const, but I've never seen
Win32::OLE::Constant. Where did that constant.pm file come from?
: (2) Though the code runs fine after these message, I get a printer popup asking
: for the pdf file name.
If there is a way to do that, it should be described in the
documentation for either Word or Acrobat PDFWriter.
As a rule, even though OLE can be done with Perl, it's not a Perl
problem. Posting to a newsgroup dealing specifically with OLE, like
say microsoft.public.vb.ole.automation, would give a better chance of
getting a good answer. If you can lay hands on some VBA code, it can
be easily rewritten in Perl.
For a guess, from looking at the Printout method in Word help, the
"PrintToFile" and "OutputFileName" arguments look promising.
------------------------------
Date: Wed, 15 Jan 2003 02:08:56 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Need to address myself
Message-Id: <Yo3V9.29460$%V.28850@nwrddc02.gnilink.net>
Jimbo wrote:
> Does anyone know how to write a regular expression that will accept
> all ways of addressing myself?
In which languages?
jue
------------------------------
Date: 14 Jan 2003 17:06:18 -0800
From: jsmirn@hotmail.com (Ed Kastenmeier)
Subject: Re: newbie: chapter 4 exercise Llama book
Message-Id: <1b5f07f8.0301141706.7259d566@posting.google.com>
You assign a scalar to your array @barney- something that's allowed in
Perl, but is re-interpreted to an assignment to the first element of
that array. $barney[0] becomes whatever you entered into <STDIN>, then
the foreach loop in the sub is executed only once, setting $sum equal
to the first element of @barney. (It's interesting that that works -
usually you have to use the . operator to 'add' strings. It wouldn't
work if @barney would contain more than one strings).
Use
my @barney = split / /, $input;
instead.
------------------------------
Date: 15 Jan 2003 05:45:38 +0300
From: Eri Mendz <eriz00@yahoo.com>
Subject: Re: newbie: chapter 4 exercise Llama book
Message-Id: <3e24cb52$1@news.sahara.com.sa>
On Tue, 14 Jan 2003 20:08:16 GMT, Michael Budash <mbudash@sonic.net> wrote:
> In article <3e246a62@news.sahara.com.sa>, Eri Mendz <eriz00@yahoo.com>
> wrote:
>
>> hi to all,
>>
>> im stumped how to get total of numbers using <STDIN>. This is in
>> exercise 1 chapter 4 of Llama book 3rd ed:
>>
>> #!/usr/bin/perl -w
>> use strict;
>>
[snip...]
hi Michael,
>
> my @barney = split /\s+/, $input;
>
thanks to you and Ed. will read up on split too to understand how this
works. appreciate it.
--
Have a nice day,
Eri Mendz
Using Slrn 0.9.7.4 [2002-03-13]
Linux 2.4.19-16mdk i686
And on the eighth day, we bulldozed it.
------------------------------
Date: Wed, 15 Jan 2003 02:20:03 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Perl command line processing, Windows/dos style ?
Message-Id: <pkent77tea-19BD3B.01275115012003@[10.1.1.10]>
In article <kkMU9.126894$FT6.25127237@news4.srv.hcvlny.cv.net>,
"Bill Smith" <wksmith@optonline.net> wrote:
> "pkent" <pkent77tea@yahoo.com.tea> wrote in message
> news:pkent77tea-86D536.02482514012003@[10.1.1.10]...
> > shell doing it. Perl doesn't even _get_ the '*'. It has no idea that's
> > what the user typed. I don't _know_ what happens in the windows shell
> > but it appears to be the same sort of deal.
> >
> I believe that you have to do the globbing yourself in windows.
>
> perl -e"print @ARGV" *
>
> prints the '*' when run in a dos window of ME.
Ah, we have Win 200 Pro at work and the globbing seems to be done by the
shell under that system. It was one of the things I checked in the User
Acceptance Tests, IIRC.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: Wed, 15 Jan 2003 04:16:04 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: poe and fork
Message-Id: <slrnb29o41.vp.troc@eyrie.homenet>
On Tue, 14 Jan 2003 17:07:08 +0100, David Zimmermann wrote:
> hello *,
Hi, David! :)
> I would like to execute a program on 100 computers
>
> someone can give me an example how i can fork with the poe module
> (POE::Filter::Reference ??)
I assume you're spawning 100 instances of ssh or something to execute
remote commands. One of the examples in POE's "cookbook" might help.
http://poe.perl.org/?POE_Cookbook
In particular, one of these examples might help.
http://poe.perl.org/?POE_Cookbook/Child_Processes_2
http://poe.perl.org/?POE_Cookbook/Child_Processes_3
Specifying the problem in more detail would help. You may contact me
via e-mail if you cannot discuss the program's details in public.
-- Rocco Caputo - troc@pobox.com - http://poe.perl.org/
------------------------------
Date: Tue, 14 Jan 2003 20:07:02 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Question about high performance spidering in perl
Message-Id: <3E24B436.83818D83@earthlink.net>
Extended Partition wrote:
[snip]
> Thank Cameron! Any suggestions on how to speed up the internet part or
> will that pretty much remain an undefined variable?
Always try and use the 'connection: keep-alive' feature of http1.1 to
decrease the number of connections used. Also, when doing this, try and
schedule the urls that have yet to be fetched in such an order that you
*can* reuse the connection within the time alloted.
Another consideration is to use LWP::Parallel::UserAgent to have
multiple internet connections simultaneously, rather than having to do
them one at a time. This internally uses select() to multiplex amongst
multiple sockets.
PS: AFAIK, LWP::P::UA does not work well with connection:keep-alive.
You'll have to do something about this yourself, if you want it done at
all.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Wed, 15 Jan 2003 04:32:40 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: return value of backticks under DOS
Message-Id: <Iv5V9.158766$FT6.29047515@news4.srv.hcvlny.cv.net>
"Koos Pol" <koos_pol@NO.nl.JUNK.compuware.MAIL.com> wrote in message
news:newscache$36qp8h$fx9$1@news.emea.compuware.com...
> Chas Friedman wrote (Tuesday 14 January 2003 17:15):
>
> > I wonder if anyone can explain the following:
> > If I perl the following under DOS, the directory listing gets
printed
> > to the DOS window, but $dir is undefined (i.e., I see the listing,
but
> > then also $dir= )
> > $dir=`dir`;
> > print "\$dir=$dir\n";
>
>
> backticks should not be used to catch returned values.
--snip remainder --
Without context, 'returned values' sounds like the 'exit status' of the
command. Backticks do not provide this. However, the OP makes it clear
that he wants the STDOUT. This is the intended use of backticks.
Bill
------------------------------
Date: Wed, 15 Jan 2003 03:28:09 GMT
From: bschler1@twcny.rr.com (Barry)
Subject: save and run bytocode
Message-Id: <3e24d266.57773397@news-server.twcny.rr.com>
Hi All,
I am relatively new to Perl. I am using it to do a CGI on Apache 2.x.
If my understanding is correct. Perl will compile the source to
bytecode then run the bytecode.
Apache now has an integrated Perl compiler - it used to have mod_perl.
Both get rid of the time needed to load the Perl interpreter.
But, if I understand correctly, isn't the Perl code still compiled
from source each time the CGI is invoked. Or, is the bytecode cached?
I've been scouring the web. It seems like one should be able to
compile the source to bytcode. Save the bytecode. Then use this as the
CGI. Saves the compile step each time.
There are things called Perl compilers, but they are off on some other
tangent.
Maybe it is possible to run from this intermediary step. Is it
possible to run from precompiled bytecode?
Is the compiling so relatively fast compared to everything else that
it does not matter?
The best solution would be to have Apache (the web server) cache the
bytecode in RAM for frequently needed CGIs? Maybe this is already
being done? ColdFusion does this.
Thanks for your discussion and pointers.
Barry.
------------------------------
Date: Tue, 14 Jan 2003 19:37:24 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: The "default thing"
Message-Id: <3E24AD44.814320CA@earthlink.net>
Bruce McKenzie wrote:
[snip]
> Is this sort of how it goes?
> $bucks is tied, so when we say
> $bucks = 45.00,
>
> we're saying something like "(using the methods defined in Centsible
> class), STORE($bucks, 45.00)"
No. We're saying:
STORE( tied($bucks), 45.00 );
Which is a bit different.
(Actually, to be more precise, it's doing:
tied($bucks)->STORE( 45.00 );
)
> And, written less tersely, STORE becomes
>
> sub STORE {
> # don't do confusing default thing ${ $_[0] } = $_[1] -- instead do
> my ($self, $value) = @_;
> # $self is a ref to a scalar (self thinks :-)
> $self = \$value; # $self now refs $value;
> }
No, this doesn't work. If you assign to $self itself, then all you're
doing is *replacing* the lexical variable $self, not the contents of
whatever $self had pointed to.
You could, though, do this:
sub STORE {
my ($self, $value) = @_;
$$self = $value;
}
This alters the scalar that $self points to, without altering the $self
variable itself.
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Wed, 15 Jan 2003 01:47:27 GMT
From: "gibbering poster" <noone@nowhere.com>
Subject: unpack usage
Message-Id: <P43V9.1997$Kt7.136858788@newssvr21.news.prodigy.com>
Given the binary string '111000111' packed with pack 'b9', '111000111'
...
Let's say I want to take that packed string which looks like binary
garbage, and be able to pull out chunks at my leisure...
One way is
print unpack 'x3a3', unpack ('b9', $string);
This will give me 3 bits starting at the 4th bit in the string...
So here's my question:
In the above case assuming $string to be packed as I've outlined above,
is there anyway for me to unpack it to pull out substrings of the packed
bitstring (like above) without using 2 unpack statements?
Thanks in advance for any solutions... The perldoc on pack and unpack
was beginning to frighten me...
------------------------------
Date: Tue, 14 Jan 2003 21:50:00 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: unpack usage
Message-Id: <3E24CC58.75899494@earthlink.net>
gibbering poster wrote:
>
> Given the binary string '111000111' packed with pack 'b9', '111000111'
> ...
>
> Let's say I want to take that packed string which looks like binary
> garbage, and be able to pull out chunks at my leisure...
>
> One way is
>
> print unpack 'x3a3', unpack ('b9', $string);
>
> This will give me 3 bits starting at the 4th bit in the string...
>
> So here's my question:
>
> In the above case assuming $string to be packed as I've outlined
> above, is there anyway for me to unpack it to pull out substrings of
> the packed bitstring (like above) without using 2 unpack statements?
Well, you can always do:
print substr( unpack('b6', $str), 3, 3 );
But other than that... not as far as I know. You can usually do it for
things *larger* than a bit, but not for single bits.
Hmm... you might, in perl 5.8, be able to do:
print unpack("x[b3]b3", $str);
> Thanks in advance for any solutions... The perldoc on pack and unpack
> was beginning to frighten me...
The perldoc on pack and unpack in 5.8 are worse,
due to the addition of "x[...]", "x![...]" and "(...)".
--
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);
------------------------------
Date: Tue, 14 Jan 2003 18:41:34 -0800
From: Steve Slaven <junk_nntp@hoopajoo.net>
Subject: Re: Using Mail::MAiler to send attachment
Message-Id: <v29iiv87a4t43f@corp.supernews.com>
nikko wrote:
> I need to send an attachment using Mail::Mailer.
>
> Currently my code looks like this:
>
> my $mailserver = "smtp.domain.com";
> my $mailer = new Mail::Mailer('smtp', Server => $mailserver);
> my(%headers) = ('To' => "$param{'email'}",
> 'Bcc' => "nikko\@domain.com",
> 'From' => "ts-systems\@domain.com",
> 'Subject' => "My subject",
> 'Date' => $date,
> );
> $mailer->open(\%headers);
> open(MAIL, ">$TEMPFILE") || &baderror('Cannot write to email file');
>
> $message =<<EOT;-
> text of message
> EOT
> print $mailer $message;
> $TEMPFILE =~ s/\//\\/g;
> unlink $TEMPFILE;
> $mailer->close;
> =====================
> How would I add a text file to this with the words "test" as content?
>
> Thanks!
You could use Mail::Sender, it has all the stuff needed for sending mime
attachments all packaged up for you:
use Mail::Sender;
open( OUT, ">/tmp/someattach.txt" );
print OUT "test";
close( OUT );
my $sender = new Mail::Sender {
smtp => $mailserver,
from => 'ts-systems@domain.com'
};
$sender -> MailFile( {
to => $param{email},
bcc => 'nikko@domain.com',
subject => 'my subject',
file => '/tmp/someattach.txt'
} );
unlink( '/tmp/someattach.txt' );
you can get it from your usual CPAN sources, I don't think it's a core
module.
--
+----------------------------------------------------------------------------+
"When the cops talk about the war on crime and the war on drugs,
everyone needs to understand that they view us, the civilians,
as the enemy."
+----------------------------------------------------------------------------+
Steve Slaven - http://hoopajoo.net
MIS Programmer, Horizon Distribution - http://horizondistribution.com
Office: (509) 453-3181 x 254 / Fax: (509) 457-5769
------------------------------
Date: Wed, 15 Jan 2003 02:18:15 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Variable naming convention
Message-Id: <Hx3V9.29498$%V.28678@nwrddc02.gnilink.net>
Andrew Allaire wrote:
> falconflyr@snet.net (Pete) wrote in message
> news:<4ca21189.0301140802.153b57a3@posting.google.com>...
>> Is there a way to dynamically define a set of variable names such
>> that the name itself consists of alpha and numeric characters, but
[...]
> I think you are going against camel hair here. Why not use an array?
> But just for the sake of an obscure exercise you could handle it like
> this:
>
> for (1..10) {
> ${'name' . $_} = $_ ;
> }
>
> print ( "name1 is $name1\n") ;
> print ("name2 is $name2\n") ;
If you feel the need to show symbolic references to someone who apparently
doesn't know how to handle them, then it is gross negligent to not mention
the FAQ and not to warn him about the dangers involved.
To the OP: _please_(!) consult the FAQ on symbolic references before using
the code above.
jue
------------------------------
Date: Wed, 15 Jan 2003 02:20:03 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: what's the similar functionality to the '#include' in C?
Message-Id: <pkent77tea-BE951F.01305015012003@[10.1.1.10]>
In article <b00k84$2e0s$1@mail.cn99.com>, "qjzhu" <ie_qjzhu@yahoo.ie>
wrote:
> 'require' requires the file to be inserted made into a package, doesn't it?
> That's not what I want.
> I just want a plain text file to be included(inserted) into another source
> file.
Then use the C preprocessor, of course! See perlrun...
>>>>>>>>>>>>>>
-P
causes your program to be run through the C preprocessor before
compilation by Perl. Because both comments and cpp directives begin
with the # character, you should avoid starting comments with any words
recognized by the C preprocessor such as "if", "else", or "define".
Also, in some platforms the C preprocessor knows too much: it knows
...
>>>>>>>>>>>>>>
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
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 4405
***************************************