[17963] in Perl-Users-Digest
Perl-Users Digest, Issue: 123 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 22 21:05:36 2001
Date: Mon, 22 Jan 2001 18:05:13 -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: <980215513-v10-i123@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 22 Jan 2001 Volume: 10 Number: 123
Today's topics:
Call for Papers: LISA 2001 <sasha@usenix.org>
Re: Deleting a line from file <gracenews@optusnet.com.au>
Re: Deleting a line from file <gracenews@optusnet.com.au>
Re: Directory Recursion Problem. <sdmeisner@SPAMGUARDyahoo.com>
Re: DOS commands with long directory names <mischief@velma.motion.net>
Re: FAQ 9.15: How do I decode a CGI form? <godzilla@stomp.stomp.tokyo>
Re: Fork stability on ActivePerl <haig.soghigian@fmr.com>
Getopt::Long question? <remi@multiweb.nl>
Re: Getopt::Long question? <ans@_nospam_x64.net>
How to compile a perl file ? <ricky@mymail.faq>
Re: Lint for perl? <bart.lateur@skynet.be>
Re: Lint for perl? <mischief@velma.motion.net>
Re: Lint for perl? (Martien Verbruggen)
Re: Newbie - whois script (David Efflandt)
Re: Newbie - whois script <ans@_nospam_x64.net>
Re: Non Unix user needs help with File::Find <bart.lateur@skynet.be>
pass parameters btw two cgi files? <b0l4549@cs.tamu.edu>
Re: pass parameters btw two cgi files? <ans@_nospam_x64.net>
Re: passing parameters from command line (and leaving f eacooper2085@my-deja.com
Re: passing parameters from command line (and leaving f <bart.lateur@skynet.be>
Re: Perl Crashes on my Win2k Box yet_another_matt@my-deja.com
Re: Posting email from PERL to Outlook (Exchange)??? <anonymous@anonymous.anonymous>
Re: Posting Guidelines (was Re: Perl - Bytecode, Compil <gracenews@optusnet.com.au>
Problem with Tie::StdHash/FETCH ?? nexus6_kills@yahoo.com
Re: Q: socket communication between perl and java <mischief@velma.motion.net>
Re: Random Numbers with a Twist (Martien Verbruggen)
Re: stability of threads + interpreter performance <dan@tuatha.sidhe.org>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 22 Jan 2001 16:19:39 -0800
From: Sasha Keller <sasha@usenix.org>
Subject: Call for Papers: LISA 2001
Message-Id: <sasha-028F5A.16193922012001@reader.news.uu.net>
Keywords: system administrator, system administrations, sys admin, UNIX, LINUX, OS, database, LISA, technical conference, seminar, tutorials, classes, invited talks, refereed papers, white papers, computers, operating systems, applications, hardware, software, SUN, Microsoft, windows, windows NT, symposium, security, databases, development, maintenance, troubleshooting, performance tuning, methodology, training, scaling, integration, programming, network, networking, technology, protocol, Perl, TCP/IP, hubs, routers, servers, CISCO, Oracle, Sybase, Open Systems
15th Systems Administration Conference (LISA 2001)
December 2-7, 2001
San Diego, CA USA
http://www.usenix.org/events/lisa01
Co-sponsored by USENIX, the Advanced Computing
Systems Association, and SAGE, the System Administrators Guild
For fifteen years, the USENIX and SAGE sponsored
Systems Administration Conference (LISA) has been the
leading forum for system administrators to meet, learn, and
exchange ideas with one another on every aspect of computer
and network management.
The LISA 2001 Program Committee invites you to contribute ideas,
proposals, and papers for tutorials, invited talks program, refereed
papers track, workshops, work-in-progress reports, and symposia
track. Submissions that address any and all aspects of systems
administration are welcome. For complete guidelines, please visit:
http://www.usenix.org/events/lisa01
Submissions are due June 5, 2001.
By participating in LISA, you are contributing to state-of-the-art
computer management, and spreading knowledge about one
of the most important challenges of the next century--
living with the machines!
Please come and share your expertise with us! Visit our Web site for
more information: http://www.usenix.org/events/lisa01
------------------------------
Date: Tue, 23 Jan 2001 10:30:09 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Deleting a line from file
Message-Id: <3a6cd09c$0$16396$7f31c96c@news01.syd.optusnet.com.au>
"Garry Williams" <garry@zvolve.com> wrote in message
news:QdXa6.5659$tg4.28857@eagle.america.net...
>
> To make a number of operations atomic, you need a semaphore.
>
> Just adopt a convention of using a lock file. Lock it before
> beginning the series of operations and unlock it after completing the
> operations. (Be sure to close any files you're updating so that their
> buffers get flushed before unlocking.) Once you "train" all processes
> to use the semaphore, you're done. :-)
Thanks!
Seems so obvious in hindsight damnit ;-)
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: Tue, 23 Jan 2001 11:01:45 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Deleting a line from file
Message-Id: <3a6cd803$0$16387$7f31c96c@news01.syd.optusnet.com.au>
"Chris Stith" <mischief@velma.motion.net> wrote in message
news:t6p0hdh1fkivcd@corp.supernews.com...
> >> >Is there a better way?
[snip several good examples]
>
Thankyou for the obvious effort you went to, to provide a solution. I will
definately use your code or at least suggestions in addition to make my code
more fail-safe. For the immediate problem I'm using a seperate semaphore
file and standard flock file locking (now if only win95 supported flock()
for some local testing :-( ) as suggested by Gary.
>
> > I was hoping not to have to put the file into memory as it is a CGI
script
> > and I'm worried about annoying the sysadmin, and getting my script
deleted.
>
> Always good to keep the sysadmin in mind. ;)
>
;-)
> [snip quoted signature]
>
> Didn't someone just ask that you didn't quote signatures?
Damnit! <looks for the nearest wall to bash head against> ;-)
>
> Chris
^ NOT a signature ;-) (it was before the --) and _yes_ I'm just
joking. ;-)
>
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: Mon, 22 Jan 2001 23:58:05 GMT
From: "Sean Meisner" <sdmeisner@SPAMGUARDyahoo.com>
Subject: Re: Directory Recursion Problem.
Message-Id: <hO3b6.177$LQ1.53650@sapphire.mtt.net>
Tad McClellan <tadmc@augustmail.com> wrote in message
news:slrn96p3b2.1pi.tadmc@tadmc26.august.net...
>
> % mungers
> Score:: -5000
> From: @.*spam
>
What does this mean? I'm not a spammer.. what's a munger?
------------------------------
Date: Tue, 23 Jan 2001 00:40:50 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: DOS commands with long directory names
Message-Id: <t6pkoijgc00o4f@corp.supernews.com>
lbieg@my-deja.com wrote:
> I am trying to execute a DOS command in Perl on Windows NT and ME using
> the back tick operator where the path contains spaces (ex: "D:\Program
> Files\...) and I keep getting a bad command or file name error returned.
> Can anyone tell me if there is any special syntax for this?
First of all, get rid of the ugly backslashes. They escape
characters and must be escaped themselves in order to not
do so. That leads to this: "D:\\Program Files\\", which is
ugly and unneccessary. Use forward slashes instead, which
is more standard. "D:/Program Files/". Just because Windows
has a broken command line doesn't mean that you can't program
it like a real OS. Even from a batch file, Windows 2000 supports
proper directory delimeters. Try this batch file:
@if exist /windows/win.com echo It worked!
Second, Windows allows spaces in file names and directory names but
the DOS portion doesn't always know this (sometimes it does, it's
complicated). It's safest to figure out the short name of a file
or directory (but this can be different from system to system) or
to find a way around needing the path as much as possible. The
command line should let you use the path. I'm not sure about
invoking the shell implicitly though.
Chris
--
Christopher E. Stith
Parking for people we like only. All other vehicles will be vandalized.
------------------------------
Date: Mon, 22 Jan 2001 15:09:57 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: FAQ 9.15: How do I decode a CGI form?
Message-Id: <3A6CBDC5.788CA8D7@stomp.stomp.tokyo>
"Joe C. Hecht" wrote:
(someone else wrote:)
> > *ploink*
> > Consider your opinion judged.
> I just love it when folks have to publically
> waste bandwidth to show themselves adding
> to the killfile.
(snipped)
I never use killfiles. This is a waste of
time and pointless. Fortunately, I am one
of those with enough intellectual capacity
to discern which articles are worth reading
and, which are not based on sender and
often, subject.
Consider being killfiled a blessing, I do.
This blessing is a person who publically
announces having killfiled you, cannot
respond to your articles. In turn, a
blessing comes about; you aren't annoyed
by opening an article by this person
only to discover idiotic blatherings.
Have you looked at these strings, hmm...
'...recursion problem' and '...3606' ??
Such a waste of bandwidth and such a
mess of clutter. Just a bunch of little
boys doing their usual weenie wagging
contest thing, over and over....
Godzilla!
------------------------------
Date: Mon, 22 Jan 2001 15:05:10 -0500
From: Haig Soghigian <haig.soghigian@fmr.com>
Subject: Re: Fork stability on ActivePerl
Message-Id: <3A6C9276.5D43A57B@fmr.com>
There is a better way. See the Activestate docs on Win32::ChangeNotify
On NT, you can be notified when a file has been dropped or attributes
have changes. You just have a long running perl program (can be a
service)
that registers to receive file/directory changes. That way you don't
have to mess with forking.
Ashish
Fidelity Investments
ashishdesai@yahoo.com
Iain Hosking wrote:
>
> I'm writing a system which involves downloading weather reports,
> distributing them amongst processing directories, then running processing
> programs to parse the data and load it into a database. Currently the
> queue-processor runs in a 1-minute loop to watch the incoming directory to
> do the distribution. Separate processing programs are fired off every 15
> minutes by NT's AT scheduler.
>
> To reduce the latency in the system it would be nice to trigger the
> processes whenever a file appears in the relevant processing directory. As I
> see it, I can either (a) run all the processing programs constantly, each
> one in a loop which checks the input directory or (b) run a 'watch' program
> which fires off the appropriate program.
>
> If I do (b) is it feasible on NT to use fork() to run the processes? I'm
> running ActivePerl 5.6.0 build 623 on NT 4.0 SP5. The system runs round the
> clock 365 days a year so must be stable.
>
> (Down the track we may migrate the system to Linux or Solaris.)
>
> Thanks
>
> Iain
------------------------------
Date: Tue, 23 Jan 2001 00:05:28 -0000
From: "paul" <remi@multiweb.nl>
Subject: Getopt::Long question?
Message-Id: <u13b6.4902$ti1.440318@news.soneraplaza.nl>
hi all
i have a question about Getopt::Long
i have a written a little test script to play around with command line
options for perl scripts
like this
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
my ($ip) = '';
GetOptions('ip=s' => \$ip );
print "The ip is $ip\n";
my ($name) = '';
GetOptions('name=s' => \$name );
print "The name is $name\n";
#########END############
now the first options the script will take as -ip but when i start use the
second option is give's me back the following
[apache@at-home test]$ ./hash.pl -ip 10.10.10.10 -name
Unknown option: name <---
The ip is 10.10.10.10
The name is
[apache@at-home test]$
now i have created the second options just like the first but it doesn't
like it ..
i have searched all over the web but i can't find the awnser
hope someone can point me in the right direction
thnx paul
------------------------------
Date: Tue, 23 Jan 2001 01:41:45 GMT
From: "Anson Parker" <ans@_nospam_x64.net>
Subject: Re: Getopt::Long question?
Message-Id: <tj5b6.77889$xW4.600146@news-server.bigpond.net.au>
paul <remi@multiweb.nl> wrote in message
news:u13b6.4902$ti1.440318@news.soneraplaza.nl...
> i have a question about Getopt::Long
>[snip]
> #!/usr/bin/perl -w
>
> use strict;
> use Getopt::Long;
>
> my ($ip) = '';
> GetOptions('ip=s' => \$ip );
> print "The ip is $ip\n";
>
> my ($name) = '';
> GetOptions('name=s' => \$name );
> print "The name is $name\n";
>
> #########END############
>
> now the first options the script will take as -ip but when i start use the
> second option is give's me back the following
>
> [apache@at-home test]$ ./hash.pl -ip 10.10.10.10 -name
> Unknown option: name <---
I'm no expert on the Getopt modules but I did encounter a similar problem.
I believe you can only call the GetOptions() function once - so if you changed
your code to the following it should work:
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
my ($ip,$name) = '';
GetOptions('ip=s' => \$ip,'name=s'=>\$name);
print "The ip is $ip\n";
print "The name is $name\n";
#########END############
Cheers,
Anson.
--
foreach (unpack 'C*','aonjixfghklceyrqtuwxvdbpz') {
print substr 'Jerk not the surreal chap!',$_-97,1;}
------------------------------
Date: Tue, 23 Jan 2001 00:00:23 GMT
From: "Ricky" <ricky@mymail.faq>
Subject: How to compile a perl file ?
Message-Id: <rQ3b6.115643$eB2.8848434@news.infostrada.it>
Immagine I have:
#!/usr/bin/perl
print "Hello world!";
<STDIN>;
and that is called file.pl
I tried :
perlcc -gen -C file.c file.pl (and does not work)
perlcc file.pl (and does not work)
etc...
I would like to compile a file, does not matter if I only get C code, I can
compile it later, no?
I read a lot of docs, but I do not understand, nothing works !!!
Thank you,
RIcky
------------------------------
Date: Mon, 22 Jan 2001 23:36:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Lint for perl?
Message-Id: <llgp6t0d0pkak8l8beo1sr8pt7qkun2tsn@4ax.com>
Tore Aursand wrote:
>Just a wild suggestion from me, but it
>should be fairly easy to write a script which checks if your variables
>are used only once?
perldoc B:Xref
This module produces a lot of junk (as of 5.6.0), but it could be a
starting point. Its log is likely easier to parse than plain Perl code.
--
Bart.
------------------------------
Date: Mon, 22 Jan 2001 23:47:13 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Lint for perl?
Message-Id: <t6phk1ist9tf47@corp.supernews.com>
Tad McClellan <tadmc@augustmail.com> wrote:
> Art Haas <arthur.haas@westgeo.com> wrote:
>>stanb@panix.com (Stan Brown) writes:
>>
>>> I find lint very useful when writing C code (even if it is showing it's
>>> agae a bit).
>>>
>>> Is there a similar tool for perl?
>>
>>At a prompt ...
>>
>>$ perl -cw your_perl_script.pl
>>
>>That's a good check.
> perl -Mstrict -cw your_perl_script.pl
Merging this and the other response to the same post, I just
ran the following on many of my own scripts:
perl -Mstrict -Mdiagnostics -cw script
Only a couple failed ;)
> That's an even better check ;-)
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
--
Christopher E. Stith
Disclaimer: Actual product may not resemble picture in ad in any way.
------------------------------
Date: Tue, 23 Jan 2001 11:36:57 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Lint for perl?
Message-Id: <slrn96pkh9.meu.mgjv@martien.heliotrope.home>
On 22 Jan 2001 14:38:01 -0800,
Ansel Sermersheim <ansel@babylon.dyndns.org> wrote:
>>>>>> "Martien" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:
>
>> On Mon, 22 Jan 2001 20:51:21 +0100, Tore Aursand <tore@extend.no>
>> wrote:
>>> In article <94hv1o$f0f$1@panix2.panix.com>, stanb@panix.com says...
>>>> If I add a new variable dcleration as in:
>>>>
>>>> my $foo;
>>>>
>>>> and don't use it in the function it is declared in, I get no
>>>> comlaints from any of the sugestiosn I have recieved so far.
>>> Why not use Perl to do this? Just a wild suggestion from me, but
>>> it should be fairly easy to write a script which checks if your
>>> variables are used only once?
>
>> And I am sure people can come up with more obscure ones that will
>> make parsing even harder. I haven't even done my best. The problem
>> isn't even really finding things that _might_ be variables, but more
>> to correctly discard the ones that aren't.
>
> Also, keep in mind subs returning anonymous closures. How could you
> parse that? E.g., from a program (inetd replacement) I'm playing
> with:
I thought hard to get an example with a closure in it, but couldn't come
up with one that didn't in some way mention each lexical variable at
least twice, once in the declaration, and once for use. Yours does that
as well..
> sub Chroot {
> my $dir = shift;
> my $sub = shift;
> return sub {
> chdir $dir
> or logerr "Unable to chdir to $dir prior to chroot: $!";
> chroot $dir
> or logerr "Unable to chroot to $dir, $!";
> &$sub(@_);
> }
> }
This would be parseable, _if_ you can do the correct scoping thing, and
can regognise all possible guises of a variable. $dir is declared, and
used 4 times in this scope, and $sub is declared once, and used once.
I still have the gut feeling however, that there is something about
closures that is going to break this parsing. I just can't seem to think
of it..
> This and its cousins let me say something like (example, real code's
> more complex):
>
> { 21 =>
> Accept Fork_redir Chroot '/home/ftp' Drop_privs sub {exec "/usr/bin/ftpd"},
> 113 =>
> Accept Task_add Pinetd::Daemons::Ident,
> }
>
> I think one of the main problems is that perl blurs the line between
> compilation and execution/interpretation to the point that anything
> just looking at the source is doomed to failure.
>
> (If anything can properly lint my signature, and not complain about @]
> being unused without actually running it, I'll sponsor it for a
> Turing test ;)
perl can :)
It'll whinge about ambiguous use of ${q} though.
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
NSW, Australia | being a damn fool about it.
------------------------------
Date: Tue, 23 Jan 2001 01:40:31 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Newbie - whois script
Message-Id: <slrn96po7j.bhh.efflandt@efflandt.xnet.com>
On Mon, 22 Jan 2001, Dave <deviant@ultra-deviant.removethisbit.com> wrote:
>Below is my copy of a whois script - how do I change the background of the
>page when it is processed - I need the background to be #666666.
This html question is not a Perl question. But a Perl answer is to
generate and process your form and html using CGI.pm and insert the
desired -BGCOLOR=>$foo in the start_html() after assigning $foo with
whatever color you want.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Tue, 23 Jan 2001 02:01:34 GMT
From: "Anson Parker" <ans@_nospam_x64.net>
Subject: Re: Newbie - whois script
Message-Id: <2C5b6.77936$xW4.600519@news-server.bigpond.net.au>
Dave wrote in message news:1a2b6.10505$3d2.48629@news11-gui.server.ntli.net...
> Below is my copy of a whois script - how do I change the background of the
> page when it is processed - I need the background to be #666666.
This is an HTML question - nothing to do with Perl! I don't know what the
appropriate
newsgroups are, so to save you a bit of time i'll let you in on the secret. Use
the
<body> tag:
<body bgcolor="#666666">
View the source of any web page and it should become remarkably clear to you
(or maybe not). Seriously, what are you doing writing web pages?
Anson.
--
foreach (unpack 'C*','aonjixfghklceyrqtuwxvdbpz') {
print substr 'Jerk not the surreal chap!',$_-97,1;}
------------------------------
Date: Tue, 23 Jan 2001 00:02:53 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Non Unix user needs help with File::Find
Message-Id: <igip6tkqtu2e8rc5qg8ccirkmbl8dodkqu@4ax.com>
sjamiso@my-deja.com wrote:
> @bad_files = (@bad_files,"$File::Find::name\n");
>Any suggestions and help is appreciated.
Learn to use push(). And why the newline?
push @bad_files, $File::Find::name;
As for the real meat... I think some people already answered those
questions rather well.
--
Bart.
------------------------------
Date: Mon, 22 Jan 2001 17:33:17 -0600
From: Bin - Lu <b0l4549@cs.tamu.edu>
Subject: pass parameters btw two cgi files?
Message-Id: <Pine.SOL.4.10.10101221731290.6015-100000@robert>
Does anyone know if it's possible to pass parameters between two CGI
files? The following is the code I write in Perl:
...
if (test1) {
$exerID=1;
}
else {
$exerID=2;
}
print qq!
<html> <head> ... </head>
<body>
<a href="http://blah.blah.com/bin/test.cgi"> test </a>
</body>
<html>!;
...
Now I want to pass the variable $exerID to the file "test.cgi".
Can I do that? If yes, how? Thanks much!
Bin
------------------------------
Date: Tue, 23 Jan 2001 01:53:32 GMT
From: "Anson Parker" <ans@_nospam_x64.net>
Subject: Re: pass parameters btw two cgi files?
Message-Id: <wu5b6.77922$xW4.600125@news-server.bigpond.net.au>
Bin - Lu <b0l4549@cs.tamu.edu> wrote in message
news:Pine.SOL.4.10.10101221731290.6015-100000@robert...
>
> Does anyone know if it's possible to pass parameters between two CGI
> files? The following is the code I write in Perl:
>
> if (test1) {
> $exerID=1;
> }
> else {
> $exerID=2;
> }
>
> print qq!
> <html> <head> ... </head>
> <body>
> <a href="http://blah.blah.com/bin/test.cgi"> test </a>
> </body>
> <html>!;
>
> Now I want to pass the variable $exerID to the file "test.cgi".
> Can I do that? If yes, how? Thanks much!
You can very easily pass variables between CGI scripts by adding
them to the url as a query string. In your case change the line:
<a href="http://blah.blah.com/bin/test.cgi"> test </a>
to:
<a href="http://blah.blah.com/bin/test.cgi?exerID=$exerID"> test </a>
In your test.cgi file just read in this paramater using @ARGV or
more appropriately CGI.pm's param() call and you'll be cooking
with gas. You'll need to deal with URL encoding your variables
if you're passing anything other than simple words and numbers -
check out CGI.pm though, it should deal with all of this for you.
Anson.
--
foreach (unpack 'C*','aonjixfghklceyrqtuwxvdbpz') {
print substr 'Jerk not the surreal chap!',$_-97,1;}
------------------------------
Date: Tue, 23 Jan 2001 00:44:10 GMT
From: eacooper2085@my-deja.com
Subject: Re: passing parameters from command line (and leaving file parameter intact)?
Message-Id: <94ik4o$kjv$1@nnrp1.deja.com>
How can I parse parameters and leave the last parameters as file input:
script.pl -a abc -b xyz file1forinput file2forinput
When the parsing code recognizes file1forinput is a file input rather
than parameter how can I leave it as ARGV. Does unshift work?
thanks in advance,
Eric
In article <3a680cec.850614138@news.itn.is>,
helgi@NOSPAMdecode.is wrote:
> On Thu, 18 Jan 2001 12:22:09 GMT, tedius@gmx.co.uk (Ted)
> wrote:
>
> >Hi!
> >
> >just a short question: how can I pass some string to my perl script
from
> >command line?
> >
> >I need something like this:
> >
> >script.pl STRING
> >
> >
> >
> >#!/usr/bin/perl
> >
> >$Foo=STRING
> >.........
>
> #!/usr/bin/perl -w
> use strict;
> if (not @ARGV) { die "Usage: $0 <string>\n"; }
> my $Foo = shift;
>
> # or my $Foo = $ARGV[0];
> # or for (@ARGV) { my $Foo = $_; }
>
> Regards,
> Helgi Briem
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 01:43:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: passing parameters from command line (and leaving file parameter intact)?
Message-Id: <aenp6tottrph0u6ngppa56lk4sgoqjahtj@4ax.com>
eacooper2085@my-deja.com wrote:
>How can I parse parameters and leave the last parameters as file input:
> script.pl -a abc -b xyz file1forinput file2forinput
>
>When the parsing code recognizes file1forinput is a file input rather
>than parameter how can I leave it as ARGV. Does unshift work?
Yes unshift works. But you can access items in @ARGV directly, by
$ARGV[0] for example.
It's not the job of the command line arguments to check to see if a
parameter exists as a file. Usually, you need to begin options
(parameters) with an option marker, in your example a leading "-". On
DOS, "/" is not uncommon, either. So, if you see that $ARGV[0] starts
with a "-", shift it and optionally what follows too, and repeat.
If you're still not sure what I mean, take a look at some scripts that
came with Perl, some of those do extensive command line processing. See,
for example, find2perl.
You can even use a module. Some even come with Perl. The string to glob
for, is "Getopt": Getopt::Long and Getopt::Std.
--
Bart.
------------------------------
Date: Tue, 23 Jan 2001 01:47:19 GMT
From: yet_another_matt@my-deja.com
Subject: Re: Perl Crashes on my Win2k Box
Message-Id: <94inr5$noj$1@nnrp1.deja.com>
In article
<t6oti4tdgjkf28@corp.supernews.com>,
<snip>
>I am attempting to run a script and I get an
>error that says Perl has generated an error
>and must be shut down. Anybody have any
>idea why this is?
Controversy aside, I'd put my money on the
use of flock somewhere in your script.
-Regards, Matt
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 22 Jan 2001 19:50:09 -0500
From: Anonymous <anonymous@anonymous.anonymous>
Subject: Re: Posting email from PERL to Outlook (Exchange)???
Message-Id: <hukp6tostf8r5vbgh0b9urepked2k3p2h2@4ax.com>
On 22 Jan 2001 12:43:03 -0500, Jonathan Feinberg <jdf@pobox.com> wrote:
>"Daniel (Dan) Rosenzweig" <danr@att.com> writes:
>
>> Having never done OLE programming before - where can I find documentation to
>> the objects /commands available to me when talking to Outlook?
>
>You're now leaving the domain of expertise of most of the people who
>read and post here. You'll most likely get quicker and better help
>from folks at whatever newsgroups are devoted to Win32 programming.
Try using Mail::SendMail like this:
use Mail::Sendmail;
$FROM = "someaddr\@somedomain.com";
$SMTP = "mail.domain.com";
$EMAIL = "someotheraddr\@someotherdomain.com";
%MAIL = ( To => $EMAIL,
From => $FROM,
Smtp => $SMTP,
Retries => 1);
$MAIL{Subject} = "Soome subject";
$MAIL{Message} = "Some Body";
if ( sendmail %MAIL ) {
...
}
else {
# Some kind of error
}
Unless for some reason you can't talk to your SMTP (Exchange) server or you have a burning desire to
use OLE, I find this a lot simpler (and portable for that matter).
--------== Posted Anonymously via Newsfeeds.Com ==-------
Featuring the worlds only Anonymous Usenet Server
-----------== http://www.newsfeeds.com ==----------
------------------------------
Date: Tue, 23 Jan 2001 10:27:00 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Posting Guidelines (was Re: Perl - Bytecode, Compile to C, Perl2EXE)
Message-Id: <3a6ccfde$0$16397$7f31c96c@news01.syd.optusnet.com.au>
<jdf@pobox.com> wrote in message news:4ryr33vi.fsf@pobox.com...
> "Jeffrey Grace" <gracenews@optusnet.com.au> writes:
>
> YOU, JEFFREY GRACE! :)
I know. ;-) Though some people are a little more direct, but I digress.
BTTP!. (Back To The Perl)
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: Tue, 23 Jan 2001 00:14:00 GMT
From: nexus6_kills@yahoo.com
Subject: Problem with Tie::StdHash/FETCH ??
Message-Id: <94iic0$j4k$1@nnrp1.deja.com>
Greetings,
The problem that I am encountering is shown in the example
file below (sorry for the length, but it is as short as I
could make it). In "package main", I have listed the seven
cases which I would like to make work. The last two cases
do not work. I would like to know why they don't work. I
understand that it has something to do with copy, but some
help would be appreciated.
The code below can be executed as is; you will get the
message:
"Can't use an undefined value as an ARRAY reference ..."
Thanks in advance.
- Nexus6
#!/usr/bin/env perl
#===============================================================================
package MyPackage_1;
use Tie::Hash;
@ISA = (Tie::StdHash);
sub new
{
my ($className) = shift;
my $self = {};
bless ($self, $className);
$self->{key_1} = "val_1";
$self->{key_2} = "val_2";
my %retHash;
tie %retHash, $className, $self;
return bless \%retHash, $className;
}
sub TIEHASH
{
my ($className, $obj) = @_;
return bless $obj, $className;
}
sub FETCH
{
my ($self, $key) = @_;
my ($rhs) = $self->{$key};
$rhs = &$rhs if (ref($rhs) eq "CODE");
return $rhs;
}
#===============================================================================
package MyPackage_2;
use Tie::Hash;
@ISA = (Tie::StdHash);
sub new
{
my ($className, $pkg_1) = @_;
my $self = {};
bless ($self, $className);
$self->{DEPS}->{pkg_1} = $pkg_1;
$self->{the_keys} = sub { return [$self->{DEPS}->{pkg_1}->{key_1},
$self->{DEPS}->{pkg_1}->{key_2}];
};
$self->{the_keys_2} = sub { return ["foo", "bar"]; };
my %retHash;
tie %retHash, $className, $self;
return bless \%retHash, $className;
}
sub TIEHASH
{
my ($className, $obj) = @_;
return bless $obj, $className;
}
sub FETCH
{
my ($self, $key) = @_;
my ($rhs) = $self->{$key};
$rhs = &$rhs if (ref($rhs) eq "CODE");
return $rhs;
}
#===============================================================================
use strict;
package main;
sub printArray
{
my (@arr) = @_;
foreach my $m (@arr) {
print "+ ", $m;
}
print "\n";
}
my $pkg_1 = new MyPackage_1 ();
my $pkg_2 = new MyPackage_2 ($pkg_1);
my ($n);
#--- Case 1 (works)
my ($theArrRef) = $pkg_2->{the_keys};
foreach $n (@{$theArrRef}) {
print " ", $n;
}
print "\n";
#--- Case 2 (works)
print join (" : ", @{$pkg_2->{the_keys}}), "\n";
#--- Case 3 (works)
$theArrRef = $pkg_2->{the_keys};
printArray (@{$theArrRef});
#--- Case 4 (works)
printArray ((@{$theArrRef = $pkg_2->{the_keys}}));
#--- Case 5 (works)
printArray ((@{$pkg_2->{the_keys_2}}));
#--- Case 6 (DOES NOT work)
printArray ((@{$pkg_2->{the_keys}}));
#--- Case 7 (DOES NOT work)
foreach my $n (@{$pkg_2->{the_keys}}) {
print " ", $n;
}
print "\n";
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 23 Jan 2001 00:15:52 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Q: socket communication between perl and java
Message-Id: <t6pj9o2nv0rj7d@corp.supernews.com>
Bjorn Hassler <bh213@damtp.cam.ac.uk> wrote:
> Hello all!
Uuuuummmmmm, hi.
> I was wondering whether somebody has experimented with `sticking a bit
> of perl'
> between two java apps (on linux btw.), e.g.
> JAVA Simple Perl Java
> APPLET---->socket1<--------Server---------------->socket2<--------Server
The languages in which your network peers are programmed is irrelevant.
TCP/IP is a standard protocol suite. It doesn't actually even matter
that both sides are programmed via the socket APIs. The XTI API can
support TCP/IP connections, too.
> where the perl server simply relays all that comes in from the applet to
> the
> Java server, and vice versa. THe reason why I want to do this is long,
> complicated
> and horrible, so let's just treat it as an exercise :-)
Okay, it's an exercise in writing a Perl middleware app that forwards
data from one socket to another (for port forwarding, data massaging,
outsmarting a firewall, or whatever reason). What is on the two ends
still isn't your focus. Focus on why the Perl app isn't doing what
it should do.
> I've got all the bits of code, and the various servers and applet all
> recognise
> eachother connecting and disconnecting, but I cannot get them to pass
> any data.
Do the Java programs send and receive data with a standard client
(for example, what happens when you connect to the Java server with
a telnet client or connect the Java client to a telnet server? Any
data at all?)? If the Java programs work and the Perl program doesn't,
then it's an issue with the Perl program. If the Perl program works
but the Java ones don't, then it's an issue with the Java programs
(or with one of them if one of them works and the other doesn't).
Even if it's an issue with the Perl program, it could be more an
issue of programming with sockets than programming with Perl. You
could check a book on network programming.
> Perl details: I am using IO::Socket, tcp connection, and recv/send
> methods
> Java details: java.net.* (serverSocket), e.g. stream.writeUTF (uses tcp
> too(?))
Does it? What are the options on the socket? TCP is a network protocol
standard. Sockets is a network programming standard. Sockets can be
used for other protocols (although this might not be implemented
in particular platforms or languages). TCP can be implemented using
other APIs. Although I don't do Java, (I drink coffee, and I'd like
to vacation to Java some day, but I don't use the language) but I
might imagine that, like some C libraries, TCP might be the only option
for protocol in calls to create a socket. That may not be the case,
though, and that is not a shortcoming of the socket API. Most people
have just never found the need for other protocols to be options.
> Both the perl methods and the java methods use tcp - so what else
> could there be going wrong? (Could of course be very elementary -
> I am really no network guru!)
As Advent might say:
I see no code here.
That is to say, I can't say for sure that your code ever has data
to send, because I can't see your code. I can't say that your data
will actually send said data, because I can't see your code. I can't
say that your code would receive data sent to it, because I can't see
your code. I can't say how you would know you have received any data,
because I can't see your code. If I were to try to help you with your
code from here, where I can't see your code, then I'd have to write
your code for you. I don't even see a firm spec from which to do that.
As Advent might say:
I see no error here.
I don't see any errors generated by perl. I see no descriptions of
what is not happening that should be. I see no descriptions of what
is happening at all.
> Just in case anybody has ever played with this kinda thing - I'd be
> grateful for a posting!
I've played with socket-based servers and clients in Perl (and a little
in C as well). I even wrote a program that, while it didn't forward
data directly from one socket to another, it did accept multiple
connections on a port, take input form users, make decisions based on
the input, and make a socket connection to another program as a back
end to process and store some of the results. I don't have that code
handy at the moment, and it's quite large for a newsgroup posting
(and it's not very good code - it's from some of my first experiences
with sockets and badly needs to be rewritten before being shown as
even an example of what not to do).
So, there's my post, but you don't have to be grateful because I'm
sure this isn't as helpful as had been hoped. Perhaps this post isn't
quite as friendly as had been hoped, either, and I apologize for that
as I don't mean to be mean. It sure is Monday, isn't it (in my timezone,
anyway)?
Chris
--
Christopher E. Stith
Where there's a will, there's a lawyer.
------------------------------
Date: Tue, 23 Jan 2001 11:49:54 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Random Numbers with a Twist
Message-Id: <slrn96pl9i.meu.mgjv@martien.heliotrope.home>
On Mon, 22 Jan 2001 14:20:32 -0700,
Rob Greenbank <rob@frii.com> wrote:
> On 20 Jan 2001 00:42:40 GMT, abigail@foad.org (Abigail) wrote:
>
>>The hard part is deciding when to stop, that is, when is the set
>>random enough?
>
> Yup. I think your solution will work, but the randomness could be
> nearly non-existent. It might be possible to create a situation where
> a solution exists, but *only* one solution (ie. the points *have* to
> be spaced evenly from corner to corner). A more likely situation
> would be having a small number of solutions possible, in which case
> the solution will not look very random.
>
> Two thoughts. I'm not a mathematician, but I would guess it would be
> possible to at least estimate of the probability of solving the
> problem with each run. Then the person (or process?) could decide if
> it was worth trying or not. If the probability was 50%, on average it
> would take two attempt to solve the problem.
One thing you could do is calculate two packings of the grid, to find an
upper limit to what is possible at all. Pack it squarely, and
hexagonally (you do need to do both for some pathological cases where a
square packing will turn out to allow more than a hexagonal packing).
This will give you an upper limit to what you can pack on your grid at
all. If the requested number is larger, you can bail out. However, to be
able to come up with a probability to solve it, is probably equivalent
to solving almost every case.
Alternatively, you could start by trying to create an equidistantly
spaced distribution of particles, and use some sort of perturbation
technique for each particle. You should be able to calculate something
like the free runlength for each article, and do something with root
mean squares of those numbers, and maybe a deviation. I think you
probably would be able to use those numbers meaningfully to say
something about the amount of useful free space available to each
particle.
I started working on a solution for continuous space, tring to remember
things that I learned in thermodynamics and such a long time ago. I gave
up after a while. It became very complex, and I just am not used to
juggling those sorts of formulas anymore. Besides that, I couldn't think
of a way to change it into a discrete problem, instead of a continuous
one.
I have the feeling that a decent algorithm for this, and a good estimate
of boundary conditions and end conditions, is not trivial by any means,
and probably belongs in sci.math (didn't someone very far upthread
suggest this?). If you really are interested in finding a solution for
this, a Perl newsgroup is probably not the best way to work out a good
algorithm :)
> I also wonder if an algorithm could be contrived to dynamically
> increase the size of the grid as needed. With that one could at least
Sure.. Make the problem even harder! :)
> generate the smallest possible grid based on the points already
> chosen.
Oh, I see what you mean.... But that's a chicken and egg problem. You
need to choose some outer bounds to pick the random spots in that will
give you the outer bounds to pick a random spot in.
> Maybe the best way is to add a rule that says if it isn't big enough
> to guarantee a solution, regardless of the points chosen, then don't
> even try.
>
> Actually, I think the best solution (for me) is to be satisfied with
> having had some stimulating thought and bow out of the thread. So,
> everyone take care,
I found it interesting too, even though I couldn't work out a decent way
to solve it.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | "Mr Kaplan. Paging Mr Kaplan..."
NSW, Australia |
------------------------------
Date: Tue, 23 Jan 2001 01:02:50 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: stability of threads + interpreter performance
Message-Id: <_K4b6.151545$P82.18385537@news1.rdc1.ct.home.com>
Koen Bossaert <not@defined.com> wrote:
> Hi,
> I read that threading is a lot more stable, but still experimental in Perl
> 5.6 than in 5.005, but that one has to pay a performance penalty if you
> recompile the interpreter to support threading (ref:
> http://www-106.ibm.com/developerworks/library/l-perl5.html?dwzone=linux).
Yup, it's better, but still has problems. It likely will never be truly
fixed in any of the releases of perl 5.
> Can anyone tell me if it is stable enough to use in business applications?
> How big is the performance penalty?
If you avoid its traps, it's safe, though the performance penalty can be
reasonably high. How high depends on your system, but you might see up to
a 20% slowdown.
Dan
------------------------------
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 V10 Issue 123
**************************************