CPAN failure in 5.16.1 (+ solution)

2012-09-10 Thread John Delacour


It seems there have been no postings to the list for over a year, but 
here goes anyway.


Last night I installed Perl 5.16.1 in /usr/local/ and immediately 
encountered problems when I tried to install and update modules using 
CPAN.  The error is copied below.  I could see no solution to the 
problem and was expecting a very tiresome late night, until by some 
stroke of luck I thought of trying cpanplus to install the modules 
and to install CPAN itself.


You can imagine my relief when this worked, and now CPAN runs without a hitch.


JD




- sudo ./cpanp
CPANPLUS::Shell::Default -- CPAN 
exploration and module 
installation (v0.9121)
*** Please report bugs to 
bug-cpanp...@rt.cpan.org.
*** Using CPANPLUS::Backend 
v0.9121.  ReadLine support 
enabled.


*** Type 'p' now to show start up log

Did you know...
   You can install modules by URL 
using 'i URL'

CPAN Terminal install Net::SMTP::SSL

[MSG] No '/Users/jd/.cpanplus/custom-sources' dir, skipping custom sources
[MSG] No '/Users/jd/.cpanplus/custom-sources' dir, skipping custom sources
[MSG] No '/Users/jd/.cpanplus/custom-sources' dir, skipping custom sources
Installing Net::SMTP::SSL (1.01)
*** Install log written to:
  /Users/jd/.cpanplus/install-logs/Net-SMTP-SSL-1.01-1347232926.log

Module 'Net::SMTP::SSL' installed successfully
No errors installing all modules

CPAN Terminal install Net::SSLeay
Installing Net::SSLeay (1.48)
...
Module 'Net::SSLeay' installed successfully
No errors installing all modules

CPAN Terminal install CPAN

Installing CPAN (1.9800)
*** Install log written to:
  /Users/jd/.cpanplus/install-logs/CPAN-1.9800-1347233052.log

Module 'CPAN' installed successfully
No errors installing all modules


__
00:17:39 User:jd   Cwd: /usr/local/bin
- sudo ./cpan
Password:
cpan[1] r 
  
   
Database was generated on Sun, 09 
Sep 2012 14:59:47 GMT
Catching error: Can't locate 
DBI.pm in \@INC (\@INC contains: 
/usr/local/lib/perl5/site_perl/5.16.1/darwin-2level 
/usr/local/lib/perl5/site_perl/5.16.1 
/usr/local/lib/perl5/5.16.1/darwin-2level 
/usr/local/lib/perl5/5.16.1 
/usr/local/lib/perl5/site_perl/5.14.2 
/usr/local/lib/perl5/site_perl/5.14.0 
/usr/local/lib/perl5/site_perl/5.12.3 
/usr/local/lib/perl5/site_perl/5.12.2 
/usr/local/lib/perl5/site_perl 
/usr/local/bin) at 
/usr/local/lib/perl5/site_perl/5.14.0/CPAN/SQLite/DBI.pm 
line 7.\cJBEGIN 
failed--compilation aborted at 
/usr/local/lib/perl5/site_perl/5.14.0/CPAN/SQLite/DBI.pm 
line 7.\cJCompilation failed in 
require at (eval 26) line 
2.\cJ\cI...propagated at 
/usr/local/lib/perl5/5.16.1/base.pm 
line 84.\cJBEGIN 
failed--compilation aborted at 
/usr/local/lib/perl5/site_perl/5.14.0/CPAN/SQLite/DBI/Search.pm 
line 8.\cJCompilation failed in 
require at 
/usr/local/lib/perl5/site_perl/5.14.0/CPAN/SQLite/Search.pm 
line 9.\cJBEGIN 
failed--compilation aborted at 
/usr/local/lib/perl5/site_perl/5.14.0/CPAN/SQLite/Search.pm 
line 9.\cJCompilation failed in 
require at 
/usr/local/lib/perl5/site_perl/5.14.0/CPAN/SQLite.pm 
line 78.\cJ at 
/usr/local/lib/perl5/5.16.1/CPAN.pm 
line 392.
	CPAN::shell() called at 
/usr/local/lib/perl5/5.16.1/App/Cpan.pm 
line 295


	App::Cpan::_process_options('App::Cpan') 
called at 
/usr/local/lib/perl5/5.16.1/App/Cpan.pm 
line 364
	App::Cpan::run('App::Cpan') 
called at ./cpan line 11


Re: Can't Update CPAN, Can't Install DBD::mysql

2011-09-28 Thread John Delacour

At 13:41 -0400 28/9/11, Lola Lee Beno wrote:


...Can't exec /usr/bin/make: No such file or directory at


Looks like I need to install make.  This means, I need to get XCode 
so I can install make, right?


Absolutely!  Isn't it on your Mac OS X install disks?

JD


Re: perl modules on osx

2011-07-27 Thread John Delacour

At 11:38 -0700 27/07/2011, Noah wrote:

...this is a beginners question.  I am trying to figure out the best 
cpan strategy for OSX.  what is the best installation option for 
installing a cpan module to mac osx?  I cant find the module in 
macports or fink packages.


I did download it and attempting to install manually but found I 
have a bunch of prerequisites that are not found.  Is there a way to 
automate their installation.  Should I be looking to do this entire 
perl module installation with installing cpan through perl directly?


Yes, provided you are using the Perl Apple installed or, which is 
most unlikely from what you have said, a version you have installed 
in /usr/local.


Make sure you have installed the Developer Tools from your Mac OS X 
disks, without which you won't be able to compile the modules.


Then, in Terminal, type

sudo cpan

and you will be asked for info needed to set up CPAN for use. You can 
choose to have prerequisites installed for modules, and I think this 
is the default.


Once you are set up, then installing modules is very straightforward. 
Just type sudo cpan and then


install Some::Module

When you have finished with CPAN make sure always to do

exit

or

q

To exit to the bash shell otherwise you will have problems with a locked file.

JD


Re: Clean Install

2011-06-18 Thread John Delacour

At 10:46 +0200 18/06/2011, Marek Stepanek wrote:


MIA - I was googeling this abbreviation. Does it mean Miami
Dolphins or Miami Airport?


Missing in Action == fatally absent


I thought I'd give myself a little useless suffering by installing 
MySQL (the Mac 64-bit .dmg) and then trying to install DBD::mysql 
with similar results to yours.


I then tried various supposed solutions to no effect.

Finally I discovered this suggestion and hey presto! success with 
both installations:



$ cd /usr/local/bin
$ sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib 
/usr/lib/libmysqlclient.18.dylib

$ sudo ./cpan
[...]
cpan[1] install DBD::mysql
[...]
Appending installation info to 
/usr/local/lib/perl5/5.14.0/darwin-2level/perllocal.pod

  CAPTTOFU/DBD-mysql-4.019.tar.gz
  /usr/bin/make install  -- OK
_

$ cd
$ sudo cpan
[...]
cpan[1] install DBD::mysql
[...]
Appending installation info to 
/Library/Perl/Updates/5.10.0/darwin-thread-multi-2level/perllocal.pod

  CAPTTOFU/DBD-mysql-4.019.tar.gz
  /usr/bin/make install  -- OK


JD


Re: Clean Install

2011-06-18 Thread John Delacour

At 12:51 +0200 18/06/2011, Marek Stepanek wrote:


...and with cpanp

DBI

and manually DBD::mysql

% perl Makefile.PL --testuser=mstep --testpassword=s3kr1t

..Library not loaded: libmysqlclient.18.dylib



Just create the symbolic link as I have just (not originally) suggested:

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib

You will then get:

$ cd /usr/lib; ls -al | grep *mysql*
lrwxr-xr-x1 root  wheel44 18 Jun 11:22 
libmysqlclient.18.dylib - 
/usr/local/mysql/lib/libmysqlclient.18.dylib



DBD::mysql and install using CPAN.

JD


Re: Clean Install

2011-06-18 Thread John Delacour

At 13:23 +0200 18/06/2011, Marek Stepanek wrote:


And now I spend a lot of time again ... I forgot the hint of Chas. doing:

% ./intro6.pl

Which is not working with my

#!/usr/bin/perl

so I have to do it like that:

% perl intro6.pl

!!

or I have to change like follows:

#!/Users/mstep/perl5/perlbrew/perls/perl-5.14.0/bin/perl


Yes, well portablility is a great thing and that's why I install Perl 
in the default location /usr/local/bin, which is linked to from 
/usr/bin on most servers.  I am sure perlbrew has its uses but I have 
a poor memory and if I install things in the usual places I can more 
easily find the answers to my problems.  In the home environment I 
simply use either #!/usr/bin/perl or #!/usr/local/bin/perl depending 
which perl I want to use.  On most remote servers the two are 
equivalent and I have no control over which Perl they have installed.



Thank you all for your great help!


Glad it worked.  If you want some real fun, try installing PDL :-)

JD









Re: Clean Install

2011-06-17 Thread John Delacour

At 23:34 +0200 17/06/2011, Marek Stepanek wrote:


Compilation failed in require at (eval 3) line 3.
Perhaps a required shared library or dll isn't installed where expected
 at intro6.pl line 12



Probably a silly question, but have you installed MySQL?
http://www.mysql.com/downloads/mysql/

I'm afraid I can't advise since I can't stand MySQL and find life 
much easier with SQLite.


JD


Re: New Perl-Installation on new OS X

2011-06-10 Thread John Delacour

At 11:45 +0100 10/06/2011, David Cantrell wrote:


Several fixes come to mind:
...
4. just set PERl5LIB to whatever you fancy after that line.  This will,
   however, mean that you override any changes that may be made to your
   startup files elsewhere at a later date.


What would be the effect of setting a value (or no value) for 
PERL5LIB in ~/.MacOSX/environment.plist?  Would that override 
anything written to .profile etc.?


JD


Re: New Perl-Installation on new OS X

2011-06-10 Thread John Delacour

At 10:38 -0400 10/06/2011, Sherm Pendley wrote:


  What would be the effect of setting a value (or no value) for PERL5LIB in

 ~/.MacOSX/environment.plist?


That plist is for setting up environment variables for GUI apps. It
has no effect on shell sessions.


Obviously I'm missing something.  If I do set it, it seems to have 
the same effect superficially as fink's exporting it via 
.profile/init.sh, which I thought was the problem:


perl -V
  Compiled at Jan 26 2010 17:48:53
  %ENV:
PERL5LIB=/usr/local/lib/perl5/site_perl/5.14.0
  @INC:
/usr/local/lib/perl5/site_perl/5.14.0
/Library/Perl/Updates/5.10.0/darwin-thread-multi-2level

perl -e 'print $ENV{PERL5LIB}'
/usr/local/lib/perl5/site_perl/5.14.0

JD


Re: New Perl-Installation on new OS X

2011-06-10 Thread John Delacour

At 16:47 +0100 10/06/2011, David Cantrell wrote:


Are you using Terminal.app?  That's a GUI application, so it takes
effect, and is then inherited by the shell.  Try sshing into your
Mac from elsewhere.


Right.  I ran a script from cgi-bin on my local server and indeed 
this key was missing.  The same script run in BBEdit had it.  All 
clear.  Thanks.


JD


RE: New Perl-Installation on new OS X

2011-06-10 Thread John Delacour

At 13:21 -0700 10/06/2011, Jan Dubois wrote:


I think a better way to modify your @INC is on a per-installation
basis.  For Apple's Perl you have the AppendToPath and PrependToPath
mechanism...
There is no PrependToPath file by default, but you can create one
yourself, and all directories listed in there will be put at the
front of @INC, just as if you put them into PERL5LIB.

If you build your own Perl, then you may want to ./Configure it
with -Dusesitecustomize.  That way you can modify @INC in a
perl/site/lib/sitecustomize.pl file at runtime.


Very useful information, Jan.  Many thanks.

JD


Re: New Perl-Installation on new OS X

2011-06-09 Thread John Delacour

At 16:14 +0100 09/06/2011, Marek Stepanek wrote:

Probably I will leave the apple Perl it as it is, and make a new 
install of perl-5.14.0 under /usr/local


That is what I do, so that the two installations are independent. I 
configure simply like this:


cd downloaded_directory
./Configure -de -Dperladmin=em...@addr.com -Dcf_email=em...@addr.com
make
make test
sudo make install

Others may have more elaborate configuration suggestions but this 
works fine for me.


If I want to use the latest perl I change the shebang accordingly.

One thing to remember, of course, is that to add modules with cpan to 
5.14.0 so configured, rather than to Apple's installation, you need to


cd /usr/local/bin; sudo ./cpan

JD




Re: New Perl-Installation on new OS X

2011-06-08 Thread John Delacour

At 16:02 +0200 08/06/2011, Marek Stepanek wrote:


...So, gcc seems to be al right. Is it possible, that the migration 
assistant has mixed up, 32bit compiled modules with 64bit? Or is 
there a confusion with the Perl of Fink? Here my Perl:


  Built under darwin
  Compiled at Jan 26 2010 17:48:54
  %ENV:
PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
  @INC:
/sw/lib/perl5/5.10.0/darwin-thread-multi-2level
/sw/lib/perl5/5.10.0 ...


I think you're going to have trouble until you get rid of everything 
Fink has installed and everything it's changed in /usr/bin.


If I were you I'd probably delete /usr/bin/perl and replace it with a 
link but I'd wait for others to give you more experienced advice.


I would also install the latest Xcode.

Note that gcc -v will give you gcc-4.0 and not gcc-4.2 unless you 
have replaced Apple's original link, so maybe Fink did that too.


JD


Re: New Perl-Installation on new OS X

2011-06-08 Thread John Delacour

At 17:55 +0200 08/06/2011, Marek Stepanek wrote:


gcc-4.2 was installed with the latest XCode 4.0.2 Is Fink installing 
into /usr/bin ? Or is it a misunderstanding?


I have  both gcc-4.0 and gcc-4.2 in /usr/bin but gcc points to 
gcc-4.0.  I have Xcode version 3.2.6 and I see in Get Info that there 
is an option to open in 32-bit mode.  That may have been switched on 
in the migration... but listen to wiser counsel than mine.


offtopicMy new laptop was a not really cheap: 2600 Euros, and 
Apple is asking for the XCode download 3.90 Euros. This is 
nit-picking in my eyes. I don't know, where Apple is going, but I 
see in the last years only toys and no real support of professionals.


I have been thinking so all day after watching the announcement of 
iCloud, a complete non-happening designed, like everything Apple, for 
shop-happy groupees.  It is free, up to a point, once you have 
bought your latest Mac, your latest iPhone and your latest iPad, paid 
the interest on the loans and the subscription to all the service 
providers for the connectivity needed to download tune after useless 
tune at an inflated price. My first 128K Mac with a dot matrix 
printer cost me over $4,000 in 1984, so the writing has been on the 
wall for a long time. /offtopic


JD


Re: New Perl-Installation on new OS X

2011-06-08 Thread John Delacour

At 18:16 +0200 08/06/2011, Marek Stepanek wrote:



On 08.06.2011 18:03, Melton Low wrote:

xCode 4 should have been included with your new Mac.  Check in the
Optional Application install disc.


XCode 4 is only for bleeding-edge developers.

Not here in Germany :-( In old times there was XCode on the optional 
installer DVD. Now there are only toys: iDVD, Sound  Jingles, 
iPhoto ... That's all, what Apple offers as extra for a 2600 Euro 
computer ...


XCode 3.2.6 should be on the disks and is all you need. On the main 
install disk I got with the Mac Mini in January there is a folder 
Optional Installs with the XCode package in it.  I have a feeling 
Sofware Update has updated it since I first installed it.


If it's not on the disk you can get it free from 
http://developer.apple.com/devcenter/mac/index.action provided you 
are a member -- and this grade of membership is free.


Good luck.

JD


Re: New Perl-Installation on new OS X

2011-06-08 Thread John Delacour

At 10:54 -0700 08/06/2011, rd ackerman wrote:



On Jun 8, 2011, at 10:33 AM, John Delacour wrote:

  If it's not on the disk you can get it free from 
http://developer.apple.com/devcenter/mac/index.action provided you 
are a member -- and this grade of membership is free.


xcode4 is only available if you are a $99/yr developer.




If you read what I wrote you will see I was not talking about XCode 4.

Besides, as Marek said in the beginning, you can get it for $4.99 at 
the app store - 
http://itunes.apple.com/us/app/xcode/id422352214?mt=12ls=1



JD



Re: New Perl-Installation on new OS X

2011-06-08 Thread John Delacour

At 15:18 -0400 08/06/2011, Sherm Pendley wrote:



On Wed, Jun 8, 2011 at 11:49 AM, Melton Low softw.d...@gmail.com wrote:


 I use MacPort and I ended up deleting everything from MacPort before
 re-installing everything.


A pointless exercise - Like Fink, MacPorts doesn't touch /usr.
Everything relevant to MacPorts is found under /opt/local.


Please explain then how Marek gets

/sw/lib/perl5/5.10.0 ...

when he does perl -V from the command line.

Are you saying that a script on his machine with the shebang 
#!/usr/bin/perl will completely ignore /sw/...?


If I do perl -V I get the Apple installation

If I do /usr/local/bin/./perl -V then I get

/usr/local/lib/perl5/site_perl/5.14.0...


JD

PS.  I don't need two copies of every posting to the list.


Re: New Perl-Installation on new OS X

2011-06-08 Thread John Delacour

At 16:17 -0400 08/06/2011, Sherm Pendley wrote:


No. I'm saying that there are *many* ways to influence @INC without
bothering any files under /usr.

PERL5LIB, for one.


I'm sure that's very clear to everyone who already knows what you are 
talking about.  Are you saying that by editing ~/.bashrc or some such 
file one could remove this environment variable that has been added 
by some fink or port or other animal?  If that's what you mean, why 
not say so.  I thought people asked questions on this list in order 
to get useful answers rather than merely to be informed that someone 
has the answer but hasn't the time to give it.



 PS.  I don't need two copies of every posting to the list.


Complain to the list admins. They're the ones who broke reply all, not me.


You alone are responsible for who you send emails to.  Are you 
getting a duplicate of this?


JD


Re: Need one more tweak...

2011-01-20 Thread John Delacour

At 15:43 -0500 20/01/2011, Levan, Jerry wrote:


I basically have a form with a text box, users
can enter sql in the text box and hit the submit
button and the Perl CGI will do its magic on all of
the text in the box.

Query results will appear as html tables.

I would like one more enhancement...

I would like to be able to 'select' some text in
the text box and using possibly a different
submit button have the CGI code only process the
selected text.

My gut feeling is that this might involve using
javascript which is bad since it has been about
Fifteen years since I have written any js code


I am halfway through doing a very similar thing and found a suitable 
script on my first attempt.


I append the subroutine I have used to insert the script into the 
head and below it the stuff for the button.  At present I have it 
only inserting the selection into text box selected_ix in form 
aform but the routine will be elaborated soon to post the query. 
I'm sure you can work it out if I can, since I'm practically 
javascript illiterate.


sub SCRIPT_GET_SELECTED_TEXT{
my $s= qq~
script type=application/ecmascript charset=utf-8
// ![CDATA[
function getSelText()
{
var txt = '';
 if (window.getSelection)
{
txt = window.getSelection();
 }
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return;
document.aform.selected_ix.value =  txt;
}
// ]]
/script
~;
return $s;
}



input type=BUTTON value=Enter selected
method=post action=icsql.pl enctype=multipart/form-data
onmousedown=getSelText()




Re: MacOSX-File-0.71

2011-01-16 Thread John Delacour

At 10:42 + 16/01/2011, Alan Fry wrote:


Installation of MacOSX-File-0.71 on 10.6.6 (Perl 5.10.0) fails with 
the following errors:


Kanga:MacOSX-File-0.71 alanfry$ perl Makefile.PL...



I get a different sort of failure with 5.12.2 on 10.6.6:


14:30:58 User:jd   Cwd: ~
➔ cd /usr/local/bin

14:31:07 User:jd   Cwd: /usr/local/bin
➔ sudo ./cpan


Writing Makefile for MacOSX::File
cp File.pm blib/lib/MacOSX/File.pm
cp File/Constants.pm blib/lib/MacOSX/File/Constants.pm
AutoSplitting blib/lib/MacOSX/File/Constants.pm 
(blib/lib/auto/MacOSX/File/Constants)

cp Catalog.pm ../blib/lib/MacOSX/File/Catalog.pm
AutoSplitting ../blib/lib/MacOSX/File/Catalog.pm 
(../blib/lib/auto/MacOSX/File/Catalog)
/usr/local/bin/perl /usr/local/lib/perl5/5.12.2/ExtUtils/xsubpp 
-typemap /usr/local/lib/perl5/5.12.2/ExtUtils/typemap  Catalog.xs  
Catalog.xsc  mv Catalog.xsc Catalog.c
cc -c  -I../ -I/Developer/Headers/FlatCarbon -fno-common 
-DPERL_DARWIN -no-cpp-precomp -fno-strict-aliasing -pipe 
-fstack-protector -I/opt/local/include -O3   -DVERSION=\0.70\ 
-DXS_VERSION=\0.70\ 
-I/usr/local/lib/perl5/5.12.2/darwin-2level/CORE   Catalog.c

Catalog.xs: In function 'xs_getcatalog':
Catalog.xs:70: error: subscripted value is neither array nor pointer
Catalog.xs: In function 'xs_setcatalog':
Catalog.xs:181: error: subscripted value is neither array nor pointer
Catalog.xs: In function 'XS_MacOSX__File__Catalog_xs_setcatalog':
Catalog.xs:263: warning: assignment makes pointer from integer without a cast
make[1]: *** [Catalog.o] Error 1
make: *** [subdirs] Error 2
  DANKOGAI/MacOSX-File-0.71.tar.gz
  /usr/bin/make -- NOT OK



Can anyone suggest a fix? Or does anyone know how to contact the author?


dankogai+c...@gmail.com


JD



Re: Need some help on installing modules...

2011-01-16 Thread John Delacour

At 11:13 -0500 16/01/2011, Levan, Jerry wrote:


I have an iPad and I have a Postgresql database on my home server.

I have turned on the MacOS(client) VPN on the mac mini that I use
as my home server and can access my home network in a secure fashion...

It turns out that once upon a time I wrote a perl cgi that allowed
me  to access postgresql and display the results of selections in
a html table.

It appears that I need to install DBI and DBD for Postgresql.

Unfortunately I have pretty much forgotten most of my Perl
( Sh*t happens when you get into your seventies...)

Could some kind soul give me a quick guide on how to install
the necessary modules to enable the cgi?


Presuming you have the developer tools installed then use CPAN.  I've 
recently installed DBI and DBD::SQLite on my Mac Mini without any 
complaints.  I see that  I am excluded from getting DBD:Pg because I 
can't answer a simple question:


Configuring DBD::Pg 2.17.2
Path to pg_config?   You tell me!
Use of uninitialized value $ENV{POSTGRES_HOME} ...

But no doubt as a user of Pg and 4 years my senior you will be able 
to answer it.




21:41:50 User:jd   Cwd: /usr/lib
➔ sudo cpan
Password:
Terminal does not support AddHistory.

cpan shell -- CPAN exploration and modules installation (v1.9402)
Enter 'h' for help.

cpan[1] install DBI DBD::Pg
CPAN: Storable loaded ok (v2.18)


JD


Re: Need some help on installing modules...

2011-01-16 Thread John Delacour

At 17:29 -0500 16/01/2011, Levan, Jerry wrote:



Is doing a:

sudo perl -MCPAN -e shell

The standard way of preparing to install modules?

Seems like root might only be needed for actual installation...


With sudo you are superuser; that's quite good enough.

I never do it that way.  I just type sudo cpan, as I said.

In fact I don't usually do that because I work mainly with my own 
installation of perl, so I do



$ cd /usr/local/bin; sudo ./cpan

in order to get the modules installed where I want them and not in 
the Apple installation.  I wouldn't trust Apple to overwrite their 
own installation.  I trust them to take my money and not much else.


JD


Re: Perl 5.10.0 Memory Usage

2010-08-02 Thread John Delacour

At 07:13 -0400 2/8/10, Bill Birkett wrote:


I recently upgraded from Leopard to Snow Leopard.

Now, some scripts that ran nicely on Perl 5.8.9 are consuming all 
available RAM on Perl 5.10.0, and bringing the system to its knees.


The scripts I'm referring to create a series of large objects, each 
of which should be garbage-collected when the next object is created.


Apparently, Perl 5.10.0 is not picking up the trash.

I know how to use Perl 5.8.9 on Snow Leopard, but I would rather use 
the 64-bit version.


Any suggestions?


Might it be worth trying upgrading to a recent version of Perl?  The 
latest stable version is 5.12.1


JD


Re: Perl install problems OSX 10.4.11

2009-09-15 Thread John Delacour

At 13:04 +0100 15/9/09, Mine wrote:

I am not quite sure which is the main Perl folder.  /usr/local/bin 
contains two Unix executable Perl files — Perl and

Perl 5.10.1. I assume that this should be the first directory.


In /usr/bin/ you should have a link which will point to the default 
version of Perl --  Eg:


?$  cd /usr/bin/; ls -al

...
lrwxr-xr-x 1 root wheel 25 Dec 19  2008 perl - /usr/local/bin/perl5.10.0

You can delete this link and create a new one to point to the Perl 
binary you want to use.  I seem to recall that you need to log out 
and log in again for the link to show up correctly in the /usr/bin/ 
listing.


JD





Mac + Windows question

2009-08-02 Thread John Delacour

The problem is simple, but here is the background:

I'm writing an interactive script that needs to work on both Mac and 
Windows running in Terminal on the Mac and in the Perl Command Line 
Interpreter (ActivePerl 5.10) on Windows.


The script and the text files it reads from are all utf-8 encoded and 
display properly on both platforms.  At the moment I am using Windows 
2000 for testing, since that's all I have here, though I have another 
machine with XP at another location.


Now for the problem:

If the script detects that it is running in Windows then I use 
Encode::from_to to convert the utf-8 to cp1252 for display in the 
Perl Command Line Interpreter console and for output.  Output is 
fine, but non-ascii characters in the console window are wrongly 
displayed -- for example:


Citroën is displayed as CitroÙn
Microsoft® as Microsoft«
- as ù

and yet when these incorrectly displayed characters are printed to 
the output file they are correctly printed, so the problem seems to 
be merely the Interpreter's interpretation of how to display the 
characters.


Does anybody know what charset this frightful console is using?

JD



Re: Dumb path question

2009-03-10 Thread John Delacour

At 21:10 -0600 9/3/09, Doug McNutt wrote:


At 22:24 -0400 3/9/09, Chris Devers wrote:

How can a Perl script reliably, portably resolve the path inside which
it is running?...


$0  That's a zero.  Has always worked for me to produce a full path 
to a running perl script.


...There is a module cwd...


or rather Cwd.  $0 will give the name but not the full path, so I'd suggest
the following:

#usr/bin/perl
use Cwd;
my $currentdir = cwd();
print $currentdir/$0\n;

JD


Re: What does ord mean?

2009-03-04 Thread John Delacour

At 20:44 -0500 4/3/09, Paul G. Hackett wrote:


NO-BREAK SPACE is 00A0, which in UTF-8 is xC2 xA0.  Hex xC2 = Decimal 194.


so

#!/usr/bin/perl -w
use strict;
use utf8;
print ord( ), \n;

JD



Re: MacPerl Script on OS X

2008-02-28 Thread John Delacour

At 15:03 -0600 28/2/08, Ben Crane wrote:

I have a Perl 4.X script that runs using MacPerl in Classic on my G5 
Mac but I can't get it to run using Perl in 10.4.11.


What do I need to do to make it run?


What errors do you get if you try to run it in BBEdit?

JD


Re: Detecting OS X version from perl

2007-10-14 Thread John Delacour

At 17:29 +0100 14/10/07, David Cantrell wrote:


Is there any simple way that people can think of to detect which major
version of OS X my perl code is running on?

ie whether it's 10.0, 10.1 etc, I don't care about the difference
between 10.3.3 and 10.3.4.


print `osascript -e 'tell app Finder to version'`

JD


Re: Perl OpenGL 0.55 - Need Mac testers

2007-04-20 Thread John Delacour

At 8:42 am -0400 20/4/07, Daniel Staal wrote:


Works here.  Mac Pro, 2.66x2 Intel, ATI Radeon X1900.


Fine here too.  Mac Mini G4, Radeon 9200

JD



Re: Perl OpenGL 0.55 - Need Mac testers

2007-04-19 Thread John Delacour

At 4:10 pm -0400 19/4/07, Sherm Pendley wrote:

It needed a few tweaks to build, but once the build issues were 
sorted, the spinning texture-mapped cube test runs fine on my G4 
w/ATI Radeon 9000 Pro.


Diff with the build changes is attached, if anyone else feels like testing it.


Sherm,

For dummies like me can you please describe the process of 
installing. Where does the .diff file go etc?  I put the file in 
OpenGL-0.55/, did perl Makefile.PL and got


...
...
Note (probably harmless): No library found for -lMesaGLUT
No OpenGL libs found

so obviously that was a bad guess :-)

JD



Re: pdf2text ?

2007-03-22 Thread John Delacour

At 9:14 am +0100 22/3/07, Dominic Dunlop wrote:

...For some reason, Preview is not scriptable (shame, Apple, shame), 
and nor is Adobe Reader.) You can even combine AppleScript and Perl 
with, for example, Mac::AppleScript or Mac::Glue.


If all that's needed is to copy the whole text of a pdf window and 
put it in a text file, then GUI scripting can be used.



tell application System Events
  tell process Preview
set frontmost to true
keystroke a using command down
delay 1
keystroke c using command down
  end tell
end tell
set _text to the clipboard
do shell script cd; pbpaste  trash.txt; open -a bbedit trash.txt

JD






Re: Upgrading Perl 5.8.8

2006-09-26 Thread John Delacour

At 7:27 pm -0400 25/9/06, Robert Hicks wrote:

I know that Tiger comes with 5.8.6 but I would like to get 5.8.8 up 
and running.


I am just wondering if I should:

a) download and compile Perl myself and replace the Tiger version
b) use macports (aka darwinports) to install 5.8.8 in /opt

What did you do?


Apple's installation is in /usr/bin.  There is no need either to 
replace it or to use any fink, darwinport etc.  Just install it in 
/usr/local/bin, which is the default anyway.  Read the install file.


JD



Re: Perl Module Installation in $HOME

2006-08-24 Thread John Delacour

At 11:32 am -0600 24/8/06, Doug McNutt wrote:


At 17:03 +0100 8/24/06, David Cantrell wrote:

Run the CPAN shell as root as all will be well.


Idonwannadodat!

...The result is that I can compile and install without being root. 
My stuff does not get any chance to screw up something like a system 
update from Apple or some Linux distribution. I happily accept the 
responsibility for fixing things up if such an update requires 
changes to my stuff. My own perl modules end up in $HOME/local so 
there can be no accidental naming confusion.


The problem is - - - How do I tell cpan to do things that way? - 
especially when there is a batch of dependencies to worry about.


I have never run the CPAN shell as root and I don't see what problems 
you're referring to.  I just do 'sudo cpan' and everything is 
installed where it should go.



Eremita:~ jd$ sudo cpan
CPAN: File::HomeDir loaded ok

cpan shell -- CPAN exploration and modules installation (v1.87)
ReadLine support enabled

cpan install CGI
CPAN: Storable loaded ok
Going to read /Users/jd/.cpan/Metadata
  Database was generated on Thu, 24 Aug 2006 01:35:30 GMT
Running install for module CGI
...
...
All tests successful, 1 subtest skipped.
Files=18, Tests=503,  3 wallclock secs ( 1.75 cusr +  0.50 csys =  2.25 CPU)
  /usr/bin/make test -- OK
Running make install
Installing /usr/local/lib/perl5/5.8.8/CGI.pm
Installing /usr/local/lib/perl5/5.8.8/CGI/Cookie.pm
Installing /usr/local/share/man/man3/CGI.3
... etc.

cpan



Eudora glue

2006-08-11 Thread John Delacour

At 3:09 pm -0700 10/8/06, Chris Nandor wrote:


At 21:37 +0100 2006.08.10, John Delacour wrote:

Ah!  That sounds terrific.  I guessed there must be some way to build
the glue, as in Frontier.


Yeah, I borrowed a bunch of ideas from Frontier.


I'm trying to work out how to make a new message using the Perl glue 
I've created for Eudora.  It's going to take me a little while to 
adapt to the Perl syntax, so I hope you don't mind my asking a few 
dumb questions.


In AppleScript it would be
 make message at end of mailbox :Out

and in the glue I made for Frontier the basic verb eudora.MS.new() is:

on new() {
	M = core.create ('CSOm', 'euMS', 0, 0, insertionloc ('end ', 
['euMB'][:Out]))}


What would the syntax be in Perl?

JD


Re: iCal modules

2006-08-10 Thread John Delacour

At 8:45 pm -0700 9/8/06, Chris Nandor wrote:


For the latter part, you may wish to just use Mac::Glue to script iCal.  You
can create calendars, add new events, and so on.


Chris, where do I get glue for BBEdit and other things?  My glues 
directory contains only these + the pods:



URL_Access_Scripting
FontSyncScripting
Finder
dialects
ColorSyncScripting
additions
TextCommands
System_Events
Keychain_Scripting
Image_Events

JD




Re: iCal modules

2006-08-10 Thread John Delacour

At 12:52 pm -0700 10/8/06, Chris Nandor wrote:


At 19:03 +0100 2006.08.10, John Delacour wrote:

Chris, where do I get glue for BBEdit and other things?  My glues




You simply need to run gluemac /path/to/app.  You may need sudo, too.
For example:

sudo gluemac /Applications/BBEdit.app

This creates the glue file and the POD file (which can be read with
gluedoc BBEdit).


Ah!  That sounds terrific.  I guessed there must be some way to build 
the glue, as in Frontier.


The only problem is that I get

sudo: gluemac: command not found
Eremita:~ jd$ man gluemac
No manual entry for gluemac
Eremita:~ jd$

so how do I get that working?  All my Mac::Carbon etc. stuff is fully 
up to date so far as I know.


TIA

JD



Re: iCal modules

2006-08-10 Thread John Delacour

At 11:30 pm +0200 10/8/06, Christian Huldt wrote:


sudo find / -name gluemac -print

gives me

/System/Library/Perl/Extras/bin/gluemac

Now, if /System/Library/Perl/Extras/bin should be added to the PATH 
or a symlink created in some other place is perhaps a matter of 
personal taste.


Good!  All done now.  Thanks!

$ cd /System/Library/Perl/Extras/bin/
$ sudo ./gluemac /Applications/Eudora\ Application\ Folder/Eudora.app/
Password:
Making glue for '/Applications/Eudora Application Folder/Eudora.app/'
What is the glue name? [Eudora]:
Created and installed App glue for 'Eudora.app, v6.2.4b5' (Eudora)


JD



Re: Mac / Perl / 3D

2006-07-26 Thread John Delacour

At 9:59 am +0800 26/7/06, Peter N Lewis wrote:

I'm interested in producing some drawings/diagrams/pictures based on 
3D data/objects generated from Perl.  Something that would allow me 
to write code that generates boxes, cylinders, spheres, etc with 
various colours and material styles and generate an image (or 
potentially an animation).


Any suggestions?  The best bet seems to be to use SDL_Perl, although 
a brief look seems to indicate I'll be installing packages for the 
next month.


After several attempts over the past 2 years to install all that's 
necessary to do this sort of thing with PerlDL (I can't remember if I 
looked at SDL_Perl) I ended up doing these things with Smile/SmileLab 
http://www.satimage.fr/software/en/presentation.html, some of the 
data being generated with Perl.  Smile creates vector PDF files and 
these can be converted to DXF using a programme called Cenon 
http://www.cenon.info/frame_gb.html for import to other programmes 
or for numerically controlled machinery.  Ghostscript and hpijs 
http://www.linuxprinting.org/macosx/hpijs/, both simply installed, 
are all that is needed besides.  Smile can also create movies from 
the drawings.  I have not done any 3D work but a licence for Smile 
allows this also.


Write me off-list if you'd like some examples.

JD


Re: Writing utf 8 files

2006-06-22 Thread John Delacour

At 9:28 pm +0200 22/6/06, Tommy Nordgren wrote:


On Jun 22, 2006, at 1:48 PM, Tommy Nordgren wrote:

How do I write proper utf 8 characters to a file? I write only 
two characters, and they come out as four

garbage characters when I view the file in an editor.


The only reason for that can be that you have your editor set to open 
files as MacRoman or some non-utf-8 charset.  Provided your editor 
prefs are set to open as utf-8 or you opt for utf-8 in the open file 
dialog you will not get this problem.




I found the problem it is necessary to
1) use the use utf8 pragma;
2) Explicitly write a BOM byte sequence immediately after opening the file.
point 2 is where I erred. I expected the BOM to be added automatically,
when opening a file for write with the utf-8 encoding.


You would need to give an example of what you are doing, but neither 
of those things should be necessary and nor should it be necessary to 
specify utf-8 when opening the filehandle as Sherm suggested.


The following script will write ö, utf8-encoded to trash.txt on 
the desktop:


#!/usr/bin/perl
my $text = ö;
my $f = $ENV{HOME}/desktop/trash.txt;
open F, $f or die $!;
print F $text;
close F;

If you open the file as utf-8 you will see ö and if you open it as 
MacRoman you will see ö.  You could also open it as Traditional 
Chinese or Simplified Chinese or many other things and see other 
things.  UTF-8 byte order is always the same, so there is no need for 
a BOM, though some editors might use it as a hint.


JD


Re: file creator id, etc

2006-06-08 Thread John Delacour

At 10:20 am -0500 8/6/06, Joseph Alotta wrote:


Greetings,

I am trying to read a CSV data file of names and addresses into Now 
Contact.  However the import feature does not see this file as it is 
ghosted.  My conclusion is that it is looking at the file creator 
information.


How do I see this information?  Apple-i, Get Info, does not show 
this.  How can I inspect these file attributes and how can I modify 
them with perl?


Without loading Mac::Carbon you can get (and set) type and creator 
with osascript in the shell, but it might be quicker (if milliseconds 
are important) just to print the data to an anonymous file and have 
NC read that, if it can.



#!/usr/bin/perl
my $csv = $ENV{HOME}/factory/accounts/2006 accounts/bos_060216.csv;
my $temp_csv = /tmp/temp.csv;
open CSV, $csv or die $!;
open TEMP, $temp_csv or die $!;
print TEMP CSV;
my $type_creator = `
osascript -e '
tell app Finder to get {file type, creator type} of (posix file $csv)
'`;
print type, creator : $type_creator\n__\n\n;
close TEMP;
open TEMP, $temp_csv;
print TEMP;

JD


Re: file creator id, etc

2006-06-08 Thread John Delacour

At 7:35 pm +0200 8/6/06, Dominic Dunlop wrote:


On 2006–06–08, at 18:46, Joseph Alotta wrote:

Thanks Dominic and John.   After playing around with it a little, 
the type attribute must be TEXT.  I guess I can just do a call to 
system() to set this.  Thank you for your help.


Careful! If you use SetFile to do this, you'll end up with a script 
that works only on systems that have devtools installed...


The file type can also be set like this:

my $f =  $ENV{HOME}/desktop/trash.csv;
open F, $f or die $!;
print F a,b,c,d,e;
`osascript -e '
tell app finder to set file type of posix file $f to TEXT
'`;

JD



Re: Install Apache, mod_perl

2006-04-07 Thread John Delacour

At 9:45 pm +0200 7/4/06, Marek Stepanek wrote:


  I looked back at the archives http://www.nntp.perl.org/group/

 perl.macosx for this subject and see a couple of responses.



Bob, I am confused! Sorry, but what the hell means this link? Am I on a
mailing list, or something, what seems to be a mailing list, but is
connected to a use group? (I am blushing!)


Look at the headers:

List-Post: mailto:macosx@perl.org
List-Help: mailto:[EMAIL PROTECTED]
List-Unsubscribe: mailto:[EMAIL PROTECTED]
List-Subscribe: mailto:[EMAIL PROTECTED]

JD



Re: openning file...

2006-04-01 Thread John Delacour

At 11:51 am -0500 1/4/06, Sherm Pendley wrote:


On Apr 1, 2006, at 3:49 AM, kurtz le pirate wrote:


mac os x store file name in utf-8 format. so, how to open file with
special characters in name ?


The wanted function only gets the file name of the file, which is 
not enough to open the file with, if it's in a subdirectory. Try 
calling open() with the full path to the file, not just the file 
name alone.



Here's an example:

#!/usr/bin/perl
binmode STDOUT, :utf8;
$desk = $ENV{HOME}/desktop;
$name = Eléments mécaniques;
$f = $desk/$name;
open F,  $f or die $!;
print F Réussi !\n;
close F;
open F, :encoding(utf8), $f;
print F;


JD




Recurrence of old CPAN problem after update

2006-02-05 Thread John Delacour


After upgrading Perl to 5.8.8 including the new CPAN, I am 
experiencing a problem I have not seen for a long time:


cpan r
CPAN: Storable loaded ok
Going to read /Users/jd/.cpan/Metadata
  Database was generated on Fri, 03 Feb 2006 02:17:31 GMT
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  ftp://cpan.etla.org/pub/CPAN/authors/01mailrc.txt.gz
LWP failed with code[404] message[File '01mailrc.txt.gz' not found]
Fetching with Net::FTP:
  ftp://cpan.etla.org/pub/CPAN/authors/01mailrc.txt.gz
Couldn't fetch 01mailrc.txt.gz from cpan.etla.org
Fetching with LWP:
  ftp://cpan.teleglobe.net/pub/CPAN/authors/01mailrc.txt.gz
Useless content call in void context at 
/usr/local/lib/perl5/site_perl/5.8.7/LWP/Protocol/ftp.pm line 398

LWP failed with code[400] message[FTP return code 000]
Fetching with Net::FTP:



This is repeated for each of the sites in my list with a very long 
wait for each failure.  when all these fail it uses curl and 
immediately gets the required files:


Trying with /usr/bin/curl -L to get 

The last time I had this trouble, more than a year ago, I seem to 
remember resolving it by reinstalling libnet or something, but I'd 
like to know the proper way to put this right and what is causing it.


JD




Problems installing PDL

2006-01-11 Thread John Delacour
Every attempt I've made over the past 3 years to install PDL has 
failed, including the last attempt I have just made, but this time I 
seem to be quite close.   I wonder if anyone can advise.


(for Joel Rees' instruction ... is an ellipsis )

The error I get both when I use CPAN and when, later, I try without 
CPAN, is the same in both cases:


Can't locate PDL/Config.pm in @INC (@INC ...
BAD2_demo.pm.PL line 12.
BEGIN failed--compilation aborted at BAD2_demo.pm.PL line 12.
make[1]: *** [BAD2_demo.pm] Error 2
make: *** [subdirs] Error 2
Eremita:~/Downloads_060101/PDL-2.4.2 root#


BAD2_demo.pm.PL line 12. reads:  use PDL::Config; !

Am I doing something stupid or is there an error in the make file?

JD



Re: Problems installing PDL

2006-01-11 Thread John Delacour

At 9:57 pm + 11/1/06, John Delacour wrote:

The error I get both when I use CPAN and when, later, I try without 
CPAN, is the same in both cases:


Can't locate PDL/Config.pm in @INC (@INC ...
BAD2_demo.pm.PL line 12.
BEGIN failed--compilation aborted at BAD2_demo.pm.PL line 12.
make[1]: *** [BAD2_demo.pm] Error 2
make: *** [subdirs] Error 2
Eremita:~/Downloads_060101/PDL-2.4.2 root#


BAD2_demo.pm.PL line 12. reads:  use PDL::Config; !

Am I doing something stupid or is there an error in the make file?


I finally succeeeded in installing PDL (a great victory after such a 
history of failure!) by manually creating directory PDL in my path 
and putting Config.pm in this folder, which I have now removed.  CPAN 
also reports that PDL is up to date, so let's hope that's true.


Nevertheless I'm curious to know why the install routine did not add 
Config.pm to the path, since what it seemed to be saying is, You 
can't install PDL because you haven't installed PDL!


JD



Re: Perl web server

2006-01-10 Thread John Delacour

At 4:39 pm -0800 10/1/06, Lou Rosinski wrote:


I can execute a Perl script in the terminal (MacOSX) but cannot get that
same Perl script to execute on a browser (ie Safari).  I can upload that
same script to my virtual Unix server and it executes just fine there.

I suspect the problem is the Apache config on my Mac but have researched and
made changes but to no avail.



I installed Apache 2 at the weekend and had to work out how to get 
things configured.  Here's what I ended up with in httpd.conf 
(/usr/local/apache2/conf/httpd.conf).  You'll need to read the whole 
file carefully, but even with my strong disinclination to prolonged 
concentration I didn't find it too difficult once I'd set my mind to 
it.


You need to stop and restard the server after every change, of course.


# /usr/local/apache2/cgi-bin should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
#Directory /usr/local/apache2/cgi-bin
Directory /users/jd/sites/cgi-bin
AllowOverride None
Options None
Order allow,deny
Allow from all
/Directory
Directory /users/jd/sites/.../.../.../cgi-bin
AllowOverride None
Options None ExecCGI
Order allow,deny
Allow from all
/Directory


Re: System rename command

2006-01-07 Thread John Delacour

At 12:25 pm +1100 8/1/06, John Horner wrote:

Supplementary question. If you were moving, copying and renaming 
files, would you use File::Copy instead of cp and mv?


You should first consider ditto if there is any chance your files 
contain valuable resource forks.


%  ditto --rsrc ...

JD





Re: @INC

2006-01-05 Thread John Delacour

At 12:15 pm -0600 5/1/06, The Ghost wrote:

...I have 2 versions of perl installed and only use one of them. 
The reason for 2 versions is a port system that refuses to rely on 
the already installed perl.  So I have:


/System/Library/Perl/5.8.6/darwin-thread-multi-2level

AND

/opt/local/lib/perl5/5.8.7/darwin-2level
/opt/local/lib/perl5/5.8.7 ...


If you download 5.8.7 and let it install itself in the default 
location without bothering even to look at the difficult questions, I 
guess you will solve all you problems and end up with this:


  @INC:
/usr/local/lib/perl5/5.8.7/darwin-2level
/usr/local/lib/perl5/5.8.7
/usr/local/lib/perl5/site_perl/5.8.7/darwin-2level
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl/5.8.6/darwin-2level
/usr/local/lib/perl5/site_perl/5.8.6
/usr/local/lib/perl5/site_perl


Whatever you have in /opt or whatever other non-standard directory 
can then porbably be safely consigned to the trash.


JD



Re: CPAN modules ...

2005-12-31 Thread John Delacour

At 3:17 am + 31/12/05, John Delacour wrote:


At 5:15 pm -0500 30/12/05, Vic Norton wrote:


How can I make BBEdit's %ENV more like the
system %ENV?


Turn BBEdit into Terminal?...


Try this:

#!/usr/bin/perl
print `/usr/bin/./printenv`

JD



Re: CPAN modules ...

2005-12-31 Thread John Delacour

At 6:49 pm -0500 31/12/05, Chris Devers wrote:


On Sat, 31 Dec 2005, John Delacour wrote:

 print `/usr/bin/./printenv`

  ^^

Why the '/./' here?

Isn't `/usr/bin/printenv` equivalent, clearer, and simpler?


Sure, but I didn't get that far.  printenv works in tcsh without the 
path but not in bash, so I tried that in bash, it worked and voilà.


JD



Re: CPAN modules ...

2005-12-30 Thread John Delacour

At 5:15 pm -0500 30/12/05, Vic Norton wrote:


A second question. When I run
   for (sort keys %ENV) {
  printf %25s = %s\n, $_, $ENV{$_};
   }
from BBEdit, I see a small subset of the %ENV that comes from running
the script in Terminal. How can I make BBEdit's %ENV more like the
system %ENV?


Turn BBEdit into Terminal?  A swallow's environment is not the same 
as a toad's, nor a CGI's the same as BBedit's or Terminal's.  You're 
asking for doors in a lake.  Enough metaphors  :-)


JD





Re: incantation for uploading shift-jis files

2005-12-26 Thread John Delacour

At 9:10 am +0900 26/12/05, Joel Rees wrote:

I note your are running both the script and the HTML in Unicode 
UTF-8. There is wisdom in that, of course, and I may rethink my 
choice of running these scripts in shift-JIS. (I like to avoid 
conversions that require tables and context decisions as much as 
possible.)


I simply hate legacy encodings.  Having worked with Chinese on the 
Mac since system 6, I would have switched to Windows NT if Apple had 
not finally implemented Unicode in Mac OS 10.  Having waited so long 
for Unicode, I use nothing else now.


I also notice you are saving the file back to disk so you can 
re-open it as shift-JIS. I want to avoid that, since perl is already 
saving it once to a temporary directory anyway...


Yes, my script was simply a very badly implemented proof of concept. 
Having looked at the question more deeply, I'm now half way through 
doing a proper job making proper use of CGI.pm.



(Muttering to self -- can perl open strings as streams like Java?)


Yes.

I have now had a better look at CGI.pm and come up with a solution 
that works, I think, as you want it.  The curious thing is that some 
browsers had no difficulty even before I used Encode-from_to.


To see the script go to http://bd8.com/temp/ and view uploadj.pl.txt

To try it out go to:
http://ccgi.bd8.com/cgi-bin/uploadj.pl



At 2:27 am + 26/12/05, John Delacour wrote:

Do you know of a way to tell perl, or, rather, the CGI module to 
open the file handle as shift-JIS?


open F, :encoding(shift_jis), $f


Clearly the Christmas goose had affected my reason!  As you were 
about to tell me, CGI.pm has already opened the file handle; so if 
you want to avoid writing the contents to another file and then 
opening that as above, it is necessary to use Encode as shown 
http://bd8.com/temp/uploadj.pl.txt


JD







Re: incantation for uploading shift-jis files

2005-12-26 Thread John Delacour

At 12:00 am +0900 27/12/05, Joel Rees wrote:


I'll have to tell you a war story or two, sometime.

Unicode is a kludge. It's one of the better kludges, and evidence 
that kludges make the world go round...


Just as well it doesn't rely on iso-2022-jp or us-ascii.  It's not 
Unicode that is the kludge; Unicode is simply the assignment of a 
unique character to a large range of numbers rather than the 
assignment of an arbitrary number of characters to a range any 
American president can conceive of.  The present temporary problems 
with Unicode arise only from a long anarchic heritage of monumental 
kludges.


...The frustrating thing about this is that I've been here before, 
about three years back when the perl implementation wasn't quite as 
complete, but I can't remember what I did, and I don't have access 
to the code I built then anymore.


I have the same problem again and again with a mere hour's interval!

The script below reduces the problem to its simplest.  Notice the 
deadly caveats.  In my experience (and I have war stories too) the 
harder one tries with Perl/Unicode the worse the mess you get into. 
You can probably forget about locale -- try “use encoding 
(:locale)” in the script below and see what you get! -- and lots 
of other things.  It's certainly a jungle, and it's growing, but it's 
getting tidier.


#!/usr/bin/perl
#
#  In BBEdit/TextWrangler set this document's
#  encoding to Japanese (Shift JIS); always open/reopen
#  as Japanese (Shift JIS).
#
#  In BBEdit/TextWrangler Preferences/Unix Scripting
#  check “use UTF-8” for Unix Script I/O.
#
#  When running in Terminal set Window Settings...
# [Display] [Character Set Encoding] to “Unicode (UTF-8)”.
#
### use utf8; # NO !!
# no encoding; # OK, optional
# binmode STDOUT, UTF-8; # OK, optional
### binmode STDOUT, :utf8; ### NO !! Quite different !!
use Encode qw~from_to~;
while (DATA) { /^#/ and next;
from_to ($_, Shift_JIS, utf8);
print
}
__DATA__
# Must not contain non-Shift_JIS characters
空欄を埋めたり、完全な文書で質問に答えたり、
一番適切に思う解答を〇で記したりする。
##


Re: possible noobie question- updates of PERL re linux OSX etc

2005-12-25 Thread John Delacour

At 12:17 pm -0500 25/12/05, Sherm Pendley wrote:


On Dec 25, 2005, at 9:39 AM, Tristan Mendoza wrote:

...the perl libs, is there a best method of getting those to auto 
update with cpan or something?  I suppose it might be somesort of 
cronjob or something.


What most folks (myself included) do is basically just follow the 
if it ain't broke, don't fix it philosophy. If I find a bug in a 
module, or need a function that isn't present in the version I have, 
I'll check the online docs for that module at 
http://search.cpan.org. Then, if a newer version fixes the bug 
and/or adds the function I need, then I'll update the module.


Other folks, with less knowledge but a craving for the very latest of 
hundreds of things they neither understand nor use, type r at the 
cpan prompt and install them all:


Eremita:~ jd$ sudo cpan

cpan shell -- CPAN exploration and modules installation (v1.8)
ReadLine support enabled

cpan r
CPAN: Storable loaded ok
Going to read /Users/jd/.cpan/Metadata
  Database was generated on Sun, 25 Dec 2005 02:08:38 GMT

Package namespace installedlatest  in CPAN file
Class::Autouse 1.21  1.22 
A/AD/ADAMK/Class-Autouse-1.22.tar.gz
Params::Util   0.07  0.08 
A/AD/ADAMK/Params-Util-0.08.tar.gz
WWW::Search::Monster   1.02  1.03 
C/CR/CRAIGK/WWW-Search-Monster-1.03.tar.gz

151 installed modules have no parseable version number

cpan install Class::Autouse Params::Util WWW::Search::Monster

JD










Re: incantation for uploading shift-jis files

2005-12-25 Thread John Delacour

At 9:22 am +0900 26/12/05, Joel Rees wrote:

Do you know of a way to tell perl, or, rather, the CGI module to 
open the file handle as shift-JIS?


open F, :encoding(shift_jis), $f

JD





Re: incantation for uploading shift-jis files

2005-12-24 Thread John Delacour

At 7:10 pm +0900 24/12/05, Joel Rees wrote:

I've looked around on the web, and it looks like I'm playing with 
edge-of-the-world stuff and rather OS and browser dependent.


The source I'm working with:

http://reiisi.homedns.org/~joel/cs/ranbunhyou/withfile2.text
http://reiisi.homedns.org/~joel/cs/ranbunhyou/requester2.html



Can you reduce the problem to the bare minimum rather than requiring 
us to plough through the whole thing?


When I try to Send File, I get
: Failed to find or open file, maybe bad file name selected.
: Upload request not processed.

I don't think it is edge-of-the-world stuff but I like simplified 
problems without noise.


JD



Re: incantation for uploading shift-jis files

2005-12-24 Thread John Delacour

At 10:30 am +0900 25/12/05, Thilo Planz wrote:

So you will have to auto-detect the encoding on the server-side or 
give the user a pulldown to select the file encoding (or support 
only Shift-JIS, which you might get away with in your case).



Here's an example that deals with sjis text files and us-ascii:

http://ccgi.bd8.com/cgi-bin/upload.pl

The script is here, warts and all:

http://bd8.com/temp/upload.pl.txt


Merry Christmas,

Thilo


And to everyone!

JD




Re: incantation for uploading shift-jis files

2005-12-24 Thread John Delacour

At 1:45 am + 25/12/05, John Delacour wrote:


The script is here, warts and all:

http://bd8.com/temp/upload.pl.txt



NB. Safari doesn't treat it as as text file.  FireFox, Opera, Omniweb 
display it properly as text.


JD


Re: Detecting file's line endings

2005-12-22 Thread John Delacour

At 3:15 pm + 22/12/05, James Harvard wrote:

I'm trying to detect a file's line endings (\r\n for DOS, \r for Mac 
and \n for Unix as I'm sure y'all know).


Is there any easy way to do this?


At 10:45 am +0800 21/11/02, Peter N Lewis wrote:


At 13:22 + 20/11/02, John Delacour wrote:


 if (/\015\012/) {
  $/ = \015\012 ;
 } elsif (/\015/) {
   $/ = \015 ;
 } else {
   $/ = \012 ;
 }


You can do this with one regular expression which will pick up the 
first line ending:


 $/ = /(\015\012|\015|\012)/ ? $1: \n;

Note that because Perl picks the first match location, and after 
that picks the first of an or | set, it will find the first 
location, and will find the \015\012 if it is there in preference to 
the \015 by itself.


Enjoy,
   Peter.


Re: Detecting file's line endings

2005-12-22 Thread John Delacour

At 3:15 pm + 22/12/05, James Harvard wrote:


Is there any easy way to do this?


PS.  The whole script, from which Peter quoted only the last bit in 
providing his genial one-liner, was as follows:




#!/usr/bin/perl
$f = $ENV{HOME}/Documents/Eudora Folder/Mail Folder/Manningham ;
sysopen F, $f, O_RDONLY ;
sysread F, $_, 1000 ;
if (/\015\012/) {
  $/ = \015\012 ;
 } elsif (/\015/) {
   $/ = \015 ;
 } else {
   $/ = \012 ;
 }
 open F, $f ;
 for (F) {
   /^From: / and chomp and print $_\n
 }


At 10:45 am +0800 21/11/02, Peter N Lewis wrote:

You can do this with one regular expression which will pick up the 
first line ending:


 $/ = /(\015\012|\015|\012)/ ? $1: \n;

   Peter.


Match composed with decomposed Unicode characters

2005-12-21 Thread John Delacour


I thought Unicode::Normalize would be the solution to this problem 
but after much trying I can't find the solution.


A file named é is stored in the file system using the decomposed 
form of é (0065 0301) rather than 00E9.  How do I search for é in 
text or file names and find it regardless of whether it is composed 
or decomposed?


For example the file /tmp/é created by this script is not found by 
simply looking for é as the composed character.


#!/usr/bin/perl
$dir = /tmp;
$f = $dir/é;
open F, $f or die $!;
close F;
opendir DIR, $dir;
for (readdir DIR) {
  if (/é/) {
print (found é) $_$/;
  }
  else {
print (no é) $_$/;
  }
}

JD



Delay in BBEdit/TextWrangler

2005-12-06 Thread John Delacour


The script below prints a list of 34 Burmese characters.  I happen to 
have a font for these but I'm not sure that matters.


If I run the script in BBEdit or TextWrangler just after launching 
the apps, there is a huge delay before the output is printed (up to 
15 seconds) but subsequent runs produce no special delay.



#!/usr/bin/perl
binmode STDOUT, q~:utf8~;
for (4096..4129) {
  $c = chr();
  $text .= qq~$_\t$c$/~;
}
print $text;

I get the same sort of behaviour if I run the script in Script Editor 
or Smile as a shell script, but there is no delay running it in 
Terminal.


Can anyone explain what causes this delay?

JD



Re: Delay in BBEdit/TextWrangler

2005-12-06 Thread John Delacour

At 6:41 am +0900 7/12/05, Joel Rees wrote:

First guess is font caching, which is mostly the time to find and 
load glyphs. It looks like you might be also implicitly invoking the 
relevant parsing attribute tables, which will also take some time to 
find and load.


It's interesting (to me) that if I go for Korean characters rather 
than Burmese, there is no appreciable delay.  It seems some sort of 
obstacle exists in the way of finding the necessary font/glyphs.



#!/usr/bin/perl
binmode STDOUT, q~:utf8~;
###for (4096..4129) {
for (44032..44066) {
  $c = chr();
  $text .= qq~$_\t$c$/~;
}
print $text;

I'll try to narrow it down by testing with various runs of characters.

JD



Re: Character Encodings

2005-11-25 Thread John Delacour

At 12:17 pm +1100 25/11/05, [EMAIL PROTECTED] wrote:


...let me reduce my question to this:

#!/usr/bin/perl
$str = 'it's a smart quote';
if ($str =~ m/\x{2019}/){
  print found
} else {
  print not found
}

BBEdit confirms that the third char in 'it's a smart quote' is 2019, 
but the regex doesn't match, with or without use utf8.



use utf8 does nothing.  Try this:

#!/usr/bin/perl
use encoding utf-8;
$str = 'it’s a smart quote';
if ($str =~ m/\x{2019}/){
  print found
} else {
  print \x{2019} not found
}

JD



Re: Character Encodings

2005-11-25 Thread John Delacour

At 3:51 am -0800 25/11/05, Gisle Aas wrote:


John Delacour [EMAIL PROTECTED] writes:

  use utf8 does nothing.

It's supposed to.  If it doesn't make the source interpreted as UTF-8
then it's a bug.

...and it works for me (perl 5.8.7).


You're right, and it does (5.8.7 here too)

#!/usr/bin/perl
use utf8;
$str = 'it’s a smart quote';
if ($str =~ m/\x{2019}/){
  print found
} else {
  print \x{2019} not found
}
 
I can only suppose that John Horner has his BBEdit document set to 
Macintosh encoding or something.  All my BBEdit prefs are set to 
UNIX/UTF-8.


JD



Re: Character Encodings

2005-11-24 Thread John Delacour

At 9:48 am +1100 24/11/05, [EMAIL PROTECTED] wrote:

I came across characters with incorrect encodings in a web-page I 
was trying to validate. [Incorrect, that is, in context. I'm sure 
they were fine in MS Word or wherever they originated.]


So, one character is a smart, single quote:

  '

and when I identify it using BBEdit's ASCII table, it says it's 
code is 8217 and its escape is %2019.


What would be the representation of this character in Perl's 
\-syntax? I tried  \x8217 and \x2019, but they didn't match in 
regexes. I'm obviously a bit out of my depth in terms of what that 
character is, to Perl. Do I need to use utf8? That didn't seem to 
work either.



If you set the encoding of your BBEdit document to UTF-8 (no bom) 
then you can simply type the curly quotes and they will be written to 
the doc as UTF-8.  Without mentioning legacy character sets, below 
are 4 more ways of writing the quotes.  You must declare the charset 
in the html.



#!/usr/bin/perl
no warnings;
$examples = EOE;
1. ldquo;doublerdquo; lsquo;singlersquo;
2. #x201c;double#x201d; #x2018;single#x2019;
3. #8220;double#8221; #8216;single#8217;
4. \x{201c}double\x{201d} \x{2018}single\x{2019}
EOE
$f = /tmp/quotes.html;
$_ = EOT;
!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 3.2 Final//EN
html
head
  meta http-equiv=content-type content=text/html; charset=utf-8
  titleQuotes/title
/head
body
prefont face=Georgia
xxx
/pre
/body
/html
EOT
s/xxx/$examples/;
open F, $f;
print F;
close F;
`open -a Safari $f`;



Re: Problem installing XML::Parser

2005-10-29 Thread John Delacour

At 2:09 pm -0500 29/10/05, Bill Stephenson wrote:

I'm pretty sure I successfully installed expat with Fink but 
apparently I still have something screwed up.


Any ideas on what I need to do?


I avoid Fink like the plague.

In trying to install XML::Parser with CPAN, I got exactly the same 
message as you did.  I therefore followed the instructions:


   You can download expat from:
http://sourceforge.net/projects/expat/;

Did that, moved the folder to my home directory, and read the file
~/expat-1.95.8/README without too much attention in order not to 
confuse myself.


Next:

% sudo -s
   
% cd
% cd expat*
% ./configure
% make
% make install
% cpan
cpan install XML::Parser
[...]
Appending installation info to
  /usr/local/lib/perl5/5.8.7/darwin-2level/perllocal.pod
  /usr/bin/make install UNINST=1  -- OK
cpan exit
%

JD



Re: ANN: CamelBones 1.0.0-beta4, ShuX 3.0-beta3

2005-10-25 Thread John Delacour

At 1:49 pm -0400 25/10/05, Sherm Pendley wrote:


ShuX is a graphical POD (Plain Old Documentation) reader for Mac OS X.


Thank you for the new ShuX, Sherm.  There's certainly a world of 
difference between this and a the very early version I last tried.


The window positions, so far as I can make out, follow an arbitrarily 
set rule and this does not respond to any user changes.  I would like 
a) to be able to set the preferred size for new windows and b) to 
have all windows open in the same position, with cascading only if 
more than one window is open.  I hope you can supply prefs for such 
things in due course.


JD



Re: How to find out if an application is running

2005-10-12 Thread John Delacour

At 2:37 pm -0700 12/10/05, Ted Zeng wrote:


I would like to find out if an application like Illustrator is running
On OS X or not from a perl script. How can I do it?



#!/usr/bin/perl
@processes = split /, /, `osascript -e '
tell app system events to name of processes whose visible is true'`;
print join $/, @processes


...if you don't mind waiting a little.

JD



Re: Get/set file type/creator in plain Perl?

2005-08-03 Thread John Delacour

At 12:28 pm +0900 3/8/05, Iyanaga Nobumi wrote:


I tried also:

use Mac::Carbon qw(:files);
print FSpGetFInfo /Users/[me]/Desktop/my_file;

but I got FInfo=SCALAR(0x1801434), what I could not understand or use...


That is because the result is a reference.  You need to dereference 
it like this:


#!/usr/bin/perl
use Mac::Carbon qw(:files);
$info_ref =  FSpGetFInfo $ENV{HOME}/Desktop/ds.jpg;
print  $$info_ref;
##  JPEG8BIM

Re: Parsing UTF8 files with wide characters

2005-06-15 Thread John Delacour

At 4:26 am +0900 16/6/05, Robin wrote:

I went back to look at perluniintro because I was sure I could 
remember reading that the use utf8 pragma was no longer needed, 
right under where it says this it continues Only one case remains 
where an explicit use utf8 is needed: if your Perl script itself 
is encoded in UTF-8


Nevertheless (Perl 5.8.6) if you simply comment

#binmode (DATA,:utf8);
#binmode (STDOUT,:utf8);

provided your script is UTF-8 encoded, there is no need for 'use 
utf8'.  The script you posted works fine in that case, as does



$f = $ENV{HOME}/junk.txt;
open F, $f;
print F ;
close F;
open F, $f;
for (F) {// and print}

JD


Re: ActiveState is announcing support for Mac OS X

2005-06-08 Thread John Delacour

At 9:41 am -0400 8/6/05, Janet Goldstein wrote:

Even those who have the knowledge to build Perl from source, as I 
have many times, welcome the convenience of binaries. Also, ppm is 
somewhat easier to use than CPAN.pm.


Amen to both.  From Jaguar onwards I have probably done a dozen or so 
installations of Perl, and not for fun but to have access among other 
things to the Unicode developments that have taken place over this 
period.  I would like to have been paid for the time and the 
frustration involved especially at the beginning -- in fact I would 
be fairly rich if I'd been paid for the time it took the installer 
itself without counting my own time.  Getting CPAN to behave is also 
a black art.


During this time I have updated my Win32 machines with every update 
of the ActiveState distribution at the cost of clicking a few 
buttons.  I am sure there are 36 different reasons for controlling 
special installations through the command line but for me, and I 
guess the majority of Perl users, they are irrelevant.


To use the Perl that came with the OS, as Sherm recommends, is 
simply not satisfactory when important developments are happening 
within Perl.  The Perls that shipped with Jaguar and with Panther 
were already aeons out of date when these were released.


Why does not Apple update Perl through sofware update?

JD




Re: [way OT] ... Intel? Maybe not.

2005-06-08 Thread John Delacour

At 10:36 am -0700 8/6/05, Edward Moy wrote:

We hope that the additional price our customers pay is justified by 
the fit-n-finish that we put into the systems.


The beachballs in Tiger are terrific!  If I'd paid the full price for 
the upgrade I'd be seriously considering demanding my money back.


JD





Re: Frickin' CPAN

2005-06-08 Thread John Delacour

At 6:00 pm -0400 8/6/05, John Mercer wrote:

That's strange. I ran CPAN with sudo perl -MCPAN etc etc and 
everything worked fine. But here's another question: why did it work 
w/ sudo but not as root (su)?


The way I log in as root is by running:  sudo -s

JD



Using my Perl installation after installing Tiger

2005-05-18 Thread John Delacour
I installed 5.8.6 a long while ago under Panther and had everything 
just as I wanted it and had a lot of extra modules installed.

Now I've just installed Tiger and see that I'm back to the Apple 
default installation.

How to I revert to using the set-up I was using before the Tiger 
installation?  Has Tiger wiped my installation?

JD


Re: Using my Perl installation after installing Tiger

2005-05-18 Thread John Delacour
At 14:51 -0400 18/5/05, Sherm Pendley wrote:
If you installed it under the default location /usr/local, then your 
old Perl 5.8.6 will still be there - if you made /usr/bin/perl a 
symlink to /usr/local/bin/perl, then the symlink would have been 
wiped out, but that's easy to fix.
Thanks for the lightning-fast reply, Sherm!  I'm glad to say I did 
install in /usr/local, so I look forward to hearing how to carry out 
the easy fix.

JD


Re: newbie question about chmod

2005-04-24 Thread John Delacour
At 7:53 pm +0200 24/4/05, Marc Manthey wrote:
when i type:
marxg4:~ marxg4$ chown -R marxg4 /Users/marxg4/Desktop/dbeacon
chown: /Users/marxg4/Desktop/dbeacon: Operation not permitted
Operation not permitted  what can i do ?
The programm needs no administrator rights.
Here are two ways to run temp.pl after creating it:
Eremita:~ jd$ cd
Eremita:~ jd$ echo '#!/usr/bin/perl
print qq~hello\n~;'  temp.pl
Eremita:~ jd$ perl temp.pl
hello
Eremita:~ jd$ ./temp.pl
hello
Eremita:~ jd$
The file does not need permissions changed in this case.
If you omit the shebang the first method will work but not the second:
Eremita:~ jd$ echo print qq~hello\n~  temp.pl
Eremita:~ jd$ perl temp.pl
hello
Eremita:~ jd$ ./temp.pl
./temp.pl: line 1: print: command not found
Eremita:~ jd$
If you need to change the permissions on temp.pl to make it executable, then
chmod +x temp.pl
JD



Re: newbie question about chmod

2005-04-24 Thread John Delacour
At 11:50 am -0700 24/4/05, Trey Harris wrote:
What you write isn't true, unless your umask is set to an odd value (I
mean 'odd' both literally and figuratively).  Did you try it?  perl
temp.pl will work, but ./temp.pl won't
Yes I tried it and it worked just as I copied the session to my 
email.  As to my umask I have no idea.

JD


Re: ?Tk on mac- Question from a novice

2005-04-15 Thread John Delacour
At 2:33 pm -0400 15/4/05, [EMAIL PROTECTED] wrote:
I'm trying to run a perl program my friend has written via komodo on his
windows machine however it uses the tk module. Despite a few attempts I cant
seem to install this on module on my mac. Any ideas? Am I missing something?
Are there issues with Tk.pm on OSX?
From README.macosx in the Perl distribution (5.8.6):-

« The default of building Perl statically may cause problems with complex
applications like Tk: in that case consider building shared Perl
Configure ... -Duseshrplib
but remember that there's a startup cost to pay in that case (see above
libperl and Prebinding). »
Sherm, who wrote that, may care to elaborate.
JD


Re: Access the Clipboard?

2005-04-14 Thread John Delacour
At 5:20 pm +1000 14/4/05, John Horner wrote:
More idle curiosity than a desperate need to know, but is it 
possible to access the OS X clipboard with perl, and if so, how?
Provided you need to get only us-ascii stuff, then
print `pbpaste`;
Otherwise
print `osascript -e 'the clipboard as unicode text'`;
or use Mac::Carbon
JD


Re: character encoding on file upload name

2005-04-07 Thread John Delacour
Andrew Mace wrote:
I've noticed that the non-ASCII characters are getting split into their 
base code pointsI thought diacritical marks were always combined with
 their preceding letter, if possible.
You're talking of file names, I suppose. I think you'll find that this 
is a function of the file system which stores file names in decomposed 
form, for what reason maybe someone else can tell you.  It is nothing to 
do with the behaviour of Perl, and you will find (I think, because I am 
at the moment working in MacOS 9/WinNT) that it is impossible to create 
a file named été (decomposed) in addition to a file named été (composed) 
in the same location.

JD


Re: character encoding on file upload name

2005-04-06 Thread John Delacour
At 12:08 pm -0400 6/4/05, Andrew Mace wrote:
Any insights would be appreciated.
What happens if you comment out
#use utf8;
...
#binmode(*STDOUT, :utf8);
...
#binmode($fh, ':bytes'); # :utf8 ?
...
#binmode($fh, ':bytes');
It seems to work then as you want:
 http://cgi.bd8.com/cgi-bin/test050406.cgi
JD


Re: sendmail question

2005-03-09 Thread John Delacour
At 9:42 am -0800 9/3/05, Ted Zeng wrote:
Do you use sendmail to send emails in your perl tools?
Or use a Perl email module to send emails? Which way you prefer?
Net::SMTP
JD


Re: Any GUI tools that can set execute bit?

2005-03-03 Thread John Delacour
At 8:23 pm +0100 3/3/05, Tommy Nordgren wrote:
Are there any Graphical User Interface Tools that can set the 
executable bits in the file info on disk?

You can make your own droplet to do this.  Save the following script 
in Script Editor as an application (stay-open if you like) naming it 
755.app and you can simply drop files onto its icon in the dock or 
wherever to change the permissions:

on open _filelist
  set _pathlist to chmod 755 
  repeat with _alias in _filelist as list
set _path to quoted form of POSIX path of _alias
set _pathlist to _pathlist  _path  space
  end repeat
  do shell script _pathlist
end open
JD


Re: What Perl editor do you recommend?

2005-03-02 Thread John Delacour
At 9:45 pm + 2/3/05, Phil Dobbin wrote:
I'm thinking that if he's not comfortable with pico maybe emacs is 
not the best idea...
I'd love to hear a convincing explanation from someone why anyone 
would use such tools in preference to TextWrangler, BBEdit or Affrus. 
I can imagine they'd make it a chore to write code in us-ascii and 
either a nightmare or an impossibility to deal with non-ascii, but 
maybe that's because I'm just an unreformed Mac user :-)

JD


Re: What Perl editor do you recommend?

2005-03-02 Thread John Delacour
At 10:39 pm + 2/3/05, David Cantrell wrote:
If you put non-ASCII in your code you're doing something wrong. 
Language-specific stuff - including English - belongs in a seperate 
resource file if you care about internationalisation.
Uhm, the Perl I use uses UTF-8 by default.  UTF-8 and Unicode have 
nothing at all to do with language, whatever you mean by that; and if 
I'm using a text editor that allows me to include Chinese and Ancient 
Greek in a perl script, as I do, and have them displayed as such for 
my convenience I am doing nothing wrong at all, since the script is 
all in UTF-8.  I think you are talking of a different century.

JD


Re: What Perl editor do you recommend?

2005-03-02 Thread John Delacour
At 5:33 pm -0800 2/3/05, Aaron Priven wrote:
The one real advantage to vi-type editors compared to other editors 
is that they enable you to edit without taking your hands off the 
home keys.
Both TextWrangler and BBEdit, which for Perl purposes are virtually 
identical (it's the html stuff that's missing in TW) are configurable 
to the nth degree as regards keystrokes and can be customised, I am 
sure, to emulate the behaviour of vim or whatever as regards 
keystrokes.  Any key combination can be used to perform any operation 
within the document, the application or beyond.  Pods can be 
displayed for selected terms of module names at a single keystroke 
etc. etc.  The most involved sequences of tasks can be performed with 
a single keystroke. In a short time a user can set up the application 
to respond as he chooses to commands that he chooses, which might be 
vim-like or might not.

JD


Re: Problem with Encoding

2005-02-18 Thread John Delacour
At 12:33 pm + 18/2/05, David Cantrell wrote:
First of all iso-8859-1 does not contain the Euro sign.  The 
character set you probably intend is Windows-1252
No he doesn't, he wants iso-8859-15
I doubt it very much, but you seem to have inside information.
#!/usr/bin/perl -w
use Encode;
$euro = \x{20ac};
$mac = encode(MacRoman, $euro);
$cp1252 = encode(cp1252, $euro);
$latin9 = encode(iso-8859-15, $euro);
print $mac $cp1252 $latin9;


Re: Variables in external file

2005-02-18 Thread John Delacour
At 4:54 pm + 18/2/05, Neil Bowers wrote:
You'll need to declare the variable in the script ('our', not 'my'), 
before you require variables.conf
I don't think it needs to be before;
for (our @list) { print }
will do the trick.
JD



Re: Problem with Encoding

2005-02-17 Thread John Delacour
At 7:32 pm +0100 17/2/05, Philippe de Rochambeau wrote:
I am trying to convert MacRoman encoded text to iso-8859-1. The 
script below show what I am trying to do.

The input file, data.txt contains the following string:
Les éléphants sont arrivés. EURO
First of all iso-8859-1 does not contain the Euro sign.  The 
character set you probably intend is Windows-1252, loosely termed 
Windows Latin 1 in OS X menus.  Unfortunately Perl has a pretty 
loose approach to charset names too, though when it says iso-8859-1 
it means it and not any extended version of it.

Try this.  It works here with Perl 5.8.6:
#!/usr/bin/perl -w
use encoding MacRoman, STDOUT = windows1252;
chdir $ENV{HOME}/temp/;
open  STDIN,   mac.txt or die $!;
open  STDOUT, windows1252.txt;
while (  ) {
  print;
}
JD


Re: TextWrangler

2005-01-21 Thread John Delacour
At 9:34 pm -0800 20/1/05, Chris Nandor wrote:
I think the only thing it cannot do that BBEdit does -- from what I can tell
-- is that it doesn't talk directly to Affrus (the perl debugger for Mac OS
X), like BBEdit can.
There is an option in Preferences/UNIX scripting to use Affrus for 
debugging.
If you've always liked BBEdit for perl development, but didn't want to buy
it, then now's your chance.
I downloaded TW just over a week ago and have practically lived in it 
ever since.  I very rarely get hooked on a piece of software and I 
have found BBEdit over the years rather unsatisfactory and behind the 
times.  Now with BBE 8 and TextWrangler at last handling Unicode 
properly I am delighted with them.  TW 2.0 is brilliant.

At 11:44 pm -0800 20/1/05, Randal L. Schwartz wrote:
Oh, just like Carbonized Emacs? :-)
I think most of us sandal-wearing new-age Mac users would prefer a 
carbonized beefsteak :-)

JD


Re: stupid newbie question

2005-01-17 Thread John Delacour
At 5:04 pm -0200 17/1/05, Marco Takita wrote:
What I need is to count how many times either CR05-C1-102 or 
CR05-C1-103 appears in the text, which I was able to do:

#!/usr/bin/perl
while () {


My problem is that I cannot do that for individual blocks like:
Sequence Contig3772
Assembled_from  CR05-C1-102-004-_A01_-CT.F_008.ab1  -40  955
Assembled_from  CR05-C1-102-006-_E05_-CT.F_035.ab1  -40  972
Assembled_from  CR05-C1-102-004-_B01_-CT.F_007.ab1  -32  1007
Assembled_from  CR05-C1-103-033-_G08_-CT.F_026.ab1  397  1400
Assembled_from  CR05-C1-102-060-_D07_-CT.F_029.ab1  403  1450
Assembled_from  CR05-C1-102-008-_G03_-CT.F_010.ab1  404  1427
Assembled_from  CR05-C1-102-065-_F12_-CT.F_043.ab1  406  1498

There are far shorter ways of doing it than I show here but since you 
say you're new to Perl I'll make it as long as I can:

#!/usr/bin/perl -w
use strict;
my ($i,  $line, @lines, $text);
$text = 'EOT';
Sequence Contig3772
Assembled_from  CR05-C1-102-004-_A01_-CT.F_008.ab1  -40  955
Assembled_from  CR05-C1-102-006-_E05_-CT.F_035.ab1  -40  972
Assembled_from  CR05-C1-102-004-_B01_-CT.F_007.ab1  -32  1007
Assembled_from  CR05-C1-103-033-_G08_-CT.F_026.ab1  397  1400
Assembled_from  CR05-C1-102-060-_D07_-CT.F_029.ab1  403  1450
Assembled_from  CR05-C1-102-008-_G03_-CT.F_010.ab1  404  1427
Assembled_from  CR05-C1-102-065-_F12_-CT.F_043.ab1  406  1498
EOT
@lines = split m~[  \012  \015  \x{2029}  ] ~x, $text;
foreach $line ( @lines ) {
  $i++  if  $line  =~  m~CR05-C1-102  |  CR05-C1-103~ix;
}
print $i;
$text is some text delimited by paragraph separators of one of 3 
kinds -- which of them being irrelevant in this case.  We split the 
$calar $text into an @rray of lines.  We then loop through  @lines 
adding 1 to the initial value 0/undefined of $i each time a match (m) 
is found in $line for ..102  or (|) ..103

JD





Re: stupid newbie question

2005-01-17 Thread John Delacour
At 6:05 pm -0200 17/1/05, you wrote:
Thanks Andrew for your input! But the script still gives me the 
result for the total number of times they appear in the text. What I 
need now is to get the results for individual blocks, something like 
this:

input file
Sequence Contig3772
Assembled_from  CR05-C1-102-004-_A01_-CT.F_008.ab1  -40  955
Assembled_from  CR05-C1-102-006-_E05_-CT.F_035.ab1  -40  972
Assembled_from  CR05-C1-102-004-_B01_-CT.F_007.ab1  -32  1007
Assembled_from  CR05-C1-103-033-_G08_-CT.F_026.ab1  397  1400
Assembled_from  CR05-C1-102-060-_D07_-CT.F_029.ab1  403  1450
Assembled_from  CR05-C1-102-008-_G03_-CT.F_010.ab1  404  1427
Assembled_from  CR05-C1-102-065-_F12_-CT.F_043.ab1  406  1498
Sequence Contig3773
Assembled_from  CR05-C1-103-041-_E11_-CT.F_044.ab1  -694  275
Assembled_from  CR05-C1-102-019-_A11_-CT.F_048.ab1  -626  289
Assembled_from  CR05-C1-102-019-_D03_-CT.F_013.ab1  -625  314
Assembled_from  CR05-C1-102-019-_B11_-CT.F_047.ab1  -733  185

Apologies first of all for my original useless response.  Here's how 
I would do it -- and it works.

while () {
  /Contig([0-9]+)/i and $hash=$1 and eval my \%$hash;
  /CR05-C1-102|CR05-C1-103/i and eval \$$hash\{\$\} += 1;
}
Every time a ...Contig line is encountered a new hash is created. 
When a -102- match is found $hash{-102-} is incremented etc.

Using the above contents for your (\n delimited) file, you can run 
the script and then test the results, as below.  How you decide to 
name the keys etc. is up to you.

## TEST
print  qq~$3772{'CR05-C1-102'} $3772{'CR05-C1-103'}~;
# Result: 6 1
JD





Re: Different results using the substr command

2005-01-05 Thread John Delacour
At 3:14 pm -0600 5/1/05, Albert Kaltenbaeck wrote:
I am having problems with the substr command.
It appears under OSX Perl the length value is being ignored.
This code worked under MacPerl ...

Do you get the expected result when you run this ?:
$f = ClientD.html;
$/ = \n;
open F, $f or die $!;
while (F) {
print $.. -- $_;
}
If not then you need to consider your line endings.
JD



Re: Reading in a File

2004-12-26 Thread John Delacour
At 10:44 pm -0500 25/12/04, Lola Lee wrote:
This script has you count words in a file.  The line where one is 
supposed to read in the file being counted is like so:

while (defined($line = ))
However, when I type this in: perl countwords.pl history.txt
Nothing happens.

The line you quote simply puts each line of a putative file into the 
scalar variable $line.  What happens will depend on how you deal 
with $line and where you print your results.

Supposing that countwords.pl is a script something like the one below 
and that history.txt is a file in the same directory (say your home 
directory), then you will get output in the terminal as below when 
you run your command.  I personally would substitute for your line:

  foreach $line ()
which does the same thing and, to me at least, is simpler and clearer.
###
#!/usr/bin/perl
foreach (@ARGV) {
  while (defined ($line = )) {
@words = split /\s+/, $line;
$wordcount = @words;
print $wordcount, ;
$total += $wordcount;
  }
  print \n$_Total: $total \words\\n;
}
###
_TERMINAL_
eremita:~ jd$ cd
eremita:~ jd$ perl countwords.pl histoire.html
7, 2, 4, 2, 4, 6, 5, 4, 2, 6, 2, 0, 1, 1, 0, 3, 1, 1,
histoire.htmlTotal: 51 words
eremita:~ jd$

.


Re: File creation issue

2004-12-24 Thread John Delacour
At 12:03 pm -0600 24/12/04, Adam Butler wrote:
What it's doing is opening the file for reading, and if the file doesn't
exist it creates it
Open(GAMELOG, $file);
@entries = GAMELOG;
close(GAMELOG);
You've had your answer. in your script 'Open' means nothing and the 
file won't be created even if you use 'open'.

#!/usr/bin/perl
chdir /tmp;
$log = game.log;
open LOG, $log or die $!; # --- !
print LOG success !;
close LOG;
open LOG, $log;
for (LOG) { print };
Make it a rule NEVER to open a filehandle without testing.
JD


Re: New to list, greetings and a (newbie)problem

2004-12-22 Thread John Delacour
At 3:53 pm -0500 22/12/04, Isaac Sherman wrote:
Then, when, in the terminal, I typed: hw.pl while in the same directory, I
got the following message.
tcsh: hw.pl: Command not found.
As others have said, you can run junk.pl using the command
perl junk.pl
and this will work even if a) the file is not executable and b) there 
is no shebang.

You can also execute the script using
./junk.pl
but in this case a) the permissions must be modified to make it 
executable and b) you must use the shebang (eg #!/usr/bin/perl).  The 
sequence below illustrates the procedure.

JD
bash-2.05a$ cd
bash-2.05a$ echo '#!/usr/bin/perl
 print qq~Hello\n~'   junk.pl
bash-2.05a$ junk.pl
bash: junk.pl: command not found
bash-2.05a$ perl junk.pl
Hello
bash-2.05a$ ./junk.pl
bash: ./junk.pl: /usr/bin/perl: bad interpreter: Permission denied
bash-2.05a$ chmod 755 junk.pl
bash-2.05a$ ./junk.pl
Hello
bash-2.05a$


CPAN delays

2004-12-06 Thread John Delacour
Can someone tell me the reason this ALWAYS happens:
cpan r
CPAN: Storable loaded ok
Going to read /Users/jd/.cpan/Metadata
  Database was generated on Sun, 05 Dec 2004 01:49:28 GMT
LWP not available
CPAN: Net::FTP loaded ok
Fetching with Net::FTP:
  ftp://cpan.etla.org/pub/CPAN/authors/01mailrc.txt.gz
Couldn't fetch 01mailrc.txt.gz from cpan.etla.org
...and so on until finally, after many minutes, something happens.
I can download the file in a second or two with an ftp client, so 
what is the problem?

JD


  1   2   3   >