my deck of cards (once again)

2007-07-03 Thread Amichai Teumim
The following shuffles up my deck of card and then prints out the top five cards. I need it to work somehwhat differently. When I shift or pop an element, I need to store it as a variable, then push it on to the array in a different order from the original order. Any suggestions? (See code below)

Re: Conditional question

2007-07-03 Thread Paul Johnson
On Tue, Jul 03, 2007 at 02:42:29AM -0400, Chas Owens wrote: > On 7/3/07, Paul Johnson <[EMAIL PROTECTED]> wrote: > snip > >And, in this case, more accurate. Unless you know something the rest of us > >don't. > snip > > The trinary operator (?:) returns the value of either the true or > false port

TWO loops and ONE if statement

2007-07-03 Thread Amichai Teumim
Hi guys You guys have been giving me some very good ideas. Very efficent ways of doing things. For this excercise that I'm trying to figure out I actually need the following inefficient way: #!/usr/bin/perl @array = (5,3,2,1,4); ## include your code here ## foreach $elem (@array){ print "$

Re: TWO loops and ONE if statement

2007-07-03 Thread Paul Johnson
On Tue, Jul 03, 2007 at 10:53:18AM +0300, Amichai Teumim wrote: > You guys have been giving me some very good ideas. Very efficent ways > of doing things. > For this excercise that I'm trying to figure out I actually need the > following inefficient way: > > > #!/usr/bin/perl > > @array = (5,3,

Re: TWO loops and ONE if statement

2007-07-03 Thread Jeff Pang
Amichai Teumim 写道: Hi guys You guys have been giving me some very good ideas. Very efficent ways of doing things. For this excercise that I'm trying to figure out I actually need the following inefficient way: #!/usr/bin/perl @array = (5,3,2,1,4); ## include your code here ## foreach $elem

Fwd: TWO loops and ONE if statement

2007-07-03 Thread Amichai Teumim
I forgot to add what I have done so far. I did: #!/usr/bin/perl use strict; use warnings; my @array = (5,3,2,1,4); my $n = @array; for my $i (0 .. $n-1) { for my $j (0 .. $n-1) { if ($array[$j+1] < $array[$j]) { #compare the two neighbors $tmp = $array[$j]; # swap

Re: Fwd: TWO loops and ONE if statement

2007-07-03 Thread Gary Stainburn
On Tuesday 03 July 2007 10:43, Amichai Teumim wrote: > I forgot to add what I have done so far. I did: > > #!/usr/bin/perl > > use strict; > use warnings; > > my @array = (5,3,2,1,4); > my $n = @array; > > for my $i (0 .. $n-1) { >for my $j (0 .. $n-1) { >if ($array[$j+1] < $array[$j])

Re: TWO loops and ONE if statement

2007-07-03 Thread Martin Barth
Hi maybe this wikipedia article can show you different sorting algorithems: http://en.wikipedia.org/wiki/Sorting_algorithm#Summaries_of_popular_sorting_algorithms there are examples in pseudocode. HTH, Martin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: TWO loops and ONE if statement

2007-07-03 Thread Mumia W.
On 07/03/2007 02:53 AM, Amichai Teumim wrote: Hi guys Hello Amichai. [...] I need to sort the @array from lowest to highest using TWO loops and ONE if statement. That's why it's so confusing. I could use a one liner to do all this. I need to do it however as above mentioned. How can I do th

Re: my deck of cards (once again)

2007-07-03 Thread Paul Lalli
On Jul 3, 3:23 am, [EMAIL PROTECTED] (Amichai Teumim) wrote: > Subject: my deck of cards (once again) Are you aware that you're reinventing a wheel? http://search.cpan.org/~akarger/Games-Cards-1.45/lib/Games/Cards.pm That module already has methods to shuffle a deck, deal cards out to hands, and

Re: Fwd: TWO loops and ONE if statement

2007-07-03 Thread Gary Stainburn
On Tuesday 03 July 2007 11:55, you wrote: > OK. So I remove temp and I get this: > > Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11. > Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11. > Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11. > U

Re: TWO loops and ONE if statement

2007-07-03 Thread Chas Owens
On 7/3/07, Amichai Teumim <[EMAIL PROTECTED]> wrote: I forgot to add what I have done so far. I did: #!/usr/bin/perl use strict; use warnings; my @array = (5,3,2,1,4); my $n = @array; for my $i (0 .. $n-1) { for my $j (0 .. $n-1) { if ($array[$j+1] < $array[$j]) { #compare the two

TWO loops and ONE

2007-07-03 Thread Amichai Teumim
OK. So I removed $tmp. Now my code looks like this: #!/usr/bin/perl use strict; use warnings; my @array = (5,3,2,1,4); my $n = @array; for my $i (0 .. $n-1) { for my $j (0 .. $n-1) { if ($array[$j+1] < $array[$j]) { #compare the two neighbors @array[$j, $j+1] = @array[$j+1,

Re: TWO loops and ONE

2007-07-03 Thread Gary Stainburn
On Tuesday 03 July 2007 15:03, Amichai Teumim wrote: > OK. So I removed $tmp. Now my code looks like this: > > > #!/usr/bin/perl > > use strict; > use warnings; > > my @array = (5,3,2,1,4); > my $n = @array; > > for my $i (0 .. $n-1) { >for my $j (0 .. $n-1) { >if ($array[$j+1] < $array

Re: TWO loops and ONE

2007-07-03 Thread Chas Owens
On 7/3/07, Amichai Teumim <[EMAIL PROTECTED]> wrote: snip my $n = @array; for my $i (0 .. $n-1) { for my $j (0 .. $n-1) { snip What is the value of @array[$j+1] when $j is at the end of the range ($n - 1)? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

Re: TWO loops and ONE

2007-07-03 Thread Chas Owens
On 7/3/07, Amichai Teumim <[EMAIL PROTECTED]> wrote: snip I was told that it just means my logic isn't in order, but it should work nevertheless right? Why isn't it working? snip It is working, but it is hard to see the result due to the lack of a \n. Try putting a print "\n"; after the last f

character Encoding in perl

2007-07-03 Thread Prabu Ayyappan
Hi, I am using XML::Simple for converting the XML into a hash. use Unicode::String qw(utf8); use XML::Simple; #use Data::Dumper; $XML = "äT©imes"; $u = utf8($XML); $XML = $u->utf8; $myHash = XMLin($XML); #print Dumper($myHash); The above code works fine... But the problem i

character Encoding in perl

2007-07-03 Thread Prabu Ayyappan
Hi, I am using XML::Simple for converting the XML into a hash. use Unicode::String qw(utf8); use XML::Simple; #use Data::Dumper; $XML = "äT©imes"; $u = utf8($XML); $XML = $u->utf8; $myHash = XMLin($XML); #print Dumper($myHash); The above code works fine... But the problem i

Re: character Encoding in perl

2007-07-03 Thread Prabu Ayyappan
Its not even being displayed in by browser.The UTF-8 Character i meant is the square characters in the Link http://www.tony-franks.co.uk/UTF-8.htm Prabu Ayyappan <[EMAIL PROTECTED]> wrote: Hi, I am using XML::Simple for converting the XML into a hash. use Unicode::String qw(utf8); u

Re: book on perl

2007-07-03 Thread [EMAIL PROTECTED]
Hi Randal, While the books are great - I saw this great idea over at the Python community. Someone came up with a list of ten small programs in python, each introducing a core part of the language. This was added to the wiki over at - http://wiki.python.org/moin/SimplePrograms . It now contains pro

Re: interpolation of function reference in a here doc

2007-07-03 Thread jenda
You may want to have a look at Interpolation.pm from CPAN. Jenda == [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == : What do people think? What, do people think? :-) -- Larry Wall in <[EMAIL PROTECTED]> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail

Controlling the Device Manager with Perl?

2007-07-03 Thread Dustin Hice
Is there a module that will do such a thing, and if there is how so? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Re: Controlling the Device Manager with Perl?

2007-07-03 Thread Chas Owens
On 7/3/07, Dustin Hice <[EMAIL PROTECTED]> wrote: Is there a module that will do such a thing, and if there is how so? First stop and explain what it is you want to achieve without preconceived notions of how to do it. You, as a human*, may use the Device Manager program to do things, but that

Re: book on perl

2007-07-03 Thread Randal L. Schwartz
> ""alex" == "alex [EMAIL PROTECTED] com" <[EMAIL PROTECTED]> writes: "alex> While the books are great - I saw this great idea over at the Python "alex> community. Someone came up with a list of ten small programs in "alex> python, each introducing a core part of the language. This was added "

Re: TWO loops and ONE if statement

2007-07-03 Thread Randal L. Schwartz
> ""Amichai" == "Amichai Teumim" <[EMAIL PROTECTED]> writes: "Amichai> I need to sort the @array from lowest to highest using TWO loops and "Amichai> ONE if statement. That's why it's so confusing. "Amichai> I could use a one liner to do all this. I need to do it however as "Amichai> above men

Perl Device Manager?

2007-07-03 Thread Dustin Hice
I was thinking about making a few different scripts that would enable/ disable components of my laptop to save power, I am hoping to be able to just make a few different scripts that will be stored on my desktop. These scripts will just check to see if a specific component is enabled or disabled,

Re: Perl Device Manager?

2007-07-03 Thread Chas Owens
On 7/2/07, Dustin Hice <[EMAIL PROTECTED]> wrote: I was thinking about making a few different scripts that would enable/ disable components of my laptop to save power, I am hoping to be able to just make a few different scripts that will be stored on my desktop. These scripts will just check to

Re: Perl Device Manager?

2007-07-03 Thread Jay Savage
On 7/2/07, Dustin Hice <[EMAIL PROTECTED]> wrote: I was thinking about making a few different scripts that would enable/ disable components of my laptop to save power, I am hoping to be able to just make a few different scripts that will be stored on my desktop. These scripts will just check to

Re: Conditional question

2007-07-03 Thread Dr.Ruud
"Chas Owens" schreef: > Joseph L. Casale: >> I want to script an "if" based on two conditions, var1=0 and var2=1. >> Is there some quicker way to write this in one "if" statement like: >> >> If ($var1=0 ?and? var2=1) { >> Do my stuff >> } >> >> I know I can nest a second if, but ju

Re: my deck of cards (once again)

2007-07-03 Thread Dr.Ruud
"Amichai Teumim" schreef: > my @startingdeck = ("A H","2 H","3 H","4 H","5 H","6 H","7 H","8 H", > "9 H","10 H","J H","Q H","K H", > "A D","2 D","3 D","4 D","5 D","6 D","7 D","8 D", > "9 D","10 D","J D","Q D","K D", > "A C","2 C","3 C

formatting a string

2007-07-03 Thread Joseph L. Casale
I have an array with the following data in it: /vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/AN-DC (Win2003 Ent x64)/AN-DC (Win2003 Ent x64).vmx /vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/AN-DC (Win2003 Ent x64)/Disc 1.vmdk /vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/AN-DC (Win2

Re: formatting a string

2007-07-03 Thread Tom Phoenix
On 7/3/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: I always deal with indices' 1 through to the end in the function in question, so it's easy to get the second indices (First disc) and so on. Huh? I need to manipulate the path though now, I am wanting to search for *all* the text followi

Re: formatting a string

2007-07-03 Thread Prabu Ayyappan
A quick solutionMay be you can enhance it more as you like.. @discarr = ('/vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/AN-DC (Win2003 Ent x64)/AN-DC (Win2003 Ent x64).vmx','/vmfs/volumes/467f06a5-7d59c067-35cb-0007e9153886/AN-DC (Win2003 Ent x64)/Disc 1.vmdk','/vmfs/volumes/467f06

hash comparison ideas

2007-07-03 Thread [EMAIL PROTECTED]
Hi I have a script which contains 2 hashes of file names as the keys and md5 sums as the values. I am looking for ideas on fast and efficient ways to compare the 2 hashes in the manner of the pseudo code below -- %base_hash %new_hash for keys in %new_hash if key in %new_hash exists in %base_ha

Need Help Installing Win32:SerialPort

2007-07-03 Thread CM Analyst
Hello everyone. I am relatively new to Perl and this is my first attempt at installing a module. I am using ActiveState v.5.8.8. I downloaded and installed Bill Birthisel's Win32::SerialPort and Win32API::CommPort (Ver 0.19) modules per the instructions. The installation appears to be gone OK b

Re: hash comparison ideas

2007-07-03 Thread Jeff Pang
A hash is an array actually in perl.So you may use Array::Diff module on CPAN: http://search.cpan.org/~typester/Array-Diff-0.04/lib/Array/Diff.pm 2007/7/4, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: Hi I have a script which contains 2 hashes of file names as the keys and md5 sums as the values. I

Re: hash comparison ideas

2007-07-03 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi Hello, I have a script which contains 2 hashes of file names as the keys and md5 sums as the values. I am looking for ideas on fast and efficient ways to compare the 2 hashes in the manner of the pseudo code below Can you fill us in on the big picture? Perhaps

RE: formatting a string

2007-07-03 Thread Joseph L. Casale
Yup, lol... Wish I understood this! What is the line that does the search called? What do I look up to read up on this? Thanks! jlc From: Prabu Ayyappan [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 03, 2007 10:55 PM To: Joseph L. Casale; beginners@perl.org Subject: Re: formatting a string A qui

foreach broken in my script

2007-07-03 Thread Joseph L. Casale
I have a list: @list = ('Exchange','Filter','DNS','Domain'); This is a list of arrays I also have of course to leverage this I am trying to . the @ symbol on it during use. foreach $vm (@list) { my_sub("@" . "$vm"); print "@" . "$vm\n"; } The print likes this, bu

Re: foreach broken in my script

2007-07-03 Thread Jeff Pang
May you need eval?Like, use strict; use warnings; my @list = ('Exchange','Filter','DNS','Domain'); my @Exchange = (1,2); my @Filter = (3,4); my @DNS = (5,6); my @Domain = (7,8); foreach my $vm (@list) { print eval '@'.$vm,"\n"; } __END__ good luck. 2007/7/4, Joseph L. Casale <[EMAIL PR

RE: formatting a string

2007-07-03 Thread Prabu Ayyappan
Read Perl reqular expression and search replace. $perldoc perlretut http://search.cpan.org/~nwclark/perl-5.8.8/pod/perlretut.pod "Joseph L. Casale" <[EMAIL PROTECTED]> wrote: v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VM