[24496] in Perl-Users-Digest
Perl-Users Digest, Issue: 6676 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 10 18:06:02 2004
Date: Thu, 10 Jun 2004 15:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 10 Jun 2004 Volume: 10 Number: 6676
Today's topics:
Re: best way to count the number of rows in a multidime (Jack)
Re: best way to count the number of rows in a multidime <tore@aursand.no>
Re: best way to count the number of rows in a multidime (Anno Siegel)
Re: best way to count the number of rows in a multidime <ittyspam@yahoo.com>
Re: change de current working directory of my session.. <uri.guttman@fmr.com>
Re: Contructing a dir. tree <ittyspam@yahoo.com>
Re: domain user <dwall@fastmail.fm>
Re: domain user <usenet@morrow.me.uk>
Re: domain user (Bill)
Expanding scalar hash element in array ref. (Dmitri Zakharov)
Re: Expanding scalar hash element in array ref. <dwall@fastmail.fm>
Re: Expanding scalar hash element in array ref. <usenet@morrow.me.uk>
Re: Expanding scalar hash element in array ref. <postmaster@castleamber.com>
Extracting Text (Jake Gottlieb)
Re: Extracting Text <ittyspam@yahoo.com>
Re: Extracting Text <noreply@gunnar.cc>
Re: Help me with threads issue ! <vetro@online.no>
How can I capture STDERR and get an exit code? (Jake Cahoon)
Re: How can I capture STDERR and get an exit code? <ittyspam@yahoo.com>
Re: How can I capture STDERR and get an exit code? <ittyspam@yahoo.com>
How to get "perl -V"'s output programmatically? <jkrugman345@yahbitoo.com>
Re: How to get "perl -V"'s output programmatically? <dwall@fastmail.fm>
Re: How to get "perl -V"'s output programmatically? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Jun 2004 10:24:23 -0700
From: jack_posemsky@yahoo.com (Jack)
Subject: Re: best way to count the number of rows in a multidimensional array
Message-Id: <209b7e58.0406100924.59b534b1@posting.google.com>
Paul Lalli <ittyspam@yahoo.com> wrote in message news:<20040601105753.J18263@dishwasher.cs.rpi.edu>...
> On Tue, 1 Jun 2004, Jack wrote:
>
> > Hello,
> >
> > Wondering if anyone knows the best way to count the number of rows in
> > a multidimensional array.
>
>
> In the first place, how are you defining a 'row'? In your own personal
> visualization of a 2d array, do you see the 'rows' as the "inner" arrays,
> or the "outer" array? In other words, given:
>
> my @foo = (1..5);
> my @bar = ('a'..'j');
>
> my @two_d = (\@foo, \@bar);
>
> what are the 'rows'? @foo and @bar? or @two_d?
>
> In either case, to answer your question, you should never 'count' how many
> elements a perl array has. You should just have perl tell you straight
> out. Evaluating an array in scalar context gives the size of that array:
>
> print "Size of numbers: " . @{$two_d[0]} . "\n";
> print "Size of letters: " . @{$two_d[1]} . "\n";
> print "Size of outer: " . @two_d . "\n";
>
> Paul Lalli
Here is what I am after, here is my 2Darray sorry if it has not been
clear:
['0', '1', '2'],
['3', '4', '5'],
['6', '7', '8']
How do I ask perl to tell me I have 3 horizontal arrays (rows), well 2
if you count 0.... ???
------------------------------
Date: Thu, 10 Jun 2004 20:18:26 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: best way to count the number of rows in a multidimensional array
Message-Id: <pan.2004.06.10.18.18.26.896923@aursand.no>
On Thu, 10 Jun 2004 10:24:23 -0700, Jack wrote:
> Here is what I am after, here is my 2Darray sorry if it has not been
> clear:
>
> ['0', '1', '2'],
> ['3', '4', '5'],
> ['6', '7', '8']
>
> How do I ask perl to tell me I have 3 horizontal arrays (rows), well 2
> if you count 0.... ???
my @array = (
['0', '1', '2'],
['3', '4', '5'],
['6', '7', '8']
);
print 'Number of elements: ' . @array . "\n";
--
Tore Aursand <tore@aursand.no>
"The pure and simple truth is rarely pure and never simple." (Oscar
Wilde)
------------------------------
Date: 10 Jun 2004 18:22:01 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: best way to count the number of rows in a multidimensional array
Message-Id: <caa8s9$eie$2@mamenchi.zrz.TU-Berlin.DE>
Jack <jack_posemsky@yahoo.com> wrote in comp.lang.perl.misc:
[...]
> Here is what I am after, here is my 2Darray sorry if it has not been
> clear:
>
> ['0', '1', '2'],
> ['3', '4', '5'],
> ['6', '7', '8']
>
> How do I ask perl to tell me I have 3 horizontal arrays (rows), well 2
> if you count 0.... ???
"2 if you count 0"? What is that supposed to mean? That the highest
index is 2?
Your question could indeed have been clearer. The answer is trivial.
Each line ("row" is ambiguous) is an arrayref stored in your 2-d array.
So the number of lines in the array is just the number of elements.
Use it in scalar context:
my $n_of_lines = @array;
Anno
------------------------------
Date: Thu, 10 Jun 2004 15:31:51 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: best way to count the number of rows in a multidimensional array
Message-Id: <20040610152554.D8971@dishwasher.cs.rpi.edu>
On Thu, 10 Jun 2004, Jack wrote:
> Paul Lalli <ittyspam@yahoo.com> wrote in message news:<20040601105753.J18263@dishwasher.cs.rpi.edu>...
> > On Tue, 1 Jun 2004, Jack wrote:
> >
> > > Hello,
> > >
> > > Wondering if anyone knows the best way to count the number of rows in
> > > a multidimensional array.
> >
> >
> > In the first place, how are you defining a 'row'? In your own personal
> > visualization of a 2d array, do you see the 'rows' as the "inner" arrays,
> > or the "outer" array? In other words, given:
> >
> > my @foo = (1..5);
> > my @bar = ('a'..'j');
> >
> > my @two_d = (\@foo, \@bar);
> >
> > what are the 'rows'? @foo and @bar? or @two_d?
> >
> > In either case, to answer your question, you should never 'count' how many
> > elements a perl array has. You should just have perl tell you straight
> > out. Evaluating an array in scalar context gives the size of that array:
> >
> > print "Size of numbers: " . @{$two_d[0]} . "\n";
> > print "Size of letters: " . @{$two_d[1]} . "\n";
> > print "Size of outer: " . @two_d . "\n";
> >
> > Paul Lalli
>
> Here is what I am after, here is my 2Darray sorry if it has not been
> clear:
>
> ['0', '1', '2'],
> ['3', '4', '5'],
> ['6', '7', '8']
>
> How do I ask perl to tell me I have 3 horizontal arrays (rows), well 2
> if you count 0.... ???
Out of curiousity, did you actually try the code I listed above? If you
had, you would have seen this output:
Size of numbers: 5
Size of letters: 10
Size of outer: 2
Hopefully you recognized that the code I used generated this structure:
@two_d = (
[1, 2, 3, 4, 5],
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
);
So in your terms, there are two rows. In a more Perl way of speaking,
@two_d contains two array references. Since this is the number you're
trying to get, you just take the size of @two_d, as I demonstrated above:
print "Size of outer: " . @two_d . "\n";
Is there anything about this you don't understand? Is there something I
can be more clear on?
Paul Lalli
------------------------------
Date: Wed, 09 Jun 2004 17:45:51 -0400
From: Uri Guttman <uri.guttman@fmr.com>
Subject: Re: change de current working directory of my session...
Message-Id: <liekoowgkw.fsf@fmr.com>
>>>>> "b" == bxb7668 <bxb7668@somewhere.nocom> writes:
b> Running the script with a "dot space" before it causes it to run in
b> the current shell. In other words:
b> . ./perl_script
where did you get that strange notion? perl is not shell and that runs
shell code in the current shell. how could a shell run perl code inside
itself?
uri
------------------------------
Date: Thu, 10 Jun 2004 11:17:32 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Contructing a dir. tree
Message-Id: <20040610110737.J8971@dishwasher.cs.rpi.edu>
On Thu, 10 Jun 2004, JR wrote:
> Paul Lalli <ittyspam@yahoo.com> wrote in message news:<20040609153546.J8971@dishwasher.cs.rpi.edu>...
> > On Wed, 9 Jun 2004, JR wrote:
> >
> > > my $info = undef;
> >
> > That's a completely worthless initialization.
> > my $info;
> > does the same thing.
>
> I know it does. It doesn't hurt anything either, to set it to undef;
> in fact, it makes is completely clear to even the novice programmer
> that it is, in fact, undefined.
I respectfully disagree. The 'hurt' this can cause is to lead a novice
Perl programmer to think that variables must be initialized, that they are
not undef by nature.
> > > my $count = 0;
> >
> > That's an almost-completely worthless initialization
> > my $count;
>
> I know dude. The reason I set it to zero is for the same reason I set
> $info to undef. Christ!
And now you seem to be getting upset without cause. If you are not
willing to have your programs critiqued, allow me to suggest this is
perhaps not the best forum for you to post your programs, whether they are
originals or solutions to another poster's problems.
Again, while *you* may know the initialization is not needed, a novice
programmer may not. Especially one who comes from a C background where
the initialization is needed. That is why I sent my post, for the
learners. Not every reply to your message is intended soley for you.
Welcome to usenet.
> > > $info = qq|Parent Folder: $_\n{\n Some text here about "$arr[0]"\n|;
> > > $info .= qq| Child Folder: bar1\n|;
> > > $info .= qq| {\n|;
> > >
> > > my $indent = 6;
> > > $info .= qq|\nFile element: Some text about "$arr[$#arr]"\n|;
> > > $info .= "=" x 39, "\n";
> > > print $info;
> >
> > I'm not at all clear as to why you're building up this (potentially huge)
>
> Potentially huge? I wonder just how huge a directory path is likely
> to be. Hmm, now I'm nitpicking just the way you have been. Sorry
> about that.
Do you have any idea what the OP meant by "Some text here"? For all we
know, he could be printing the Gutenberg Bible for every directory level.
So yes, I think "potentially huge" is a valid description.
> > scalar to be printed only once at the end. Why are you not just printing
> > each line of text as it comes? Can you explain what benefit is to be
> > gained by storing all this text in memory before printing?
> >
> > Paul Lalli
>
> The o/p used an array to capture the information; I used a scalar.
> Perhaps he needs to use the scalar or array, whichever, later in the
> program. I realize he could just print the thing, instead of storing
> it and then printing it! I'm just throwing out a script to the o/p
> that he can either use or not, one that resebmles to some degree his
> original script.
My comments were not about the OP's post, nor about how well your post
answered his question. I was simply wondering if there was any reason you
made the design decision of storing all text in memory before printing it.
There is no sarcasm in that sentence, btw. I am always willing to believe
there are reasons for things I don't understand - this was a case of my
asking if you had such a reason.
> Rather than lambaste my script, why don't you show us what you have,
> in the way of a solution? That would be a far more useful way for you
> to spend your time. You are clearly a vastly superior programmer, so
> put your talents to use.
Again, welcome to usenet. I was not 'lambasting' your script, I was
critiquing it and asking for further explanation. This is a community.
The community is best served when many people make their comments and
opinions known. The idea that any solution posted should just be left out
in the world without any critiques is a poor one at best. Code should be
critiqued and evaluated no matter where it comes from, nor why. That is
how to best serve both the OP as well as any one else reading who may have
similar questions.
Paul Lalli
------------------------------
Date: Thu, 10 Jun 2004 15:39:55 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: domain user
Message-Id: <Xns950476AA47641dkwwashere@216.168.3.30>
louis <louisccc@hotmail.com> wrote:
> I've created an application in Perl but I have to build some
> security in it. The application runs on a Linux-server with apache
> as web-server. The Linux-server operates in an NT4-domain. The
> application is only vailable for internal use (not on internet).
> When the user starts his PC, he has to log on to the domain to get
> the normal netwerk-facilities (mail, netwerkacces, ...)
> Is there a way I can get this username (domain-user) to check who
> is asking a web-page (executing of a perl script on the server).
> so I don't have to ask the user a second time for a username and
> password and I create a single sign-on.
Well, it really doesn't have much to do with Perl per se, but check
out the Windows NBTSTAT command. I know you're running on Linux, but
maybe you could use $ENV{REMOTE_ADDR} to get the IP address, send
that to a Windows server service or CGI program that returns the
userid?
I have to use a Windows machine as a web server, so I just run
NBTSTAT on the same machine and extract the userid from the output;
for example, something like
my $output = `NBTSTAT -A $ENV{REMOTE_ADDR}`;
my $userid;
if ($output =~ /some-regex/ ) {
$userid = $1;
}
else {
# didn't find a userid ...
}
...except that I have it in a module customized for my organization,
because machine names here always include the userid of the primary
user, so I use that as an alternate method.
I don't consider this very dependable, so I only use it to set a
default value in a form. The user can enter their password or stay
out -- after all, someone can always sneak into another person's
office and use their computer if it's left unguarded and unlocked.
------------------------------
Date: Thu, 10 Jun 2004 19:03:08 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: domain user
Message-Id: <caab9c$1kl$1@wisteria.csv.warwick.ac.uk>
Quoth "louis" <louisccc@hotmail.com>:
>
> I've created an application in Perl but I have to build some security in it.
> The application runs on a Linux-server with apache as web-server. The
> Linux-server operates in an NT4-domain. The application is only vailable for
> internal use (not on internet).
> When the user starts his PC, he has to log on to the domain to get the
> normal netwerk-facilities (mail, netwerkacces, ...)
> Is there a way I can get this username (domain-user) to check who is asking
> a web-page (executing of a perl script on the server). so I don't have to
> ask the user a second time for a username and password and I create a single
> sign-on.
See http://modntlm.sourceforge.net/
Ben
--
The cosmos, at best, is like a rubbish heap scattered at random.
- Heraclitus
ben@morrow.me.uk
------------------------------
Date: 10 Jun 2004 12:12:43 -0700
From: wherrera@lynxview.com (Bill)
Subject: Re: domain user
Message-Id: <239ce42f.0406101112.13e9bf21@posting.google.com>
"louis" <louisccc@hotmail.com> wrote in message news:<40c86e2a$0$8993$6c56d894@feed0.news.be.easynet.net>...
> Hi,
>
> I've created an application in Perl but I have to build some security in it.
> The application runs on a Linux-server with apache as web-server. The
> Linux-server operates in an NT4-domain. The application is only vailable for
> internal use (not on internet).
> When the user starts his PC, he has to log on to the domain to get the
> normal netwerk-facilities (mail, netwerkacces, ...)
> Is there a way I can get this username (domain-user) to check who is asking
> a web-page (executing of a perl script on the server). so I don't have to
> ask the user a second time for a username and password and I create a single
> sign-on.
>
There is a security issue here--do you want the user to be giving
arbitrary web servers even part of their internal network logon
information? I doubt it.
I suggest that you create a shared directory on the web server that
can be accessed as a network drive share and have the users access the
pages as drive-based web content, not http content. That way it is
possibly more secure, and the network login should allow the page
views.
Not that this has _anything_ to do with Perl.
------------------------------
Date: 10 Jun 2004 11:37:55 -0700
From: zakd@videotron.ca (Dmitri Zakharov)
Subject: Expanding scalar hash element in array ref.
Message-Id: <a87edfb4.0406101037.19ff9def@posting.google.com>
Hello guys,
Is there any way in Perl to convert scalar hash element value to an
array reference with the original scalar as a first element of the
array. I just
want to convert the following PHP code into Perl:
<?php
while ($buf = fgets($fp, 1024) ) {
// ... parsing code here
if (array_key_exists($var, $conf)) {
if (!is_array($conf[$var])) {
$tmpval = $conf[$var]; // grab original value
$conf[$var] = array(); // convert to array
$conf[$var][] = $tmpval; // store original value as a first
element
}
$conf[$var][] = $val;
} else {
$conf[$var] = $val;
}
// ...
} // end while
?>
The idea here is that some variable can have multiple entries in conf
file, so
I want to store them in a 'bucket' under the same key. But most of the
entries
are simple 'var = value' pair, so I want to have flexibility to
process both.
In Perl there is a way to check for existence of 'key' with exists()
function
(which is equivalent to PHP array_key_exists()). BUT the problem I
encountered
in Perl is to convert the scalar value of the key to array reference.
<perl>
while ( <$fh> ) {
# parsing code here
if ( exists($conf->{$var}) ) {
# ??? There's nothing equivalent to PHP is_array() function in
Perl
# How do I know if value is still a scalar or an already an array
ref
# If I value is already an array ref, I would do
push @{$conf->{$var}}, $val;
} else {
# var encountered for the first time
$conf->{$var} = $val;
}
} # end while
</perl>
Is there anyway to do it? Any suggestion are appreciated
$dmitri--; # ;-)
------------------------------
Date: Thu, 10 Jun 2004 19:00:40 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: Expanding scalar hash element in array ref.
Message-Id: <Xns950498B381183dkwwashere@216.168.3.30>
[comp.lang.perl deleted from Newsgroup header because it doesn't exist]
Dmitri Zakharov <zakd@videotron.ca> wrote:
> Is there any way in Perl to convert scalar hash element value to
> an array reference with the original scalar as a first element of
> the array.
Convert? No, not that I know of. Reassign? Yes.
my %hash;
$hash{foo} = 'bar';
$hash{foo} = [ $hash{foo} ];
------------------------------
Date: Thu, 10 Jun 2004 19:14:49 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Expanding scalar hash element in array ref.
Message-Id: <caabv9$1kl$3@wisteria.csv.warwick.ac.uk>
Quoth zakd@videotron.ca (Dmitri Zakharov):
> Is there any way in Perl to convert scalar hash element value to an
> array reference with the original scalar as a first element of the
> array. I just
> want to convert the following PHP code into Perl:
>
> <?php
>
>
> while ($buf = fgets($fp, 1024) ) {
>
> // ... parsing code here
>
> if (array_key_exists($var, $conf)) {
> if (!is_array($conf[$var])) {
> $tmpval = $conf[$var]; // grab original value
> $conf[$var] = array(); // convert to array
> $conf[$var][] = $tmpval; // store original value as a first
> element
> }
> $conf[$var][] = $val;
> } else {
> $conf[$var] = $val;
> }
> // ...
>
> } // end while
>
> ?>
Presuming that your parsing code ends up with something like
my %var = (
one => 'foo',
two => ['bar', 'baz'],
);
and you want to convert them all to arrayrefs, you can do this:
for (keys %var) {
$var{$_} = [ $var{$_} ] unless ref $var{$_};
}
> <perl>
>
> while ( <$fh> ) {
>
> # parsing code here
>
> if ( exists($conf->{$var}) ) {
> # ??? There's nothing equivalent to PHP is_array() function in
> Perl
> # How do I know if value is still a scalar or an already an array
> ref
perldoc -f ref
Ben
--
Outside of a dog, a book is a man's best friend.
Inside of a dog, it's too dark to read.
ben@morrow.me.uk Groucho Marx
------------------------------
Date: Thu, 10 Jun 2004 14:19:36 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Expanding scalar hash element in array ref.
Message-Id: <40c8b448$0$198$58c7af7e@news.kabelfoon.nl>
Dmitri Zakharov wrote:
> Hello guys,
> Is there any way in Perl to convert scalar hash element value to an
> array reference with the original scalar as a first element of the
> array. I just
> want to convert the following PHP code into Perl:
>
> <?php
>
>
> while ($buf = fgets($fp, 1024) ) {
>
> // ... parsing code here
>
> if (array_key_exists($var, $conf)) {
> if (!is_array($conf[$var])) {
> $tmpval = $conf[$var]; // grab original value
> $conf[$var] = array(); // convert to array
> $conf[$var][] = $tmpval; // store original value as a first
> element
> }
> $conf[$var][] = $val;
> } else {
> $conf[$var] = $val;
> }
> // ...
>
> } // end while
>
> ?>
>
> The idea here is that some variable can have multiple entries in conf
> file, so
> I want to store them in a 'bucket' under the same key. But most of the
> entries
> are simple 'var = value' pair, so I want to have flexibility to
> process both.
>
> In Perl there is a way to check for existence of 'key' with exists()
> function
> (which is equivalent to PHP array_key_exists()). BUT the problem I
> encountered
> in Perl is to convert the scalar value of the key to array reference.
>
> <perl>
>
> while ( <$fh> ) {
>
> # parsing code here
>
> if ( exists($conf->{$var}) ) {
> # ??? There's nothing equivalent to PHP is_array() function in
> Perl
> # How do I know if value is still a scalar or an already an array
> ref
>
> # If I value is already an array ref, I would do
> push @{$conf->{$var}}, $val;
>
>
> } else {
> # var encountered for the first time
> $conf->{$var} = $val;
> }
>
> } # end while
>
> </perl>
>
> Is there anyway to do it? Any suggestion are appreciated
Why not push the value *always*? If there is just one element, it's
single value. You make it yourself hard two times, while storing the
values (you have to check), and when retrieving (another check).
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 10 Jun 2004 09:19:43 -0700
From: jakegottlieb@hotmail.com (Jake Gottlieb)
Subject: Extracting Text
Message-Id: <986e0b6a.0406100819.14848438@posting.google.com>
I am trying to extract lines with:
GO:0009986
out of:
ENSG00000113494.3 AAA60174.1 GO:0009123 5618 216638_s_at
ENSG00000113494.3 AAD32032.1 GO:0009345 5618 216638_s_at
ENSG00000113494.3 AAK32703.1 GO:0009764 5618 216638_s_at
ENSG00000113494.3 AAH59392.1 GO:0009986 5618 216638_s_at
ENSG00000113494.3 AAA60174.1 GO:0009986 206346_at
ENSG00000113494.3 AAD32032.1 GO:0009867 206346_at
ENSG00000113494.3 AAK32703.1 GO:0004567 206346_at
ENSG00000113494.3 AAH59392.1 GO:0000678 206346_at
ENSG00000113494.3 AAA60174.1 GO:0009986 211917_s_at
ENSG00000113494.3 AAD32032.1 GO:0009986 211917_s_at
ENSG00000113494.3 AAK32703.1 GO:0005764 211917_s_at
ENSG00000113494.3 AAH59392.1 GO:0009986 211917_s_at
ENSG00000113494.3 AAA60174.1 GO:0009986 210476_s_at
ENSG00000113494.3 AAD32032.1 GO:0003765 210476_s_at
ENSG00000113494.3 AAK32703.1 GO:0009986 210476_s_at
ENSG00000113494.3 AAH59392.1 GO:0005876 210476_s_at
I have been trying to write a program for it, but can't seem to do it.
If someone could help, I would be very appreciative (I am sure it's
really easy, but Perl is new to me).
Thanks
------------------------------
Date: Thu, 10 Jun 2004 12:23:52 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Extracting Text
Message-Id: <20040610122214.H8971@dishwasher.cs.rpi.edu>
On Thu, 10 Jun 2004, Jake Gottlieb wrote:
> I am trying to extract lines with:
>
> GO:0009986
>
> out of:
>
>
> ENSG00000113494.3 AAA60174.1 GO:0009123 5618 216638_s_at
> ENSG00000113494.3 AAD32032.1 GO:0009345 5618 216638_s_at
> ENSG00000113494.3 AAK32703.1 GO:0009764 5618 216638_s_at
> ENSG00000113494.3 AAH59392.1 GO:0009986 5618 216638_s_at
>
> ENSG00000113494.3 AAA60174.1 GO:0009986 206346_at
> ENSG00000113494.3 AAD32032.1 GO:0009867 206346_at
> ENSG00000113494.3 AAK32703.1 GO:0004567 206346_at
> ENSG00000113494.3 AAH59392.1 GO:0000678 206346_at
>
> ENSG00000113494.3 AAA60174.1 GO:0009986 211917_s_at
> ENSG00000113494.3 AAD32032.1 GO:0009986 211917_s_at
> ENSG00000113494.3 AAK32703.1 GO:0005764 211917_s_at
> ENSG00000113494.3 AAH59392.1 GO:0009986 211917_s_at
>
> ENSG00000113494.3 AAA60174.1 GO:0009986 210476_s_at
> ENSG00000113494.3 AAD32032.1 GO:0003765 210476_s_at
> ENSG00000113494.3 AAK32703.1 GO:0009986 210476_s_at
> ENSG00000113494.3 AAH59392.1 GO:0005876 210476_s_at
>
> I have been trying to write a program for it, but can't seem to do it.
> If someone could help, I would be very appreciative (I am sure it's
> really easy, but Perl is new to me).
Show us what you've written so far, so we can help you to see why it
"doesn't work". You've shown us the input and we can deduce the desired
output. Now show us your code, and what output it gave, so we may see how
it doesn't meet your specifications.
Paul Lalli
------------------------------
Date: Thu, 10 Jun 2004 18:25:31 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Extracting Text
Message-Id: <2irgdrFqh08hU1@uni-berlin.de>
Jake Gottlieb wrote:
> I am trying to extract lines with:
>
> GO:0009986
<snip>
> I have been trying to write a program for it, but can't seem to do
> it. If someone could help, I would be very appreciative (I am sure
> it's really easy, but Perl is new to me).
http://learn.perl.org/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 10 Jun 2004 15:10:22 +0200
From: "Vetle Roeim" <vetro@online.no>
Subject: Re: Help me with threads issue !
Message-Id: <opr9dqvkez3hk3cf@localhost>
On 10 Jun 2004 14:50:40 GMT, <ctcgag@hotmail.com> wrote:
> "Vetle Roeim" <vetro@online.no> wrote:
>> On Thu, 10 Jun 2004 08:41:58 +0000 (UTC), Ben Morrow
>> <usenet@morrow.me.uk> wrote:
>>
>> > I've searched on google (including groups.google.com) for
>> > information
>> >> on threading in Perl, and I'm under the impression that it has
>> >> improved alot lately.
>> >
>> > Perl ithreads now effectively perform a fork in userland, without
>> using
>> > copy-on-write. This has removed the problems with 5005threads, sure,
>> > but it has also removed any point in using threads on an OS which can
>> > fork. The OS will *always* be able to do it faster.
>>
>> I discovered something interesting when testing forks.pm. Parts of my
>> code totally unrelated to the part where I use a thread pool were
>> significantly slower /with/ forks, than without!
>
> Can you expand on the "completely unrelated" part? Do you mean this code
> is run after "use forks" statement, but before any forks are actually
> made?
Yes. There make be some use of threads/forks/whatever that I don't know
of, but the explicit use of threads/forks in _my_ code happens after
the code I benchmarked.
I could try moving the "use forks" statement, though. Hmmmmm...
[...]
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
------------------------------
Date: 10 Jun 2004 12:31:01 -0700
From: jrcahoon@yahoo.com (Jake Cahoon)
Subject: How can I capture STDERR and get an exit code?
Message-Id: <d8f9255f.0406101131.67b4d90a@posting.google.com>
I need to run a system command, find out if it failed and put its
output in a log file. The way I am trying to do it right now is to
get the exit code from the command with system() but then I don't know
how to capture its output. The backticks are the opposite problem. I
can capture the command's output but I don't know what its exit code
is. It just seems like an ugly solution to me to have to pattern
match the command's output just to see if the command executed
successfully.
Anyone have some tips?
Thanks,
J Cahoon
------------------------------
Date: Thu, 10 Jun 2004 15:36:05 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: How can I capture STDERR and get an exit code?
Message-Id: <20040610153506.A8971@dishwasher.cs.rpi.edu>
On Thu, 10 Jun 2004, Jake Cahoon wrote:
> I need to run a system command, find out if it failed and put its
> output in a log file. The way I am trying to do it right now is to
> get the exit code from the command with system() but then I don't know
> how to capture its output. The backticks are the opposite problem. I
> can capture the command's output but I don't know what its exit code
> is. It just seems like an ugly solution to me to have to pattern
> match the command's output just to see if the command executed
> successfully.
>
> Anyone have some tips?
Read perldoc perlvar. Look for the section on the $? variable. Read it
thoroughly. It might not be *quite* what you expect.
Paul Lalli
------------------------------
Date: Thu, 10 Jun 2004 16:04:37 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: How can I capture STDERR and get an exit code?
Message-Id: <20040610160259.H8971@dishwasher.cs.rpi.edu>
On Thu, 10 Jun 2004, Paul Lalli wrote:
> On Thu, 10 Jun 2004, Jake Cahoon wrote:
>
> > I need to run a system command, find out if it failed and put its
> > output in a log file. The way I am trying to do it right now is to
> > get the exit code from the command with system() but then I don't know
> > how to capture its output. The backticks are the opposite problem. I
> > can capture the command's output but I don't know what its exit code
> > is. It just seems like an ugly solution to me to have to pattern
> > match the command's output just to see if the command executed
> > successfully.
> >
> > Anyone have some tips?
>
> Read perldoc perlvar. Look for the section on the $? variable. Read it
> thoroughly. It might not be *quite* what you expect.
>
> Paul Lalli
Re-reading your post, you might be better off or at least aided by reading
the FAQ on this topic:
perldoc -q STDERR
"How can I capture STDERR from an external command?"
Paul Lalli
------------------------------
Date: Thu, 10 Jun 2004 16:10:25 +0000 (UTC)
From: J Krugman <jkrugman345@yahbitoo.com>
Subject: How to get "perl -V"'s output programmatically?
Message-Id: <caa15g$q7s$1@reader2.panix.com>
Is there a better way to get, within a Perl script, the string
generated by "perl -V" than going through sh:
my $perl_V = do { local $/; `perl -V` };
?
My guess is that the answer is no, because
perl -MO=Deparse -V
produces one big mess (I quote it below). Unfortunately, even this
big mess includes some "hard-coded" strings (such as " Build under
linux\n"), which means that even if I wanted it, I cannot turn this
mess into a general utilities library routine.
TIA,
jill
Output of perl -MO=Deparse -V
sub myconfig {
package Config;
return $summary if $summary_expanded;
$summary =~ s/\$(\w+)/my $c = $Config{$1};
defined $c ? $c : 'undef';/eg;
$summary_expanded = 1;
$summary;
}
sub Config::config_re {
package Config;
my $re = shift @_;
my(@matches) = $config_sh =~ /^$re=.*\n/gm;
@matches ? print(@matches) : print("$re: not found\n");
}
sub config_vars {
package Config;
foreach $_ (@_) {
config_re($_), next if /\W/;
my $v = exists $Config{$_} ? $Config{$_} : 'UNKNOWN';
$v = 'undef' unless defined $v;
print "$_='$v';\n";
}
}
print myconfig();
print "\nCharacteristics of this binary (from libperl): \n", " Compile-time options: USE_LARGE_FILES\n", " Built under linux\n", " Compiled at Apr 4 2004 05:57:53\n";
$" = "\n ";
@env = map({qq[$_="$ENV{$_}"];} sort(grep({/^PERL/;} keys %ENV)));
print " %ENV:\n @env\n" if @env;
print " \@INC:\n @INC\n";
--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.
------------------------------
Date: Thu, 10 Jun 2004 17:53:45 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: How to get "perl -V"'s output programmatically?
Message-Id: <Xns95048D5AFADC2dkwwashere@216.168.3.30>
J Krugman <jkrugman345@yahbitoo.com> wrote:
> Is there a better way to get, within a Perl script, the string
> generated by "perl -V" than going through sh:
>
> my $perl_V = do { local $/; `perl -V` };
>
> ?
Um, how about looking at the docs for Config.pm, one of the core
modules? Or am I misunderstanding you?
------------------------------
Date: 10 Jun 2004 18:09:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to get "perl -V"'s output programmatically?
Message-Id: <caa858$eie$1@mamenchi.zrz.TU-Berlin.DE>
J Krugman <jkrugman345@yahbitoo.com> wrote in comp.lang.perl.misc:
>
>
> Is there a better way to get, within a Perl script, the string
> generated by "perl -V" than going through sh:
>
> my $perl_V = do { local $/; `perl -V` };
Why the do-block to undef $/? That is necessary for file slurping, but
backticks always return all the output in a multiline string. So
my $perl_V = `perl -V`;
would do the same thing. But there is indeed a better way:
use Config;
my $perl_V = Config::myconfig();
That reproduces most of the text of "perl -V". There are a few insertions
in "perl -V" that are not in myconfig (probably those you are complaining
about in the part I snipped).
Anno
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6676
***************************************