[19555] in Perl-Users-Digest
Perl-Users Digest, Issue: 1750 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 15 00:05:36 2001
Date: Fri, 14 Sep 2001 21:05:07 -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: <1000526707-v10-i1750@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 14 Sep 2001 Volume: 10 Number: 1750
Today's topics:
Re: AoH - continued <gnarinn@hotmail.com>
Re: Difference between .pl, .cgi, and .pm File Extensio (Trewth Seeker)
Re: Does Perl Support Multi-Byte Parsing and Comparisio (Tad McClellan)
Re: Help needed using "CDONTS.NewMail" in Perl scripts <skradel@mindspring.common.sense>
I need Many Very Time Efficient forks from a large prog (Xeno Campanoli)
Re: I need Many Very Time Efficient forks from a large (Logan Shaw)
Re: Lotus Notes <skradel@mindspring.common.sense>
Re: newbie question: membership script w/ credit card v (Stephen)
Re: parsing large DNA files into smaller files (correct <nobody@no_where.net>
Re: parsing large DNA files into smaller files <gruen.lab@yale.edu>
Re: parsing large DNA files into smaller files <gruen.lab@yale.edu>
Re: parsing large DNA files into smaller files (Tad McClellan)
Pattern Matching Help Needed (Ralph Freshour)
Re: Perl (slurping) is TOO much fun (Damian James)
Re: Perl (slurping) is TOO much fun (Logan Shaw)
Re: Perl (slurping) is TOO much fun (Damian James)
Re: PERL modules and GPL license <iltzu@sci.invalid>
Re: Perl to MS SQL <simon.oliver@umist.ac.uk>
Re: Problems with format (perlform) and carriage return (Martien Verbruggen)
Re: recognize MS Windows with perl <wyzelli@yahoo.com>
Re: Running perl scripts (Martien Verbruggen)
Re: Using Perl to post regular usenet messages. <overlord_q@hotmail.com>
Re: Using Perl to post regular usenet messages. <simon.oliver@umist.ac.uk>
Re: Using the c preprocessor for non c purposes <kst@cts.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 14 Sep 2001 23:23:42 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: AoH - continued
Message-Id: <1000509822.579373770859092.gnarinn@hotmail.com>
In article <45a0e21a.0109140849.61c99f4@posting.google.com>,
jason <jason@gimptroll.com> wrote:
>As a precaution, I have the absolute path to the directory where my DB
>files are located hard coded. so the only valid value for the db_file
>key is a filename within that directory. Does this fill that hole or
>do you see other ways this can be exploited?
>for example:
>...
>my $db_dir = '/usr/local/DB/';
>$filename = $q->param("db_file") || $filename; #query or default
>open(FILE,"<${db_dir}$db_file") || die($!);
what happens the user enters '../../../etc/passwd' ?
gnari
------------------------------
Date: 14 Sep 2001 17:29:47 -0700
From: trewth_seeker@yahoo.com (Trewth Seeker)
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <d690a633.0109141629.1a2ebcf7@posting.google.com>
damian@qimr.edu.au (Damian James) wrote in message news:<slrn9pnqsr.o41.damian@puma.qimr.edu.au>...
> Trewth Seeker chose 6 Sep 2001 18:44:55 -0700 to say this:
> >"J?gen Exner" <jurgenex@hotmail.com> wrote in message news:<3b8fcb68$1@news.microsoft.com>...
> >> "Trewth Seeker" <trewth_seeker@yahoo.com> wrote in message
> >> news:d690a633.0108302015.60293f45@posting.google.com...
> >> > .pl and .cgi files also must be "installed onto a server" -- where *else*
> >> > do you expect them to be?
> >>
> >> Hmm, then I guess my computer is broken.
> >> If I type "foobar.cgi" at the command line my computer will run the program
> >> "foobar.cgi". No server of whatever kind involved here.
> >
> >Your PC is a server of a kind.
>
> Dude, you are confusing the notion of a machine with web-server software
> running (which would be necessary to provide a CGI environment) with a
> machine that merely has perl installed -- which need not be serving
> anything at all. This suggests that you are making an implicit assumption
> that Perl is only for CGI. Many people here would find that not merely
> wrong, but also vaguely offensive. Myself, I wouldn't even go so far as to
> assume that Juergen is using a peecee...
>
> I suggest you refrain from making blanket statements involving such
> generalisations until you have these details cleared up at least.
You might try actually reading the thread, wherein I wrote
The issue here is the meaning of "server"
in various contexts. I think you need to do a lot more reading.
"server" means "HTTP server" only to ignoramuses. Do you suppose
a machine must have "perl installed" to run, say, an X server?
Or a time-sharing server? A PC is, as I said,
"a server of a kind" -- it serves up execution of programs.
The conclusion that what I have written suggests the "implicit
assumption" you state is, frankly, ridiculous. The original query
resulted from confused thinking, and you replicate it. The
original poster thinks that .pl's are different from .pm's
because of instructions to install the latter "onto a server".
What he doesn't seem to grasp is that .pl's, .pm's, and .cgi's
are ALL installed on *computers*, some of which happen to
be acting as HTTP servers. .pl's, .pm's. and .cgi's all
get installed "onto a" X -- where X is a computer that
might, under various circumstances, be an HTTP server.
The instruction "install .pm's onto the server" does not, as he mistakenly
thought, divide files into those that are installed onto servers
and those that are not, but rather merely refers to the role
of the machine being installed onto. I'd point you to the
philosophical literature of ontology to help clarify your thinking
about what "is", if I thought it would do any good -- "dude".
------------------------------
Date: Fri, 14 Sep 2001 23:24:53 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Does Perl Support Multi-Byte Parsing and Comparision?
Message-Id: <slrn9q51je.l2p.tadmc@tadmc26.august.net>
Murali Chari <muchari@cisco.com> wrote:
>Please email me to share your thoughts. (and code if you have any. ;-)
^^^^^^^^
Hoarding answers in not very community conscious.
_Post_ your thoughts, let more than one person benefit.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 14 Sep 2001 20:58:32 -0400
From: "Steve K" <skradel@mindspring.common.sense>
Subject: Re: Help needed using "CDONTS.NewMail" in Perl scripts (with Win32::OLE)?
Message-Id: <9nu9hd$dhf$1@slb4.atl.mindspring.net>
Perhaps the current user doesn't have access to the mailroot\drop directory?
CDONTS will also carp if the email addresses you feed it are not in the
format it expects.
Beyond that, unless you really need the multipart formatting provided by
this object, it's probably better not to use it in the face of
equally-straightforward SMTP packages.
--Steve
"Batormaster666" <batormaster666@hotmail.com> wrote in message
news:9ns928$np6$1@news1.xs4all.nl...
> Hi all,
> I've been trying to use the COM component CDONTS.NewMail in my Perl CGI
> script but keep getting errors. Below is a code snippet of mine. I
performed
> 2 tests which both raise the error
> Win32::OLE(0.1101) error 0x80070005: "Access is denied" in
> METHOD/PROPERTYGET "Send"
[snip]
------------------------------
Date: 15 Sep 2001 01:43:54 GMT
From: xeno@eskimo.com (Xeno Campanoli)
Subject: I need Many Very Time Efficient forks from a large program
Message-Id: <9nuboq$rbj$1@eskinews.eskimo.com>
My problem is this: I'm trying to send from a single large testing
application a large number of requests to a server as close to the
same time as possible without having to use threads. My application
is very big, but I can divide out a piece of it to run on a small
script. The thing is, I don't understand how fork works. It seems
if children always get mirrored from the parent, don't the processes
needfully get bigger and bigger, or at best never get smaller? Is
there any good way to fork a subroutine directly off my main Perl
application (especially many many times, like 300) but have the
children immediately become smaller so they don't eat up all my memory
or start having to work off of paged memory so the whole deal is counter-
productive anyway? All serious suggestions specific to my described
need are welcome.
Thanks.
------------------------------
Date: 14 Sep 2001 21:53:07 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: I need Many Very Time Efficient forks from a large program
Message-Id: <9nufqj$801$1@charity.cs.utexas.edu>
In article <9nuboq$rbj$1@eskinews.eskimo.com>,
Xeno Campanoli <xeno@eskimo.com> wrote:
>My problem is this: I'm trying to send from a single large testing
>application a large number of requests to a server as close to the
>same time as possible without having to use threads. My application
>is very big, but I can divide out a piece of it to run on a small
>script. The thing is, I don't understand how fork works. It seems
>if children always get mirrored from the parent, don't the processes
>needfully get bigger and bigger, or at best never get smaller? Is
>there any good way to fork a subroutine directly off my main Perl
>application (especially many many times, like 300) but have the
>children immediately become smaller so they don't eat up all my memory
>or start having to work off of paged memory so the whole deal is counter-
>productive anyway?
You've said you don't understand how fork() works, but it seems like
you do understand. When fork() is called, each process gets its own
copy of the memory, so one process cannot change any of the others'
data. This seems like it use lots of memory, and it does use lots of
it, but it is not as bad as it seems.
There are two reasons for this:
(1) All of the processes will have the same data as when fork()
was called (unless they deallocate it), but not all of them will
use it. On a modern operating system, if memory is never used,
the paging system will send it to swap space if there is a memory
shortage, and it will never return to waste RAM. So it wastes
only swap space, and disk is cheap these days. (Well, it also
wastes time writing to it the disk.)
(2) Most modern operating systems implement a copy-on-write system,
which means that as long as the child processes don't write to a
given page it is shared among all the processes. As soon as one
writes to it, the memory management hardware detects this and
gives that process its own copy of the page, changing the page
tables so that even though this is a different page, it appears in
the same place in memory from the application's point of view.
This is really a neat trick, and it saves on memory use
considerably.
Despite those two things, fork() still does waste some memory. For one
thing you may only write to single byte of a page and the copy-on-write
system will still have to make a copy the entire page. So threads are
still better, but fork() isn't probably as bad as you think.
On the other hand, if you want to send as many requests as possible at
the same time, the best thing is to use threads and have lots of
processors. If you have too many threads or processes going at once,
they may not be able to be scheduled onto a processor in a short enough
period. But maybe you just mean that you'd like to have several
separate but overlapping sessions with a server. In that case, it
shouldn't be a problem.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: Fri, 14 Sep 2001 21:40:06 -0400
From: "Steve K" <skradel@mindspring.common.sense>
Subject: Re: Lotus Notes
Message-Id: <9nubrl$iqu$1@slb6.atl.mindspring.net>
Notes' support of ODBC is questionable, or rather, the performance has a
tendency to disappoint. (It isn't relational, so non-trivial queries are a
lot more expensive than you might think.) Better to use its Java, IIOP, or
COM/OLE interfaces. But this has much to do with where the databases you
wish to manipulate are located, and what it is you want to do with them.
--Steve
"Dale Henderson" <projectobjects@earthlink.net> wrote in message
news:isso7.7895$s97.831564@newsread1.prod.itd.earthlink.net...
> I believe Notes supports ODBC, therefore the DSN will be available for
> connecting via DBD::ODBC.
>
> "Hansgeorg Zauner" <hg_zauner@gmx.de> wrote in message
> news:9nsuq5$9b2u7$1@ID-45951.news.dfncis.de...
> > Is there a way to access a Lotus Notes Database from perl?
> > I could not find any module for this purpose.
> >
> > Thanx
> >
> >
> >
>
>
------------------------------
Date: 14 Sep 2001 19:52:33 -0700
From: fjsaldi@hotmail.com (Stephen)
Subject: Re: newbie question: membership script w/ credit card verification
Message-Id: <854dabf6.0109141852.54a9e0f5@posting.google.com>
To revise my previous message. I don't actually need the credit card
to be validated, but will need the credit card info sent to the
company. Any ideas?
Stephen
fjsaldi@hotmail.com (Stephen) wrote in message news:<854dabf6.0109141035.a0a21a0@posting.google.com>...
> I'm working on a new site that requires a person to enroll and pay a
> tuition fee online. Is there a script available that requests and
> supports the following:
>
> Name
> Address
> Username
> password
> credit card
>
> Upon verification of the credit card, the user
> is allowed access to the paid area of the site
> (in this case, an online school)? It then sends
> a receipt to the student and the information to
> the company.
>
>
> I've found a couple, but they all use iBill or something similar, and
> I'd rather not use that.
>
> Thanks for your help,
> Stephen
------------------------------
Date: Fri, 14 Sep 2001 22:23:37 GMT
From: "Patrik Birgersson" <nobody@no_where.net>
Subject: Re: parsing large DNA files into smaller files (correction: there's a bug)
Message-Id: <Jrvo7.3794$sn6.482123@newsc.telia.net>
Line 23 should read:
until ($diff <= 0) {
or there will be an infinite loop, since $diff will outcome to -1 and
(probably) not 0.
Sorry!
> #!/usr/bin/perl -w
> #
> # Usage: dna.pl [filename]
>
> use strict;
>
> my
>
($orig,$start,$end,$len,$string,$total,$humanS,$humanE,$filename,$diff,$file
> s);
>
> open (BIGFILE, "$ARGV[0]");
> $orig = <BIGFILE>;
> close BIGFILE;
>
> $total = length($orig);
> $start = 0;
> $end = 9999;
> $diff = $total - $start;
> $files = 0;
>
> until ($diff == 0) {
> $string = substr($orig,$start,$end);
> $humanS = $start + 1;
> $humanE = $end + 1;
> $filename = "$humanS\_$humanE\.seq";
> open (OUT, ">>$filename");
> print OUT "\>$filename\n";
> print OUT $string;
> close OUT;
> $start = $end + 1;
> $end = $start + 9999;
> if ($end > $total) {
> $end = $total - $start;
> }
> $diff = $total - $start;
> $files++;
> }
>
> print "Done! $ARGV[0] was devided into $files files.\n";
------------------------------
Date: Fri, 14 Sep 2001 18:12:32 -0400
From: "Jeff Gruen" <gruen.lab@yale.edu>
Subject: Re: parsing large DNA files into smaller files
Message-Id: <9ntuvi$q6r$1@news.ycc.yale.edu>
Thank you very much. The script works brilliantly.
Jeff
Thomas Bätzler <thomas@baetzler.de> wrote in message
news:ltk4qt4gomt36ber7cremv1dahmhapnjqg@4ax.com...
> On Fri, 14 Sep 2001, "Jeff Gruen" <gruen.lab@yale.edu> wrote:
> >I am a newbie to perl and unix script writing.
> >I am looking for a script that will help us to parse a large DNA sequence
> >file into smaller text files.
> [...]
>
> That way, you'll always stay a newbie - how'bout trying to do it
> yourself first?
>
> #!/usr/bin/perl -w
>
> use strict;
>
> # where's the input data?
> my $infile = 'dna.seq';
>
> # how many bases in each split?
> my $splitsize = 10000;
>
> open( IN, "$infile" )
> or die "Can't open DNA file '$infile': $!\n";
>
> for( my($pos,$data,$got)=(1); !eof( IN ); $pos += $got ){
>
> # note: no slurping - instead ingestion via a small spoon
> if( defined( $got = read IN, $data, $splitsize ) ){
> my $file = "$pos\_" . ( $pos + $got - 1) . ".seq";
>
> open( OUT, ">$file" )
> or die "Can't open DNA file '$file': $!\n";
>
> print( OUT ">$file\n$data\n" )
> or die "Can't write to DNA file '$file': $!\n";
>
> close( OUT );
>
> } else {
> die "read on '$infile' failed: $!\n";
> }
> }
>
> __END__
>
> HTH,
> --
> use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
> split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
> '"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
> $_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl
------------------------------
Date: Fri, 14 Sep 2001 18:13:16 -0400
From: "Jeff Gruen" <gruen.lab@yale.edu>
Subject: Re: parsing large DNA files into smaller files
Message-Id: <9ntv0t$q6s$1@news.ycc.yale.edu>
Tad:
Thanks very much - the script works beautifully!
Much appreciated.
Jeff
Tad McClellan <tadmc@augustmail.com> wrote in message
news:slrn9q4k88.kdc.tadmc@tadmc26.august.net...
> Jeff Gruen <gruen.lab@yale.edu> wrote:
>
> >I am looking for a script that will help us to parse a large DNA sequence
> >file into smaller text files.
>
> >We would like to parse the larger file into non-overlapping smaller files
of
> >10,000 letters. Each file should contain it's own descriptive name,
which
> >would also be contained in the first line of the sequence file.
>
> >Please note the ">" sign in the first position of the header.
>
>
> ----------------------------------
> #!/usr/bin/perl -w
> use strict;
>
> my $size = 10;
> my $lower = 1;
> my $upper = $lower + $size - 1;
>
> #open(DATA, ...
> my $str; # string buffer
> while ( my $bytes = read(DATA, $str, $size) ) {
> my $fname = "${lower}_$upper.seq";
> $lower += $size;
> $upper += $size;
>
> open(OUT, ">$fname") or die "could not open '$fname' $!";
> print OUT ">$fname\n$str\n";
> close(OUT);
> }
>
> __DATA__
> aaccaataggagagatacatagcgaaccaataggagagatacatagcgaaccaataggagagatacatagcg
> ----------------------------------
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Fri, 14 Sep 2001 23:24:52 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: parsing large DNA files into smaller files
Message-Id: <slrn9q51af.l2p.tadmc@tadmc26.august.net>
Patrik Birgersson <nobody@no_where.net> wrote:
>I'm not sure if this is the nicest way of doing this
One part of it is very "not nice"...
> open (OUT, ">>$filename");
You should always, yes *always*, check the return value from open():
open (OUT, ">>$filename") or die "could not open '$filename' $!";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 15 Sep 2001 02:03:54 GMT
From: ralph@primemail.com (Ralph Freshour)
Subject: Pattern Matching Help Needed
Message-Id: <3ba2b802.5046826@news-server>
I wrote this code quite a while back - I noticed something not working
quite right in it recently and when I went to take a look, I realized
that I don't remember the little tidbits of what it is doing when
checking for matches! I'm wonder for example why I have a nested
if-then in the 2nd, 3rd, and 4th check and not the 1st?
Also, can someone tell me if I even used the correct characters to do
exact match, begins with, ends with and contains statements?
(Assuming of course that the vars do match when the script actually
runs).
Thanks....
Ralph
if ($Target[$x] =~ /^\Q$filtFilter\E$/)
{
$msg = "exact match\n";
}
if ($Target[$x] =~ /^\Q$filtFilter\E/)
{
if ($Target[$x] =~ /^\Q$filtFilter\E$/)
{
$msg = "beginning match\n";
}
}
if ($Target[$x] =~ /\Q$filtFilter\E$/)
{
if ($Target[$x] =~ /^\Q$filtFilter\E$/)
{
$msg = "ending match\n";
}
}
if ($Target[$x] =~ /\Q$filtFilter\E/)
{
if ($Target[$x] =~ /^\Q$filtFilter\E$/)
{
$msg = "contains match\n";
}
}
------------------------------
Date: 14 Sep 2001 23:38:21 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Perl (slurping) is TOO much fun
Message-Id: <slrn9q553h.920.damian@puma.qimr.edu.au>
Logan Shaw chose 14 Sep 2001 14:17:45 -0500 to say this:
>In article <slrn9q39rb.og2.damian@puma.qimr.edu.au>,
>Damian James <damian@qimr.edu.au> wrote:
>> ... Even then,
>>for some operations it will be easier to slurp for now, then later tie() your
>>data structure to a disk file.
>
>Is there an easy tie() equivalent for this?
I should have moderated my language. 'Easy' probably isn't the right word
:-). Neither is 'will'.
>[slurping examples snipped]
>If so, that could be a good answer to some of the "how do you modify a
>file in place" questions.
>
No. You are simply moving the 'modify in place' code from the main program
to the package containing the methods for working with the file the
variable is tie()ed to. The presence of the required functionality in a
CPAN module make it easier, of course.
There is a Tie::Handle module on CPAN by Steffen Beyer, whose namespace has
been reclaimed by the synonymous core module, but which appears to have the
functionality required to do the above. It also appears not to have been
maintained since 1997.
Perhaps someone can shed some light?
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker, ### rev 3.3 -- stupidectomy performed :-)
------------------------------
Date: 14 Sep 2001 19:22:31 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Perl (slurping) is TOO much fun
Message-Id: <9nu707$71f$1@charity.cs.utexas.edu>
In article <slrn9q553h.920.damian@puma.qimr.edu.au>,
Damian James <damian@qimr.edu.au> wrote:
>Logan Shaw chose 14 Sep 2001 14:17:45 -0500 to say this:
>>In article <slrn9q39rb.og2.damian@puma.qimr.edu.au>,
>>Damian James <damian@qimr.edu.au> wrote:
>>>for some operations it will be easier to slurp for now, then later tie() your
>>>data structure to a disk file.
>>Is there an easy tie() equivalent for this?
>No. You are simply moving the 'modify in place' code from the main program
>to the package containing the methods for working with the file the
>variable is tie()ed to.
I don't quite understand that sentence. Are you saying that writing a
Perl module moves the implementation of the hard bits into a module
where nobody has to deal with it[1]? That's fairly obvious, and it
doesn't sound like that's what you're saying anyway. The module would
be a standard and general purpose one -- it wouldn't have to be
extended by its user or anything like that to make it work.
>There is a Tie::Handle module on CPAN by Steffen Beyer, whose namespace has
>been reclaimed by the synonymous core module, but which appears to have the
>functionality required to do the above.
I looked at that module, and to me it looks like what it does is allow
you to tie filehandles to objects, so that you are using the filehandle
interfaces to operate on in-memory objects. What I am proposing is
something more akin to Unix's mmap(), so that you can operate on what
looks like a normal variable, but actually your changes are being
written to disk when you do so.
- Logan
[1] Except of course the module maintainer(s).
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: 15 Sep 2001 02:05:21 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Perl (slurping) is TOO much fun
Message-Id: <slrn9q5dn4.9rg.damian@puma.qimr.edu.au>
Logan Shaw chose 14 Sep 2001 19:22:31 -0500 to say this:
>In article <slrn9q553h.920.damian@puma.qimr.edu.au>,
>Damian James <damian@qimr.edu.au> wrote:
>
>>Logan Shaw chose 14 Sep 2001 14:17:45 -0500 to say this:
>
>>>In article <slrn9q39rb.og2.damian@puma.qimr.edu.au>,
>>>Damian James <damian@qimr.edu.au> wrote:
>
>>>>for some operations it will be easier to slurp for now, then later tie() your
>>>>data structure to a disk file.
>
>>>Is there an easy tie() equivalent for this?
>
>>No. You are simply moving the 'modify in place' code from the main program
>>to the package containing the methods for working with the file the
>>variable is tie()ed to.
>
>I don't quite understand that sentence. Are you saying that writing a
>Perl module moves the implementation of the hard bits into a module
>where nobody has to deal with it[1]? That's fairly obvious...
[footnote moved]
>[1] Except of course the module maintainer(s).
Sorry, that's exactly what I meant. Somebody does, of course, have to deal
with it as your footnote mentions. I was considering this in the absence of
an existing CPAN module that provides the functionality (and silently
avoiding volunteering to write one -- I'm not the other Damian :-).
>...and it
>doesn't sound like that's what you're saying anyway.
Sorry. It's Saturday morning and I'm posting in between bouts of clearing
the yard and looking at CNN.
>The module would
>be a standard and general purpose one -- it wouldn't have to be
>extended by its user or anything like that to make it work.
Yeah. I was assuming user == maintainer in this case.
>>There is a Tie::Handle module on CPAN by Steffen Beyer, whose namespace has
>>been reclaimed by the synonymous core module, but which appears to have the
>>functionality required to do the above.
>
>I looked at that module, and to me it looks like what it does is allow
>you to tie filehandles to objects, so that you are using the filehandle
>interfaces to operate on in-memory objects.
I got this the other way around in my (I guess cursory) reading of the
docs. I would have tested it if not for the namespace conflict. A second
glance suggests you are right.
>What I am proposing is
>something more akin to Unix's mmap(), so that you can operate on what
>looks like a normal variable, but actually your changes are being
>written to disk when you do so.
Indeed, and effectively you are managing your own swap for that variable.
Exactly what I had in mind when bringing it up. ISTR there's a discussion
of precisely this in the other Damian's OOP book, though my copy is at
work. So, what next? I'm quite happy to help out in the production of such
a module, but can't help but thinking that two Australian Damians
contributing to CPAN at once is at the face of it absurd, especially
considering the grossly divergent levels of expertise :-).
Cheers,
Damian
--
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__
Just another Perl Hacker, ### rev 3.3 -- stupidectomy performed :-)
------------------------------
Date: 15 Sep 2001 03:58:18 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: PERL modules and GPL license
Message-Id: <1000520028.29802@itz.pp.sci.fi>
In article <3B9F5C49.8090508@coppit.org>, David Coppit wrote:
>Stefan Weiss wrote:
>>
>> I've been wondering about this for some time: how can the GPL coexist
>> with any other license in a statement like "may be distributed under
>> the same terms as Perl itself"?
>
>Good question. I think you can pick which license you want. Anyone have
>more data?
No, unless guesswork counts. IANAL, and when I last looked into this
issue, it gave me a headache.
I think the way it can all work involves section 6 of the GPL, which
seems to say between the lines that the original author of the software
may, even indirectly and implictly, grant to recipients rights that go
beyond those granted by the GPL, including the right to violate it.
But see below...
>> Somebody ports perl to a new OS and decides to distribute this perl
>> version under the GPL (and no mention about the AL). Perl's licence
>> would allow him to do that, I think.
>
>No... The license doesn't say "you can change the license". :)
It's not that simple. Without any license restrictions -- i.e. if the
code was in the public domain -- you'd be allowed to slap any license
you wanted on it when redistributing. The same goes for any license
that allows unrestricted redistribution.
A software license is essentially a mixture of copyright and contract
law. As a (usually implicit) contract, a license exists between two
people -- the person giving away a copy of the software and the person
receiving it. For commercial software, that's it. Redistributable
licenses (shareware, freeware, open source, free software, etc.),
however, include a clause that permits redistribution _if_ certain
conditions are met. The minimum condition is usually that the
redistributed software should have a license that is _at least_ as
restrictive as the original. (The GPL goes further than that.)
The point of all that is that the persistence of open source licenses is
artificial, a product of specific wording in the license -- each link in
the chain of redistribution is legally a separate contract, but licenses
like the GPL allow redistribution only under the same (or equivalent,
for license-specific definitions of equivalence) contract the software
was originally obtained under. It may seem as if the license was an
inseparable part of the program, but that is not fundamentally the case.
The problem? The GPL makes no mention of the possibility that it might
be part of a dual license. So yes, just as the Artistic license lets
you modify and redistribute perl in ways that can make it un-GPL-able,
the GPL also lets you modify it in ways that exclude the Artistic
license.
In fact, all you need to do is add a bit of you own code, and decide
that you want this code distributed under GPL only. As you are now one
of the authors, your permission would be needed for the resulting work
to be distributed under any other license.
So it's all really based on nothing but good faith.
>> If I was going to use a module
>> with this perl version that had a note about being "distributed under
>> the same terms as Perl itself", would I *have* to use it under the GPL,
>> or could I still take the AL?
>
>I always thought that this phrase was a lazy error-prone one.
It is. Arguably, however, it would have to be taken as referring to the
_official_ perl distribution, as sanctioned by Larry, simply because
this is the only "Perl" for which the definitive singular could apply.
If the license of the official distribution were to change, things would
indeed get messy. The "at the time of release" interpretation would
indeed seem reasonable, but I've no idea if it would hold up in court or
not. At the very least, the code could still be distributed under the
GPL no matter what -- the intent of the GPL is that GPLed code should
stay GPLed, and a license-by-symref isn't enough to get around that.
--
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: Fri, 14 Sep 2001 23:34:40 +0100
From: "Simon Oliver" <simon.oliver@umist.ac.uk>
Subject: Re: Perl to MS SQL
Message-Id: <3ba28882$1@news.umist.ac.uk>
I would advise you toward the Perl DBI.
As far as I know there are four options: DBD::Sybase, DBD::ODBC,
DBD::JDBC and DBD::Proxy. I have only used the first to solve this problem.
If you choose DBD::Sybase you'll need a TDS library such as provided with
Sybase Server software or freeTDS (http://www.freetds.org/). Once you have
tested the TDS libraries you can install the DBD::Sybase driver.
Also take a look at: http://www.linuxgazette.com/issue18/sybase.html
--
Simon Oliver
------------------------------
Date: Sat, 15 Sep 2001 10:33:11 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Problems with format (perlform) and carriage returns...
Message-Id: <slrn9q58e7.bfe.mgjv@martien.heliotrope.home>
On 14 Sep 2001 08:14:26 -0700,
James Minor <jminor@crystal.cirrus.com> wrote:
>
>> Now, what this is all about, I can't tell you, but it certainly isn't
>> the correct behaviour.
>
> Is there someone I should notify that this appears to be a bug? As a
> programmer myself, I usually like to make sure that even though
> something appears to just 'not work', I like to at least insure that
> something somewhere else isn't affected by the bug (if this is one).
You could compile a bug report, and send it to perlbug@perl.org (You
should probably use the perlbug program, which comes with perl, but you
should make sure it sends the bug report to the right place).
If you feel unsure about how to do this, send me an email, and I'll
compile the report, with the examples I sent in the earlier post, and
submit it.
Martien
--
Martien Verbruggen | The Second Law of Thermodenial: In
Interactive Media Division | any closed mind the quantity of
Commercial Dynamics Pty. Ltd. | ignorance remains constant or
NSW, Australia | increases.
------------------------------
Date: Sat, 15 Sep 2001 10:22:26 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: recognize MS Windows with perl
Message-Id: <vhxo7.3$HB1.336@wa.nnrp.telstra.net>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:43j3qtssp0cc9entkmppt566mg3ol0upli@4ax.com...
> Zachary Kent wrote:
>
> >Don't Laugh....
> >
> ><ducking>I use if (-e '\autoexec.bat') to distinguish my Win95
development
> >machine from my Unix server.</ducking>
>
> So you only have one hard disk? Because if your script runs on D: or E:,
> this won't work.
>
> AFAIK C: is ALWAYS the boot disk.
In win9x C: is always the boot disk, on Win2k, the boot disk will be
whatever partition name it was installed into, which can vary with
multi-boot environments depending on the installation sequence. In a recent
system C: was the boot under win98, but when selecting Win2k the boot drive
became F:. (This indicates a sub-optimal installation though).
I am less certain with WinNT, (since I rarely see a dual boot system with
that OS).
Still, you can't even depend on c:\autoexec.bat being there, especially
considering that some win32 systems don't have an autoexec.bat at all (if
nothing has ever been put into it since it is not NEEDED).
I have had the most success with the 'perlvar' option, because I generally
only need to know whether I am on Windows or Linux, and once I know that I
can handle the rest, but then my programs only run on my own systems, so I
am usually programming for known environments, not the general case.
In other cases where I have programmed for other people's systems, I have
usually given them a couple of well commented global variables at the top of
the script which they edit to indicate the path to various things, which
means they have to at least have some idea what is going on.
For example that may take the form of something like:
# set the true local path on your system where the script will run
my $path = 'd:/inetpub/wwwroot/site/cgi-bin';
# set the path for where your data files reside
my $datapath = 'd:/inetpub/data/sitedata';
etc
If the user is on Linux, they just edit accordingly, and all file accesses
use those variables with hard coded filenames (or appropriate un-tainting).
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: Sat, 15 Sep 2001 11:11:59 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Running perl scripts
Message-Id: <slrn9q5amu.bfe.mgjv@martien.heliotrope.home>
On Fri, 14 Sep 2001 15:18:01 GMT,
Tad McClellan <tadmc@augustmail.com> wrote:
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>>On Thu, 13 Sep 2001 16:31:30 -0500,
>> Michael Carman <mjcarman@home.com> wrote:
>
> [snip cwd in path]
>
> [snip bad 'xs' program waiting for 'cd' to be mistyped]
>
>>There are other 'standard' typos of commands.
>
> Do you know where there is a list of them? I'd like to scan the fs
> for such names from time to time.
I haven't ever seen such a list, and a bit of google searching doesn't
turn up much either. I didn't mean 'standard' as in well-documented,
really, more as something that many people mistype. I know the subject
comes up regularly on comp.unix.shells and comp.unix.programmer, and
sometimes people post examples.
> I have:
>
> alias gerp='/bin/grep'
> alias sl='/bin/ls'
The sl one is one that I see a lot as well on my command line. Others
are
dc (cd, but this one won't hurt with . at the end of the path)
fidn (instead of find)
elss (instead of less)
an (instead of man)
tzr (instead of tar)
csv (instead of cvs)
gvi (instead of gvim)
Any command where a 'left-hand' and a 'right-hand' letter follow each
other is subject to having those two reversed, the most frequently used
commands of course being the most frequently mistyped. Commands
containing a 'pinky' letter or some letters from the bottom row are
vulnerable for some typists (me, for example). Sometimes the first
letter of a command gets swallowed because the terminal is in an odd
state, for example after accidentally cat-ing a binary file.
Then there's a set where a space is missing:
ls-al (and other option combinations)
cd-
cd..
pushd-1 or pu-1 (which is why I have aliases 1,2,3 etc for these)
tarxvf (and other options)
df-k
du-sk
And I'm sure there are more that occur less frequently, which I can't
readily think of right now. On my laptop there another set of potential
problems, because of the odd arrangement of the keys, and I sometimes
end up accidentally using ctrl-a in the middle of typing a comand.
If you're going to look for these things, you should probably consider
using the locate database. It can severely shorten the time needed to
find offending file names. :)
I have on some occasions also found traps for sudo and su (and often
su-), which are of course particulary dangerous (capture password, then
exec real program). Anyone who ever needs to use su or sudo, or work
with non-default privileges, should be particularly careful not _ever_
to have . in their path.
Just for fun, I just went through the history in a few of my open
terminals. I could only find 2 of the ones above (tzr and an), but I've
got a distint memory of typing some of the others at some time in the
past.
Martien
--
Martien Verbruggen |
Interactive Media Division | life ain't fair, but the root
Commercial Dynamics Pty. Ltd. | password helps. -- BOFH
NSW, Australia |
------------------------------
Date: Fri, 14 Sep 2001 22:12:59 GMT
From: "OverlordQ" <overlord_q@hotmail.com>
Subject: Re: Using Perl to post regular usenet messages.
Message-Id: <Lhvo7.293127$GN.41396884@typhoon.kc.rr.com>
<insert perl proggy here>
Very much appreciated :)
I know the best thing is to try it figure it out yourself, but I do better
if i have examples :)
-------------------------------
Newsgroup: alt.eo
For all your Evil Overlord Needs
http://www.thedarkcitadel.com
------------------------------
Date: Fri, 14 Sep 2001 23:45:39 +0100
From: "Simon Oliver" <simon.oliver@umist.ac.uk>
Subject: Re: Using Perl to post regular usenet messages.
Message-Id: <3ba28e21@news.umist.ac.uk>
Net::NNTP - NNTP Client class
OverlordQ <overlord_q@hotmail.com> wrote in message
news:8Huo7.293013$GN.41352272@typhoon.kc.rr.com...
> Any Idea on where to get started? any docs out-there which help?
>
> Any clues on which module would be required?
>
> TIA.
>
> --
> -------------------------------
> Newsgroup: alt.eo
> For all your Evil Overlord Needs
> http://www.thedarkcitadel.com
>
>
------------------------------
Date: 14 Sep 2001 16:37:26 -0700
From: Keith Thompson <kst@cts.com>
Subject: Re: Using the c preprocessor for non c purposes
Message-Id: <yec3d5ps5s9.fsf@king.cts.com>
"B. Caligari" <bcaligari@fireforged.com> writes:
> While just toying around, I was wondering if I can use the c preprocessor
> for just about anything.
There's no requirement that the preprocessor be a separate program.
As you've seen, it is separate in gcc; it may not be in other
implementations.
One thing to watch out for is that the preprocessor parses its input
into a sequence of valid preprocessor tokens. This may be a problem
for some input text. For example, an input line with an odd number of
apostrophes or double quotes is likely to cause an error. (This has
caused problems for attempts to use the C preprocessor on Ada source
code. Ada uses a single apostrophe to introduce an attribute name, as
in Object'Size.)
--
Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Cxiuj via bazo apartenas ni.
------------------------------
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 1750
***************************************