Re: How do I pick one random element from an array?

2009-11-03 Thread John W. Krahn
Majian wrote: Hi ,all : Hello, I want to know if there is a way in which I can randomnize(?) the content in an array. In this example : my @array = ('uriel', 'daniel', 'joel', 'samuel'); Now what I want is create a process so every time I print the array it prints one element from the arr

Re: AW: AW: How do I pick one random element from an array?

2009-11-03 Thread Dave Tang
On Tue, 03 Nov 2009 17:48:55 +1000, Thomas Bätzler wrote: Dave Tang asked: Just a quick question, how does Perl interpret something like $array[0.7995038473872]? Just like $array[ int(0.7995038473872) ], i.e. the floating point number is coerced into an integer value by cutting off the

Re: How do I pick one random element from an array?

2009-11-03 Thread Philip Potter
2009/11/3 John W. Krahn : > Majian wrote: >> my @array = ('uriel', 'daniel', 'joel', 'samuel'); >> >> Now what I want is create a process so every time I print the array it >> prints  one element from the array . >> >> I wrote it like this : >> >> #!/usr/bin/perl -w >> >> use strict; > > use List::

Re: Problem about substitution..

2009-11-03 Thread tom smith
On Mon, Nov 2, 2009 at 7:41 PM, Remy Guo wrote: > hi folks, > i've got problem when trying to perform a substitution. > > the text file i want to process is like this: > ... > XX { > ABDADADGA > afj*DHFHH > } (a123) > XXDFAAF { > af2hwefh > fauufui > } (b332) > ... > > i want to match the

Re: How do I pick one random element from an array?

2009-11-03 Thread tom smith
On Tue, Nov 3, 2009 at 12:11 AM, Majian wrote: > Hi ,all : > > I want to know if there is a way in which I can randomnize(?) the content > in > an array. > > In this example : > > my @array = ('uriel', 'daniel', 'joel', 'samuel'); > > Now what I want is create a process so every time I print the

Re: How do I pick one random element from an array?

2009-11-03 Thread Majian
Thanks all . But I found an another question : If I wrote this script like this : #!/usr/bin/perl while (){ @lines = $_; print "$lines[rand @lines]"; } __DATA__ uriel daniel joel samue It would not display the random element of the array Why ? Or if I want to display the random element of t

Re: How do I pick one random element from an array?

2009-11-03 Thread John W. Krahn
Philip Potter wrote: 2009/11/3 John W. Krahn : Majian wrote: my @array = ('uriel', 'daniel', 'joel', 'samuel'); Now what I want is create a process so every time I print the array it prints one element from the array . I wrote it like this : #!/usr/bin/perl -w use strict; use List::Util '

Re: How do I pick one random element from an array?

2009-11-03 Thread John W. Krahn
Majian wrote: Thanks all . Hello, But I found an another question : If I wrote this script like this : #!/usr/bin/perl use warnings; use strict; while (){ @lines = $_; You are assigning one scalar value to the whole array the array will only ever have one element in it. You need to

Re: Problem about substitution..

2009-11-03 Thread John W. Krahn
tom smith wrote: On Mon, Nov 2, 2009 at 7:41 PM, Remy Guo wrote: i've got problem when trying to perform a substitution. the text file i want to process is like this: ... XX { ABDADADGA afj*DHFHH } (a123) XXDFAAF { af2hwefh fauufui } (b332) ... i want to match the content in the paren

Increment Operator (++) question in Perl

2009-11-03 Thread Majian
Hi ,all: When I test the increment operator in Perl and find a question : The question is : #!/usr/bin/perl use warnings; my $i = 1; print ++$i + ++$i, "\n"; The above code prints out the answer 6 . But in the other language the anser is 5 , So I don't understand the reason why it is

Re: Increment Operator (++) question in Perl

2009-11-03 Thread Erez Schatz
2009/11/3 Majian : > > my $i = 1; > print  ++$i  + ++$i, "\n"; > > The above code prints  out  the answer 6 . > But in the other language  the anser is 5 , > >From the documentation (http://perldoc.perl.org/perlop.html#Auto-increment-and-Auto-decrement): "Note that just as in C, Perl doesn't defi

Re: Increment Operator (++) question in Perl

2009-11-03 Thread Philip Potter
2009/11/3 Majian : > Hi ,all: > >  When I test the increment operator in Perl and  find   a question : > > The question is : > #!/usr/bin/perl > use warnings; > > my $i = 1; > print  ++$i  + ++$i, "\n"; > > The above code prints  out  the answer 6 . > But in the other language  the anser is 5 , > >

Re: Increment Operator (++) question in Perl

2009-11-03 Thread Paul Johnson
On Tue, Nov 03, 2009 at 07:15:43PM +0800, Majian wrote: > Hi ,all: Hello, > When I test the increment operator in Perl and find a question : > > The question is : > #!/usr/bin/perl > use warnings; > > my $i = 1; > print ++$i + ++$i, "\n"; > > The above code prints out the answer 6 . >

Re: Increment Operator (++) question in Perl

2009-11-03 Thread John W. Krahn
Majian wrote: Hi ,all: Hello, When I test the increment operator in Perl and find a question : The question is : #!/usr/bin/perl use warnings; my $i = 1; print ++$i + ++$i, "\n"; The above code prints out the answer 6 . But in the other language the anser is 5 , And the lesson t

Re: printf

2009-11-03 Thread C.DeRykus
On Oct 27, 1:52 pm, aim...@sfbrgenetics.org (Aimee Cardenas) wrote: > Hi, All! > > I need to fix the width of some strings padding with leading spaces if   > necessary.  I wanted to use printf but I don't know if you can put a   > variable in the format part the the printf statement.  For example,

Re: Regex to array woes

2009-11-03 Thread matt
On Nov 2, 9:54 am, brentgclarkl...@gmail.com (Brent Clark) wrote: > Hiya > > I was hoping that someone would be kind to help me. > > I have a string like so : > > Haresources : 10.203.4.5, Interfaces : 10.203.4.5 10.203.4.7 > > Im trying to get the ip's after Interfaces into an array, but for the >

RE: the google keywords for debug...

2009-11-03 Thread Ming Qian
Thanks a lot. >>> "Hack, Gabi (ext)" 11/3/2009 1:35 AM >>> hi bruce, warn throws a warning message on STDERR. see perldoc -f warn warn LIST Produces a message on STDERR just like "die", but doesn't exit or throw an excep- tion. If LIST is

can't post to perl.beginners

2009-11-03 Thread Charles DeRykus
Hello, I subscribed to perl.beginners via Google groups but none of my posts get through Can you help or suggest what might be amiss? -- Charles DeRykus

print flips to scientific notation when integer exceeds 15 decimal digits

2009-11-03 Thread David Lee
Although I've used perl for many years, I've just been surprised (in the unpleasant sense) by a recent event. Given a variable, say "$int", which is a growing integer, I would expect "print $int" to print it as a simple integer; indeed it usually does so. But when its size takes it from 15 de

Re: Problem about substitution..

2009-11-03 Thread John W. Krahn
tom smith wrote: On Tue, Nov 3, 2009 at 4:33 PM, tom smith wrote: Thanks for the tips! More comments below. I saw it written the other way somewhere, and I thought it looked cleaner. I'll do it your way from now on. if ($line =~ /\((.*?)\)/) { $line =~ s/$1/$i;$j/; If you hav

Re: AW: AW: How do I pick one random element from an array?

2009-11-03 Thread Uri Guttman
> "DT" == Dave Tang writes: DT> On Tue, 03 Nov 2009 17:48:55 +1000, Thomas Bätzler DT> wrote: >> Dave Tang asked: >>> Just a quick question, how does Perl interpret something like >>> $array[0.7995038473872]? >> >> Just like $array[ int(0.7995038473872) ], i.e. the floating

Re: Problem about substitution..

2009-11-03 Thread tom smith
Thanks for the tips! More comments below. On Tue, Nov 3, 2009 at 4:10 AM, John W. Krahn wrote: > tom smith wrote: > >> On Mon, Nov 2, 2009 at 7:41 PM, Remy Guo wrote: >> >> i've got problem when trying to perform a substitution. >>> >>> the text file i want to process is like this: >>> ... >>

Re: can't post to perl.beginners

2009-11-03 Thread tom smith
On Tue, Nov 3, 2009 at 12:51 PM, Bob goolsby wrote: > Um -- this one got through. What kind of error message did you > receive from one of the posts that didn't go through? > > > B > > On Mon, Nov 2, 2009 at 9:40 PM, Charles DeRykus wrote: > > Hello, > > > > I subscribed to perl.beginners via G

Re: print flips to scientific notation when integer exceeds 15 decimal digits

2009-11-03 Thread Philip Potter
2009/11/3 David Lee : > Although I've used perl for many years, I've just been surprised (in the > unpleasant sense) by a recent event.  Given a variable, say "$int", which is > a growing integer, I would expect "print $int" to print it as a simple > integer; indeed it usually does so.  But when it

Re: Regex to array woes

2009-11-03 Thread John W. Krahn
Brent Clark wrote: Hiya Hello, I was hoping that someone would be kind to help me. I have a string like so : Haresources : 10.203.4.5, Interfaces : 10.203.4.5 10.203.4.7 Im trying to get the ip's after Interfaces into an array, but for the likes of me, im just not getting it right. This i

Re: can't post to perl.beginners

2009-11-03 Thread Bob goolsby
Um -- this one got through. What kind of error message did you receive from one of the posts that didn't go through? B On Mon, Nov 2, 2009 at 9:40 PM, Charles DeRykus wrote: > Hello, > > I subscribed to perl.beginners via Google groups but none of my posts > get through > > Can you help or

Re: tried to install my first module (Mac OSX 10.4.11)

2009-11-03 Thread tom smith
On Mon, Nov 2, 2009 at 3:47 PM, Jeremiah Foster wrote: > > On Nov 2, 2009, at 20:38, tom smith wrote: > > On Mon, Nov 2, 2009 at 8:02 AM, Peter Scott wrote: >> >> On Mon, 02 Nov 2009 04:25:18 -0700, Tom Smith wrote: >>> >>> I believe that your HTML::Parser needs upgrading. But you're getting

Re: Regex to array woes

2009-11-03 Thread John W. Krahn
John W. Krahn wrote: Brent Clark wrote: I was hoping that someone would be kind to help me. I have a string like so : Haresources : 10.203.4.5, Interfaces : 10.203.4.5 10.203.4.7 Im trying to get the ip's after Interfaces into an array, but for the likes of me, im just not getting it right.

Re: Problem about substitution..

2009-11-03 Thread tom smith
On Tue, Nov 3, 2009 at 4:33 PM, tom smith wrote: > Thanks for the tips! More comments below. > I saw it written the other way somewhere, and I thought it looked cleaner. > I'll do it your way from now on. > > >> >> if ($line =~ /\((.*?)\)/) { >>> >>>$line =~ s/$1/$i;$j/; >>> >> >> If

perl DBM RH 5.3 non root install drivers for MS SQL

2009-11-03 Thread syd_p
Hello, I have a requirement to add drivers for mysql and mssql for a couple RH 5.x intel boxes as non-root. DBM and DBI are already installed. perl is 64-bit and version 5.8.8 and has been installed as root. Also there is no Internet access so cpan -e is not possible. So I wonder if someone could

Sharing objects between threads.

2009-11-03 Thread Prasad Joshi
Hi All, I want to create few threads and want to share objects of class between threads. Although there is a package Thread::Queue but it only allows sharing of scalar data. I tried sending data as a reference parameter to thread but seems like it is passed as value to thread function. Here is an