Re: array question

2006-05-09 Thread Chad Perrin
On Tue, May 09, 2006 at 11:52:26AM -0700, Timothy Johnson wrote: > > As much as I would hate to make you cry, if I had my way, I'd remove > that as well as the default variable $_. It would be like the first > time you had to convert all of your scripts to use the strict pragma, > but in the end

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 14:54 -0700, Bryan R Harris wrote: > Regarding Timothy's thoughts, I tend to believe perl wouldn't be as popular > if the "use strict" pragma defaulted to on. I don't code in C because it's > too hard to get all the little details right. Perl is very forgiving, and > for my

Re: array question

2006-05-09 Thread Bryan R Harris
> On Tue, 2006-09-05 at 11:52 -0700, Timothy Johnson wrote: >> It's the Perl >> equivalent of having to remember 'I before E except after C...'. > > '.. except where it's not.' > > E.g: > height > weight > sex > > (OK, I included 'sex' just to get your attention.) On some platforms:

Re: array question

2006-05-09 Thread Dr.Ruud
"Mr. Shawn H. Corey" schreef: > Dr.Ruud: >> One exception: the pattern / / does not work like the pattern ' '. > > But it should, that's my point. Not for / / vs. ' ', because that is a special case. It is far too late to change the special case to undef or whatever. I like your example that sh

using Perl grep to populate a scalar

2006-05-09 Thread Smith, Derek
All, I am trying to populate a scalar (ideally a hash) using a Perl grep but it is not working. I even tried to use an array and no data was pushed. use strict; use warnings; my @lvs; my @lvaray = qx(bdf); foreach (@lvaray) { if (/(?)vg00/) { push @lvs, (split)[0] } }

Re: Text manipulation

2006-05-09 Thread D. Bolliger
Per Larsson am Dienstag, 9. Mai 2006 17.50: > Thank you, that solved the problem, but only partly I'm afraid. Problem > is that the lines need to be formatted in a certain way, so that one > line looks exactly like this: > ATOM 1 N ALA 1 41.744 64.901 30.842 1.00 47.38 > 2CDV 8

RE: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 11:52 -0700, Timothy Johnson wrote: > It's the Perl > equivalent of having to remember 'I before E except after C...'. '.. except where it's not.' E.g: height weight sex (OK, I included 'sex' just to get your attention.) -- __END__ Just my 0.0002 million dolla

RE: array question

2006-05-09 Thread Timothy Johnson
-Original Message- From: Bryan R Harris [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 09, 2006 11:24 AM To: Beginners Perl Subject: Re: array question >> On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote: >>> One exception: the pattern / / does not work like the pattern ' '. >> >> But it

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 11:23 -0700, Bryan R Harris wrote: > Are you proposing that the special case be removed? If so, PLEASE NO! I > use that special case in almost every script I write, and if they removed it > I would probably shed tears over it. Don't worry; they won't. Well, maybe in Perl6;

Re: array question

2006-05-09 Thread Bryan R Harris
> On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote: >> One exception: the pattern / / does not work like the pattern ' '. > > But it should, that's my point. Are you proposing that the special case be removed? If so, PLEASE NO! I use that special case in almost every script I write, and if t

Re: array question

2006-05-09 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > On Tue, 2006-09-05 at 09:05 -0700, John W. Krahn wrote: >>I don't understand what you are trying to say. > > I saying this should work: > > split '+', 'this+is+a+test'; > > Yes, I know how to fix it. I'm saying it _should_ work, not that it > does. If split is follo

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 09:44 -0700, chen li wrote: > split /PATTERN/,EXPR,LIMIT > split /PATTERN/,EXPR > split /PATTERN/ > split > > 1. I check the perldoc -f split but I am not quite > sure what EXPR really means. Does it refer to a > string, or a scalar variable contaning a string, or an > ar

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 18:33 +0200, Dr.Ruud wrote: > One exception: the pattern / / does not work like the pattern ' '. But it should, that's my point. -- __END__ Just my 0.0002 million dollars worth, --- Shawn "For the things we have to learn before we can do them, we learn by doing t

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 09:05 -0700, John W. Krahn wrote: > I don't understand what you are trying to say. I saying this should work: split '+', 'this+is+a+test'; Yes, I know how to fix it. I'm saying it _should_ work, not that it does. If split is followed by a string, the string should be quot

Re: array question

2006-05-09 Thread John W. Krahn
chen li wrote: > > --- "John W. Krahn" <[EMAIL PROTECTED]> wrote: >> >>$ perl -le' >>my $string = q[ a b c d ]; >>print join "\t", map "<$_>", split q[\s+], >>qq[$string], q[4]; >>print join "\t", map "<$_>", split /\s+/, >>$string,4; >>' >><> >><> >> >

Re: array question

2006-05-09 Thread Dr.Ruud
Mr. Shawn H. Corey" schreef: > John W. Krahn: >> Anything used as a pattern is a string. See the "Quote and >> Quote-like Operators" section of perlop: > > Huh? > > Do you mean all strings can be used as a pattern? > > split( quotemeta( $split_string ), $data_string ); > > > Or that patterns ar

Re: array question

2006-05-09 Thread chen li
--- "John W. Krahn" <[EMAIL PROTECTED]> wrote: > Mr. Shawn H. Corey wrote: > > On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson > wrote: > >>Um, that's not quite correct. > >> > >>See `perldoc -f split` for details. > > > > Oh, yes, a special case. I have long ago abandoned > special cases since

Re: array question

2006-05-09 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > On Tue, 2006-09-05 at 01:30 -0700, John W. Krahn wrote: >>Anything used as a pattern is a string. See the "Quote and Quote-like >>Operators" section of perlop: > > Huh? > > Do you mean all strings can be used as a pattern? A pattern is a string. Perl does string int

Re: array question

2006-05-09 Thread John W. Krahn
M. Kristall wrote: > chen li wrote: I have an arry like this: @arry=('AA bb','BB','CC AG') How do I turn it into new array like this: > TMTOWTDI @new_array=('AA','bb','BB','CC','AG') >>> my @new_array = split ' ', "@arry"; >> >> Both line codes work perfectly: >>

Re: Text manipulation

2006-05-09 Thread Per Larsson
Thank you, that solved the problem, but only partly I'm afraid. Problem is that the lines need to be formatted in a certain way, so that one line looks exactly like this: ATOM 1 N ALA 1 41.744 64.901 30.842 1.00 47.38 2CDV 83 Is there a way to combine the code below w

Re: Text manipulation

2006-05-09 Thread Chas Owens
On 5/9/06, Per Larsson <[EMAIL PROTECTED]> wrote: snip ie. get everything that is sitting between two ATOM-identifiers to occur on the same line. How can I achieve this? As always, TMTOWTDI: You can set the input record separator use strict; use warnings; { local $/ = 'ATOM\n'; <>; #throw awa

Text manipulation

2006-05-09 Thread Per Larsson
Hello, I have a question about doing the following in perl: I have a file (a protein pdb file) thatt, for various (and unchangeable) reasons look like this: ATOM 1 N ALA 1 41.744 64.901 30.842 1.00 47.38 2CDV 83 ATOM 2 CA ALA 1 41.676 63.465 31.165 1.00 47.22 2CDV 84 ...and so on. What I woul

Re: array question

2006-05-09 Thread M. Kristall
chen li wrote: I have an arry like this: @arry=('AA bb','BB','CC AG') How do I turn it into new array like this: TMTOWTDI @new_array=('AA','bb','BB','CC','AG') my @new_array = split ' ', "@arry"; Both line codes work perfectly: my @new_array = map { split } @arry; or my @new_array = spl

Re: array question

2006-05-09 Thread Mr. Shawn H. Corey
On Tue, 2006-09-05 at 01:30 -0700, John W. Krahn wrote: > Anything used as a pattern is a string. See the "Quote and Quote-like > Operators" section of perlop: Huh? Do you mean all strings can be used as a pattern? split( quotemeta( $split_string ), $data_string ); Or that patterns are buil

Re: module for killing?

2006-05-09 Thread Jorge Almeida
On Tue, 9 May 2006, zentara wrote: On Tue, 9 May 2006 09:57:29 +0100 (WEST), [EMAIL PROTECTED] (Jorge Almeida) wrote: Is there any Perl module to find and kill unix processes (pgrep, kill, pkill...). I need to kill all processes descending from a given process (children, grandchildren, etc). S

module for killing?

2006-05-09 Thread Jorge Almeida
Is there any Perl module to find and kill unix processes (pgrep, kill, pkill...). I need to kill all processes descending from a given process (children, grandchildren, etc). Surprisingly, it seems there isn't a unix utility for this, so I thought to make a Perl script, but using system seems clum

Re: regex..gah

2006-05-09 Thread Dr.Ruud
"Dan" schreef: Please don't top-post. > "name" <[EMAIL PROTECTED]> > the question was pertaining to get 'name' out of "name" at the start, > and the email address out of the <<>> brackets. however i managed to > figure that one out by playing. Don't play but use Regexp::Common::Email::Address h

Re: array question

2006-05-09 Thread John W. Krahn
Mr. Shawn H. Corey wrote: > On Tue, 2006-09-05 at 01:33 +0200, Paul Johnson wrote: >>Um, that's not quite correct. >> >>See `perldoc -f split` for details. > > Oh, yes, a special case. I have long ago abandoned special cases since > they lead to errors. Note that `perldoc -f split` starts with: >

Re: require or use

2006-05-09 Thread Gopal Krishnan
Hi, require $file is like do $file, except the former: checks for redundant loading, skipping already loaded files. raises an exception on failure to find, compile, or execute $file. use Module is like require Module, except the former: loads the module at compile time, n

Re: require or use

2006-05-09 Thread Paul Johnson
On Tue, May 09, 2006 at 03:16:45PM +0800, Practical Perl wrote: > Could anyone tell me what's the difference between 'use' and 'require'? > And,is there any difference for these two statements? > > use Exporter (); > require Exporter; I think that "perldoc -f use" should tell you everything you

Re: regex..gah

2006-05-09 Thread Dan
hi thanks for the pointers. i think the news thing, or something, made the question a little unclear, as it stripped some characters from the input. the input is the default way email headers are sent with the "from" and "to" portions, "name" <[EMAIL PROTECTED]> the question was pertaining to ge

Re: regex..gah

2006-05-09 Thread Anthony Ettinger
On 5/7/06, Dan <[EMAIL PROTECTED]> wrote: i been doing perl long enough that you'd think i should know this, but one thing i've never ever ever managed to get my head around is how regex works. i'm using net::pop3 (mail::pop3client doesn't work!), and i'm trying to extract certain data from the

require or use

2006-05-09 Thread Practical Perl
Could anyone tell me what's the difference between 'use' and 'require'? And,is there any difference for these two statements? use Exporter (); require Exporter; Thank you.