[18187] in Perl-Users-Digest
Perl-Users Digest, Issue: 355 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 26 03:06:54 2001
Date: Mon, 26 Feb 2001 00: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: <983174709-v10-i355@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 26 Feb 2001 Volume: 10 Number: 355
Today's topics:
[OT] Re: Problem with Program - can you help? <joe+usenet@sunstarsys.com>
Any way to modify a script while executing it? <donkan7@yahoo.com>
Re: Any way to modify a script while executing it? (Logan Shaw)
Calling SMBPASSWD from a CGI script <stag1400@pacbell.net>
Re: delete the own directory <ekke@chamber.ee>
Exceptions module in development, Comments? <cdh@ala.net>
Executing perl on Win98 <bmccann@naisp.net>
Re: Graphic file manipulation <termix@earthlink.net>
Re: Graphic file manipulation (Martien Verbruggen)
Re: Graphic file manipulation <patrickolson@qwest.net>
Re: Graphic file manipulation (Martien Verbruggen)
GUI interface for Perl program <cave@pertus.com.pl>
Re: How is @INC populated <wbn1@qNowesspamt.net>
Re: How is @INC populated (Martien Verbruggen)
Re: How is @INC populated (Ilya Zakharevich)
One form submit to many servers (DrewWatk)
Re: Perl SAS Oracle WWW <pm@katz.cc.univie.ac.at>
perl thread woes.. <mjf@efortress.com>
Problem with Program - can you help? (Betastar)
Re: Problem with Program - can you help? (Steven Smolinski)
Re: Problem with Program - can you help? <thelma@alpha2.csd.uwm.edu>
Re: Problem with Program - can you help? (Garry Williams)
Re: Problem with Program - can you help? (Betastar)
XML parsing for large documents (Ajaman2001)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Feb 2001 00:15:01 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: [OT] Re: Problem with Program - can you help?
Message-Id: <m3k86e3u0a.fsf_-_@mumonkan.sunstarsys.com>
insq@yahoo.com (Betastar) writes:
> For Steven, who questions the usefulness of this, what this will do is
> let me take a database of 6,626 DNA sequences and parse them into one
> sequence per file which will allow me to both insert the sequences
> individually into a database as well as use them in another analysis
> program which will only take input files with one sequence once at a
> time.
>
> I won't go into the long-term larger implications of this for my
> research.
Let's hope you will publish your results and not go looking for yet
another genome patent ;-)
--
Joe Schaefer "Sometimes one pays most for the things one gets for nothing."
--Albert Einstein
------------------------------
Date: Sun, 25 Feb 2001 22:31:24 -0800
From: "Dick" <donkan7@yahoo.com>
Subject: Any way to modify a script while executing it?
Message-Id: <UKmm6.1250$GE3.169909@news03.micron.net>
Is there a way to modify a script while executing it?
To illustrate my question I've written this little script:
===============================
#!/usr/bin/perl -w
use diagnostics;
use strict;
my ($n, $x, $rand) = 0;
$n = 33;
print "default is $n; change by entering a different positive integer: ";
chomp ($x = <>);
$n = $x if $x ne "";
$rand = rand($n);
print "\nrand\($n\) is $rand\n";
================================
Each time I run this it of course says the default is 33. What I'd like to
be able to do is to have a change in the default value "stick". For example
if the second time I run the script I change the default to 100, then the
third run of the script would say the default is 100, not 33. It seems to
this newbie that this would involve somehow rewriting the "$n = 33;" line to
"$n = 100;" at some point in the execution of the script. Is this
impossible? And if not, how can this be done?
I'm using perl version 5.004_04 .
Dick
------------------------------
Date: 26 Feb 2001 01:57:48 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Any way to modify a script while executing it?
Message-Id: <97d29s$2k2$1@boomer.cs.utexas.edu>
In article <UKmm6.1250$GE3.169909@news03.micron.net>,
Dick <donkan7@yahoo.com> wrote:
>$n = 33;
>print "default is $n; change by entering a different positive integer: ";
:
:
>Each time I run this it of course says the default is 33. What I'd like to
>be able to do is to have a change in the default value "stick".
>It seems to
>this newbie that this would involve somehow rewriting the "$n = 33;" line to
>"$n = 100;" at some point in the execution of the script. Is this
>impossible?
No, it's not impossible, but what you're talking about is called
self-modifying code, and it quickly becomes a maintenance nightmare
in many situations.
What would probably be better would be to have a data file to store the
current value of the variable.
For example:
#! /usr/local/bin/perl
$filename = $ENV{HOME} . "/.some-file";
sub read_number
{
my ($filename) = @_;
my ($number);
open (FOO, $filename)
or die "Can't open $filename ($!)\n";
$number = <FOO>;
$number =~ s/\n//;
close FOO;
return ($number);
}
sub write_number
{
my ($filename, $number) = @_;
open (FOO, ">$filename")
or die "Can't open $filename ($!)\n";
print FOO $number, "\n";
close FOO;
}
$x = read_number ($filename);
print "The number was $x last time.\n";
print "What should it be this time?\n";
$x = <STDIN>;
write_number ($filename, $x) if $x =~ /[0-9]/;
Hope that helps.
- Logan
--
my your his her our their *its*
I'm you're he's she's we're they're *it's*
------------------------------
Date: Sun, 25 Feb 2001 18:00:41 -0800
From: "stag1400" <stag1400@pacbell.net>
Subject: Calling SMBPASSWD from a CGI script
Message-Id: <qZim6.1401$qv3.653226@nnrp5-w.sbc.net>
Hi All,
I am a sysadmin and set up a linux box for sendmail, pop3, and imap. so far
so good.
Then manegement wanted to use Outlook and be able to publish free/busy data.
This I did by using Samba. As users are added they get a home dir and access
to a shared public dir.
I found a web-based password changer, and it will change the UNIX password
but not the Samba password.
I looked at the perl code and thought i could simply add a line to use
SMBPASSWD and use the variables $username and $newpassword.
here is the line I am using now:
`system("/usr/bin/smbpasswd -s $username $newpasswd")`;
I have tried everything I can think of but still have not been sucessful.
Thank in Advance
------------------------------
Date: Mon, 26 Feb 2001 05:41:05 +0000
From: ekke vasli <ekke@chamber.ee>
Subject: Re: delete the own directory
Message-Id: <3A99EC71.A2C4513F@chamber.ee>
Christian Gersch wrote:
> ...and what's the command to delete a directory...I think "unlink" is only
> for files...?
rmdir
--
ekke
+3725058839
I think we're in trouble.
-- Han Solo
------------------------------
Date: Mon, 26 Feb 2001 01:19:52 -0600
From: cdh <cdh@ala.net>
Subject: Exceptions module in development, Comments?
Message-Id: <3A9A0398.DEFEFCD0@ala.net>
This is a multi-part message in MIME format.
--------------724F4124372C251ECFDD3C28
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I'm toying around with writing a module to implement a generic exception handling scheme.
The "try {} catch {}" example in perlsub gave the the idea, and I took it a few steps further.
The basic "innovation" is that the return value of the catch block may cause execution to
exit the try block (if return 0) or continue on with the rest of the
block.
a simple example:
try {
foo() or die "foo failed";
bar() or die "bar failed";
} catch {
/^foo failed/ and do {
fix_foo();
return 1; # the exception is considered "fixed" and processing continues on
# with the next statement: bar()
};
/^bar failed/ and do {
# bar is unfixable (this catch isn't really necessary since it would fall thru,
# it's just for demonstration)
return 0; # the exception is uncaught. it would propagate to other enclosing
# try blocks or ultimately to the "top" where execution would halt.
};
};
Basically I'm just looking for comments on it, and maybe some
reccomendations or heads up on problems areas.
Thanks,
Chris Hickman
--------------724F4124372C251ECFDD3C28
Content-Type: text/plain; charset=us-ascii;
name="Exception.pm"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Exception.pm"
package Exception;
# Author: Christopher Hickman (cdh@ala.net)
# Ripped-off from/Inspired by the try/catch example in the perlsub manpage.
use strict;
# wtf?!? after hours and endless hacks to track down why Carp.pm seemed to be getting special treatment by not
# having to call my die sub, it turns out vars is responsible!
# use vars qw/$try $catch/;
our ($try, $catch, $prior_catch);
BEGIN {
use Exporter;
our ($VERSION, @ISA, @EXPORT);
$VERSION = "0.05";
@ISA = qw(Exporter);
# this is very naughty... is there a better way?
*CORE::GLOBAL::die = \¨
@EXPORT = qw/try catch/;
}
sub die {
my $catch_sub = $catch;
local $catch = $prior_catch;
local $_ = shift;
chomp;
(defined($catch_sub) && &$catch_sub) or CORE::die $_;
};
sub catch (&) {}
sub try (&@) {
local $prior_catch = $catch;
{
local ($try, $catch) = @_;
eval { &$try };
}
die($@) if $@;
}
1;
# Bugs:
# I finally have it working with Carp, it turns out my use of vars.pm was the problem. It still
# breaks if vars is loaded anywhere *before* Exception.pm:( So for now, Exception.pm
# carries the caveat that it must be loaded before other modules.
# line numbers reflect the end of the try block rather than the line that threw the exception.
# Possible plans for future versions:
# Support exception classes
# Right now I haven't even tested this, and I highly doubt they work. I plan on making it work.
# The advantage is that you can set a trap for an exception class and it will catch objects of
# that and all "derived" exception classes. (At the very least, it's neater than having to
# pattern-match strings.)
# C coding
# a major bottleneck is the eval, not sure if coding in C will allow me to finally get rid of
# it, or if there's some better means from within perl.
# Definitly write a better test.
# Change Log:
# version 0.05
# It now exports die globally so that other imported modules use it. (See Bugs).
# This maybe should be optional.
# Fixed problem with exceptions thrown within a catch being caught by that catch.
#
# version 0.04
# Removed crack-induced invoke() and revoke() subs.
# These only allowed you to suppress/reinstate exceptions, but there was no way to
# handle exceptions AND then return to the point the exception was thrown. This can
# now be accomplished through the return value of the catch block. Returning 0 means
# the exception is not "trapped" and, even though some amount of processing may have
# occurred, the try block is terminated and the exception is propagated up the call
# chain. Returning 1 means that the exception is trapped and processing may resume
# where it left off within the try block. If you want to "revoke" exceptions you can
# now just install a do-nothing handler that returns 1.
# Removed throw() sub.
# The module now overrides die() which makes throw() redundant.
# Speed.
# Benchmarking indicates the v0.04 is well over 3x faster than v0.03
# (that's still slow though)
#
# version 0.03
# This version only lived a few hours before I had better ideas and completely rewrote it.
# The later versions are much smaller and faster, and more functional.
# The prior versions were just crude tests of the idea.
--------------724F4124372C251ECFDD3C28
Content-Type: application/x-perl;
name="exception_demo.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="exception_demo.pl"
#!/usr/bin/perl
# Author: Christopher Hickman (cdh@ala.net)
use strict;
use Exception;
use Carp;
use Benchmark;
# choose your form of execution;)
sub throw {
# &confess(@_); # XXX dumps core sometimes
# &croak(@_); # note... the benchmark is MUCH faster with die than croak
die(@_);
}
catch { throw "You shouldn't see this.\n"; }; # This would simply be insane
try {
try {
throw "foo1";
&test1;
&test2;
&test3;
throw "baz5";
print "You should not see this\n";
} catch {
/^foo/ && do {
print "'$_' caught, continuing\n";
return 1;
};
/^baz/ && do {
print "'$_' caught, exception re-thrown (you'll see this one again)\n";
return 0;
}
};
print "this is the last line\n";
} catch {
/^baz/ && do {
print "'$_' caught in outer try, continuing\n";
try {
print "You should see 2 more lines\n";
throw "baz6";
} catch {
/^baz/ && do {
print "'$_' caught, you should see 1 more line\n";
return 1;
}
};
return 1;
};
};
sub test1 {
throw "foo2";
}
sub test2 {
try {
throw "foo3";
} catch {
# noop
};
}
sub test3 {
try {
throw "bar4";
} catch {
/^bar/ && do {
print "'$_' caught, continuing\n";
return 1;
};
};
}
print "\n";
print "Done testing logic!\n";
# exit;
# now to benchmark
print "Benchmarking...\n";
# you might want to lower this if you are on a slow machine
# (especially if you use croak inside the throw sub)
my $count = 100000;
my $code = q{
try {
throw "foo";
} catch {
/^foo/ && do {
return 1;
};
};
};
print "This code used to benchmark:\n";
print $code;
timethis ($count, $code);
print "done benchmarking.\n\n";
print "Comparison: \n";
$code = q{
$test = "foo";
$test =~ /^foo/ && do {
my $a = eval { return 1; };
};
};
print $code;
timethis ($count, $code);
print "Testing complete.\n\n";
--------------724F4124372C251ECFDD3C28--
------------------------------
Date: Mon, 26 Feb 2001 01:24:54 -0800
From: "Brian McCann" <bmccann@naisp.net>
Subject: Executing perl on Win98
Message-Id: <t9jts1o67th64b@corp.supernews.com>
I usually run perl scripts on Sun or Win NT and to execute a script
all you have to do at the prompt is type filename.pl and the script executes
but on Win98 to get the script to execute you have to type
perl filename.pl
is there a way to run the script without calling the interpreter
before the filename?
tia
Brian
------------------------------
Date: Mon, 26 Feb 2001 03:11:53 GMT
From: "Termix" <termix@earthlink.net>
Subject: Re: Graphic file manipulation
Message-Id: <ZPjm6.53$M4.7743@newsread1.prod.itd.earthlink.net>
This might be a bit complicated but you can create a special file handle
type variable
that actually references your memory structure. More information on this is
available in the perltie man page. (I've no experience in this myself).
There might actually be modules available on CPAN that let you create
'virtual' files.
There are perl libraries for 'gimp'. ImageMagick is much simpler to use
though.
Neb <berube@odyssee.net> wrote in message
news:97bodg$803$1@cti15.citenet.net...
> Hi,
>
> I have a script that reads from a database an image file content (.gif or
> .jpg) into a variable. What I want to do is to resize this image and send
> it back to the client browser (content-type: image/gif).
>
> I'm trying to use Image::Magick, but the problem is that the Read method
> *needs* a FILEHANDLE to the image file. But since the image data is in
> memory, there can't seem to be a way to create the image object. Note
that
> I don't want to write the image data to a file.
>
> Is there a way to bypass this problem ? Or is there an other graphic
> manipulation lib that will allow to do this ?
>
> Thanks,
>
> Ben
>
>
>
>
------------------------------
Date: Mon, 26 Feb 2001 15:59:02 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Graphic file manipulation
Message-Id: <slrn99jokm.gro.mgjv@martien.heliotrope.home>
[alt.perl removed]
[comp.lang.perl removed. Newsgroup is long dead]
On Sun, 25 Feb 2001 15:15:38 -0500,
Neb <berube@odyssee.net> wrote:
> Hi,
>
> I'm trying to use Image::Magick, but the problem is that the Read method
> *needs* a FILEHANDLE to the image file. But since the image data is in
No, it doesn't A file name is fine.
> memory, there can't seem to be a way to create the image object. Note that
> I don't want to write the image data to a file.
Then you should use BlobToImage() and its converse, ImageToBlob().
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: Sun, 25 Feb 2001 22:26:52 -0700
From: ">-\",\",\",\"D>" <patrickolson@qwest.net>
Subject: Re: Graphic file manipulation
Message-Id: <tOlm6.6055$e23.753919@news.uswest.net>
"Neb" <berube@odyssee.net> wrote in message
news:97bodg$803$1@cti15.citenet.net...
> Hi,
>
> I have a script that reads from a database an image file content (.gif
or
> .jpg) into a variable. What I want to do is to resize this image and
send
> it back to the client browser (content-type: image/gif).
>
> I'm trying to use Image::Magick, but the problem is that the Read
method
> *needs* a FILEHANDLE to the image file. But since the image data is
in
> memory, there can't seem to be a way to create the image object. Note
that
> I don't want to write the image data to a file.
>
> Is there a way to bypass this problem ? Or is there an other graphic
> manipulation lib that will allow to do this ?
>
> Thanks,
>
> Ben
>
>
>
this is using GD but the binmode STDOUT is needed I need to install
Image::Magick but if you have it in a string just print it you will
have to check the
documentation on re-sizing
print "Context-Type: image/\n\n";
# make sure we are writing to a binary stream
binmode STDOUT;
# Convert the image to PNG and print it on standard output
print $im->png;
------------------------------
Date: Mon, 26 Feb 2001 17:48:52 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Graphic file manipulation
Message-Id: <slrn99jv2k.gro.mgjv@martien.heliotrope.home>
[bogus newsgroups removed]
On Sun, 25 Feb 2001 22:26:52 -0700,
>-\",\",\",\"D> <patrickolson@qwest.net> wrote:
[article reformatted to be legible again]
> "Neb" <berube@odyssee.net> wrote in message
> news:97bodg$803$1@cti15.citenet.net...
>> Hi,
>>
>> I have a script that reads from a database an image file content (.gif or
>> .jpg) into a variable. What I want to do is to resize this image and send
>> it back to the client browser (content-type: image/gif).
>>
>> I'm trying to use Image::Magick, but the problem is that the Read method
>> *needs* a FILEHANDLE to the image file. But since the image data is in
>> memory, there can't seem to be a way to create the image object. Note that
>> I don't want to write the image data to a file.
>>
>> Is there a way to bypass this problem ? Or is there an other graphic
>> manipulation lib that will allow to do this ?
>>
> this is using GD but the binmode STDOUT is needed I need to install
> Image::Magick but if you have it in a string just print it you will
> have to check the
> documentation on re-sizing
>
> print "Context-Type: image/\n\n";
>
> # make sure we are writing to a binary stream
> binmode STDOUT;
>
> # Convert the image to PNG and print it on standard output
> print $im->png;
And how does that answer the question the OP had? It's nice of you to
try to help, but if you do so, try to give enough help to be useful.
What you wrote is next to nothing, if not plainly misleading.
Besides that, you glance over the 'check the documentation on re-sizing'
bit quite fast. Could you elaborate which bit of the documentation tells
you how to resize an image with GD? It may come as a surprise to you,
but GD doesn't have anything native to resize images, which means you
need to do it all in a bit of a roundabout way.
Besides that, you failed to warn the OP that GD only supports up to 256
colours in an image. If you read in JPEG, you lose quality, colour
depth, and quality again, on export. GD is not the nest module to do
this stuff at all.
To reiterate the question: How does the OP get an image object of any
kind that can be resized, given that he has the image's contents in a
scalar of some kind?
I've already given an answer using Image::Magick in another post, since
that is what the OP indicated they wanted to use, but I see that I'll
have to do this one as well..
GD can take a scalar (make sure you have a recent version) as an
argument to its new method:
[warning, untested code follows. Use it as a code outline only]
my $gd_src = GD::Image->new($image_data);
my ($width, $height) = $gd_src->getBounds();
# Calculate the new dimensions for your image
my ($new_width, $new_height) = resize($width, $height);
# Create a new image
my $gd_new = GD::Image->new($new_width, $new_height);
# Copy the old data to the new image, resizing on the fly
$gd_new->copyResized($gd_src, 0, 0, 0, 0,
$new_width, $new_height, $width, $height);
# print to output, assuming that binmode has already been used
print STDOUT $gd_new->png;
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use
NSW, Australia | being a damn fool about it.
------------------------------
Date: Mon, 26 Feb 2001 07:38:44 +0100
From: Mirek Rewak <cave@pertus.com.pl>
Subject: GUI interface for Perl program
Message-Id: <fqtj9tchkkhd2sj7v2e15qtgblvkmhhomb@4ax.com>
Hi,
I want to to write program that will be interfaced by a GUI on Win32.
I don't know what interface will I use: Win32, GTK or Tk. I know that
there are modules for that GUIs, but I want someone to share some
opionions about stability, practical use, etc. these modules. (I'd
preffer Win32::GUI)
I'm writting this program for HCI topic on my study - it will by
interface to simple database.
Program also will be interpreter simple query language (similiar to
SQL). I think that Perl will be excelent tool for this (I hope).
Thanks for any help.
Regards
Mirek Rewak
cave@pertus.com.pl
------------------------------
Date: Sun, 25 Feb 2001 18:32:12 -0800
From: "Bruce N. Wheelock" <wbn1@qNowesspamt.net>
Subject: Re: How is @INC populated
Message-Id: <Oejm6.4934$e23.623887@news.uswest.net>
Thank you for the explanation. Do I correctly understand this to mean that
I cannot permanently change @INC without recompiling perl? All I want to do
is add another directory to it, permanently and globally.
"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn99hube.hp7.mgjv@martien.heliotrope.home...
> On Sun, 25 Feb 2001 01:51:49 -0800,
> Bruce N. Wheelock <wbn1@qNowesspamt.net> wrote:
> > I suppose this will turn out to be an embarrassingly simple question,
but
> > how is the @INC array populated? The values are retained between
sessions,
> > so the data come from somewhere, but where? I've checked the Camel book
and
> > I've searched online, but I can't find the answer to this.
> >
>
> They're compiled in:
>
> $ strings `which perl` | grep perl/lib
> /opt/perl/lib/5.6.0
> /opt/perl/lib/5.6.0/i686-linux
> /opt/perl/lib/site_perl/5.6.0/i686-linux
> /opt/perl/lib/site_perl/5.6.0
> /opt/perl/lib/site_perl
>
> After configuring your Perl for compilation, you can find these in
> config.h as various defined macros with LIB in their names. You can have
> a look at perl.c:S_init_perllib() to see what gets loaded, and how. Look
> for occurences of incpush() in the code.
>
> You should also be able to find these directories in ARCHLIB/Config.pm,
> where archlib is the 2nd one in the list above.
>
> $ perl -MConfig=config_sh -we 'print config_sh' | grep perl/lib
> archlibexp='/opt/perl/lib/5.6.0/i686-linux'
> installarchlib='/opt/perl/lib/5.6.0/i686-linux'
> installprivlib='/opt/perl/lib/5.6.0'
> privlibexp='/opt/perl/lib/5.6.0'
> archlib='/opt/perl/lib/5.6.0/i686-linux'
> installsitearch='/opt/perl/lib/site_perl/5.6.0/i686-linux'
> installsitelib='/opt/perl/lib/site_perl/5.6.0'
> privlib='/opt/perl/lib/5.6.0'
> sitearch='/opt/perl/lib/site_perl/5.6.0/i686-linux'
> sitearchexp='/opt/perl/lib/site_perl/5.6.0/i686-linux'
> sitelib='/opt/perl/lib/site_perl/5.6.0'
> sitelib_stem='/opt/perl/lib/site_perl'
> sitelibexp='/opt/perl/lib/site_perl/5.6.0'
>
> Perl does however also do some clever things to include version specific
> libraries of older versions of Perl that may be installed in the same
> tree.
>
> > ActiveSource Perl v5.6.0 running on Windows 2000 Professional.
>
> The same should hold for the ActiveState version, even though you
> probably didn't compile it up yourself, or got the source code
> available.
>
> > A minimal amount of derisive laughter gratefully appreciated. ;-)
>
> I don't see any need for derisive laughter.
>
> Martien
> --
> Martien Verbruggen | The problem with sharks is that they
> Interactive Media Division | are too large to get to the shallow
> Commercial Dynamics Pty. Ltd. | end of the gene pool. -- Scott R.
> NSW, Australia | Godin
------------------------------
Date: Mon, 26 Feb 2001 15:56:53 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How is @INC populated
Message-Id: <slrn99jogl.gro.mgjv@martien.heliotrope.home>
[In the future, please put your reply after the suitably trimmed quoted
text you reply to. It's the generally accepted convention on this group,
and Usenet in general.]
On Sun, 25 Feb 2001 18:32:12 -0800,
Bruce N. Wheelock <wbn1@qNowesspamt.net> wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn99hube.hp7.mgjv@martien.heliotrope.home...
>> On Sun, 25 Feb 2001 01:51:49 -0800,
>> Bruce N. Wheelock <wbn1@qNowesspamt.net> wrote:
>> > I suppose this will turn out to be an embarrassingly simple
>> > question, but how is the @INC array populated? The values are
>> > retained between sessions, so the data come from somewhere, but
>> > where? I've checked the Camel book and I've searched online, but I
>> > can't find the answer to this.
>>
>> They're compiled in:
>>
> Thank you for the explanation. Do I correctly understand this to mean
> that I cannot permanently change @INC without recompiling perl? All I
> want to do is add another directory to it, permanently and globally.
I don't know of any ways, which doesn't mean there aren't any. Maybe
manipulation of some of the variables in Config.pm works. The FAQ, part
8, has a few things to say about how to add them at runtime, under the
question 'How do I add a directory to my include path at runtime?'.
Maybe that's enough for your needs?
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | "Mr Kaplan. Paging Mr Kaplan..."
NSW, Australia |
------------------------------
Date: 26 Feb 2001 07:45:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: How is @INC populated
Message-Id: <97d1i4$1p8$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was NOT sent to Martien Verbruggen
<mgjv@tradingpost.com.au>],
who wrote in article <slrn99jogl.gro.mgjv@martien.heliotrope.home>:
> >> They're compiled in:
> >>
> > Thank you for the explanation. Do I correctly understand this to mean
> > that I cannot permanently change @INC without recompiling perl? All I
> > want to do is add another directory to it, permanently and globally.
>
> I don't know of any ways, which doesn't mean there aren't any.
I think that your replies are absolutely off-the-key. I do not know
anything about how Win* ports work, but I know that compiling the
paths in works only on the systems where you are *supposed* to
recompile the package separately for each machine/network.
With binary distributions *this does not work*. So it cannot be so
for the ActivePerl port.
> Maybe manipulation of some of the variables in Config.pm works.
How would it find Config.pm?
Here is how the OS/2 port does it: the paths are compiled in, but you
can specify a-kind-of s/// translation to do on the compiled-in paths
in $ENV{PERLLIB_PREFIX}.
Another approach would be to do the translation w.r.t. the Perl
executable path. [The problem with this is that there are two equally
good - in different situations - ways to organize the directory
structure: if $DIR is the directory of Perl, you may want to look for
modules in $DIR/../lib/perllib, or $DIR/libperl.]
So the answer should be: read the ActivePerl docs....
Ilya
------------------------------
Date: 26 Feb 2001 04:38:27 GMT
From: drewwatk@aol.com (DrewWatk)
Subject: One form submit to many servers
Message-Id: <20010225233827.19480.00002778@ng-mp1.aol.com>
Hello,
How could one persuade PERL to initiate multiple form submissions to other
servers from one submit element.
Sorry if this question doesn't seem to follow the topic and should probobly be
located in ...authoring.cgi but posting is not presently available there.
Thanks,
Drew
------------------------------
Date: 26 Feb 2001 07:33:26 GMT
From: Peter Marksteiner <pm@katz.cc.univie.ac.at>
Subject: Re: Perl SAS Oracle WWW
Message-Id: <97d0s6$4620$1@www.univie.ac.at>
Knuj Liam <knuj2000@hotmail.com> wrote:
: I'm a total newbie to Perl so please bear with me. I'd like to know if Perl
: is capable of serving as the intermediary in an environment that looks like
: this:
: - UNIX
: - Oracle database
: - Many SAS programs
: - Desire to web-enable the applications so that users can point and click
: launch of SAS programs (batch & interactive).
: - Other applications such as OLAP tools and S-PLUS.
Perl is eminently suitable for tasks like this. I am using it in pretty
much the same way as you intend to do (not with SAS, but the principle
is the same: passing data from the browser to Oracle, from Oracle to
other applications, building HTML pages with the result).
Peter
--
Peter Marksteiner
Vienna University Computer Center
------------------------------
Date: Mon, 26 Feb 2001 02:10:36 GMT
From: Morgan Freeman <mjf@efortress.com>
Subject: perl thread woes..
Message-Id: <wWim6.26751$rO3.1017394@e3500-chi1.usenetserver.com>
I am having some difficulty making perl threads work right for me.
I have a list of websites that I want to retrieve information from
in parallel, so that no matter the order called, the fastest
website would return its data first.
So I wrote a test program, trying to create a new thread for each
site, where I use LWP to retrieve the website, when I get the
response object back, I want to return it so it can be passed
on to another sub for parsing and processing. So In theory, I thought
that the fastest sites would return first if they finished, but
in practice, all the sites were accessed seriallly, the first site in the
list returned first, and the last site in the list returned last.
My first thoughts are that LWP is blocking the other threads but i'm not really sure
whats going on. Any advice? I was thinking of other ways to do this
like just do forks and IPC, but I can't pass around perl objects
through sockets, so i'm not sure what is the best way to do this.
Any thoughts?
------------------------------
Date: Mon, 26 Feb 2001 02:15:38 GMT
From: insq@yahoo.com (Betastar)
Subject: Problem with Program - can you help?
Message-Id: <3a99ba10.41496143@news-server.nc.rr.com>
I know I know - I hate subjects like that too - but I didn't know how
to get more specific. Sorry.
Here's my problem....
I have a file that looks something like this:
>First one
1a
b2
3x
y4
5z
>Second one
1G
C2
3GGC
>Third one
1shfgh
sfhfd2
3asfd
iuahwo4
>Fourth one
1
>Fifth one
1843hj
2fih45his
(I call this "testfile")
I want to make five separate files that have each >line followed by
the text in a separate file. (Actually, I have a file with 6,626
segments of data like this, and want to parse that file into 6,626
separate files... this is just to test the program)
Here's my program thus far:
#!/usr/local/bin/perl -w
open (INFILE, "testfile") || die "Can't open file: $\n";
$x = 1;
while(<INFILE>) {
open(OUT, ">$x.out");
if ($_ !~ /^$/){
print OUT $_;
}
else {
close(OUT);
$x++;
}
}
close(INFILE);
I get all 5 files I need, but they're empty.
I've also tried using:
if ($_ =~ [A-Za-z0-9])
(so if the line contains any text) and I get the same results.
I've tried replacing the if/else with a while statement, where I have:
while ($_ !~ /$_/) {
print OUT $_;
}
close (OUT);
$x++
but that gives me one file with the first line >First one repeated...
well, until I hit CTRL-C to stop it running.
Anyone have any idea what else I might try to get this to work?
(I'm fairly new to the whole Perl thing, but I'm trying to learn and
I've run out of ideas from my books)
Thanks!
Betastar
------------------------------
Date: Mon, 26 Feb 2001 03:12:09 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: Problem with Program - can you help?
Message-Id: <slrn99jn2d.5i4.sjs@ragnar.stevens.gulch>
Betastar <insq@yahoo.com> wrote:
> I know I know - I hate subjects like that too - but I didn't know how
> to get more specific. Sorry.
That's usually a hint that you really don't even know what your problem
is. In this case, it's that you don't seem to have an algorithm, not
that you're having trouble with Perl.
> I have a file that looks something like this:
>
> >First one
> 1a
> b2
> 3x
> y4
> 5z
>
> >Second one
> 1G
> C2
> 3GGC
[...three more for a total of five...]
> I want to make five separate files that have each >line followed by
> the text in a separate file.
[... snip code: you should really indent consistently; it makes your
program much easier to read ...]
> Anyone have any idea what else I might try to get this to work?
> (I'm fairly new to the whole Perl thing, but I'm trying to learn and
> I've run out of ideas from my books)
Well, although I question the usefulness of the 6k files you want to
make, this program fulfills the requirements of the test file:
#!/usr/bin/perl -w
use strict;
open IN, 'testfile' or die "open testfile failed: $!";
my $inc;
while ( <IN> ) {
# New files are started when we encounter
# a leading > at the start of the line.
if ( /^>/ ) {
$inc++;
open OUT, ">$inc.out" or die "open $inc.out failed: $!";
}
print OUT;
}
__END__
Steve
--
Steven Smolinski => http://www.steven.cx/
------------------------------
Date: 26 Feb 2001 03:23:14 GMT
From: Thelma Lubkin <thelma@alpha2.csd.uwm.edu>
Subject: Re: Problem with Program - can you help?
Message-Id: <97ci72$p7s$1@uwm.edu>
Betastar <insq@yahoo.com> wrote:
: I have a file that looks something like this:
:>First one
: 1a
: b2
: 3x
: y4
: 5z
:>Second one
: 1G
: C2
: 3GGC
:>Third one
: 1shfgh
: sfhfd2
: 3asfd
: iuahwo4
:>Fourth one
: 1
:>Fifth one
: 1843hj
: 2fih45his
: (I call this "testfile")
: I want to make five separate files that have each >line followed by
: the text in a separate file. (Actually, I have a file with 6,626
: segments of data like this, and want to parse that file into 6,626
: separate files... this is just to test the program)
: Here's my program thus far:
: #!/usr/local/bin/perl -w
: open (INFILE, "testfile") || die "Can't open file: $\n";
: $x = 1;
[TRL] open(OUT, ">$x.out");
: while(<INFILE>) {
[TRL] remove line that follows
: open(OUT, ">$x.out"); #<------You are opening $x.out as a
# new, empty file each time
# that you write a line of
# text to it. For an inelegant
# but minimal fix, see the lines
# labeled [TRL] --thelma
: if ($_ !~ /^$/){
: print OUT $_;
: }
: else {
: close(OUT);
: $x++;
[TRL] open(OUT, ">$x.out");
: }
: }
: close(INFILE);
[TRL] close(OUT); #not really necessary, but I like to finish what
#I'm doing when I remember to...
: Thanks!
: Betastar
------------------------------
Date: Mon, 26 Feb 2001 03:34:43 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Problem with Program - can you help?
Message-Id: <n9km6.1190$C5.54100@eagle.america.net>
On Mon, 26 Feb 2001 02:15:38 GMT, Betastar <insq@yahoo.com> wrote:
>I have a file that looks something like this:
>
>>First one
>1a
>b2
>3x
>y4
>5z
>
>>Second one
>1G
>C2
>3GGC
>
>>Third one
>1shfgh
>sfhfd2
>3asfd
>iuahwo4
>
>>Fourth one
>1
>
>>Fifth one
>1843hj
>2fih45his
>
>
>(I call this "testfile")
>
>I want to make five separate files that have each >line followed by
>the text in a separate file. ...
>
>Here's my program thus far:
>
>#!/usr/local/bin/perl -w
>
>open (INFILE, "testfile") || die "Can't open file: $\n";
>$x = 1;
>
>while(<INFILE>) {
>
> open(OUT, ">$x.out");
>
> if ($_ !~ /^$/){
> print OUT $_;
> }
>
>else {
> close(OUT);
> $x++;
> }
>
>}
>close(INFILE);
>
>I get all 5 files I need, but they're empty.
Okay, so the thing that separates the segments is `>' in the first
character of a line. Right? There can be no data records within a
segment that begin with `>', right? And each segment is to be written
to a new file _without_ the separating line in it, right? And each
file is to be named `n.out', where n is 1 for the first segment and is
incremented for each new segment, right?
Here's a way to do that:
#!/usr/bin/perl -w
use strict;
my $n = 0;
open(OUT, ">$n.out") || die "can't open $n.out: $!";
while (<DATA>) {
if (/^>/) {
close(OUT);
$n++;
open(OUT, ">$n.out") || die "can't open $n.out: $!";
next;
}
print OUT;
}
__DATA__
>First one
1a
b2
3x
y4
5z
>Second one
1G
C2
3GGC
>Third one
1shfgh
sfhfd2
3asfd
iuahwo4
>Fourth one
1
>Fifth one
1843hj
2fih45his
This writes everything _before_ the first segment into 0.out. That
will be nothing in the test case that you give. You could read the
first record outside the loop and make sure it's a segment header
before starting the loop so that the 0.out file would be unnecessary.
>I've also tried using:
>if ($_ =~ [A-Za-z0-9])
That probably doesn't do what you intended:
$ perl -we '$_=">";if ($_ =~ [A-Za-z0-9]){}'
Argument "Za" isn't numeric in subtraction (-) at -e line 1.
Argument "A" isn't numeric in subtraction (-) at -e line 1.
Argument "z0" isn't numeric in subtraction (-) at -e line 1.
$
The [] is an anonymous array constructor. Enabling warnings would
have given you a hint.
[snip]
--
Garry Williams
------------------------------
Date: Mon, 26 Feb 2001 04:31:05 GMT
From: insq@yahoo.com (Betastar)
Subject: Re: Problem with Program - can you help?
Message-Id: <3a99db95.50078622@news-server.nc.rr.com>
On 26 Feb 2001 03:23:14 GMT, Thelma Lubkin <thelma@alpha2.csd.uwm.edu>
wrote:
THANK YOU Thelma. Opening the outfiles this way does indeed solve the
problem!
I'm also now looking at the split operator - a friend pointed me at
that one and if I can get it to work, I'll be sure to post that
solution, too!
For Steven, who questions the usefulness of this, what this will do is
let me take a database of 6,626 DNA sequences and parse them into one
sequence per file which will allow me to both insert the sequences
individually into a database as well as use them in another analysis
program which will only take input files with one sequence once at a
time.
I won't go into the long-term larger implications of this for my
research.
Thank you again, Thelma!
Betastar
------------------------------
Date: 26 Feb 2001 02:44:05 GMT
From: ajaman2001@aol.com (Ajaman2001)
Subject: XML parsing for large documents
Message-Id: <20010225214405.04242.00001461@ng-ck1.aol.com>
I am parsing a large XML document ( 50 - 100 MB) using XML::Parser module and
the entire operation takes more than an hour. I am using the "Subs" style for
XML parser. Is there a faster way to process such large XML documents in Perl?
Any pointers would be greatly helpful. Thanks in advance
Ajay
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 355
**************************************