[19763] in Perl-Users-Digest
Perl-Users Digest, Issue: 1958 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 18 14:05:55 2001
Date: Thu, 18 Oct 2001 11:05:10 -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: <1003428310-v10-i1958@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 18 Oct 2001 Volume: 10 Number: 1958
Today's topics:
[NEWBIE] How to work with a FoxPro database with Perl ? <Kevin.Roussel@pharma.u-nancy.fr>
Re: [NEWBIE] How to work with a FoxPro database with Pe <jeff@vpservices.com>
Re: Can't get the output for shell command from CGI (Carfield Yim)
Re: Case-insensitive Command Line Args (Tad McClellan)
Re: charAt??? (John J. Trammell)
how can i make perl retreive a web page and save it to <trullock@yahoo.com>
Re: how can i make perl retreive a web page and save it (Tad McClellan)
Re: how can i make perl retreive a web page and save it <trullock@yahoo.com>
Re: how can i make perl retreive a web page and save it <lmoran@wtsg.com>
Re: IE6 Error - Perl Output <rlally1@nycap.rr.com>
Re: IE6 Error - Perl Output <jeff@vpservices.com>
Re: IE6 Error - Perl Output <comdog@panix.com>
is there an "Instr" in perl like in vb? <trullock@yahoo.com>
Re: is there an "Instr" in perl like in vb? <trullock@yahoo.com>
Re: is there an "Instr" in perl like in vb? <nobody@nowhere.com>
Re: is there an "Instr" in perl like in vb? (Andrew Hutchinson)
Re: is there an "Instr" in perl like in vb? <rich@21cws.com>
Re: Matching & Merging two text files <jeff@vpservices.com>
need ideas for two-way associative array <tzz@beld.net>
need value of struct for system() <bogus@bogus.com>
Re: Objects: Setting defaults and calling themselves?? (Peter Scott)
Re: precedence question <joe+usenet@sunstarsys.com>
Re: Problem with output order (Tad McClellan)
Re: readdir probs??? <Graham.T.Wood@oracle.com>
Regex: extracting repeating values like x=a,b,c,d (EED)
Re: Regex: extracting repeating values like x=a,b,c,d (EED)
Re: Scaling a DNA string <darkon@one.net>
Re: Scaling a DNA string <darkon@one.net>
Re: Scaling a DNA string (Jay Tilton)
Re: Scaling a DNA string (Jay Tilton)
Setting Perl search paths in win32 <llordani@qualcomm.com>
SV: how can i make perl retreive a web page and save it <mostromx32s@x32siname.com>
Re: SV: how can i make perl retreive a web page and sav <comdog@panix.com>
Re: SV: how can i make perl retreive a web page and sav (John J. Trammell)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Oct 2001 15:20:47 GMT
From: Kévin Roussel <Kevin.Roussel@pharma.u-nancy.fr>
Subject: [NEWBIE] How to work with a FoxPro database with Perl ?...
Message-Id: <9qms0f$rll$1@wanadoo.fr>
Hello,
Does anyone over here know how (if it's possible) to work with FoxPro
databases with Perl ?... Every suggestion is welcome.
Thanks and Regards,
KR
==
------------------------------
Date: Thu, 18 Oct 2001 08:29:06 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: [NEWBIE] How to work with a FoxPro database with Perl ?...
Message-Id: <3BCEF542.A89EA81E@vpservices.com>
"Kévin Roussel" wrote:
>
> Hello,
>
> Does anyone over here know how (if it's possible) to work with FoxPro
> databases with Perl ?... Every suggestion is welcome.
Use DBI with DBD::Xbase, both available from ActiveState or CPAN.
BTW, when you have a simple question like this, you can usually find the
anser by looking through the newsgroup archives at google like so:
http://groups.google.com/groups?as_q=foxpro&as_ugroup=comp.lang.perl.misc
--
Jeff
------------------------------
Date: 18 Oct 2001 09:12:44 -0700
From: carfield@programmer.net (Carfield Yim)
Subject: Re: Can't get the output for shell command from CGI
Message-Id: <c40dea5f.0110180812.2fa40744@posting.google.com>
> My goodness that's ugly. There are much better ways of doing that.
>
Thx for reply. Yes, that was ugly, because this script suppost only
know by a few people and as apache run as user apache who can't write
any files in my system. So there should have no security problem even
if the script is ulgy, is that right? or it is common
mis-understanding?
Actually I code java in most of the time but I like perl in some task
when it done tasks quick and clever. However it waste me so much time
so I write a jsp to replace it. Why I still ask the question here
because I am so curious that why the shell command will know my domain
that I haven't pass it to the command.
> > open(IN, $command) || die "cannot open file for reading: $!";
> >
> > while (<IN>) { # read a line from the command into $_
> > print $_; # print that line to file $b
> > }
> > close(IN) || die "can't close file: $!";
>
> When closing a filehandle which is a pipe, you also need to include $?
> in the error message, or examine it for creating an appropriate message.
>
> unless( close(IN) ) {
> my ($sig, $ret) = ($?&255, $?>>8);
> die "java2html died from signal $sig" if $sig;
> die "java2html exited with code $ret" if $ret;
> die "Error closing pipe from java2html $!";
> }
>
Thx
> > The $command can successful run at shell and display the HTML to
> > stdout, however in this CGI I get the following error:
> >
> > /usr/local/bin/java2html: unrecognized option
> > `--code=http://www.carfield.com.hk/java_store/SUN_j2se_runtime_lib_src_1.4/java/lang/String.java'
> > can't close file: at /var/www/cgi-bin/java2html.pl line 14.
> > [Wed Oct 17 00:50:13 2001] [error] [client 10.0.0.1] Premature end of
> > script headers: /var/www/cgi-bin/java2html.pl
> >
> > why will this happen?
>
> Well, the reason for the part in [] about "premature..." is that perl
> buffers STDOUT, so that the error message created by java2html.java was
> printed out before your print "content-type: text/html" got done.
>
Thx, I will call out.flush() in java but I never do similar thing in
perl. But it just done the task before...
> The reason for the earlier part is that you have the --title after you
> redirect the input of the program... which the shell doesn't like.
>
I have some confusion here. Even if I remove --title, I still get that
error. And more important, support the shell doesn't like adding
parameter after redirect. It should reply some error like file not
find or illegel option --title... But now the error is illegel option
--code=http://www.carfield.com.hk/java_store/SUN_j2se_runtime_lib_src_1.4/java/lang/String.java
where it is the whole query string. That should be happen even shell
dont' like it. Can you explain more?
> I would replace your code with the following:
>
> #!/usr/bin/perl -w
> use strict;
> $| = 1; # turn on autoflush. Very important sometimes.
> print "Content-Type: text/html\n\n";
> open( STDIN, "</server/http/java_store/applet/chat/src" .
> "/com/lyrisoft/auth/mysql/Mysql.java" ) or do {
> print "<HTML><HEAD></HEAD><BODY><XMP>\n";
> print "Couldn't open Mysql.java: $!\n";
> print "</XMP></BODY></HTML>\n";
> exit;
> };
> { # extra {} to disable warning "Statement unlikely to be reached"
> exec( qw( /usr/local/bin/java2html
> --title "powered by java2html from gun.org"
> ) );
> }
> print "<HTML><HEAD></HEAD><BODY><XMP>\n";
> print "Exec java2html failed: $!\n";
> print "</XMP></BODY></HTML>\n";
> __END__
>
> This is a much cleaner way to run your program than via open.
> NB: This code is untested.
------------------------------
Date: Thu, 18 Oct 2001 15:33:25 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Case-insensitive Command Line Args
Message-Id: <slrn9stq9e.ord.tadmc@tadmc26.august.net>
Buck Turgidson <jc_va@hotmail.com> wrote:
>I want to be able to enter
>command line args such as "GREP -IL" in upper case
>I tried adding the noted line, but it is ignored.
Your added line is the only line that operates on the
$opt scalar variable. $opt is not related to %opt in
any way, they are in separate namespaces (glob slots).
>Can someone suggest what I should change? I am trying to avoid
>putting lc() on each reference to $opt in the program.
You could process @ARGV before calling getopts(), but that
could get tricky.
>use Getopt::Std;
>my %opt;
>getopts('ivcle:',\%opt);
>$opt = lc($opt); # <----- added this
You should be running with "use strict;" enabled. It would have
immediately pointed out why that line has no effect...
I'd allow either case in the getopts() call, and then patch
up the %opts hash:
----------------------------
#!/usr/bin/perl
use warnings;
use strict;
use Getopt::Std;
my %opt;
getopts('ivcle:IVCLE:',\%opt);
adjust_case(\%opt);
print "$_ ==> $opt{$_}\n" for sort keys %opt;
sub adjust_case {
my($href) = @_;
my @keys = keys %$href; # can't delete() while iterating
foreach my $key ( @keys ) {
if ( $key =~ /^[A-Z]$/ ) {
$href->{lc $key} = $href->{$key};
delete $href->{$key}
}
}
}
----------------------------
Fails horribly if called with switches in _both_ cases though...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Oct 2001 12:44:09 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: charAt???
Message-Id: <slrn9su579.mfv.trammell@haqq.hypersloth.net>
On 18 Oct 2001 14:00:34 GMT, Bernard El-Hagin wrote:
> On Thu, 18 Oct 2001 08:57:58 -0500, John J. Trammell
> <trammell@haqq.hypersloth.invalid> wrote:
> > On 18 Oct 2001 06:48:02 -0700, Markus Dehmann <markus.cl@gmx.de> wrote:
> >> If I want just one char out of a string - do I have to use substr?
> >>
> >> For example, I want the char number 3:
> >> $_ = "Markus";
> >> print substr $_, 3, 1;
> >>
> >> > k
> >>
> >> There is something more efficient, right? I couldn't find something like
> >> print charAt $_, 3
> >> or so! What is it?
> >>
> >
> > sub charAt { return substr($_[0],$_[1],1) }
>
> How is that more efficient than substr?
>
Who said anything about more efficient? I was responding to "... something
like ... charAt".
Personally, StudlyCaps give me the hives.
------------------------------
Date: Thu, 18 Oct 2001 16:14:16 +0100
From: "']['rull" <trullock@yahoo.com>
Subject: how can i make perl retreive a web page and save it to my website?
Message-Id: <jgCz7.3526$sF.406540@news2-win.server.ntlworld.com>
hi guys, i wonder if someone could give me a pointer, i need to make my
web-based perl script save a webpage from a certian site, onto my website.
basically, im trying to make a script that can retrieve a line of text from
a page, and use it accordingly. the file needs to be saved first.
any ideas how i can go about this?
im absolutely fine when i have got the page saved, its just making perl
fetch it.
is this possible?
thanks
--
']['rull
------------------------------
Date: Thu, 18 Oct 2001 15:47:16 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how can i make perl retreive a web page and save it to my website?
Message-Id: <slrn9strnp.p4l.tadmc@tadmc26.august.net>
']['rull <trullock@yahoo.com> wrote:
>im absolutely fine when i have got the page saved, its just making perl
>fetch it.
>
>is this possible?
Sure:
use LWP::Simple; # part of the libwww bundle on CPAN
my $html_page = get 'http://www.perl.com';
# do stuff with $html_page...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Oct 2001 17:21:45 +0100
From: "']['rull" <trullock@yahoo.com>
Subject: Re: how can i make perl retreive a web page and save it to my website?
Message-Id: <AfDz7.4075$sF.459956@news2-win.server.ntlworld.com>
can i use an array so that i can find each line?
--
']['rull
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9strnp.p4l.tadmc@tadmc26.august.net...
> ']['rull <trullock@yahoo.com> wrote:
>
> >im absolutely fine when i have got the page saved, its just making perl
> >fetch it.
> >
> >is this possible?
>
>
> Sure:
>
> use LWP::Simple; # part of the libwww bundle on CPAN
> my $html_page = get 'http://www.perl.com';
> # do stuff with $html_page...
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Thu, 18 Oct 2001 13:17:12 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: how can i make perl retreive a web page and save it to my website?
Message-Id: <ns2usto888hpgrqkk70techbvif33ldo5o@4ax.com>
On Thu, 18 Oct 2001 16:14:16 +0100, "']['rull" <trullock@yahoo.com>
wrote wonderful things about sparkplugs:
SNIP
>
>im absolutely fine when i have got the page saved, its just making perl
>fetch it.
>
>is this possible?
>
yes
>
this code will do it.
#!/usr/bin/perl -w
use LWP::Simple;
getprint ("http://www.yahoo.com") ;
---
You'll need to get LWP::Simple from CPAN or ActiveState
You might want to run it from the command line like this:
C:\yahoo.pl >>C:\Some\Directory\yahoo.txt
or on *nix
$ perl yahoo.pl >> /home/your/name/yahoo.txt
Amongst the million other things you could do to the above code.
>thanks
sure
--
TMTOWTDI: My way tends to be wrong...
lmoran@wtsg.com
------------------------------
Date: Thu, 18 Oct 2001 16:34:14 GMT
From: "RSL" <rlally1@nycap.rr.com>
Subject: Re: IE6 Error - Perl Output
Message-Id: <awDz7.26086$1%.6866941@typhoon.nyroc.rr.com>
Hi:
This is a Perl Misc. newsgroup, No? Misc. meaning misc. items dealing with
Perl?
My question is very Perl related especially for a MISC newsgroup. The
server apparently has a 404 sitting around in some variable. From within a
Perl script can this variable be changed?
What is so difficult about this question? It is Perl related because I am
using Perl.
Bob
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3BCDB077.8347391C@vpservices.com...
> RSL wrote:
> >
> > How much more on topic can this be?
> > My question is can I change the error
> > code from one value (say 404) to another from a Perl script?
>
> Yes you can change the value in Perl, just print a different value. The
> question then becomes what value should you print and what impact will
> that new value have. Those questions have nothing to do with Perl. The
> number 404 has absolutely no special significance in Perl while it does
> in CGI and HTTP so it's in newsgroups and documentation on those issues
> you should be seeking.
>
> > Not a VB
> > script or any other type of script but a Perl script.
>
> Please take a minute to think about your logic here. You are saying
> that because X is printed using perl, that therefore X is on topic to a
> perl newsgroup. What if X is a dictionary of Ancient Greek? Is Ancient
> Greek therefore on topic in a perl newsgroup?
>
> We aren't telling you this to be rude, it would not be a favor to you to
> make you think that you can understand CGI and HTTP by learning Perl.
> If you want to understand CGI and HTTP, you need to learn them and
> learning Perl syntax won't help you do that.
>
> --
> Jeff
>
------------------------------
Date: Thu, 18 Oct 2001 09:51:00 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: IE6 Error - Perl Output
Message-Id: <3BCF0874.4D7E7479@vpservices.com>
RSL wrote:
>
> My question is very Perl related especially for a MISC newsgroup. The
> server
SEVER, SEVER, SEVER. That is not a *perl* server, but a *web* (httpd)
server which has nothing to do with perl.
> apparently has a 404
404, 404, 404. That is a server/browser related code having nothing to
do with perl.
> sitting around in some variable.
No it is not sitting around in some variable. That is your problem --
you think that because the script is written in perl that perl variables
contain the answer to your problem. They don't. In the question you
are asking about, perl is only an intermediary that passes along
information to a webserver. You need to find out how webservers work to
know what information to pass it. Perl can not tell you that.
> It is Perl related because I am using Perl.
My gosh you are dense. No it is not Perl related simply because you are
using perl. If that were true then the topic of this newsgroup would be
biology and mathematics and Greek and all of the other things you can do
with perl.
--
Jeff
------------------------------
Date: Thu, 18 Oct 2001 13:25:19 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: IE6 Error - Perl Output
Message-Id: <comdog-F7B46A.13251918102001@news.panix.com>
In article <awDz7.26086$1%.6866941@typhoon.nyroc.rr.com>, "RSL"
<rlally1@nycap.rr.com> wrote:
> This is a Perl Misc. newsgroup, No? Misc. meaning misc. items dealing with
> Perl?
misc meaning things not appropriate in other forums.
> My question is very Perl related especially for a MISC newsgroup.
it's not at all Perl related since the solution is the same
regardless of the language used. your question was about HTTP.
comp.infosystems.www.authoring.cgi is the forum that you want.
--
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: Thu, 18 Oct 2001 17:35:37 +0100
From: "Scup" <trullock@yahoo.com>
Subject: is there an "Instr" in perl like in vb?
Message-Id: <zsDz7.4216$sF.472742@news2-win.server.ntlworld.com>
im trying to extract any comment withing a txt file that has <quote>
</quote> either side of it.
is there something like Instr (like vb) that i can use to find them and
hence extract the comment in between?
ta
Scup
------------------------------
Date: Thu, 18 Oct 2001 17:58:34 +0100
From: "Scup" <trullock@yahoo.com>
Subject: Re: is there an "Instr" in perl like in vb?
Message-Id: <4ODz7.4490$sF.496610@news2-win.server.ntlworld.com>
index() is what i want isnt it?
scup
"Scup" <trullock@yahoo.com> wrote in message
news:zsDz7.4216$sF.472742@news2-win.server.ntlworld.com...
> im trying to extract any comment withing a txt file that has <quote>
> </quote> either side of it.
>
> is there something like Instr (like vb) that i can use to find them and
> hence extract the comment in between?
>
>
> ta
>
> Scup
>
>
>
>
>
>
------------------------------
Date: Fri, 19 Oct 2001 03:23:59 +1000
From: "Gregory Toomey" <nobody@nowhere.com>
Subject: Re: is there an "Instr" in perl like in vb?
Message-Id: <scEz7.10882$e5.110956@newsfeeds.bigpond.com>
"Scup" <trullock@yahoo.com> wrote in message
news:4ODz7.4490$sF.496610@news2-win.server.ntlworld.com...
> index() is what i want isnt it?
>
> scup
Yes, but remember people put comments and whitespace in places you might not
expect.
gtoomey
------------------------------
Date: Thu, 18 Oct 2001 17:33:55 GMT
From: andrew.hutchinson@mcmail.vanderbilt.edu (Andrew Hutchinson)
Subject: Re: is there an "Instr" in perl like in vb?
Message-Id: <3bcf0fc3.505463718@news.vanderbilt.edu>
There is something similar - you could use index to find the
occurrances, and then use the offsets to pull the text inbetween.
However, that would be the hard-vb-ish way to do this. In Perl, you
can just use a regular expression to grab these.
On Thu, 18 Oct 2001 17:58:34 +0100, "Scup" <trullock@yahoo.com> wrote:
>index() is what i want isnt it?
>
>
>
>scup
>
>
>"Scup" <trullock@yahoo.com> wrote in message
>news:zsDz7.4216$sF.472742@news2-win.server.ntlworld.com...
>> im trying to extract any comment withing a txt file that has <quote>
>> </quote> either side of it.
>>
>> is there something like Instr (like vb) that i can use to find them and
>> hence extract the comment in between?
>>
>>
>> ta
>>
>> Scup
>>
>>
>>
>>
>>
>>
>
>
------------------------------
Date: Thu, 18 Oct 2001 12:44:11 -0500
From: "RH" <rich@21cws.com>
Subject: Re: is there an "Instr" in perl like in vb?
Message-Id: <CpEz7.7347$K8.597814@e3500-atl1.usenetserver.com>
"Scup" <trullock@yahoo.com> wrote in message
news:zsDz7.4216$sF.472742@news2-win.server.ntlworld.com...
> im trying to extract any comment withing a txt file that has <quote>
> </quote> either side of it.
>
> is there something like Instr (like vb) that i can use to find them and
> hence extract the comment in between?
>
>
> ta
>
> Scup
You can use a simple regular expression.
my $txt = q|some text <quote>quote 1</quote> some more text <quote>quote
2</quote> some text <quote>quote 3</quote> some more text|;
my @quotes = ($txt =~ /<quote>(.+?)<\/quote>/sg);
print join("\n", @quotes);
Rich
------------------------------
Date: Thu, 18 Oct 2001 08:19:44 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Matching & Merging two text files
Message-Id: <3BCEF310.DAEBFEE1@vpservices.com>
Lou Moran wrote:
> I am not a Database kind of guy BUT I have used various DBI modules
> (mostly MySQL... hmmm idea forming) I will go get DBD::AnyData right
> now. I would like to see what the code would look like.
>
> Thank you I appreciate it!
If your files have the field names on the top row and the column names
are valid SQL names (e.g. use underscore instead of a space on
Last_Name), then this is all you have to do in order to get a third file
that joins the first two on the Last_Name field:
use DBI;
my $dbh=DBI->connect('dbi:AnyData:');
$dbh->func('merged','CSV',$file1,'ad_import');
$dbh->func('merged','CSV',$file2,'r',{key=>'Last_Name'},'ad_import');
$dbh->func('merged','CSV',$file3,'ad_export');
__END__
If your field names are not on the top line or not valid SQL names, you
can manually supply them, see the docs on column names.
--
Jeff
------------------------------
Date: Thu, 18 Oct 2001 13:28:18 -0400
From: Ted Zlatanov <tzz@beld.net>
Subject: need ideas for two-way associative array
Message-Id: <m34rowc0y5.fsf@heechee.beld.net>
There's no such beast in CPAN AFAIK, so I decided to check with the
newsgroup.
Basically, I need to associate two lists with a many-to-many
relationship. If the lists are A and B, we need to associate A1 with
B1, B2, and B3, and A2 with B3 and B1.
A1 -> { B1, B2, B3 }
A2 -> { B1, B3 }
This is easy to do with hashes. But what if I want to know what the
associations of B1 (A1 and A2) are? I have to generate them on the
fly from the associations in the A list, or I have to keep two
separate hashes and keep them synchronized. The first way is
inefficient, the second way creates a lot of extra work.
Is there a built-in or CPAN module for Perl that can do this
automatically, basically keeping the two associative lists
synchronized behind the curtain? I hate reinventing the wheel.
Thanks
Ted
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Thu, 18 Oct 2001 12:49:02 -0500
From: MJ <bogus@bogus.com>
Subject: need value of struct for system()
Message-Id: <3BCF160E.21F223DB@bogus.com>
I have a structure:
struct vc_struct => {
vm1 => '$',
};
How do I refer vm1 to do a system call?
I try:
if ( system("rcp $RCCVAR/$vc->vm1 $system1:$RCCVAR/$vc->vm1") ) {
# code to print error
return 1;
}
But I get an error:
sh: syntax error at line 1: `(' unexpected
ERROR: Failure to execute rcp /opt/RCC/default/var/vc_struct=HASH(0x133e3c)->vm1
sunny8f:/opt/RCC/default/var/vc_struct=HASH(0x133e3c)->vm1
I tried $RCCVAR/${$vc->vm1}, bud it didn't work.
Any suggestions?
MJ
------------------------------
Date: Thu, 18 Oct 2001 17:00:37 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Objects: Setting defaults and calling themselves??
Message-Id: <VUDz7.6310$Gh2.2201832@news2.rdc1.bc.home.com>
In article <u9u1wyoy5z.fsf@wcl-l.bham.ac.uk>,
nobull@mail.com writes:
>peter@PSDT.com (Peter Scott) writes:
>
>> In article <86669fd63w.fsf@jon_ericson.jpl.nasa.gov>,
>> Jon Ericson <Jon.Ericson@jpl.nasa.gov> writes:
>> >Ed Kulis <ekulis@apple.com> writes:
>> >
>> >> use lib ".";
>
>> Not to mention that it is in @INC by default unless you're root...
>
>Yes, it would be good not to mention that. Mostly because it's not
>(in general) true.
Eh? I've examined builds of Perl 4.018, 5.004, 5.005, and 5.6.1 on Solaris and
Linux, and every one of them has . at the end of @INC on startup. And none of
them were built with any non-default answers to Configure with respect to @INC.
perlvar says:
@INC
The array @INC contains the list of places that the do EXPR,
require, or use constructs look for their library files. It initially
consists of the arguments to any -I command-line switches,
followed by the default Perl library, probably /usr/local/lib/perl,
followed by ``.'', to represent the current directory.
So what do you mean by "it's not (in general) true"?
--
Peter Scott
http://www.perldebugged.com
------------------------------
Date: 18 Oct 2001 13:20:37 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: precedence question
Message-Id: <m3y9m8amqi.fsf@mumonkan.sunstarsys.com>
tadmc@augustmail.com (Tad McClellan) writes:
> Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>
> >Where exactly in the Perl documentation does it say that the RHS
> >of an assignment always gets _fully evaluated_ *before* the LHS does?
>
> Eureka!
>
> perltrap.pod:
>
> "LHS vs. RHS of any assignment operator. LHS is evaluated first
> in perl4, second in perl5"
Unfortunately most assignment operators mix LHS with RHS, so that's
not a particularly helpful statement. Also consider this:
% perl -wle '${\(++$a)} = ++$a + 0; print $a'
1
% perl -wle '${\(++$a)} = ++$a ; print $a'
2
While it's true that in both cases perl evaluates the RHS before the LHS,
it's also true that the resulting scalar (from the RHS) is still subject
to side-effects arising from the evaluation on the LHS. IMO trying to
say this is behavior is actually a language feature rather than an
implementation arfifact is a mistake.
--
Joe Schaefer
perl -wle '$,=" ";{ my @x;sub x {if(@_){push @x,@_; return sub{push @x,@_;@x}}
sub{push @x,@_;@x}}
} print x ("Just")->("another"), x -> ("perl","hacker,")'
------------------------------
Date: Thu, 18 Oct 2001 15:33:23 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem with output order
Message-Id: <slrn9stom8.ord.tadmc@tadmc26.august.net>
Thomas Bätzler <Thomas@Baetzler.de> wrote:
>You could try to unbuffer STDOUT by doing "$| = 1;".
^^
^^
STDOUT will _still be buffered_ after doing that (but the buffer
will be flushed a lot more often).
$| controls "autoflushing", not "buffering".
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 18 Oct 2001 16:36:56 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: readdir probs???
Message-Id: <3BCEF718.FA7CEC8E@oracle.com>
This is a multi-part message in MIME format.
--------------067732EA385AF235ACD0028C
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Bruno Boettcher wrote:
> hello,
> i have the following:
> if(open(THISDIR,'/home/bboett/test/'))
Shouldn't that be "opendir" to open a directory handle rather than "open"
to open a file handle?
Graham
>
> {
> my @dirlist = readdir(THISDIR);
> print "error: $!\n";
> print "openend list: '@dirlist'\n";
> foreach my $filename (@dirlist)
> {
> print "processing $filename\n";
> }
> }
>
> the dir exists, i can make an 'ls' on it, and the opendir runs fine
> (means reports no error...) but the readdir gives me:
>
> error: Bad file descriptor
> i nearly cut&pasted this example from the perl doc, so i don't
> understand what's going wrong....
>
> and as expected @dirlist is empty....
> --
> ciao bboett
> ==============================================================
> bboett@earthling.net
> http://inforezo.u-strasbg.fr/~bboett http://erm1.u-strasbg.fr/~bboett
--------------067732EA385AF235ACD0028C
Content-Type: text/x-vcard; charset=UTF-8;
name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
filename="Graham.T.Wood.vcf"
begin:vcard
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard
--------------067732EA385AF235ACD0028C--
------------------------------
Date: Thu, 18 Oct 2001 18:10:21 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Regex: extracting repeating values like x=a,b,c,d
Message-Id: <3BCEFEED.FBA8BCF@eed.ericsson.se>
Hi,
everyone on c.l.p.m. loves regex problems, right? :-)
I'm trying to extract the hex addresses from strings like this:
PCORR:BLOCK=V5CCH,IA=H'22EF&H'2354&H'4BD4&H'4C4B&H'4D52&H'4DC9;
with this piece of code:
push @addr, hex $1 while /(?:\bI[AS]=|\G&)H'([0-9A-F]{1,4})/g;
for my $addr (@addr)
{
printf "H'%04X\n", $addr;
}
But unfortunately it doesn't work and stucks into an infinite loop
already at the first line:
PCORR:IA=H'040B,BLOCK=APFPI;
Probably because the IA= matches the same spot again and again.
To fix that I could probably remove the \G in the above regex:
/(?:\bI[AS]=|&)H'([0-9A-F]{1,4})/g
But then it would also match "lonely" strings like BLAH&H'4BD4
also when they are not prepended by the assignment IA=...
I wonder if there are some nice ways to solve this problem or
should I construct some (?<=IA=...) monster? Thank you in advance
Regards
Alex
------------------------------
Date: Thu, 18 Oct 2001 18:39:22 +0200
From: "Alexander Farber (EED)" <eedalf@eed.ericsson.se>
Subject: Re: Regex: extracting repeating values like x=a,b,c,d
Message-Id: <3BCF05BA.51159334@eed.ericsson.se>
Or to rephrase the question, why does this:
perl -e 'print $1 while "x=a,b,c,d" =~ /(?:x=|\G,)(\w)/g'
prints:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa^C
but this:
perl -e 'print $1 while "x=a,b,c,d" =~ /(?:x=|,)(\w)/g'
prints:
abcd
------------------------------
Date: Thu, 18 Oct 2001 15:39:44 -0000
From: David Wall <darkon@one.net>
Subject: Re: Scaling a DNA string
Message-Id: <Xns913E766299773darkononenet@207.126.101.97>
mgjv@tradingpost.com.au (Martien Verbruggen) wrote on 18 Oct 2001:
> On Wed, 17 Oct 2001 22:52:57 -0400,
> DocDodge <DocDodge@hotmail.com> wrote:
>
>> As you may know, the DNA which codes for all the instructions of life
>> is simply a string composed of the four characters A, C, G, or T. We
>> have experimental evidence that suggests that a motif composed of
>> four G's or four C's in a row might have implications for how some
>> genes are regulated. But, it would matter how close these motifs are
>> to the genes they are suppose to control.
[snip]
>> So, I grabbed 2000 characters from nearby an important gene and
>> stored it in a string. Here is what part of that might look like:
>>
>> ...ACGACGTCCAGGGGGGTTGTTACGTCCCCAATCAGTCGGGGCTATTCAGTC...
>
[snip]
> What about coming up with a totally different encoding scheme? One
> that simply tells you how many repeats it's seen? Your string would be
> encoded as
>
> -10G6-9C4-8G4-10
>
> or maybe
>
> -10 G6 -9 C4 -8 G4 -10
This works, I guess, but it's visually cluttered and hard to tell what's
happening at a glance. Why not just replace everything but the motifs of
interest with spaces, and then print them with a ruler over them so you
can get their distance from the beginning of the sequence? What I have in
mind is the following. $seq contains the gene sequence of interest.
my $bases_per_line = 50;
my $num_rulers = $bases_per_line / 10;
$seq =~ s/(G{4,})/lc $1/ge;
$seq =~ s/(C{4,})/lc $1/ge;
$seq =~ tr/AGCT/ /;
$seq = uc $seq;
my $ruler = '----+----';
my $count=0;
while ( $seq =~ /(.{$bases_per_line})/g ) {
print ' 'x5;
my $ruler_start = $count;
for (1 .. $num_rulers) {
$count += 10;
print $ruler, $_;
}
printf "\n%4d %s\n", $ruler_start, $1;
}
Some sample output:
----+----1----+----2----+----3----+----4----+----5
0 GGGGG CCCCCC GGGG
----+----1----+----2----+----3----+----4----+----5
50 GGGG
----+----1----+----2----+----3----+----4----+----5
100 CCCC
IMHO this is much easier to understand, although it uses a lot of
screen/page space. (It's not an original idea with me; I saw something
similar in some gene sequencing data when I was working as a research
assistant for a biostats professor.)
Oh, I almost forgot; the above requires a non-proportional font, so if
for some strange reason you're reading this newsgroup in a proportional
font (why?), it won't look right.
--
David Wall
darkon@one.net
------------------------------
Date: Thu, 18 Oct 2001 15:56:48 -0000
From: David Wall <darkon@one.net>
Subject: Re: Scaling a DNA string
Message-Id: <Xns913E79470CB2Adarkononenet@207.126.101.97>
David Wall <darkon@one.net> wrote on 18 Oct 2001:
>
> my $bases_per_line = 50;
> my $num_rulers = $bases_per_line / 10;
Oops. I guess it's obvious, but I only coded this for $bases_per_line to
be multiples of 10. I'm sure it could be made more general, but 10's were
easiest, and perhaps best.
--
David Wall
darkon@one.net
------------------------------
Date: Thu, 18 Oct 2001 17:08:43 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Scaling a DNA string
Message-Id: <3bcefcc2.445725301@news.erols.com>
On Thu, 18 Oct 2001 08:37:36 -0400, "DocDodge"
<DocDodge@hotmail.com> wrote:
>"Jay Tilton" <tiltonj@erols.com> wrote in message
>news:3bce660d.407138606@news.erols.com...
>> Summarizing the apparent key points,
>> 1. Sequences of four G's or four C's in the string are important.
>> 2. Condense sequences of -'s in the string.
>> 3. Chewing on the string in 10-character chunks is not working well
>> because a single motif may cross the boundary between chunks.
>>
>> How about crunching four or more G's or C's down to one,
>> $sequence =~ s/([GC])\1{3,}/$1/g;
>> then crunching multiple -'s down to one, so the motifs are visually
>> separate.
>> $sequence =~ s/(-)+/$1/g;
>>
>> What should happen where there are three or fewer C's or G's in a row?
>> Keep them, discard them, or some other notation indicating "something there,
>> but not what I'm really looking for"?
>
>Thanks for your quick response. I'll answer your last question first. If
>there are three or fewer C's or G's in a row they can be ignore (replaced
>with -'s).
>
>The problem with crunching four or more G's or C's down to one and then
>crunching multiple -'s down to one is that the string would not be evenly
>scaled. What I need to know is not only how many motifs are in the
>sequence, but were they are in relation to each other and to the ends of the
>string.
>Your answer does give me an idea though. If I scale by 2, i.e.. replace
>all --'s with a single dash and all GG or CC with a single G or C I won't
>have the problem of a motif crossing a boundary. I could then repeat this
>two more times, leaving a string of length 125. This might be small enough
>for my purposes. The only glitch now, is how to tell GGGGGG that scaled to
>G or GGGGGGGG (two motifs) that also scales to G.
I see better now. I completely missed that the scaling factor
should be constant. Adding a couple more things to the list of
requirements above,
4. Sequences of three or fewer C's or G's can be ignored.
5. A single character in the output string will represent
(roughly) X characters in the input.
See how this grabs you.
Change chains of four G/C to a single lowercase g/c, because
those are what's important and to prevent pulverizing them in the
next step
$sequence =~ s/([GC])\1{3}/lc $1/eg;
Because G/C in the remaining string only exist in chains of three
or fewer, which can be ignored, change any remaining G/C into -
$sequence =~ tr/GC/--/;
Scale chains of -'s down by a constant factor, say 8.
1 to 8 become 1, 9 to 16 become 2, etc.
my $scale = 8; # In case you want to play with it
$sequence =~ s!(-+)!'-' x (.9 + length($1)/$scale)!eg;
^^^^^
Nuke the ".9 +" part if you want to scale 1 to 8 down to 0, 9 to
16 to 1, etc.
And if it's important, make G/C uppercase again.
$sequence = uc $sequence;
It won't give an exact 1:X scaling. You can't tell exactly where
things are in the original string by looking at the result, but
you can at least gauge approximate location.
------------------------------
Date: Thu, 18 Oct 2001 17:21:45 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Scaling a DNA string
Message-Id: <3bcf0fa5.450561281@news.erols.com>
On Thu, 18 Oct 2001 17:08:43 GMT, tiltonj@erols.com (Jay Tilton)
wrote:
>Scale chains of -'s down by a constant factor, say 8.
>1 to 8 become 1, 9 to 16 become 2, etc.
> my $scale = 8; # In case you want to play with it
> $sequence =~ s!(-+)!'-' x (.9 + length($1)/$scale)!eg;
That's real damn ugly and silly. If I'd thought just a bit
longer before posting I would have said
$sequence =~ s/-{1,$scale}/-/g;
------------------------------
Date: Thu, 18 Oct 2001 09:30:22 -0700
From: "Lawrence Lordanich" <llordani@qualcomm.com>
Subject: Setting Perl search paths in win32
Message-Id: <9qn02n$483$1@coset.qualcomm.com>
I think I know enough now to form a more to the point question:
How do I setup a search path for Perl .pl programs that I can run within my
.pl scripts without an absolute path?
I am confused between using the PATH variable and perl -S <prog.pl> switch
and setting the @INC and PERL5LIB variables and using just perl <prog.pl>.
I could use some advice here for accessing both .pm and .pl files.
Thanks,
Lawrence.
------------------------------
Date: Thu, 18 Oct 2001 18:16:28 +0200
From: "Mr. Mostrom" <mostromx32s@x32siname.com>
Subject: SV: how can i make perl retreive a web page and save it to my website?
Message-Id: <8eDz7.5272$Ad3.17524@nntpserver.swip.net>
> Sure:
>
> use LWP::Simple; # part of the libwww bundle on CPAN
> my $html_page = get 'http://www.perl.com';
> # do stuff with $html_page...
This is why I like Perl! Its so nice one could cry! :-)
Cheers,
Efraim
------------------------------
Date: Thu, 18 Oct 2001 13:28:26 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: SV: how can i make perl retreive a web page and save it to my website?
Message-Id: <comdog-1D8803.13282618102001@news.panix.com>
In article <8eDz7.5272$Ad3.17524@nntpserver.swip.net>, "Mr. Mostrom"
<mostromx32s@x32siname.com> wrote:
> > Sure:
> > use LWP::Simple; # part of the libwww bundle on CPAN
> > my $html_page = get 'http://www.perl.com';
> > # do stuff with $html_page...
> This is why I like Perl! Its so nice one could cry! :-)
in all fairness, you could do this with most languages.
this code simply loads a library and uses one of its
functions. the code isn't short because its Perl -- it's
short because everything is hidden behind LWP::Simple. ;)
--
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: Thu, 18 Oct 2001 12:41:26 -0500
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: SV: how can i make perl retreive a web page and save it to my website?
Message-Id: <slrn9su526.mfv.trammell@haqq.hypersloth.net>
On Thu, 18 Oct 2001 18:16:28 +0200, Mr. Mostrom wrote:
> This is why I like Perl! Its so nice one could cry! :-)
>
Sure, it makes me cry all the time.
------------------------------
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 1958
***************************************