Re: uniq elements of an array

2002-08-30 Thread Jeff 'japhy' Pinyan
On Aug 30, david said: >Ramprasad A Padmanabhan wrote: > >> Hi All, >>I have been using perl on linux for quiet some time now and I have >> found that Perl does not work the same in windows >> >>eg. To get all the unique elements of an array in linux I use a >> simple one liner >> >>

Re: dos2unix.pl not working...

2002-08-30 Thread drieux
On Friday, August 30, 2002, at 12:51 , Omanakuttan wrote: > I am trying to strip off ^Ms from a number of text files. > The following does not seem to work. any suggestions? [..] > Thank you. my favorite generic solution is: http://www.wetware.com/drieux/pbl/RegEx/eolOut.txt my $cr =

a bit over the top wraper for Getopt::Long

2002-08-30 Thread drieux
Since I had to go and clean up my old friend, because I actually had to do it - and since I have frumped about did you put in the '--help|-h|-?' thing for making sure that people have their gnu style help I thought I should show one of several ways to do this. http://www.wetwar

Re: how to be safe and secure

2002-08-30 Thread brian gilbert
Hey, great discussion folks! Thanks for all the tips. Some of that is a bit of a stretch for this beginner, but it gets me going in the right directions. Off to learn more about DBM... And yes, in this case the server is Win2k. Unfortunately the scripts have to be run by the world at large

RE: uniq elements of an array

2002-08-30 Thread David . Wagner
The one sent in by david which was @uniq{@a} = () was even faster by a significant margin where you have sub using_array { @uniq{@a} = (); } Need to define my %uniq above as you do my @uniq. Wags ;) -Original Message- From: NYIMI Jose (BMB) [mailto:[EMAIL PROTE

Re: XML::LibXML

2002-08-30 Thread Steve Grazzini
Melanie Rouette <[EMAIL PROTECTED]> wrote: > > I need to create xml DOM trees from scratch save them as xml files > so that I can reload them & make modifications to the elements' > values as well as adding new elements or attributes. Right now I'm > using the XML::LibXML::Document & XML::LibXM

RE: uniq elements of an array

2002-08-30 Thread NYIMI Jose (BMB)
Sorry for the sort in front of grep :) Removing it gives: Benchmark: timing 100 iterations of using_grep, using_slice... using_grep: 25 wallclock secs (24.41 usr + 0.00 sys = 24.41 CPU) @ 40973.53/s (n=100) using_slice: 15 wallclock secs (15.56 usr + 0.00 sys = 15.56 CPU) @ 64254.96/s

RE: uniq elements of an array

2002-08-30 Thread NYIMI Jose (BMB)
Slice is simple and also faster ! Look: #!/usr/bin/perl use strict; use Benchmark; my @a=qw(a c b c a a b d c c); my @uniq=(); sub using_grep{ my %seen=(); @uniq=sort grep{ ! $seen{$_}++ } @a; } sub using_slice{ my %h=(); @h{@a}=(); @uniq=keys %h; } t

Re: uniq elements of an array

2002-08-30 Thread Felix Geerinckx
on Fri, 30 Aug 2002 18:26:03 GMT, Tom Allison wrote: > david wrote: >> @hash{@all_elements} = (); >> >> now "keys %hash" gives you the unique elements. > > Would these exist but be undef? > > Why don't you write a little program to try it out, using the aptly named 'exists' and 'defined' fu

Re: uniq elements of an array

2002-08-30 Thread Tom Allison
david wrote: > Ramprasad A Padmanabhan wrote: > > >>Hi All, >> I have been using perl on linux for quiet some time now and I have >>found that Perl does not work the same in windows >> >> eg. To get all the unique elements of an array in linux I use a >>simple one liner >> >> @unique = gr

Re: uniq elements of an array

2002-08-30 Thread david
Ramprasad A Padmanabhan wrote: > Hi All, >I have been using perl on linux for quiet some time now and I have > found that Perl does not work the same in windows > >eg. To get all the unique elements of an array in linux I use a > simple one liner > >@unique = grep{!/$seen{$_}++/} @

Re: find the lowest number?

2002-08-30 Thread Tagore Smith
Felix Geerinckx wrote: > For small array sizes, it doesn't matter which method you use, since > the cpu time will be near zero anyway. For larger sizes it does > matter, and the loop method is a clear winner. > Therefor, imho, your suggestion in March (and mine now :-) to use a > loop, is *always

Re: find the lowest number?

2002-08-30 Thread Janek Schleicher
David Samuelsson wrote at Fri, 30 Aug 2002 10:22:56 +0200: > > i get an array conataining a lot off numbers like this: > > 567 > 551 > 540 > 540 > 540 > 533 > 531 > 526 > 493 > 476 > 468 > 429 > 421 > 520 > > how do i find the lowest or the higest number in this series? There's also a module

X.400 and Perl

2002-08-30 Thread JEFERSON_LADEIA
--- Hi All, I need access x.400 mailboxes in a X.25 network throught Perl. The connection are configurated in a Win2K, now i need send and receive data to X.400 server. Any information about this subject, Please send me. Thanks, Jeferson Ladeia -- To unsubscribe, e-mail:

RE: Really newbie question

2002-08-30 Thread Bob Showalter
> -Original Message- > From: Panel Vincent - A53 [mailto:[EMAIL PROTECTED]] > Sent: Friday, August 30, 2002 10:24 AM > To: [EMAIL PROTECTED] > Subject: Really newbie question > > > I've made a script that looks like this > > " > #!/usr/bin/perl -w > use Net::LDAP::LDIF; > use Net::LDAP:

RE: Extracting bits from a string of bits

2002-08-30 Thread Kipp, James
Bridget Please reply to the list, that way if i am not available, someone else on the list can help you. Couple of questions: You want to extract the 4 bits into an array or into an string? Is this a raw packet dump in hex? There are many ways but here is one: $packet = "234BBFF56"; @array =

XML::LibXML

2002-08-30 Thread Melanie Rouette
Hi, I need to create xml DOM trees from scratch save them as xml files so that I can reload them & make modifications to the elements' values as well as adding new elements or attributes. Right now I'm using the XML::LibXML::Document & XML::LibXML::Element classes. And I have a bunch of quest

Really newbie question

2002-08-30 Thread Panel Vincent - A53
I've made a script that looks like this " #!/usr/bin/perl -w use Net::LDAP::LDIF; use Net::LDAP::Entry; $file= $ARGV[0]; open(LDIF, $file) || die "Failed to open file $ARGV[0] : $!"; $ldif = Net::LDAP::LDIF->new(LDIF); while (not $ldif->eof()) { $entry = $ldif->read_entry(); }; " Perl is

Re: win2k erase page

2002-08-30 Thread Sudarshan Raghavan
On Fri, 30 Aug 2002, Bob Green wrote: > On Win2k, how do I erase the page? > > This seems like it should be so simple, I've tried... > @cmd = ( "cls" ); > `@cmd`; > > from the NT shell, "cls" clears the screen. This is a faq perldoc -q 'How Do I clear the screen?' If you are using activestate

win2k erase page

2002-08-30 Thread Bob Green
On Win2k, how do I erase the page? This seems like it should be so simple, I've tried... @cmd = ( "cls" ); `@cmd`; from the NT shell, "cls" clears the screen. Any idea's appreciated. thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Perl on AS/400

2002-08-30 Thread JEFERSON_LADEIA
Hi All, I have been using perl on windows nt,novell e as/400. I have a problem in Perl in the as/400, the release of perl is 5.005 and some scripts running in the NT and novell not running in AS/400. I need any information about new releases of Perl for AS/400. Jeferson Ladeia -- To unsu

Re: find the lowest number?

2002-08-30 Thread Felix Geerinckx
on Sat, 31 Aug 2002 04:30:34 GMT, [EMAIL PROTECTED] (Sudarshan Raghavan) wrote: > My statement was far too general, what I should have said was to > have a unsorted array of 1000 or more elements when your problem > requires finding the max or min of that list is not a good design. Again, I beg

Re: find the lowest number?

2002-08-30 Thread Sudarshan Raghavan
On 30 Aug 2002, Felix Geerinckx wrote: > on Sat, 31 Aug 2002 03:51:39 GMT, [EMAIL PROTECTED] (Sudarshan > Raghavan) wrote: > > > I thought on similar lines too when that thread was on, but I > > convinced myself saying that an unsorted array of 1000 or more > > elements in your code is a poor d

Re: find the lowest number?

2002-08-30 Thread Felix Geerinckx
on Sat, 31 Aug 2002 03:51:39 GMT, [EMAIL PROTECTED] (Sudarshan Raghavan) wrote: > I thought on similar lines too when that thread was on, but I > convinced myself saying that an unsorted array of 1000 or more > elements in your code is a poor design to start with :-) I beg to differ. From perld

Re: find the lowest number?

2002-08-30 Thread Sudarshan Raghavan
On 30 Aug 2002, Felix Geerinckx wrote: > This if for a seven-element array. > > I did some testing myself for larger array sizes (times are in > CPU seconds): > > Size Loop Sort > 1000 0.00 0.01 > 1 0.02 0.08 > 10 0.13 1.03 > 20 0.24 2.18 >

Re: find the lowest number?

2002-08-30 Thread Felix Geerinckx
on Sat, 31 Aug 2002 02:23:20 GMT, [EMAIL PROTECTED] (Sudarshan Raghavan) wrote: > On 30 Aug 2002, Felix Geerinckx wrote: > >> There is no need to sort the full array (as others suggested) to >> just find the lowest and highest number when an O(n) operation >> will suffice: > > Precisely the co

Re: AW: find the lowest number?

2002-08-30 Thread Sudarshan Raghavan
On Fri, 30 Aug 2002, Dharmendra Rai wrote: The list FAQ requests folks to snip uneccessary lines before replying to mails. But surely the entire mail cannot be uneccessary. Please leave some parts of it so that other's in this list know what you are replying to. > > my $ret_val; > > my $i; >

Re: AW: find the lowest number?

2002-08-30 Thread Dharmendra Rai
why use sorting and other algos which have non-linear time-complexity. traverse the array once and get the max and min - Get a bigger mailbox -- choose a size that fits your needs.

Re: find the lowest number?

2002-08-30 Thread Sudarshan Raghavan
On Sat, 31 Aug 2002, Sudarshan Raghavan wrote: > For further proof here is a benchmarking result > #!/usr/local/bin/perl -w > use strict; > use Benchmark; > > my @arr = qw(34 12 23 45 11 91 32); > sub using_sort { > my $min = (sort {$a <=> $b} @arr)[0]; > my $max = (reverse sort {$a

Re: AW: find the lowest number?

2002-08-30 Thread Dharmendra Rai
my $ret_val; my $i; if ($#your_array < 0){ ## do appropriate thing } elsif ($#your_array == 0){ ## return the only value it has} ## following is the ELSE part for (my $i = 0; i < $#your_array; ++i) { $ret_val = your_array[i+1]; $ret_val = your_array[i] if (your_array[i] > your_array[i+1

AW: AW: find the lowest number?

2002-08-30 Thread Angerstein
ok, i see. That´s what i thought. > -Ursprüngliche Nachricht- > Von: Sudarshan Raghavan [mailto:[EMAIL PROTECTED]] > Gesendet am: Samstag, 31. August 2002 04:33 > An: Perl beginners > Betreff: Re: AW: find the lowest number? > > On Fri, 30 Aug 2002, Angerstein wrote: > > > fake! you dont

Re: AW: find the lowest number?

2002-08-30 Thread Sudarshan Raghavan
On Fri, 30 Aug 2002, Angerstein wrote: > fake! you dont need to sort the array to times... because u know where the > lowest hand the higest is. Yes I do know that, you don't have to sort the array two times. > Less of the half of 11 wallclocks would be what i expect. I think you should read t

AW: find the lowest number?

2002-08-30 Thread Angerstein
fake! you dont need to sort the array to times... because u know where the lowest hand the higest is. Less of the half of 11 wallclocks would be what i expect. > -Ursprüngliche Nachricht- > Von: Sudarshan Raghavan [mailto:[EMAIL PROTECTED]] > Gesendet am: Samstag, 31. August 2002 04:11 >

Re: find the lowest number?

2002-08-30 Thread Sudarshan Raghavan
On 30 Aug 2002, Felix Geerinckx wrote: > There is no need to sort the full array (as others suggested) to just > find the lowest and highest number when an O(n) operation will > suffice: Precisely the comment that I had a few months back for a similar question. Read through this thread http://

Re: find the lowest number?

2002-08-30 Thread Felix Geerinckx
on Fri, 30 Aug 2002 08:22:56 GMT, [EMAIL PROTECTED] (David Samuelsson) wrote: > i get an array conataining a lot off numbers like this: > > 567 [snipped] > 520 > > how do i find the lowest or the higest number in this series? There is no need to sort the full array (as others suggested) to

Re: dos2unix.pl not working...

2002-08-30 Thread Sudarshan Raghavan
On Sat, 31 Aug 2002, Sudarshan Raghavan wrote: > > I guess your filenames are in @ARGV array, your shift inside the while > suggests it either @ARGV or @_. If it is @ARGV you can do this If it is @_ you will have to do this before the while in your sub local @ARGV = @_; > > $^I = '~'; > whil

RE: Customer Name Parsing

2002-08-30 Thread Jackson, Harry
> -Original Message- > From: John W. Krahn [mailto:[EMAIL PROTECTED]] > > Felix Geerinckx wrote: > > > > on Wed, 28 Aug 2002 10:11:16 GMT, [EMAIL PROTECTED] (Harry > > Jackson) wrote: > > > > > What I would like to know is if there are any modules > > > that can find similar matches i

Re: dos2unix.pl not working...

2002-08-30 Thread Sudarshan Raghavan
On Fri, 30 Aug 2002, Omanakuttan wrote: > I am trying to strip off ^Ms from a number of text files. > The following does not seem to work. any suggestions? > > my $filename ; > while ($filename = shift) { > open (INF, $filename) or die "Could not open $filename. $!" ; > my @file = ; > close

Re: find the lowest number?

2002-08-30 Thread Sudarshan Raghavan
On Fri, 30 Aug 2002, Ramprasad A Padmanabhan wrote: > > @a = qw(121 23 31 4 11); > > print "LOWEST " . (reverse sort @a )[0]; By default sort does a lexical sort, this will not work Correct way to do this my @list = qw(121 23 31 4 11); print "LOWEST: ", (sort {$a <=> $b} @list)[0]; -- To

AW: find the lowest number?

2002-08-30 Thread Angerstein
sort will sort like windows does with filename if you do this that way. example sort do: 1, 16, 20, 3, 35, 4, 400 not: 1,3,4,16,20,35,400 > -Ursprüngliche Nachricht- > Von: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]] > Gesendet am: Freitag, 30. August 2002 10:39 > An: [EMAIL PR

AW: find the lowest number?

2002-08-30 Thread Angerstein
@numbers[$#numbers]; # highest @numbers[-1]; # highest > -Ursprüngliche Nachricht- > Von: Angerstein [mailto:[EMAIL PROTECTED]] > Gesendet am: Freitag, 30. August 2002 10:34 > An: [EMAIL PROTECTED] > Betreff: AW: find the lowest number? > > @numbers = (44, 55, 38, 10 , 5, 7); > @numbers =

Re: dos2unix.pl not working...

2002-08-30 Thread Ramprasad A Padmanabhan
Omanakuttan wrote: > I am trying to strip off ^Ms from a number of text files. > The following does not seem to work. any suggestions? > > my $filename ; > while ($filename = shift) { > open (INF, $filename) or die "Could not open $filename. $!" ; > my @file = ; > close INF ; > open (OUT, "

AW: find the lowest number?

2002-08-30 Thread Angerstein
@numbers = (44, 55, 38, 10 , 5, 7); @numbers = sort { $a<=>$b } @number; print $numbers[0]; # the lowest > -Ursprüngliche Nachricht- > Von: David Samuelsson (PAC) [mailto:[EMAIL PROTECTED]] > Gesendet am: Freitag, 30. August 2002 10:23 > An: '[EMAIL PROTECTED]' > Betreff: find the lowest

AW: Perl 5.8.0

2002-08-30 Thread Angerstein
full 64Bit support > -Ursprüngliche Nachricht- > Von: Jason Frisvold [mailto:[EMAIL PROTECTED]] > Gesendet am: Donnerstag, 29. August 2002 23:02 > An: [EMAIL PROTECTED] > Betreff: Perl 5.8.0 > > Ok, I'm a bit behind the times... :-) > > What are the major advantages (if any) to moving to

find the lowest number?

2002-08-30 Thread David Samuelsson (PAC)
i get an array conataining a lot off numbers like this: 567 551 540 540 540 533 531 526 493 476 468 429 421 520 how do i find the lowest or the higest number in this series? //Dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: how to be safe and secure

2002-08-30 Thread doug
Of course, making sure CGI isn't readable is the only real bastion you've got with interpreted Perl. Some other things to think about: 1) Make sure the SQL server is locked down! Ensure that it'll at a minimum accept connections from only certain IP addresses. Don't rely on mere password encry

Perl 5.8.0

2002-08-30 Thread Jason Frisvold
Ok, I'm a bit behind the times... :-) What are the major advantages (if any) to moving to 5.8.0? I'm running 5.6.1 right now... Is it worth it? Is it fully backwards compatible? --- Jason H. Frisvold Senior ATM Engineer Engineering Dept. Penteledata RHCE - 80730234940

Re: uniq elements of an array

2002-08-30 Thread Ramprasad A Padmanabhan
Dharmendra rai wrote: > have u seen the values in @unique when @all_elements contains (1,2,3,1,2) when u >apply @unique = grep { !$seen{$_}} @all_elements ??? > > its is not working > > > > > - > Get a bigger mailbox -- choose a size that fits your need

Re: uniq elements of an array

2002-08-30 Thread Sudarshan Raghavan
On 30 Aug 2002, Felix Geerinckx wrote: > on Fri, 30 Aug 2002 17:32:36 GMT, [EMAIL PROTECTED] (Sudarshan > Raghavan) wrote: > > > Why do you need to do a pattern match anyways? Just a > > @unique = grep{!$seen{$_}} @all_elements; > > should do > > You forgot to increment. The correct way is: >

dos2unix.pl not working...

2002-08-30 Thread Omanakuttan
I am trying to strip off ^Ms from a number of text files. The following does not seem to work. any suggestions? my $filename ; while ($filename = shift) { open (INF, $filename) or die "Could not open $filename. $!" ; my @file = ; close INF ; open (OUT, ">$filename") or die "Could not open $

Re: uniq elements of an array

2002-08-30 Thread Dharmendra Rai
have u seen the values in @unique when @all_elements contains (1,2,3,1,2) when u apply @unique = grep { !$seen{$_}} @all_elements ??? its is not working - Get a bigger mailbox -- choose a size that fits your needs.

Re: uniq elements of an array

2002-08-30 Thread Felix Geerinckx
on Fri, 30 Aug 2002 17:32:36 GMT, [EMAIL PROTECTED] (Sudarshan Raghavan) wrote: > Why do you need to do a pattern match anyways? Just a > @unique = grep{!$seen{$_}} @all_elements; > should do You forgot to increment. The correct way is: @unique = grep{!$seen{$_}++} @all_elements; -- feli