RE: sort question
> -Original Message- (B> From: [EMAIL PROTECTED] (B> [mailto:[EMAIL PROTECTED] On (B> Behalf Of Michael Meltzer (B> Sent: Wednesday, December 15, 2004 2:44 PM (B> To: Perl-Win32-Users (B> Subject: sort question (B> (B> The following strings I have in an array: (B> (B> xyz (B> abcd (B> ZABC (B> (B> if I do @sorted = sort(@unsorted) I get (B (B>From perldoc -f sort: (B (B# now case$B!>(Jinsensitively (B@articles = sort {uc($a) cmp uc($b)} @files; (B (B> ZABC (B> abcd (B> xyz (B> (B> I would like to sort this strings alphabetical ignoring (B> capitalisation but whithout changing the output format. (B> I want to get this: (B> (B> abcd (B> xyz (B> ZABC (B> (B> How can I do this ? (B> (B> Michael (B> (B> -- (B> +-- Michael Meltzer (B> -+-+ (B> | AED-SICAD Aktiengesellschaft | EMail : (B> [EMAIL PROTECTED] | (B> | Lilienthal-Str. 7| Phone : +49-89-45026-108 (B> | (B> | 85579 Neubiberg | Fax : +49-89-45026-113 (B> | (B> ++ (B> -+ (B> (B> (B> (B> ___ (B> Perl-Win32-Users mailing list (B> [EMAIL PROTECTED] (B> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs (B> (B___ (BPerl-Win32-Users mailing list ([EMAIL PROTECTED] (BTo unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
IPC::Open2 & Net::Telnet
I've been trying to write a script that controls an interactive command-line program. From the searching I've done, it looks like IPC::Open2/IPC::Open3 paired with Net::Telnet would be the easiest way to do this on Windows. The included script is my attempt, however I get the following error when I run the script: unexpected read error: Bad file descriptor at fcli.pl line 22 Any suggestions/comments appreciated. James 1 use strict; 2 use warnings; 3 4 use IPC::Open2; 5 use Net::Telnet; 6 $| = 1; 7 8 my ($readme, $writeme, $results, $pid); 9 eval { $pid = open2($readme, $writeme, 'flarecons', 'd', 'f', 'a'); }; 10 if ($@) { 11 if ($@ =~ /^open2:/i) { 12 die "open2 failed: [EMAIL PROTECTED]"; 13 } 14 die; 15 } 16 17 my $telnet = Net::Telnet->new(-fhopen => $readme, 18 -telnetmode => 0, 19 -cmd_remove_mode => 1, 20 -prompt => '/fcli> $/'); 21 print $writeme "l\n"; 22 $results = $telnet->waitfor('/q\' to Quit\) $/'); 23 print $writeme "\n"; 24 $results .= $telnet->waitfor('/q\' to Quit\) $/'); 25 print $writeme "q\n"; 26 print $writeme "\cC\n"; 27 waitpid($pid, 0); 28 print "$results\n"; ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: UNIX utilities in Perl
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Martin Leese > Sent: Wednesday, November 10, 2004 1:40 PM > To: [EMAIL PROTECTED] > Subject: UNIX utilities in Perl > > > Hi, > > I am not sure if this is the right list for this question. > I suspect it belongs on a list about CPAN, but the CPAN > site doesn't appear to mention one. > > I am working on Windows, and find I keep writing very > short Perl scripts to implement UNIX utilities. I call > them zap_grep, zap_wc, zap_unique, zap_diff, zap_sort. > My versions are very crude compared with the UNIX > originals, and I wondered if somebody had already gone > through this exercise. > > A search of CPAN came up with "prep" (Perl grep), "wc", > and "uniq". > Are these modules collected together anywhere? > Should they be? > What additional UNIX utilities would be useful? (Above, > I suggest diff and sort.) Do you need Perl versions? You can get win32 native version from the following URLs: http://unxutils.sourceforge.net/ has a nice little collection of tools. http://www.mingw.org/msys.shtml has a bit more comprehensive collection. > What would be *really* useful is a method to pipe > filters together. > > Regards, > Martin > > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: How remove newlines?
> -Original Message- > From: A B [mailto:[EMAIL PROTECTED] > Sent: Friday, November 05, 2004 2:10 PM > To: vega, james; Martin Leese > Cc: 'Glenn Linderman'; [EMAIL PROTECTED] > Subject: RE: How remove newlines? > > > $tempVale =~ s/\r?\n//g; What about Mac-formatted files which use just \r? > --- "vega, james" <[EMAIL PROTECTED]> wrote: > > > -Original Message- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] On > > > Behalf Of Glenn Linderman > > > Sent: Friday, November 05, 2004 1:48 PM > > > To: Martin Leese > > > Cc: [EMAIL PROTECTED] > > > Subject: Re: How remove newlines? > > > > > > > > > On approximately 11/5/2004 10:38 AM, came the following > > > characters from > > > the keyboard of Martin Leese: > > > > Hi, > > > > > > > > A nice easy one for a Friday afternoon. > > > > > > > > I have a variable containing text in which I wish to convert > > > > embedded newlines to spaces. And, I wish to do this in a way > > > > which is portable. > > > > > > > > I have come up with: > > > > > > > > $tempValue =~ s/\r\n/ /g; > > > > $tempValue =~ s/\n/ /g; > > > > > > > > I believe this pair of statements will work on both Windows and > > > > UNIX, and with text originating on both Windows and UNIX. I > > > > welcome improvements. > > > > > > > > Also, how do I accommodate Macs? > > > > > > If a sequence of newlines can be converted to a single space, then > > > > > > $tempValue =~ s/[\r\n]*/ /g; > > > > That should be: > > > > $tempValue =~ s/[\r\n]+/ /g; > > > > Otherwise you'll end up putting spaces in more places than you like. > > > > > will do it. Otherwise, add > > > > > > $tempVale =~ s/\r/ /g; > > > > > > to your existing commands. (AFAIK -- I've never owned a Mac) > > > > > > -- > > > Glenn -- http://nevcal.com/ > > > === > > > Having identified a vast realm of ignorance, Wolfram is > > > saying that much of this realm lies forever outside the light > > > cone of human knowledge. > > >-- Michael Swaine, Dr Dobbs > > > Journal, Sept 2002 ___ > > > Perl-Win32-Users mailing list > > > [EMAIL PROTECTED] > > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > > > > ___ > > Perl-Win32-Users mailing list > > [EMAIL PROTECTED] > > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > > > __ > > Post your free ad now! http://personals.yahoo.ca > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: How remove newlines?
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Glenn Linderman > Sent: Friday, November 05, 2004 1:48 PM > To: Martin Leese > Cc: [EMAIL PROTECTED] > Subject: Re: How remove newlines? > > > On approximately 11/5/2004 10:38 AM, came the following > characters from > the keyboard of Martin Leese: > > Hi, > > > > A nice easy one for a Friday afternoon. > > > > I have a variable containing text in which I wish to > > convert embedded newlines to spaces. And, I wish to > > do this in a way which is portable. > > > > I have come up with: > > > > $tempValue =~ s/\r\n/ /g; > > $tempValue =~ s/\n/ /g; > > > > I believe this pair of statements will work on both > > Windows and UNIX, and with text originating on both > > Windows and UNIX. I welcome improvements. > > > > Also, how do I accommodate Macs? > > If a sequence of newlines can be converted to a single space, then > > $tempValue =~ s/[\r\n]*/ /g; That should be: $tempValue =~ s/[\r\n]+/ /g; Otherwise you'll end up putting spaces in more places than you like. > will do it. Otherwise, add > > $tempVale =~ s/\r/ /g; > > to your existing commands. (AFAIK -- I've never owned a Mac) > > -- > Glenn -- http://nevcal.com/ > === > Having identified a vast realm of ignorance, Wolfram is > saying that much of this realm lies forever outside the light > cone of human knowledge. >-- Michael Swaine, Dr Dobbs > Journal, Sept 2002 ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: split and ^ character
> I'm trying to figure how to get the following code to work. > I've tried a > few combos, but nothing seems to get it right. I'm guessing > it's something > simple, but I couldn't nail down what it was. I realize that > ^ is a special > operator but I don't see a way to escape it, given that it's > input from a > scalar variable. > > > $subrecdelim = '^'; > > $mystr = 'cat^dog^pony^rat'; > > @array = split(/$subrecdelim/, $mystr); @array = split(/\Q$subrecdelim\E/, $mystr); \Q - Quotes nonword characters until \E > foreach (@array) { > print " - $_\n"; > } > > > > Any hints would be appreciated. > > Thanks! > Paul --- ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Round Numbers
> -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Anderson, Mark (Service Delivery) > Sent: Wednesday, September 08, 2004 9:59 AM > To: '[EMAIL PROTECTED]'; Chris > Cc: perl-win32-users; > [EMAIL PROTECTED] > Subject: RE: Round Numbers > > > Nope... try it :-) It only returns the integer component. > > C:\logchecks>perl -e "print int(1.7)" > 1 > C:> That's the point. If you have a number in the range .5 - 1.4, adding .5 to it will put it in the range 1 - 1.9. If you then int() that number, it will be truncated to 1, properly rounding your number. I performing all of the mentioned steps next time. :) H:\>perl -e "print int(1.1+.5)" 1 H:\>perl -e "print int(1.5+.5)" 2 H:\> James > > Kind regards, > > Mark Anderson > SMS Deployment > The Royal Bank of Scotland > 113 Dundas Street, Edinburgh, EH3 5DE > http://www.manufacturing.rbs.co.uk/GTrswi/ > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [SMTP:[EMAIL PROTECTED] > > Sent: Wednesday, September 08, 2004 2:52 PM > > To: Chris > > Cc: perl-win32-users; > [EMAIL PROTECTED] > > Subject:Re: Round Numbers > > > > *** WARNING : This message originates from the Internet *** > > > > > > > > > > > > how about > > > > $rounded = int($number+ 0.5) > > > > Regards, > > Gerhard > > > > > > > > |-+-> > > | | | > > | | | > > | | | > > | | | > > | | | > > | |"Chris" <[EMAIL PROTECTED]> | > > | | | > > | |Sent by: | > > | |[EMAIL PROTECTED]| > > | |.com | > > | | | > > | |2004-09-08 03:41 PM | > > | | | > > |-+-> > > > > > >- > > > > > --| > > | > > | > > | To: "perl-win32-users" > > <[EMAIL PROTECTED]>| > > | cc: (bcc: Gerhard Petrowitsch/STN/SC/PHILIPS) > > | > > | Subject:Round Numbers > > | > > | > > | > > | Classification: > > | > > | > > | > > | > > | > > > > > >- > > > > > --| > > > > > > > > > > All, > > > > Is there an easy way to round numbers in Perl? > > > > > > Regards, > > > > Chris ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs