[19538] in Perl-Users-Digest
Perl-Users Digest, Issue: 1733 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 11 18:05:31 2001
Date: Tue, 11 Sep 2001 15:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1000245908-v10-i1733@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 11 Sep 2001 Volume: 10 Number: 1733
Today's topics:
Re: AoH - continued <iltzu@sci.invalid>
Re: concatenating files with the same name <gnarinn@hotmail.com>
Re: Convert hex dump to binary <gnarinn@hotmail.com>
Re: dbmopen file extensions <gnarinn@hotmail.com>
Re: dbmopen file extensions <fiendy@claraNO-SPAM.co.uk>
Re: email this page script <iltzu@sci.invalid>
Re: Fixing jeopardy quotes (was Re: how to get the leng <spam@funnybytes.com>
Re: GetOptions($argument => \$output); <gnarinn@hotmail.com>
Re: GetOptions($argument => \$output); (Malcolm Dew-Jones)
Re: Getting response from KEA \ Reflection <iltzu@sci.invalid>
Re: Help: TiedHash.pm module in @INC not being recogniz <mel2000@hotmaildot.com>
Re: Help: TiedHash.pm module in @INC not being recogniz <gnarinn@hotmail.com>
Re: How can I correct "Use of uninitialized value in su <Dan.Nguyen@lsil.com>
Re: How do you use <> and @ARGV with 4nt? (Malcolm Dew-Jones)
Re: how to get the size of each attachment? (Malcolm Dew-Jones)
Re: how to substitute letters within a string <pauls_spam_no@pauls.seanet.com>
Laugh: BT webspace CGI conditions <stumo@bigfoot.com>
Re: Laugh: BT webspace CGI conditions (John J. Trammell)
Re: Laugh: BT webspace CGI conditions <tex@lager.engsoc.carleton.ca>
Re: ODBC with perl problem <gnarinn@hotmail.com>
Re: PERL modules and GPL license (Malcolm Dew-Jones)
Re: Problem reading an XML file <iltzu@sci.invalid>
Re: Problem with parsing more than one line ( Please HE (Ken Laird)
Re: recognize MS Windows with perl <bart.lateur@skynet.be>
Re: references, slices, voodoo <iltzu@sci.invalid>
Serial port communication <shino_korah@yahoo.com>
to get the process ID of a running process <luke@chipcity.com.au>
Re: Verify https communication <comdog@panix.com>
Re: Web form to Perl SQL query <iltzu@sci.invalid>
Re: Where Can I Find the path to the desktop on Win9X/2 <paul@net366.com>
Re: Why would the perl compiler report errors on the wr <jgrg@sanger.ac.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 11 Sep 2001 16:53:55 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: AoH - continued
Message-Id: <1000226877.29911@itz.pp.sci.fi>
In article <3B943FD1.D3A8FEFD@acm.org>, Dave Tweed wrote:
>
># pull off the first line of @data to get the sort order
>my %sorthash = %{shift @data};
># create an inverted hash that swaps the keys and values
>my %invhash;
>for my $k (keys %sorthash) { $invhash{$sorthash{$k}} = $k }
Better written as:
my %invhash = reverse %{shift @data};
There's no need for a slow and verbose for-loop.
># sort the keys of the inverted hash and pull out the values in that order
>my @sortkeys = @invhash{sort keys %invhash};
This will not work as expected for keys above 9. Use this instead:
my @sortkeys = @invhash{ sort {$a <=> $b} keys %invhash };
Otherwise, you approach is generally fine.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Tue, 11 Sep 2001 19:15:24 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: concatenating files with the same name
Message-Id: <1000235724.0422313888557255.gnarinn@hotmail.com>
In article <72fd0cf4.0109102251.27c0e142@posting.google.com>,
soumitra bhattacharya <soumitra@mailandnews.com> wrote:
>Hi!
>I have files with the same name but in different directories.
>I have four directories a,b,c,d
>within each directory I have files with the same name.
>Like within "a" directory I have
>k.txt (100Kb),l.txt(50Kb),m.txt(70Kb)
>again within "b" directory I have
>k.txt(77Kb),l.txt(70Kb),m.txt(770Kb)
>again within "c" directory I have
>k.txt(200Kb),l.txt(100Kb),m.txt(10Kb)
>
>
>I want to make a new directory "concatenated"
>where I will have files
>k.txt(file size= 100+77+200).....
>l.txt(file size = 50+7++100).....
>k.txt(377Kb),l.txt(220Kb),m.txt(850Kb)
>these files will contain the
>concatenated data of all the
>files with the same name from all the directories.
>I need to do this recursively as there are 10000+ files in each directory.
you do not need to do this recursively, unless there are subdirectories
that need to be processed the same way.
you do not say, what should be done if file xxx.txt only exists in
directory 'b', for example.
assuming all 4 directories contain the same filenames, and no subdirectories,
you can just loop through the files of directory 'a' with readdir(),
and for each file, open it for write in the new directory, and in turn
for each of the directories a,b,c and d open the file for read, and read each
line, and print each line to the new file.
so:
perldoc -f opendir
perldoc -f closedir
perldoc -f readdir
perldoc -f open
perldoc opentut
you should really try to solve this yourself, as this is not a
very complicated problem.
but if you really have problems, you can look at this:
#assuming directory "concatenated" exists
my $path='.';
my $file;
@dirs=qw(a b c d);
opendir(ADIR, "$path/a") or die "blah: $!";
while (defined ($file=readdir(ADIR))) {
if ($file=~/.+\.txt$/) { # just make sure '.' and '..' do not match
open(OUT,"> $path/concatenated/$file") or die "arrgh! ($file) : $!";
for my $dir (@dirs) {
open(IN,"< $path/$dir/$file") or die "oops ($dir/$file): $!";
while (<IN>) {
print OUT $_;
}
close(IN);
}
close(OUT);
}
}
closedir ADIR;
if you want to add tests for existence of the files, you
can use 'if (-f $file)' see perldoc -f -X
gnari
------------------------------
Date: Tue, 11 Sep 2001 19:25:41 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Convert hex dump to binary
Message-Id: <1000236341.0880347001366317.gnarinn@hotmail.com>
In article <3B9DD910.D5DC345D@fujitsu-siemens.com>,
Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote:
>Phil Hibbs wrote:
>> =
>
>> Is there anything around that would help me take something like this:
>> =
>
>> 0000: 0d 0a 0d 0a 41 70 70 6c ....Appl
>> 0008: 69 63 61 74 69 6f 6e 20 ication.
>> 0010: 65 78 63 65 70 74 69 6f exceptio
>> 0018: 6e 20 6f 63 63 75 72 72 n.occurr
>> 0020: 65 64 3a 0d 0a ed:
>> =
>
>> and convert it to a plain text file containing "Application exception
>> occurred:" etc.
>
>Have you tried
> perldoc -f hex
>
>I'd suggest split + hex to do the dirty work.
>
I'd suggest pack()
also, the OP should be aware that if files are on this form, it often means
that the data contains non-printable control codes. does he want them
converted to binary, or does he want 0d 0a converted to '\r\n' ?
gnari
------------------------------
Date: Tue, 11 Sep 2001 19:52:19 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: dbmopen file extensions
Message-Id: <1000237939.0862350631505251.gnarinn@hotmail.com>
In article <KMon7.40724$y_3.2978623@nnrp3.clara.net>,
Fiendy <fiendy@claraNO-SPAM.co.uk> wrote:
>Hi,
>I've just moved from Perl 5.005-03 on Redhat 6 to Perl 5.6.0 on Linux
>Mandrake 8 and I'm now having problems with accessing DB files via dbmopen.
>Previously, I only needed to specify the filename, but now I have to specify
>the filename AND extension Eg:
>To open a DB file called '/tmp/MyDb.db':-
> Perl 5.005 code = dbmopen(%H,'/tmp/MyDb', 0666);
> Perl 5.6.0 code = dbmopen(%H,'/tmp/MyDb.db', 0666);
>
>How do I get Perl 5.6.0 to add the extension automatically?
>I don't really want to have to go through all the code changing every
>instance unless absolutely necessary as there's a lot of it!
$ perl -e'use DB_File;dbmopen(%H,"MyDb", 0666);print `ls My*`'
MyDb
$ perl -v
This is perl, version 5.005_03 built for i686-linux
gnari
------------------------------
Date: Tue, 11 Sep 2001 22:24:32 +0100
From: "Fiendy" <fiendy@claraNO-SPAM.co.uk>
Subject: Re: dbmopen file extensions
Message-Id: <qgvn7.41695$y_3.3070472@nnrp3.clara.net>
"gnari" <gnarinn@hotmail.com> wrote in message
news:1000237939.0862350631505251.gnarinn@hotmail.com...
> In article <KMon7.40724$y_3.2978623@nnrp3.clara.net>,
> Fiendy <fiendy@claraNO-SPAM.co.uk> wrote:
> >Hi,
> >I've just moved from Perl 5.005-03 on Redhat 6 to Perl 5.6.0 on Linux
> >Mandrake 8 and I'm now having problems with accessing DB files via
dbmopen.
> >Previously, I only needed to specify the filename, but now I have to
specify
> >the filename AND extension Eg:
> >To open a DB file called '/tmp/MyDb.db':-
> > Perl 5.005 code = dbmopen(%H,'/tmp/MyDb', 0666);
> > Perl 5.6.0 code = dbmopen(%H,'/tmp/MyDb.db', 0666);
> >
> >How do I get Perl 5.6.0 to add the extension automatically?
> >I don't really want to have to go through all the code changing every
> >instance unless absolutely necessary as there's a lot of it!
>
> $ perl -e'use DB_File;dbmopen(%H,"MyDb", 0666);print `ls My*`'
> MyDb
>
> $ perl -v
> This is perl, version 5.005_03 built for i686-linux
>
> gnari
>
I've just tried that on 5.005_03 & as you show, it doesn't add the
extension, but does create exectly the same type of Berkeley DB file, as
does using 'tie' instead. The thing is, if I don't include the "use
DB_File", it will create the file with the ".db" extension, so what module
is dbmopen using by default?
Maybe I'm just going to have to trawl thru all the code replacing dbmopen's
with tie's instead :(
Cheers,
Mark.
------------------------------
Date: 11 Sep 2001 17:29:18 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: email this page script
Message-Id: <1000227514.300@itz.pp.sci.fi>
In article <9n200e$8dj$2@news.panix.com>, David Combs wrote:
>In article <slrn9ol2cc.plv.abigail@alexandra.xs4all.nl>,
>Abigail <abigail@foad.org> wrote:
>>Class Spokesman (galligat@tcd.ie) wrote on MMCMXIV September MCMXCIII in
>><URL:news:3B850966.7D1FC124@tcd.ie>:
>>^^ Hay
>>^^ I'm looking for a freeware perl script that can email a page
>>^^ Does anyone where i can find one thanks
>>
>>I'd suggest you go bugger the people in comp.lang.python for such
>>a script in Python, then use the following Perl program:
>
>Question: why not stick to perl? (You probably
> have a very good reason -- please elaborate
> a bit.)
Just to spell it out: She wanted the OP to bugger off and go bother
someone else.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Tue, 11 Sep 2001 23:17:59 +0200
From: "Admin UsePad" <spam@funnybytes.com>
Subject: Re: Fixing jeopardy quotes (was Re: how to get the length of string)
Message-Id: <9nlur0$8fe$1@news.hccnet.nl>
Let's go and fuck yourself,... you were a newbe too in the past.
Besides that,.. I'm dutch so I don't understand every english word.
If you people are talking about 'jeopardy ' I could think of an sweet candy
bar or something like that.
Don't speak to other people without any respect.
(And don't say that my first sentence is also without respect,.. you
deserved it)
Sweet greets,... and a whole lot of 'candy-bar-quoted-text' below,.. only
for you.
"Tintin" <tintin@snowy.calculus> schreef in bericht
news:zpmn7.41$rP5.530580@news.interact.net.au...
>
> "Admin UsePad" <spam@funnybytes.com> wrote in message
> news:9njid7$95$1@news.hccnet.nl...
> > It worked!
> >
> > How do I get rid of this jeopardy quoted text? I'm using Outlook
>
> See that mouse you're using? If you're right handed, it will be on the
> right. If you are left handed it will be on the left. In Windoze, you
have
> an amazingly inovative feature known as "scroll bars". This incredible
> feature allows you to scroll the text up or down. In your case, you can
> scroll it down to insert your reply in the appropriate spot. Another
> inovative Micro$oft feature was to include a cut/delete function. This
> simple, but remarkably handy function allows you to remove parts of the
text
> (such as signatures) that aren't relevant to the reply.
>
> When you've mastered these functions, you can obtain guru status by doing
> everything *without* a mouse. Of course, this complicated and dangerous
> operation should *not* be performed by beginners. It takes many, many
years
> of experience to ride in the fast lane.
>
> Good luck ;-)
>
>
------------------------------
Date: Tue, 11 Sep 2001 17:18:09 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: GetOptions($argument => \$output);
Message-Id: <1000228689.469184399582446.gnarinn@hotmail.com>
In article <5ad86837.0109101152.2c5d17b3@posting.google.com>,
Sten Sogaard <sten_sogaard@juno.com> wrote:
>I am trying to get GetOptions to work with variable arguments.
>Bacially I am getting the possible arguments somewhere else during
>runtime and want to feed that to GetOptions.
>When I define the argument as a constant (line 2) it works, but when I
>get the argument from another variable it does not work.
>
>Can anyone please give me a hint to what I am doing wrong.
>
>> $set{'name'}="teste_2";
>> my $argument = "$set{'name'}=s"; # this does not work
>> # my $argument = "teste_2=s"; # this works
>>
>> print ">$argument<\n"; # prints out >teste_2=s<
>> my $output;
>> GetOptions($argument => \$output);
i do not believe you
gnari
------------------------------
Date: 11 Sep 2001 11:25:21 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: GetOptions($argument => \$output);
Message-Id: <3b9e5711@news.victoria.tc.ca>
gnari (gnarinn@hotmail.com) wrote:
: In article <5ad86837.0109101152.2c5d17b3@posting.google.com>,
: Sten Sogaard <sten_sogaard@juno.com> wrote:
: >I am trying to get GetOptions to work with variable arguments.
: >Bacially I am getting the possible arguments somewhere else during
: >runtime and want to feed that to GetOptions.
: >When I define the argument as a constant (line 2) it works, but when I
: >get the argument from another variable it does not work.
: >
: >Can anyone please give me a hint to what I am doing wrong.
: >
: >> $set{'name'}="teste_2";
: >> my $argument = "$set{'name'}=s"; # this does not work
: >> # my $argument = "teste_2=s"; # this works
: >>
: >> print ">$argument<\n"; # prints out >teste_2=s<
: >> my $output;
: >> GetOptions($argument => \$output);
: i do not believe you
: gnari
Perhaps he has an old version of perl. At some point in the past hash
variables did not interpolate.
--
Want to access the command line of your CGI account? Need to debug your
installed CGI scripts? Transfer and edit files right from your browser?
What you need is "ispy.cgi" - visit http://nisoftware.com/ispy.cgi
------------------------------
Date: 11 Sep 2001 16:44:46 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Getting response from KEA \ Reflection
Message-Id: <1000226328.29637@itz.pp.sci.fi>
In article <8382da14.0109051120.1da7adeb@posting.google.com>, Brian Duffy wrote:
>
>I noticed that the strings that you are sending out on the TTY contain
>special characters.
Special to what? They'd better be special to the terminal emulator, but
as far as I can see they aren't special to anything else involved.
>You might want to try prepending the ';' and '.' characters with a
>backslash '\'. Perl tries to interpet anything within double-quotes
>and the backslash will prevent that.
Perl does no such thing. The only metacharacters in double-quoted
string literals are '$', '@', '\' and '"'.
>Hope it helps!
It won't, since it's nonsense. It won't actually hurt, either, as
backslashing non-alphanumeric non-meta characters in quoted string
literals is documented not to affect the value of the literal.
It's still useless, and will only distract from the actual problem.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Tue, 11 Sep 2001 12:48:33 -0700
From: "M.L." <mel2000@hotmaildot.com>
Subject: Re: Help: TiedHash.pm module in @INC not being recognized
Message-Id: <9nlpu5$82ek2$1@ID-19545.news.dfncis.de>
> > My program can't find the AnyData::Storage::TiedHash module no matter
how I
> > point to it.
> >
> You need:
>
> use lib '/u/s/sample/public_html/cgi-bin/lib';
>
> You need to point to the root of the directory
> tree; you're pointing to a branch.
>
> James
Thanks James, but I previously tried that, where:
use lib '/u/s/sample/public_html/cgi-bin/lib';
and
use AnyData; # line 19
and got the following error:
[Tue Sep 11 12:41:47 2001] AnyData.pm: Can't locate AnyData.pm in @INC (@INC
contains: /u/s/sample/public_html/cgi-bin/lib
/usr/lib/perl5/5.00503/sparc-linux /usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/sparc-linux /usr/lib/perl5/site_perl/5.005 .)
at buildpgs.cgi line 19. BEGIN failed--compilation aborted at buildpgs.cgi
line 19.
------------------------------
Date: Tue, 11 Sep 2001 19:37:21 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Help: TiedHash.pm module in @INC not being recognized
Message-Id: <1000237041.944969197269529.gnarinn@hotmail.com>
In article <9nkp1f$82b91$1@ID-19545.news.dfncis.de>,
M.L. <mel2000@hotmaildot.com> wrote:
>My program can't find the AnyData::Storage::TiedHash module no matter how I
>point to it.
>
>I tried pointing to it using the following methods according to PerlFAQ 8:
>
>use lib '/u/s/sample/public_html/cgi-bin/lib/AnyData';
>use lib '/u/s/sample/public_html/cgi-bin/lib/AnyData/Storage';
>use AnyData;
> and
>use FindBin;
>use lib "$FindBin::Bin/lib/AnyData";
>use lib "$FindBin::Bin/lib/AnyData/Storage";
>use AnyData;
you probably mean
use lib '/u/s/sample/public_html/cgi-bin/lib';
use AnyData;
or
use FindBin;
use lib "$FindBin::Bin/lib";
use AnyData;
gnari
------------------------------
Date: Tue, 11 Sep 2001 11:34:58 -0500
From: "Dan Nguyen" <Dan.Nguyen@lsil.com>
Subject: Re: How can I correct "Use of uninitialized value in substitution iterator at ..."?
Message-Id: <9nlegq$pt8$1@news.lsil.com>
Hi Tad,
I have been learning perl for a few weeks, so there are a lot I need to
learn. This is also the first time that I subscribered to the newsgroup so
please forgive me what I have done wrong.
I would like to say a big THANK YOU for your help and your kindness. I have
been searching the internet for a few days regarding this problem. I also
would like to say thank you for your advice regarding my personal
information.
You've saved my life. Again, I'm very appreciated for all of your great
HELP.
Sincerely,
Dan Nguyen
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9ppj8h.u9q.tadmc@tadmc26.august.net...
> guest <guest@email.com> wrote:
>
> >I'm having a problem of using the example of "removing C/C++ comments" in
> >page 293 of in the "Mastering Regular Expressions" book
> >written by Jeffrey E. F. Friedl. The problem occurred when I used "(?:"
in
> ^^^^^^^^^^^
> >the "Traditional C comments" statement.
>
>
> That has nothing to do with your problem.
>
>
> >Dan
> >(316-636-8484)
>
>
> There are lots of kooks on the internet. You should consider
> carefully whether you want to give them your phone number...
>
>
> Your word-wrapping has broken the code. Please don't post broken code.
>
>
> >###Line below is 8
> >$dataFile =~ s {
> > # First, we'll list things we want to match, but not
throw
> >away
> > (
> > [^"'/]+ # other stuff that couldn't possibly
> >begin one of other alternatives
> > |
# -or-
> > (?:"[^"\\]*(?:\\.[^"\\]*)*" [^"'/]*)+ #
> >doublequoted string
> > |
# -or-
> > (?:'[^'\\]*(?:\\.[^'\\]*)*' [^"'/]*)+ #
> >singlequoted constant
> > )
> > | # OR...
> > # ...we'll match a comment. Since it's not in
the
> >$1 paraenthese above,
> > # the comments will disappear when we use $1 as
the
> >replacement text.
> >
> > / #
(all
> >comments start with a slash)
> > (?:
> > \*[^*]*\*+(?:[^/*][^*]*\*+)*/ #
> >Traditional C comments
> > |
# -or-
> > /[^\n]* # C++
> >//-style comments
> > )
> > }{$1}gsx;
>
> [snip]
>
> >Use of uninitialized value in substitution iterator at rcomments line 8.
>
> There are only 2 variables on line 8, $dataFile and $1. A quick
>
> print $dataFile;
>
> before the s/// shows that that isn't the one, so it must be $1
> that is not defined ("uninitialized value" means "undef").
>
> Q: How can $1 be undef at this point?
>
> A: When the "OR" part above matches (when we've found a comment to
ignore).
>
>
> To avoid the warning, just check the define()edness of $1:
>
> ...
> }{defined $1 ? $1 : ''}gsxe; # used to be }{$1}gsx;
> ^
> ^
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 11 Sep 2001 09:54:42 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: How do you use <> and @ARGV with 4nt?
Message-Id: <3b9e41d2@news.victoria.tc.ca>
Adi Inbar (bis@world.std.com) wrote:
: It looks like @ARGV doesn't work with 4NT.
: I tried to run a Perl script that I wrote on a Unix system on a
: Windows 2000 system. I invoked the script at the 4NT 3.02B command
: prompt, and the line
: my @input = <>;
: produced this error:
: Can't open %*: Invalid argument at E:\Data Files\Perl\ex6-3.pl line 6.
: I added a line to print the contents of @ARGV, and sure enough, the
: result was "%*". @ARGV contains %* whether I supply command line
: arguments or not. I tried invoking the script from the Windows 2000
: command prompt, and it did what it was supposed to do. So, apparently
: the problem is that 4NT passes %* to @ARGV no matter what you put on
: the command line. Is there a solution or workaround? I'd really hate
: to have to use Windows 2000's idiot command prompt instead of 4NT.
: (Are there any 4NT newsgroups? I couldn't find any...)
$0.02
You could do a work around, something like
@ARGV = map {expand_wild_cards_here } @ARGV;
at the top of the script. Perhaps you could put this in a module
something like
#my_gludgle.pm
@ARGV = map {expand_wild_cards_here } @ARGV;
1;
and then when even you run perl on 4NT you always go
perl -Mmy_gludge script.pl
--
Want to access the command line of your CGI account? Need to debug your
installed CGI scripts? Transfer and edit files right from your browser?
What you need is "ispy.cgi" - visit http://nisoftware.com/ispy.cgi
------------------------------
Date: 11 Sep 2001 09:48:57 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: how to get the size of each attachment?
Message-Id: <3b9e4079@news.victoria.tc.ca>
Bing Du (bing-du@tamu.edu) wrote:
: Hi,
: 'Content-Length' returned by uploadInfo() is the length of the entire
: form content, right? If the form allows users to upload multiple files,
: how should I get the size of each uploaded file?
Just guessing, but in CGI.pm I think the files are saved to disk, and each
file is "returned" to your script as a handle. Therefore you should be
able to use stat(handle) to get the size of each file.
--
Want to access the command line of your CGI account? Need to debug your
installed CGI scripts? Transfer and edit files right from your browser?
What you need is "ispy.cgi" - visit http://nisoftware.com/ispy.cgi
------------------------------
Date: Tue, 11 Sep 2001 08:22:07 -0700
From: Paul Spitalny <pauls_spam_no@pauls.seanet.com>
Subject: Re: how to substitute letters within a string
Message-Id: <3B9E2C1F.B2E74806@pauls.seanet.com>
Paul Spitalny wrote:
> Hi,
> I wish to substitute any occurrences of an uppercase I in a variable
> with the lower case i. I am familiar with using:
>
> s/I/i/g;
>
> but this operates on the standard input $_
>
> whereas I have a variable ( $fred) who's value is a string with
> possible occurrences of "I" within it. SO, how do I get the substitute
> command to work on $fred ??
>
> Any ideas?
>
> Thanks
>
> Paul
>
> --
> To respond to this posting, remove -nospam- from my email address.
> Sorry for the inconvenience
Hi Everyone,
Thanks for your help!!
Paul
--
To respond to this posting, remove -nospam- from my email address.
Sorry for the inconvenience
------------------------------
Date: Tue, 11 Sep 2001 19:33:52 +0100
From: "Stuart Moore" <stumo@bigfoot.com>
Subject: Laugh: BT webspace CGI conditions
Message-Id: <mOsn7.13106$iD.2181858@news6-win.server.ntlworld.com>
Anyone who wants a bit of humour, see if you can spot my problem here:
BT's conditions for use of it's CGI webspace.
* CGIs must only access/modify data in your own web space. Any attempt to access
information outside this file space will be prevented via the custom CGI
service.
* If the script creates new/temporary files, cleanup activity should be in place
to ensure that these files do not accumulate unnecessarily.
- these would imply that I can use perl to open files. Which is nice of them.
But then:
* Do not use "exec", "fork", "open", "pipe", "system", "backticks" or "eval".
/\ !!!
Any suggestions?
------------------------------
Date: 11 Sep 2001 18:58:04 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Laugh: BT webspace CGI conditions
Message-Id: <slrn9psnls.vg3.trammell@haqq.hypersloth.net>
On Tue, 11 Sep 2001 19:33:52 +0100, Stuart Moore <stumo@bigfoot.com> wrote:
> Anyone who wants a bit of humour, see if you can spot my problem here:
>
> BT's conditions for use of it's CGI webspace.
[snip]
> - these would imply that I can use perl to open files. Which is nice of them.
> But then:
>
> * Do not use "exec", "fork", "open", "pipe", "system", "backticks" or "eval".
> /\ !!!
> Any suggestions?
IO::File->new() ?
--
The Internet: may contain traces of nuts.
------------------------------
Date: 11 Sep 2001 18:57:49 GMT
From: "Clayton L. Scott" <tex@lager.engsoc.carleton.ca>
Subject: Re: Laugh: BT webspace CGI conditions
Message-Id: <9nlmrd$i15$2@bertrand.ccs.carleton.ca>
Stuart Moore <stumo@bigfoot.com> wrote:
> Anyone who wants a bit of humour, see if you can spot my problem here:
> * Do not use "exec", "fork", "open", "pipe", "system", "backticks" or "eval".
> /\ !!!
> Any suggestions?
use IO::File;
$fh = new IO::File;
if ($fh->open("< file")) {
print <$fh>;
$fh->close;
}
/tex
------------------------------
Date: Tue, 11 Sep 2001 19:34:17 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: ODBC with perl problem
Message-Id: <1000236857.543306384701282.gnarinn@hotmail.com>
In article <3b9de148$1_1@news.chariot.net.au>,
Matthew Frick <mfrick@chariot.net.au> wrote:
>Does anyone know why with my connection to an oracle database the commented
>out statement with the MAX included doesn't work yet without the MAX it does
>work??
[code fragment with sql snipped]
define doesn't work.
what are the errors?
did you try to enter the statement into the oracle tool sqlplus ?
gnari
------------------------------
Date: 11 Sep 2001 10:55:45 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: PERL modules and GPL license
Message-Id: <3b9e5021@news.victoria.tc.ca>
Mark Jason Dominus (mjd@plover.com) wrote:
: In article <3b98e3b4@news.victoria.tc.ca>,
: Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
: >David Coppit (newspost@coppit.org) wrote:
: >: Mark Jason Dominus wrote:
: >
: >: > In article <30586a1d.0109060149.2fa2141a@posting.google.com>,
: >: > Samppa <sami@xenetic.fi> wrote:
: >: >
: >: >>I am planning to use PERL modules which are publised under
: >: >>GPL license. I am not changing the code of these modules just
: >: >>using them.
: >: >>
: >: >>What is your opinion, how does these modules (under GPL)
: >: >>affect to my code licensing and the availability
: >: >>to my source code ?
: >: >
: >: > The GPL requires that your entire program be released under the terms
: >: > of the GPL. The would mean that you are required to make the source
: >: > code available.
: >: >
: >
: >Not exactly.
: Yes, exactly.
: For example:
: Can I use the GPL for a plug-in for a non-free program?
: If the program uses fork and exec to invoke plug-ins,
: then the plug-ins are separate programs, so the license
: for the main program makes no requirements for them. So
: you can use the GPL for a plug-in, and there are no
: special requirements.
: If the program dynamically links plug-ins, and they make
^^^^^
"Link" is a technical term, which has quite specific meanings. The above
paragraph can only apply if a court of law decides that perl "links" when
a module is loaded.
Now notice that the perl documentation which discusses use, do, and
require, does not claim that this is in any way the equivalent of
"linking" as it is used in languages which have an explicit need to
"link". Also notice that the representations of the data read and created
by perl when a module is loaded have many conceptual differences compared
to the data read and written by a traditional linker. Finally, note that
the algorithms that perl must use when it loads a module are substantially
more complex, and encompass many steps for which a linker has nothing
comparible.
So why do you think that a judge would agree with your opinion that
loading a module fullfils the requirements of "linking" as layed out in
the licence?
: function calls to each other and share data structures,
: we believe they form a single program, so plug-ins must
: be treated as extensions to the main program. This means
: that linking the GPL-covered plug-in with the main
: program would violate the GPL.
Please note that the GPL does not have any section that allows the various
"clarifications" from the FSF to be considered a part of the GPL. In
other words, the FAQs from the FSF are merely their opinions on how the
GPL should be interpretted. Those opinions do not bind any one in any way
because they are not in the contract!
: http://www.gnu.org/licenses/gpl-faq.html
Actually I have read it, and the various versions on numerous times.
: > If you derive code from GPL code or link your code to GPL
: >code then that is true.
: The situation here is that the guy has someone else's Perl module,
: which he wants to use in his program. This is exactly the situation
: discussed above.
No,
<quote> If identifiable sections of that work are not derived from the
Program, and can be reasonably considered independent and separate works
in themselves, then this License, and its terms, do **not apply** to those
sections when you distribute them as separate works. </quote>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Its easy to distribute a perl program in pieces so the only question is
whether loading a module later falls under the definition of "linking".
In your opinion it does, but your opinion is not definitive. As pointed
out above, the various documents from the FSF are not part of the GPL.
and therefore they too are merely opinions.
: If it were a separate program running in a separate process, it would
: be exempt, but it isn't, so it isn't.
: As you point out, the LGPL was designed to allow such things as
: dynamic linking of free libraries with non-free programs. This should
: have suggested to you that such uses are *not* allowed under the GPL,
: or there would have been no need for the LGPL in the first place.
On the contrary - it proves that even minor differcnes in technologies
make large pratical differences. Therefore, the vast differences between
the perl loading and traditional linking means these should perhaps be
considered entirely different operations.
: >...questions, not answers...
: Except you began with "not exactly", which makes it sound like you
: have some idea what you're talking about.
It is logically impossible for any text except the GPL to assuredly mean
exactly what the GPL says. Anything else is interpretation. Until a
court decides the interpretation is valid then you should not assume it is
correct.
Have the ever heard of a politian who passes a law, and then a judge who
make an "unexpected" interpretation of the law when it is used? It
happens all the time. The FSF have an opinion on how the words of the GPL
should be interpreted, but that doesn't mean that that's the way it is.
: If you're really interested in the answers, you may want to consult
: the FSF's GPL FAQ, which addresses your questions in some detail.
As I noted, the FSF's answers are not answers, they are opinions which are
not part of the GPL contract.
You should not think that the GPL protects you the way you think it does.
------------------------------
Date: 11 Sep 2001 16:37:17 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Problem reading an XML file
Message-Id: <1000225618.29238@itz.pp.sci.fi>
In article <slrn9p853g.nlg.tadmc@tadmc26.august.net>, Tad McClellan wrote:
>
>>I wrote a tiny script to read an XML file and
>>display its contents. To my surprise, when the contents are sent to
>>the browser (as an HTML page), all the tags are stripped out !!
>
>The browser does that, not Perl, so you should ask about it
>in a newsgroup that has something to do with browsers.
>
>This is not such a newsgroup.
However, once he has asked the correct question in the correct place,
and received the correct answer (which he should still do, because he
will probably have need for it later), he'll have a second question,
for which a simple answer will be:
$data_line =~ s/&/&/g;
$data_line =~ s/</</g;
Figuring out where to insert those lines is left as an exercise. :-)
This is not a sufficient answer on its own, since it omits important
details that could bite anybody who blindly cuts and pastes the code
above without really understanding it. With the necessary background
information, however, this code is sufficient.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Tue, 11 Sep 2001 19:00:29 GMT
From: kenlaird@yahoo.com (Ken Laird)
Subject: Re: Problem with parsing more than one line ( Please HELP )
Message-Id: <hbtn7.102242$ju1.3062549@amsnews02.chello.com>
In article <m1r8tfjat6.fsf@halfdome.holdit.com>, merlyn@stonehenge.com says...
>
>>>>>> "Ken" == Ken Laird <kenlaird@yahoo.com> writes:
>
>Ken> I know comments are comments because they dont begin with "name"
>Ken> and because they are in uppercase.
>
>Hmm. How about providing a *real* example, and then a *description*
>of how it could vary then, instead of providing a *fake* example with
>*no* specification? I'm not sure how psychic you expect us to be, but
>I would NEVER have predicted the comments were "uppercase", and that's
>how you'd know it was a comment!
>
>--
>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
><merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
>Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
>See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Hi Randal,
I am really sorry,it was my fault.
The example I gave was not very clear.
I did not mention the comments were uppercase because I thought
it was not important for the example.
Anyway I am really sorry.
Cordially
Ken
------------------------------
Date: Tue, 11 Sep 2001 21:49:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: recognize MS Windows with perl
Message-Id: <hi1tpt8f33v9fsk5acp60s7h5k07jdn3am@4ax.com>
Alex Hart wrote:
>What is the best way to determine whether my program is being run on a
>MS Windows box? Is there a sure fire way?
$^O, but that does NOT make a distinction between various flavours of
Win9x and/or NT/Win2K. Its always "MSWin32". The reason is because this
value is baked into the executable, and you run the same executable on
all versions.
--
Bart.
------------------------------
Date: 11 Sep 2001 16:10:02 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: references, slices, voodoo
Message-Id: <1000223943.28123@itz.pp.sci.fi>
In article <5y5l7.770$zi3.384429@news2-win.server.ntlworld.com>, Stuart Moore wrote:
>
>Just out of interest, is anyone able to comment on whether this technique
>produces results as random as
[snip]
>Code isn't very nice and also very inefficient, but seems to me to be more
>random, as each permutation would have equal chance - not sure that's the case
>for the other one.
The Fisher-Yates shuffle can be mathematically proven to produce a
uniform distribution (i.e. one where each permutation is equally
likely), assuming the random number generator is truly random and
uniform.
(This is an assumption which the Perl rand() function does not actually
satisfy, although it does come close enough for many purposes. However,
this issue affects all attempts to shuffle an array uniformly regardless
of the algorithm involved.)
This is in fact quite obvious, once you understand how the F-Y shuffle
algorithm works. At first, it picks a random element from the array,
and makes that the last element. Then it picks a random element from
the *remainder* of the array, and makes that the second-to-last one.
And so on, until there are no more unpicked elements left.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Tue, 11 Sep 2001 09:35:35 -0700
From: "terminalsplash" <shino_korah@yahoo.com>
Subject: Serial port communication
Message-Id: <9nlegm$gcc@news.or.intel.com>
Hi
I'm trying to write a perl script for serial port communication in LINUX.
Which module can I use?
I know in windows I can use WIN32.
Please help
------------------------------
Date: Wed, 12 Sep 2001 05:27:39 +0930
From: Luke Vanderfluit <luke@chipcity.com.au>
Subject: to get the process ID of a running process
Message-Id: <3B9E6CB2.96129B3B@chipcity.com.au>
Hi,
Thanks to those who helped me yesterday.
I want to get the process ID of a running process.
I've tried running the process like this
$PID = open(KEEP, "keepLinkUp > /dev/null &|");
But when I do a 'ps auxw' and look at the actual ID, it is $PID + 1,
why is this?
Thanks,
L.
--
Lo que ves es lo que obtienes
Luke Vanderfluit
[if no image, click here]
Phone 61 8 8556 6112
Aldinga Beach, South Australia
------------------------------
Date: Tue, 11 Sep 2001 12:25:47 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Verify https communication
Message-Id: <comdog-3195FC.12254711092001@news.panix.com>
In article <f87cbf2f.0109101638.4aad30ae@posting.google.com>,
niting@onebox.com (Nitin G.) wrote:
> This might sound like a dumb question but how do I confirm that a
> script that I have to do POST requests to a HTTPS server is actually
> encrypting the data before transferring it?
your server should be able to tell you that. if you can't trust
your server then you can't do much about it.
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: 11 Sep 2001 16:17:34 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Web form to Perl SQL query
Message-Id: <1000224675.28602@itz.pp.sci.fi>
In article <YpLk7.89703$hm3.5729338@news1.cableinet.net>, Alan Farrington wrote:
>
>The problem I have is that when a user of the web form types no information
>into the text field and just presses the submit button, it return everything
>(including blank rows ) from the database. I can overcome this by putting a
>further condition on the entry to the populate array routine, but it's a bit
>of a botch.
Well, that's what it's supposed to do. You've specified that the search
should return all rows that _contain_ the search string. If the string
is empty, then all (non-NULL) records will contain it.
First decide exactly what you want the search to do, including boundary
conditions like the search string being empty. Then implement it.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Tue, 11 Sep 2001 16:48:26 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Re: Where Can I Find the path to the desktop on Win9X/2K and NT?
Message-Id: <1000223239.17714.0.nnrp-14.d4f094e4@news.demon.co.uk>
"Admin T." <perlquestion@hotmail.com> wrote in message
news:c58c442c.0109102253.13af1d4@posting.google.com...
> I never thought something so simple be so hard. Is there a ENV.
> variable that I can access in Perl that contains the path to the
> desktop? Is there any where I can find the path to the desktop?
>
> Thankful for any help;
> -A
It's in the registry on more modern OSs, like 2K, in Windows (ENV
variable)/Desktop on older ones. Also it's different on multi-user. Look at
the MS help on the subject, it's not really a Perl question. Not as easy as
you think, but not impossible!
------------------------------
Date: Tue, 11 Sep 2001 17:45:33 +0100
From: James Gilbert <jgrg@sanger.ac.uk>
To: Stan Brown <stanb@panix.com>
Subject: Re: Why would the perl compiler report errors on the wrong line nO.?
Message-Id: <3B9E3FAD.C2528686@sanger.ac.uk>
Stan Brown wrote:
>
> Sometime yesterday, for a particualr script, the perl compile sudenly
> started reporting syntax errors as 1 to 2 lines _prior_ to the actual
> placement of the error.
>
> Any sugestions as to what may be causing this?
The compiler will report the location of the
first line of the statement that causes the
error.
------------------------------
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 1733
***************************************