[17483] in Perl-Users-Digest
Perl-Users Digest, Issue: 4903 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 16 14:05:40 2000
Date: Thu, 16 Nov 2000 11:05:10 -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: <974401510-v9-i4903@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 16 Nov 2000 Volume: 9 Number: 4903
Today's topics:
Re: A silly. Substitution - s/// (Anno Siegel)
Re: A silly. Substitution - s/// <bart.lateur@skynet.be>
Chart graphing suitable for web page (Oscar Vallarino)
Re: Checking Writable Sockets on Solaris 2.6 <bkennedy99@home.com>
Re: compiling/securing Perl code <jimNOSPAM@gosquad.com>
Re: compiling/securing Perl code (Rafael Garcia-Suarez)
Counting bracket matching <alun.moon@ncl.ac.uk>
DBI Problem - Help Please amerar@my-deja.com
Re: DBI Problem - Help Please <joe+usenet@sunstarsys.com>
Re: Delete empty directories (Gwyn Judd)
Re: display shell alias in perl? <tim@ipac.caltech.edu>
Dynamic Array Ques <polar@cloud9.net>
Re: Dynamic Array Ques <bart.lateur@skynet.be>
Re: Dynamic Array Ques (David H. Adler)
Examples of Reading RSS? <IAMsvore@mindspring.com>
Re: Extracting data from a string <josef.moellers@fujitsu-siemens.com>
Re: Extracting data from a string (Rafael Garcia-Suarez)
Re: Finer points of lists, etc. <jeffross@bendcable.com>
Re: Help with if(file_exists) <phallicity_2000@yahoo.com>
Re: Help with if(file_exists) (Rafael Garcia-Suarez)
Re: Help with if(file_exists) <geoff-at-farmline-dot-com@127.0.0.1>
How do I ensure that only a single instance of my scrip <c.manley@chello.nl>
How to get name of current opened file in while(<>) <dross@iders.ca>
Re: IP geography (Tony L. Svanstrom)
Re: IP geography (Tony L. Svanstrom)
Security Problem kangchenjunga@my-deja.com
Re: Sort files by date <mischief@velma.motion.net>
Re: Where are param and redirect defined <sladb69@magma.ca>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Nov 2000 17:15:49 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: A silly. Substitution - s///
Message-Id: <8v14o5$g94$1@lublin.zrz.tu-berlin.de>
Bart Lateur <bart.lateur@skynet.be> wrote in comp.lang.perl.misc:
>If you want to reduce it to just one instance: tr/// with the /s option
>(for "single") is designed for that.
Pity. I thought "s" was for "squeeze", and found that more colorful.
Anno
------------------------------
Date: Thu, 16 Nov 2000 17:27:21 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: A silly. Substitution - s///
Message-Id: <76681t8u28lbanecse6tb62oqsb5qcprae@4ax.com>
Anno Siegel wrote:
>>If you want to reduce it to just one instance: tr/// with the /s option
>>(for "single") is designed for that.
>
>Pity. I thought "s" was for "squeeze", and found that more colorful.
Why not. The /s is part of the language, the word itself is not. perlop
talks about "squash", which is even more colorful.
--
Bart.
------------------------------
Date: Thu, 16 Nov 2000 22:24:09 GMT
From: ovallari@tse.com (Oscar Vallarino)
Subject: Chart graphing suitable for web page
Message-Id: <B%VQ5.67271$Z2.887536@nnrp1.uunet.ca>
Hi folks!
I am looking for some off-the-shelf software that can generate simple
2-D graph charts from number series, and produce output in GIF or PNG
format suitable to display on a web page.
For simplicity, I am planning to run this function as CGI script. My
webserver is hosted on a Sun machine under Solaris 2.7.
I've looked for some Perl modules and found GD.pm as a possible
candidate. Unfortunately this is a low level package that would
require we design and write charting code on top of it to get charts
similar to what Microsoft Excel can do (which is what I am using).
Given the number of websites that show 2-D charts out there, perhaps
there is something already available which does what I am looking for.
Does anyone have any suggestions?
Thanks in advance for any pointers.
Oscar
------------------------------
Date: Thu, 16 Nov 2000 17:25:43 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: Checking Writable Sockets on Solaris 2.6
Message-Id: <rMUQ5.118895$td5.17872361@news1.rdc2.pa.home.com>
"Jimmy" <someone@compugenx.com> wrote in message
news:8uumu2$ovu$1@bob.news.rcn.net...
> if the above code is executed after $client has disconnected, my die will
> never be called, instead an error of "Broken Pipe" is sent to STDERR and
the
> progrma is terminated.
>
> I want to handle these, and I have tried eval() IO::Select->can_write as
> well as trying to verify peeraddr, all to no avail. It seems that all
> socket calls that fail under Solaris 2.6 are disreagrding whatever
mechanism
> I have set up to trap and handle these failures.
A broken pipe is really a caught process signal which default behavior is to
halt the script, regardless of eval's or otherwise. You may be able to do
something like
$SIG{PIPE} = IGNORE; # ignore SIGPIPE's
# your code
$client->send($data) or die "Couldn't send, probably broken pipe: $!\n";
I don't really know the gory details, but this should get you started. You
may also install a more robust signal handler that does something like set a
global "broken pipe" flag to true, though that error may also be in $! -
hope this helps
--Ben Kennedy
------------------------------
Date: Thu, 16 Nov 2000 17:08:58 GMT
From: "Jim" <jimNOSPAM@gosquad.com>
Subject: Re: compiling/securing Perl code
Message-Id: <KwUQ5.68389$n9.1603749@news2.rdc1.on.home.com>
"Philip S Tellis" <philip@tae.tellis.home> wrote in message
news:Pine.LNX.4.30.0011160127500.662-100000@tae.tellis.home...
> Sometime on Nov 15, Jim assembled some asciibets to say:
>
> > To state my problem directly, I need to distribute a large perl-based
web
> > application in a secure way. I'm sure this topic has been discussed
> >
> > 3) Code must not be easily viewable (encrypted, compiled w/ another
>
> Compiled code can be reverse engineered, so there's no security there.
> Encrypting your code doesn't help either, because at some point it needs
> to be decrypted in order to execute it. If it _can_ be decrypted, then
> there's nothing to stop anyone from decrypting it.
>
> I suppose your licence could prevent reverse engineering, but that would
> only stop people who weren't _really_ interested in the code.
>
> The only advantage you gain by compiling, is that you distribute
> everything in one package, but then, why not distribute perl with your app
> anyway?
>
Well, I guess I should have stressed the word 'easily':
3) Code must not be /easily/ viewable (encrypted, compiled w/ another
So, basically, once this package is installed on another machine, we don't
want someone with minimal 'vi' experience 'fixing' bugs by themselves..
Jim
------------------------------
Date: Thu, 16 Nov 2000 17:19:07 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: compiling/securing Perl code
Message-Id: <slrn9185p9.424.rgarciasuarez@rafael.kazibao.net>
Jim wrote in comp.lang.perl.misc:
>
> "Philip S Tellis" <philip@tae.tellis.home> wrote in message
> news:Pine.LNX.4.30.0011160127500.662-100000@tae.tellis.home...
> > Sometime on Nov 15, Jim assembled some asciibets to say:
> >
> > > To state my problem directly, I need to distribute a large perl-based web
> > > application in a secure way. I'm sure this topic has been discussed
> > >
> > > 3) Code must not be easily viewable (encrypted, compiled w/ another
> >
> > Compiled code can be reverse engineered, so there's no security there.
> > Encrypting your code doesn't help either, because at some point it needs
> > to be decrypted in order to execute it. If it _can_ be decrypted, then
> > there's nothing to stop anyone from decrypting it.
> >
> > I suppose your licence could prevent reverse engineering, but that would
> > only stop people who weren't _really_ interested in the code.
> >
> > The only advantage you gain by compiling, is that you distribute
> > everything in one package, but then, why not distribute perl with your app
> > anyway?
>
> Well, I guess I should have stressed the word 'easily':
>
> 3) Code must not be /easily/ viewable (encrypted, compiled w/ another
>
> So, basically, once this package is installed on another machine, we don't
> want someone with minimal 'vi' experience 'fixing' bugs by themselves..
Why?
If you don't want full security, why don't you rely on a software
license instead of some crappy obfuscation?
perldoc -q hide
-> How can I hide the source for my Perl program?
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 16 Nov 2000 17:13:54 +0000
From: Alun Moon <alun.moon@ncl.ac.uk>
Subject: Counting bracket matching
Message-Id: <qmk7l63yh4d.fsf@aidan.ncl.ac.uk>
Dear all,
I'm writing a simple program where I need to print out everything
between the next opening bracket ( a `[' or a '}') and its closing
counterpart. There are other [] {} pairs within.
I've got something like
$l = scalar(@_=/(\x7B)/g);
while( <> ) {
$l += scalar (@_=/(\x7B)/g);
$l -= scalar (@_=/\x7D/g);
print;
last if not $l;
}
(The opening bracket may not be on the current line, but that's easy
to move to)
Is there a neater more eligant way of doing this?
Mant thanks
Alun
---------------------------------------------------------------------------
Dr Alun Moon University of Newcastle uponTyne alun.moon@ncl.ac.uk
------------------------------
Date: Thu, 16 Nov 2000 18:31:52 GMT
From: amerar@my-deja.com
Subject: DBI Problem - Help Please
Message-Id: <8v196q$oul$1@nnrp1.deja.com>
Hi there,
Perhaps I'm just not understanding how the syntax is supposed to be, but
here is my code and here is the error:
$summary_date_time = "TO_DATE('10012000','MMDDYYYY')";
$cur = $dbh->prepare("SELECT SUM(total_revenue) FROM revanal_summary
WHERE summary_date_time=?");
$cur->execute( $summary_date_time );
my($total)=$cur->fetchrow();
Error:
DBD::Oracle::st execute failed: ORA-01858: a non-numeric character was
found where a numeric was expected (DBD: oexfet error) at art.pl line
18.
What am I missing? I am going on about 3 hours of working on this....
Please CC a copy to this e-mail: amerar@ci.chi.il.us
Thanks,
Arthur
amerar@ci.chi.il.us
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Nov 2000 14:01:39 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: DBI Problem - Help Please
Message-Id: <m3vgtnoi5o.fsf@mumonkan.sunstarsys.com>
amerar@my-deja.com writes:
> Hi there,
>
> Perhaps I'm just not understanding how the syntax is supposed to be, but
> here is my code and here is the error:
>
> $summary_date_time = "TO_DATE('10012000','MMDDYYYY')";
> $cur = $dbh->prepare("SELECT SUM(total_revenue) FROM revanal_summary
> WHERE summary_date_time=?");
You can't use a ? mark like this- DBI treats $summary_date_time
as an escaped string variable in
> $cur->execute( $summary_date_time );
effectively your SQL looks like this:
SELECT SUM(total_revenue) FROM revanal_summary WHERE
summary_date_time="TO_DATE(\'10012000\',\'MMDDYYYY\')"
which is bad since TO_DATE is an SQL function.
In short, you need TO_DATE to be a part of your prepare'd
SQL statement so your db knows what to do with it.
HTH.
--
Joe Schaefer
------------------------------
Date: Thu, 16 Nov 2000 18:01:08 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Delete empty directories
Message-Id: <slrn918871.p3i.tjla@thislove.dyndns.org>
I was shocked! How could Martien Verbruggen <mgjv@tradingpost.com.au>
say such a terrible thing:
> { wanted => sub { return unless -d; rmdir }, no_chdir => 1}, 'a');
*doh* significantly simpler than my effort. I claim that mine is better
because it doesn't attempt to unnecessarily delete all those directories
:)
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If you are shooting under 80 you are neglecting your business;
over 80 you are neglecting your golf.
-- Walter Hagen
------------------------------
Date: Fri, 17 Nov 2000 11:00:37 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: display shell alias in perl?
Message-Id: <3A158055.EBB300B@ipac.caltech.edu>
[A copy of this posting CC'd to the OP]
Philip Tsai wrote:
> Thanks for all your replies on this matter. It was discouraging to find out
> that one can't really do that in Perl.
>
> QM: I was trying to read an alias already set in the shell. I tried
> eval `perl -e 'print "alias xyz banner perl"'` to no avail, either.
>
> I pretty much gave up on this (Yes, as some posters indicated, if I define
> all aliases in some file, e.g. .alias, instead of .cshrc or .tcshrc, then
> there is a way around it -- but not all client users are going to have that
> alias file ready though ).
I didn't see all of this thread, but I didn't see this suggested:
perl -we 'my @aliases = qx/csh -c alias/; print for @aliases;'
... which works fine for me.
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Thu, 16 Nov 2000 12:41:41 +0000
From: brian <polar@cloud9.net>
Subject: Dynamic Array Ques
Message-Id: <3A13D604.72985685@cloud9.net>
I'm sure there's a simple way to do the following but I haven't been
able to find the answer. Basically what I want to do is dynamically
create arrays depending on the number of files I am opening. For
example, if I am reading in three files ( abc.profit_loss,
fgh.profit_loss and xyz.profit_loss ) I then want to create @abc_date,
@abc_pl, @fgh_date, @fgh_pl, etc... I have had no problem matching for
the security name but I am unable to create the array. On the loop
through the file list I set $var to the name but I cannot create
@$var_date, @$var_pl. I tried enclosing in quotes or using backslashes
but this still doesn't work. Any help is greatly appreciated
Brian
------------------------------
Date: Thu, 16 Nov 2000 17:50:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Dynamic Array Ques
Message-Id: <bu681tovg343ho411dtifc468b1r1h6ng0@4ax.com>
brian wrote:
>For
>example, if I am reading in three files ( abc.profit_loss,
>fgh.profit_loss and xyz.profit_loss ) I then want to create @abc_date,
>@abc_pl, @fgh_date, @fgh_pl, etc... I have had no problem matching for
>the security name but I am unable to create the array.
It seems like you're asking for symbolic references, which should work,
but I wouldn't do it that way. I would go for a tree structure:
$array{abc}{date}
$array{abc}{pl}
$array{fgh}{date}
$array{fgh}{pl}
$array{xyz}{date}
$array{xyz}{pl}
These hash (%array) items are, of course, scalars, but they may just as
well be array references. Like this:
$id = 'abc';
push @{$array{$id}{date}}, 10;
push @{$array{$id}{pl}}, 'a';
push @{$array{$id}{date}}, 20;
push @{$array{$id}{pl}}, 'b';
And if you want to check out the contents of this data structure, use
Data::Dumper:
use Data::Dumper;
print Dumper \%array;
$VAR1 = {
'abc' => {
'pl' => [
'a',
'b'
],
'date' => [
10,
20
]
}
};
Of course, you can also access individual array items more directly:
print $array{abc}{date}[1];
-->
20
or get the number of items, and the index of the last item:
$\ = "\n";
print scalar @{$array{abc}{date}};
print $#{$array{abc}{date}};
-->
2
1
So you think it's clumsy? Well, use a copy of the reference for easier
access:
$ary = $array{abc}{date};
print "@$ary\n$#$ary\n";
-->
10 20
1
--
Bart.
------------------------------
Date: 16 Nov 2000 18:39:18 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: Dynamic Array Ques
Message-Id: <slrn918aem.q70.dha@panix2.panix.com>
On Thu, 16 Nov 2000 12:41:41 +0000, brian <polar@cloud9.net> wrote:
>I'm sure there's a simple way to do the following but I haven't been
>able to find the answer. Basically what I want to do is dynamically
>create arrays depending on the number of files I am opening. For
>example, if I am reading in three files ( abc.profit_loss,
>fgh.profit_loss and xyz.profit_loss ) I then want to create @abc_date,
>@abc_pl, @fgh_date, @fgh_pl, etc... I have had no problem matching for
>the security name but I am unable to create the array. On the loop
>through the file list I set $var to the name but I cannot create
>@$var_date, @$var_pl. I tried enclosing in quotes or using backslashes
>but this still doesn't work. Any help is greatly appreciated
Short answer: Don't do that.
Medium answer: Use a hash of array references.
Long answer: See http://perl.plover.com/varvarname.html (and
following) for the reason for the short answer.
More to the point, this is discussed in perlfaq7, under "How can I use
a variable as a variable name?"
best,
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
It didn't bother me before there was a for modifier, and now that
there is one, it still doesn't bother me. I'm just not very easy to
bother. - Larry Wall
------------------------------
Date: Thu, 16 Nov 2000 13:51:40 -0500
From: "Steven" <IAMsvore@mindspring.com>
Subject: Examples of Reading RSS?
Message-Id: <8v1abu$7p9$1@slb0.atl.mindspring.net>
Ladies and Gentlemen,
Do you have any pointers to examples of *reading* and processing RSS? All I
seem to be able to find "out there" are examples of writing content as RSS.
thanks
--
-Steven
http://Mumble.EditThisPage.com
------------------------------
Date: Thu, 16 Nov 2000 17:17:58 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Extracting data from a string
Message-Id: <3A1408B6.FA13219E@fujitsu-siemens.com>
Jonathan MILLEY wrote:
> =
> I'm kind of new to perl, but I', getting the hang of it.
> My question pertains to extracting information from a string.
> =
> Example I'm parseing an HTML file and I want to get the title, so
> I look for the line with <TITLE> in it, and I want to extract everythin=
g
> between <TITLE> and </TITLE> is there an easy way to accomplish this?
> =
> Any and all help is appreciated,
Say the data is in $line, then
$line =3D~ s/.*<title>(.*)<\/title>.*/\1/i;
will leave the title in $line.
-- =
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
------------------------------
Date: Thu, 16 Nov 2000 16:37:20 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Extracting data from a string
Message-Id: <slrn9183au.3sr.rgarciasuarez@rafael.kazibao.net>
Josef Moellers wrote in comp.lang.perl.misc:
>Jonathan MILLEY wrote:
>>
>> I'm kind of new to perl, but I', getting the hang of it.
>> My question pertains to extracting information from a string.
>>
>> Example I'm parseing an HTML file and I want to get the title, so
>> I look for the line with <TITLE> in it, and I want to extract everything
>> between <TITLE> and </TITLE> is there an easy way to accomplish this?
>>
>> Any and all help is appreciated,
>
>Say the data is in $line, then
> $line =~ s/.*<title>(.*)<\/title>.*/\1/i;
>will leave the title in $line.
This will work only if the title is on a single line.
You should use the /s modifier if $line contains several lines :
$line =~ s/.*<title>(.*)<\/title>.*/\1/is;
or, better (does not change the value of $line) :
my ($title) = m!<title>(.*)</title>!is;
or, use a more general solution: the HTML::Parser module, available from
CPAN.
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Thu, 16 Nov 2000 10:31:13 -0800
From: Jeff Ross <jeffross@bendcable.com>
Subject: Re: Finer points of lists, etc.
Message-Id: <5B0CE43BCEFF3BEB.8B1D3AFF608B0149.B3EAAAA74909ABA5@lp.airnews.net>
On Wed, 15 Nov 2000 15:51:34 -0800, Jeff Zucker <jeff@vpservices.com>
wrote:
>
>my %hash = reverse qw(30188 A01 3644 A02 4080 B03 2976 B09 2912 C01);
>for my $key(sort keys %hash) {
> print "$key = $hash{$key}\n";
>}
This worked out perfectly. Thanks.
------------------------------
Date: Thu, 16 Nov 2000 16:49:40 GMT
From: Phallicity <phallicity_2000@yahoo.com>
Subject: Re: Help with if(file_exists)
Message-Id: <8v1370$j2q$1@nnrp1.deja.com>
In article <8uf3fp$fjb$1@nnrp1.deja.com>,
Phallicity <phallicity_2000@yahoo.com> wrote:
> I am trying to check the existance of a file. The cgi script is being
> run from www.somepage.com/cgi-bin/test/prog.cgi. I want prog.cgi to
> test for the existance of file www.somepage.com/junk/more/me.gif. Can
> someone tell me how to write the if statement? I have tried: if
> (/junk/more/me.gif) {...} but I get an error from the server when I
> try to run this.
>
> Thanks in advance
>
> --
> Phallicity
>
> "He must have a huge Schwanstucker!"
> -Young Frankenstein
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
Anyone?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 16 Nov 2000 17:09:09 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Help with if(file_exists)
Message-Id: <slrn91856j.40b.rgarciasuarez@rafael.kazibao.net>
Phallicity (barely a name...) wrote in comp.lang.perl.misc:
>> I am trying to check the existance of a file. The cgi script is being
>> run from www.somepage.com/cgi-bin/test/prog.cgi. I want prog.cgi to
>> test for the existance of file www.somepage.com/junk/more/me.gif. Can
>> someone tell me how to write the if statement? I have tried: if
>> (/junk/more/me.gif) {...} but I get an error from the server when I
>> try to run this.
'www.somepage.com/junk/more/me.gif' is not a file, and it's barely an
URL. You want to test the existence of a file whose path is :
'/path/to/document/root/junk/more/me.gif'. This is done with one of the
filetest operators. See the perlfunc manpage and look for '-X'. '-f' is
probably what you want.
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Thu, 16 Nov 2000 17:11:45 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: Help with if(file_exists)
Message-Id: <8v14gi$qpp$1@soap.pipex.net>
"Phallicity" <phallicity_2000@yahoo.com> wrote in message
news:8v1370$j2q$1@nnrp1.deja.com...
> In article <8uf3fp$fjb$1@nnrp1.deja.com>,
> Phallicity <phallicity_2000@yahoo.com> wrote:
> > I am trying to check the existance of a file. The cgi script is being
> > run from www.somepage.com/cgi-bin/test/prog.cgi. I want prog.cgi to
> > test for the existance of file www.somepage.com/junk/more/me.gif. Can
> > someone tell me how to write the if statement? I have tried: if
> > (/junk/more/me.gif) {...} but I get an error from the server when I
> > try to run this.
> Anyone?
There were 7 different responses to this.
Basically check out
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/_X.html
If you're going to post a FAQ question like this at least have the grace to
check on deja.com before posting a followup request.
Posted and emailed.
Geoff
------------------------------
Date: Thu, 16 Nov 2000 18:56:13 GMT
From: Craig Manley <c.manley@chello.nl>
Subject: How do I ensure that only a single instance of my script is running (in Linux)?
Message-Id: <3A14309D.B84DD659@chello.nl>
Hi,
I've made a script that runs as a cron job every minute. It is important
that only one instance runs at a time. Currently I use this function to
check that:
#####
# Name : isSingleInstance
# Description : Checks that only one instance of this program is active.
# Parameters : none
# Returns : boolean result
####
sub isSingleInstance {
@_ = split("\n",`ps -A | grep $lv_AppName`);
return (@_ == 1);
}
I've noticed that only sometimes (like once every 2 hours) @_ contains
no elements. Normally grep should return at least one match and not
none.
In Windows you can use Mutexes to safely check if your script is running
as a single instance. I'm new to Linux, so I'm not sure what I can use
in Linux and how... I hope somebody can help me out there.
-Craig Manley.
------------------------------
Date: Thu, 16 Nov 2000 18:49:15 GMT
From: Derek Ross <dross@iders.ca>
Subject: How to get name of current opened file in while(<>)
Message-Id: <3A142B94.2118@iders.ca>
Hello,
I'm new to perl and I'm having a problem I can't seem to find the answer
to.
I'm using a while(<>) loop to process a file... is there a way to get
the current filename that is being processed?
I'm calling perl from the commandline, and processing files by the batch
using wildcards for the file name, like so:
perl -w process.pl *.txt > output.html
Any help would be greatly appreciated.
Derek Ross
------------------------------
Date: Thu, 16 Nov 2000 17:36:03 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: IP geography
Message-Id: <1ek7cu7.1r7g83tflgymyN%tony@svanstrom.com>
Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> I was shocked! How could Jeff Zucker <jeff@vpservices.com>
> say such a terrible thing:
> >Bart Lateur wrote:
> >>
> >> Martien Verbruggen wrote:
> >>
> >> >> I guess when IPv6 rolls out, early in the 31st century (no, that isn't
> >> >> a typo), each planet, station, moon, asteroid, etc, will get its own
> >> >> set of subnets.
> >> >
> >> >There's enough room in that address space to individually address each
> >> >organ in everyone's body :)
> >>
> >> Ooh, that's not enough. I'll be satisfied only if there are enough IP
> >> addresses for every cell in everybody's body.
> >
> >Bah, wimps! I want one for every nucleotide in every strand of human
> >DNA. Yeah, that's the ticket.
>
> More than enough to address every atom in the entire universe so I think
> it should be okay :)
I don't think we should settle for anything less than one address for
every primenumber... :)
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Thu, 16 Nov 2000 17:36:04 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: IP geography
Message-Id: <1ek7cxl.1kg3j8u1ow7uyxN%tony@svanstrom.com>
<tcblue@my-deja.com> wrote:
> Hi, does any know if there is a perl module or script that can 'try' and
> detect the physical location of a given IP address or hostname?
Using an optional lil DNS-thing (whaddaya call those things anyway?) you
can get the information that they, maybe, provided for ya to look at...
Just search your fav. RFC-library and you'll find it.
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Thu, 16 Nov 2000 18:07:50 GMT
From: kangchenjunga@my-deja.com
Subject: Security Problem
Message-Id: <8v17pf$nf5$1@nnrp1.deja.com>
Here is my problem. I am succesfully poping up a dialog that is used
to save an exe. I do this in perl by doing using javascript like this
print <<ENDOFTEXT;
<script LANGUAGE="Javascript">
window.location.href="http://www.somesight.com/downloads/someexe.exe";
</script>
ENDOFTEXT
of course the
<script LANGUAGE="Javascript">
window.location.href="http://www.somesight.com/downloads/someexe.exe";
</script>
gets left in the generated HTML which shows the exact location to
get the exe.
So what is the easiest way in perl to open up a dialog box that will
enable a user to download a product without showing any traces of
the exact location?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 16 Nov 2000 16:30:41 -0000
From: <mischief@velma.motion.net>
Subject: Re: Sort files by date
Message-Id: <t182thmbmegp8a@corp.supernews.com>
John Lin <johnlin@chttl.com.tw> wrote:
> In many cases, Perl programmers tend to write convenient codes, like:
> (1) my ($oldest,$newest) = (sort {-M $a <=> -M $b} @files)[-1,0];
> (2) if(grep {$_ eq 'target'} @array) { print "found" }
Yes, these are convenient.
> But, in (1), sort is O(N log N), while min/max just need a O(N) loop.
> For (2) the Perl FAQ (perldoc -q "element") tells us: Please do not
> use grep to tell whether a list or array contains a certain element
> because it checks every element even if the first matches.
This loss of effieciency is not good, agreed.
> Well then, for subsitiution of these very frequently written codes,
> I would suggest to provide a module (or build in?) like:
> use List::Utilities;
> my ($min,$max) = minmax {-M $a <=> -M $b} @files;
> if(first {$_ eq 'target'} @array) { print "found" }
> so we can write conveniently without losing efficiency.
Sounds like you're volunteering? If not, let's at least discuss
what else should go into a module to do that, as that's not a lot
of code for a whole module. Maybe the module should have other
subroutines of similar ilk as well.
I'd say that a minmax() function is a good candidate for a module
that offers a slew of 4GL features. In many spreadsheets and
RDBMSs, for example, there's a min(), a max(), and several other
convenient functions like mean(), mode(), median(), and sort().
Of course, Perl already has sort(), and there may, as far as I know,
be statistical packages out there that do most of this and more.
I wouldn't want to add a minmax() or min() and max() to the core,
because these are simple enough to do by hand for the particular
case, and are better served as modules in a general case. Anything
that can be done in less than 15 lines or so I'd normally hesitate
to put into a module, and anything that, in a module, could be made
with less than about 100 lines I'd be wary to put into the core
unless there's a huge overriding reason like commonality or huge
speed differences - preferably both. A module that contains many
of these mathematical and statistical style of functions in one
place does sound promising though.
I'm not sure where I'd draw the line. Some higher mathematical
functions and higher statistical functions I'm sure are already
implemented somewhere. Something that might be overlooked is the
ability to quickly and easily port spreadsheet-like macro
programs to Perl by using a module that provides the functions a
spreadsheet system offers. I know there are modules that deal with
files exported from Excel or other spreadsheets, and there are
DBMS interfaces, including the ubiquitous DBI. In the case that
these files could be manipulated using a Perl module that provides
functions very similar to those offered by the porgrams importing
and exporting them, much time could be saved between writing macros
in a spreadsheet to do part of the work and Perl to do another part.
Wouldn't it be better to use a spreadsheet mainly for display and
simple math and a full-fledged programming language for the bulk
of the processing?
--
Chris Stith Motion Internet mischief@motion.net
`If you know what you want, you'll have a much easier time getting it.'
------------------------------
Date: Thu, 16 Nov 2000 16:37:58 GMT
From: Scott Thornton <sladb69@magma.ca>
Subject: Re: Where are param and redirect defined
Message-Id: <3A140D77.9525BF06@magma.ca>
Thank you for that. I am new to Perl programming and I didn't know about
the libraries.
Thanks,
Scott
Rafael Garcia-Suarez wrote:
> Scott Thornton wrote in comp.lang.perl.misc:
> >I have seen in a few examples in the newsgroups the use of param and
> >redirect. Where are they defined? They are not part of the original
> >PERL language, or at least they are not listed in the man pages.
>
> at the prompt :
> perldoc CGI
>
> and, BTW, it's "Perl", not "PERL".
>
> --
> # Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
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 4903
**************************************