Re: Conditional question

2007-07-03 Thread Paul Johnson
On Mon, Jul 02, 2007 at 11:28:47PM -0600, Joseph L. Casale wrote: Heh, I never tried to use and? I assumed it wasn't that simple! Problem with learning something from the beginning is I don't even know what that's called so searching the net is rather hard:) Of course, searching the net for

Re: Conditional question

2007-07-03 Thread Paul Johnson
On Tue, Jul 03, 2007 at 01:31:59AM -0400, Chas Owens wrote: On 7/3/07, Prabu Ayyappan [EMAIL PROTECTED] wrote: You can even do like this $var1 == 0 $var2 == 1 ? print hai : print bye; snip If you are going for succinctness, then try this print !$var1 $var2 ? hai : bye; But in

Re: Component Object Model

2007-07-03 Thread Sunil Prabhakaran
hi Yes of course Try Win32::OLE module For me this Blog http://www.perl.com/pub/a/2005/04/21/win32ole.html is a good starter. regards sunil On 7/2/07, ash [EMAIL PROTECTED] wrote: Hello! Does Perl support COM? If yes can I have an example of creating an object and using functions? Thank you

Re: Conditional question

2007-07-03 Thread Chas Owens
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 portion depending on the conditional portion, so putting print in both the true

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

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 portion

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,2,1,4);

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

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]) { #compare

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:

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

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. Use of

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[$j]) {

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 for

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 = STARTäT©imes/START; $u = utf8($XML); $XML = $u-utf8; $myHash = XMLin($XML); #print Dumper($myHash); The above code works fine... But the

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 = STARTäT©imes/START; $u = utf8($XML); $XML = $u-utf8; $myHash = XMLin($XML); #print Dumper($myHash); The above code works fine... But the

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);

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

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 alex to the wiki

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 mentioned. need. Who

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

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 just hoped I could do it

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,4 C,5 C,6 C,7 C,8 C, 9 C,10 C,J C,Q C,K 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

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

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

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

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

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