Re: japanese in regular expressions possible?
At 5:40 pm +0900 14/8/03, Joel Rees wrote: Am I expecting too much, too early? Not at all. I pasted your message into TextEdit and saved it as utf-8 on the desktop with the name biao.txt. This script then behaves as I would expect: #!/usr/bin/perl no warnings ; $f = $ENV{HOME}/Desktop/biao.txt ; # file saved as UTF-8 open F, $f or die $! ; $/ = \015 ; # only if the file has Mac line endings !!! print \x{8868}\n\n; # prints the character as utf-8 for (F) { print 1. $_ if // ; print 2. $_ if /\xE8\xA1\xA8/ ; } Note that if you write use utf8; it will NOT work JD
Re: Ordering keys in a hash
On Tue, 5 Aug 2003, Adam Witney wrote: Date: Tue, 05 Aug 2003 16:12:50 +0100 From: Adam Witney [EMAIL PROTECTED] To: MacOS X perl [EMAIL PROTECTED] Subject: Ordering keys in a hash Hi, I have a hash with keys of the format sar0011_4 sar0203_3 sar0050_5 sar2001_1 sar0002_9 And I would like to generate a list ordered by the \d\d\d\d bit in the middle. I have this from the perl cookbook my @keys = sort {criterion()} keys(%gene_pool); but I don't really know how to approach the criterion() function Anybody have any suggestions? Thanks for any help Adam I don't know how many values you need to sort, but it's probably advisable to use a Schwartzian Transform. Here's my suggestion: my @sorted = map { $_-[1] } sort { $a-[0] = $b-[0] } map { [ $_ =~ /(\d{4})/, $_ ] } qw( sar0011_4 sar0203_3 sar0050_5 sar2001_1 sar0002_9 ); print Sorted = , join(', ', @sorted), \n; Gives me: Sorted = sar0002_9, sar0011_4, sar0050_5, sar0203_3, sar2001_1 Is that what you want? ky
Re: Psync, small pseudo-bug
Yikes. I could have used rmtree() of File::Path to make sure it is empty (the obvious drawback is that it is slow). There's always the pseudo-hackish way: add a flag to psync which causes it to delete .DS_Store files in empty directories before rm-ing them. Ugh. Osx finder... find /Volumes/Backup -type f -name .DS_Store -delete -print before committing psync. That ensures that .DS_Store does not exist. Ah, for a moment I thought that would be useless becayse psync would just re-sync the DS_Store, but if it goes through and cleans first then it would work, xlnt. Just did that (but didn't test psync since it will copy 4GB of my mail) :) Yes, I will but I can't make promises as to when to release the next version of MacOSX::File. Unfortunately I am thrashing recently. Dude, ditto. Also this is minor. Psync has never fscked up on me and I consider this an extremely minor annoyance at worst.. Deleting a couple empty folders from a perfect bootable backup copy of my box is not a big deal :) Dan the Man with Too Many Projects to Proceed Heh, know the feeling. Good luck ta yeh, _a
Re: Ordering keys in a hash
On Tuesday, August 5, 2003, at 10:12 AM, Adam Witney wrote: Hi, I have a hash with keys of the format sar0011_4 sar0203_3 sar0050_5 sar2001_1 sar0002_9 And I would like to generate a list ordered by the \d\d\d\d bit in the middle. I have this from the perl cookbook my @keys = sort {criterion()} keys(%gene_pool); but I don't really know how to approach the criterion() function If all of them will start with the same prefix and contain 4 digits there, then you can just do my @keys = sort keys %gene_pool; If they don't, and you really need to sort by the \d\d\d\d, then the following would work: sub by_id { my ($x, $y) = ($a =~ /(\d\d\d\d)/, $b =~ /(\d\d\d\d)/); $x = $y or $a cmp $b; # Fall back to comparison of entire key } my @keys = sort by_id keys %gene_pool;
JPG to Quicktime
Hi all - I have a webcam and am using EvoCam to generate JPG's from it. EvoCam will also generate QuickTime movies, but it takes too long on my old Pismo (500 MHz G3) and I would rather have the JPG's than the movies. I also have QuickTime Pro, which will allow you to make movies from a directory of JPG's, but you have to open QuickTime Pro to do that. Is there some way to make movies from the command line? I looked through the table of contents and index of Perl Graphics Programming but didn't see any mention of QuickTime. I'd prefer using Perl, of course, but pointers to AppleScript or shell are certainly welcome. Mike Schienle
Re: DBI and DBD::MySQL (Panther)
On Friday, August 8, 2003, at 8:35 AM, Mike Schienle wrote: On Friday, August 8, 2003, at 7:28 AM, John Delacour wrote: At 4:09 pm -0600 7/8/03, Mike Schienle wrote: I'm having some trouble with DBI and DBD::MysqlPP (and DBD::MySQL) on 10.3. Can I get a sanity check response that some people are able to run one of these? 10.3 is not that important for what I'm working on, but MySQL is, so I can roll back to older versions of MacOS X, MySQL, etc., if necessary. I never got DBD::MySQL to make so I tried MySQLPP today, which installed fine. I'm about to check out DBI::PurePerl, as well. Any hints on getting this working so I don't have to roll back would be greatly appreciated. I haven't tried yet on Panther, but I guess nothing has changed and that you'll have to install Perl without threads in you wand to use DBI and MySQL. http://nathan.torkington.com/mac/ Thanks for the link, John. I'm also going to move back from an Alpha MySQL 4.1 to 4.0. I'll report back if anything works. Using MySQL 4.0, DBI 1.37 and DBD::mysqlPP worked for me. I'm getting a compile error with DBD::mysql listed below (I can spend a little time troubleshooting this, but not much): cpan install DBD::mysql Running install for module DBD::mysql Running make for R/RU/RUDY/DBD-mysql-2.9002.tar.gz ... Removing previously used /Users/mschienle/.cpan/build/DBD-mysql-2.9002 CPAN: Module::Signature security checks disabled because Module::Signature not installed. Please consider installing the Module::Signature module. CPAN.pm: Going to build R/RU/RUDY/DBD-mysql-2.9002.tar.gz I will use the following settings for compiling and testing: cflags(mysql_config) = -I'/usr/local/include/mysql' libs (mysql_config) = -L/usr/local/lib/mysql -lmysqlclient -lz -lm nocatchstderr (default ) = 0 nofoundrows (default ) = 0 ssl (guessed ) = 0 testdb(default ) = test testhost (default ) = testpassword (default ) = testuser (default ) = To change these settings, see 'perl Makefile.PL --help' and 'perldoc INSTALL'. Argument 6.10_03 isn't numeric in numeric ge (=) at Makefile.PL line 89, PIPE line 58. Checking if your kit is complete... Looks good Using DBI 1.37 installed in /Library/Perl/5.8.1/darwin-thread-multi-2level/auto/DBI Writing Makefile for DBD::mysql cp lib/DBD/mysql.pm blib/lib/DBD/mysql.pm cp lib/DBD/mysql/GetInfo.pm blib/lib/DBD/mysql/GetInfo.pm cp lib/Mysql.pm blib/lib/Mysql.pm cp lib/DBD/mysql/INSTALL.pod blib/lib/DBD/mysql/INSTALL.pod cp lib/Mysql/Statement.pm blib/lib/Mysql/Statement.pm cp lib/Bundle/DBD/mysql.pm blib/lib/Bundle/DBD/mysql.pm cc -c -I/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/DBI -I'/usr/local/include/mysql' -g -pipe -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -Os -DVERSION=\2.9002\ -DXS_VERSION=\2.9002\ -I/System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE dbdimp.c /usr/local/bin/perl -p -e s/~DRIVER~/mysql/g /Library/Perl/5.8.1/darwin-thread-multi-2level/auto/DBI/Driver.xst mysql.xsi /usr/local/bin/perl /System/Library/Perl/5.8.1/ExtUtils/xsubpp -typemap /System/Library/Perl/5.8.1/ExtUtils/typemap mysql.xs mysql.xsc mv mysql.xsc mysql.c Warning: duplicate function definition 'do' detected in mysql.xs, line 193 Warning: duplicate function definition 'rows' detected in mysql.xs, line 291 cc -c -I/Library/Perl/5.8.1/darwin-thread-multi-2level/auto/DBI -I'/usr/local/include/mysql' -g -pipe -pipe -fno-common -no-cpp-precomp -fno-strict-aliasing -Os -DVERSION=\2.9002\ -DXS_VERSION=\2.9002\ -I/System/Library/Perl/5.8.1/darwin-thread-multi-2level/CORE mysql.c Running Mkbootstrap for DBD::mysql () chmod 644 mysql.bs rm -f blib/arch/auto/DBD/mysql/mysql.bundle LD_RUN_PATH=/usr/local/lib/mysql:/usr/lib /usr/local/bin/perl myld MACOSX_DEPLOYMENT_TARGET=10.3 cc -bundle -undefined dynamic_lookup -L/usr/local/lib dbdimp.o mysql.o -o blib/arch/auto/DBD/mysql/mysql.bundle -L/usr/local/lib/mysql -lmysqlclient -lz -lm make: *** [blib/arch/auto/DBD/mysql/mysql.bundle] Error 1 /usr/bin/make -- NOT OK Running make test Can't test without successful make Running make install make had returned bad status, install seems impossible Mike Schienle
Ordering keys in a hash
Hi, I have a hash with keys of the format sar0011_4 sar0203_3 sar0050_5 sar2001_1 sar0002_9 And I would like to generate a list ordered by the \d\d\d\d bit in the middle. I have this from the perl cookbook my @keys = sort {criterion()} keys(%gene_pool); but I don't really know how to approach the criterion() function Anybody have any suggestions? Thanks for any help Adam -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
Re: japanese in regular expressions possible?
On Thursday, August 14, 2003, at 05:40 pm, Joel Rees wrote: I really wanted to use Japanese my experiences mirror yours pretty closely Am I expecting too much, too early? I always put my lack of success down to my missing something vital in the knowledge department (and getting my hands on CJKV Information Processing is proving tougher than I had imagined). I assume my own ineptitude due to the fact Japanese perlers were doing regex substitutions before 5.8, granted they did most of the groundwork which perl now does for you (thanks Dan). What are you guys doing for these? I'm ashamed to admit it but I currently cop out and use English for web pages that will be processed by perl Robin
Re: DBI and DBD::MySQL (Panther)
Does this mean that the version of perl installed on Panther will not support DBI and DBD::MySQL? That would be a real pain. On Friday, Aug 8, 2003, at 15:28 Europe/Madrid, John Delacour wrote: At 4:09 pm -0600 7/8/03, Mike Schienle wrote: I'm having some trouble with DBI and DBD::MysqlPP (and DBD::MySQL) on 10.3. Can I get a sanity check response that some people are able to run one of these? 10.3 is not that important for what I'm working on, but MySQL is, so I can roll back to older versions of MacOS X, MySQL, etc., if necessary. I never got DBD::MySQL to make so I tried MySQLPP today, which installed fine. I'm about to check out DBI::PurePerl, as well. Any hints on getting this working so I don't have to roll back would be greatly appreciated. I haven't tried yet on Panther, but I guess nothing has changed and that you'll have to install Perl without threads in you wand to use DBI and MySQL. http://nathan.torkington.com/mac/ Robert Whittle BookAssist [EMAIL PROTECTED] http://www.bookassist.com
Re: DBI and DBD::MySQL (Panther)
On Friday, August 8, 2003, at 7:28 AM, John Delacour wrote: At 4:09 pm -0600 7/8/03, Mike Schienle wrote: I'm having some trouble with DBI and DBD::MysqlPP (and DBD::MySQL) on 10.3. Can I get a sanity check response that some people are able to run one of these? 10.3 is not that important for what I'm working on, but MySQL is, so I can roll back to older versions of MacOS X, MySQL, etc., if necessary. I never got DBD::MySQL to make so I tried MySQLPP today, which installed fine. I'm about to check out DBI::PurePerl, as well. Any hints on getting this working so I don't have to roll back would be greatly appreciated. I haven't tried yet on Panther, but I guess nothing has changed and that you'll have to install Perl without threads in you wand to use DBI and MySQL. http://nathan.torkington.com/mac/ Thanks for the link, John. I'm also going to move back from an Alpha MySQL 4.1 to 4.0. I'll report back if anything works. Mike Schienle
Re: Apache on Panther
At 10:01 am -0700 7/8/03, David Wheeler wrote: % httpd -v On Panther? I'm really curious as to whether Apple has ditched Apache 1.3 for 2.0. Server version: Apache/1.3.27 (Darwin) But there's nothing to stop you running 2. I run 2 under Jaguar. JD
Re: Ordering keys in a hash
* Ken Y. Clark [EMAIL PROTECTED] I don't know how many values you need to sort, but it's probably advisable to use a Schwartzian Transform. Here's my suggestion: Which in turn may be slower than a new sorting method: http://www.sysarch.com/perl/sort_paper.html Sorting can be a major bottleneck in Perl programs. Performance can vary by orders of magnitude, depending on how the sort is written. In this paper, we examine PerlĀ“s sort function in depth and describe how to use it with simple and complex data. Next we analyze and compare several well-known Perl sorting optimizations (including the Orcish Maneuver and the Schwartzian Transform). We then show how to improve their performance significantly, by packing multiple sortkeys into a single string. Finally, we present a fresh approach, using the sort function with packed sortkeys and without a sortsub. This performs much better than any of the other methods, and is easy to implement directly or by using a new module we created, Sort::Records.