Re: File creator info Chinese water torture

2001-07-24 Thread Bruce Van Allen

At 3:42 AM +0900 7/25/01, [EMAIL PROTECTED] wrote:
>At the moment I'm switching between OS 9 and OSX  via 'STARTUP
>DISK'->'RESTART' due to the fact none of the drivers for 3rd party
>USB periphs (like my ISDN TA modem, the hell I'm going back to 56k)
>have been updated yet, which in turn means I'm generating copious
>quantities of files with dual creators for those apps I use which
>have been ported to OSX. Double clicking them under OSX, causes OS9
>'in emulation'  to kick in which then goes into a never ending cycle
>of restart->crash, restart->crash, restart->crash, as it  tries to
>load an external HD which is another of those
>3rd-party-not-yet-updated jobs. In short I'm having to manually
>update the OSX finder to use the OSX version app not the OS9
>. _And_it's_starting_to_wear_me_down_
>
>
>I've been over the docs at ADC believing system('some_CFfunction')
>would be the path to take but I'm unable to make sense of how I can
>apply raw carbon code to get perl to do what I want.
>
>anyone got any pointers?


Robin -- I think you know more about this stuff than I do, but I've 
been doing all my work under OS X since the Public Beta came out, and 
I just wanted to mention something in case this is what you're 
frustrated with.

Over several months, my reliance on Classic applications and non-OS 
X-updated utilities/device drivers/etc has gradually diminished - yay!

But the consistent reminder that it's not all there yet is what 
happens when I double-click docs: if there's a Classic version of an 
application (in the Classic environment's boot disk at least), then 
double-clicking that app's doc icons will cause the Classic version 
of the app to attempt to launch, even if the OS X version of the app 
is already running.

So even though OS X BBEdit and I start with coffee and end with 
candles, because I keep a Classic version of BBEdit handy, if I 
double-click a BBE doc, Classic BBE tries to launch, fails, and my 
work routine momentarily stumbles while I remember why I'm clicking 
out of error messages instead of looking at my document.

So I've quit double-clicking doc icons, and now instead drag them to 
the OS X or Classic app icon on the Dock (which will cause the app to 
launch if it isn't already running). Or, of course opening via the 
Open/Recent menu commands, etc...

So if this related to what you've been trying to hack around, then a) 
you're not alone! and b) maybe for the time being use an interface 
other than double-clicking?

Anyway, my sympathies. And, since this appears to be a generalized 
behavior under OS X/Classic, if someone does have ideas regarding 
system('some_CFfunction') or similar, it might help to get back our 
full GUI in several ways, not just your pesky peripherals.

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: IP Address with DHCP

2001-08-23 Thread Bruce Van Allen

The 'D' in DHCP is for 'Dynamic'.

So let's go back to the OP's question: does anyone know a way to 
extract one's *current* dynamic IP address from OS X via Perl?

Pre- OS X, I found this once:

   IP Poster Script version 1.1
   --
   Since there is no Mac IP Poster application availible yet I decided
   to write a simple AppleScript that uses Fetch 3.0.3 and
   IP Moniter 1.1.1 to update a remote web page with your
   current IP address.

   Bill Hase
   [EMAIL PROTECTED]

but I've never used it. IP Monitor is still around.

But I want it via Perl, direct from Net Info or some such...
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: IP Address with DHCP

2001-08-23 Thread Bruce Van Allen

At 8:46 PM -0400 8/23/01, Bohdan Peter Rekshynskyj wrote:
>At 19:37 -0500 8/23/2001, Timothy A. Canon wrote:
>>Thanks for the tip.  From the command line this works for me:
>>
>>/usr/sbin/ipconfig getifaddr en1
>
>
>I don't agree here - this showed me an old ip address.
>
>I used en0 instead to show my dynamic address assigned by dhcp...
>
>Please advise.
>

I get:

[dslX-XX-XXX-XX-XX:~] bruce% /usr/sbin/ipconfig getifaddr en0
XX.XXX.XX.XX
[dslX-XX-XXX-XX-XX:~] bruce% /usr/sbin/ipconfig getifaddr en1
get if addr en1 failed, (os/kern) failure

which agrees with Bohdan.

OS X 10.0.4.

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: IP Address with DHCP

2001-08-23 Thread Bruce Van Allen

At 10:00 PM -0400 8/23/01, Sean P. Scanlon wrote:
>en1 or en0 is the name of the interface. if you have only one 
>ethernet card, you will get an error
>trying to get the ip address of the second (non-existent) interface.
>

Thanks for the info. So I can explore this further, I assume since 
it's used here on the command line, that this is a UNIX construct, 
independent of OS X (and also Perl), yes?
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: DropScript

2001-12-01 Thread Bruce Van Allen

At 4:25 PM -0600 12/1/01, Joshua Kaufman wrote:
>Thanks for the help. Now I can see the errors that the script is 
>generating, but I'm still not sure how to access argv from my perl 
>script. For example, if I want to assign the contents of argv to 
>@some_array how do I do that?
>
>Tantalizingly, if i just write:
>
>#!/usr/bin/perl -w
>
>use strict;
>
>open LOG, ">log.txt" or die "can't open the logfile $!";
>
>
>foreach my $file (@ARGV) {
>print  LOG "$file\n";
>}
>
>
>then I get (just) one of the files, but this leads me to believe 
>that I don't need to create my own array. Any help is appreciated.
>

@ARGV _is_ an array, and it can be copied to another array:

@some_array = @ARGV;

Just to check: are you dropping multiple files on the droplet in one 
'drop', or are you dropping each file one at a time?

If the latter, study the open() command; as written, each time your 
script is called, it writes over what was already there.

Otherwise, what are the errors you see? Maybe there's a hint there.

HTH

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: Why "1;"?

2002-01-07 Thread Bruce Van Allen

At 10:00 AM -0600 1/7/02, James Edward Gray II wrote:
>My memory must be failing because I'm pretty sure I've read the 
>answer to this in my Programming Perl book, but I can't for the life 
>of me find it now.  Why do so many modules end with the line "1;"?

To ensure that a true value is returned when the module is 'use'd. 
Any value or expression would do, provided it yields a value Perl 
interprets as true.

People complain about having to provide it, and I think it's going 
away in Perl 6.

I just think of it as the module signing off, "Yours Truly."

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: MacPerl 5.6.1 Released

2002-03-11 Thread Bruce Van Allen

At 7:51 AM -0500 3/11/02, Chris Nandor wrote:
>It's been over four years since a new MacPerl has been released, and it
>has been at least five years since MacPerl has been updated to the
>latest perl source (at the time, perl 5.004).

[snip]

>MacPerl 5.6.1r1 is the result of well over a year of development.
>Matthias Neeracher, the author of MacPerl has produced much of the code,
>including GUSI.  Thomas Wegner added a great many patches, including the
>overhaul of Shuck.  Gurusamy Sarathy and Jarkko Hietaniemi helped
>integrate the MacPerl with the perl 5.6 and perl 5.8 sources, as well as
>fixed various bugs and portability issues.  Many other people helped in
>many other ways as well.

Including, of course, YOU, Chris.

Congrats and many thanks!
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: About testing cgi at command line

2002-04-12 Thread Bruce Van Allen

At 10:35 AM -0700 4/12/02, drieux wrote:
>volks,
>
>when I run
>
>   perl Skank.pl
>
>on the command line on my solaris and/or unix boxes it takes
>the default path through the code and dumps out what the html
>would be - but when I run the same code on my OSX box it dumps
>out a weird case:
>[jeeves:/tmp/drieux/perl] drieux% perl Crap.pl
>(offline mode: enter name=value pairs on standard input)

[snip]
>
>is this a feature or a bug?

It's a feature of CGI.pm to allow offline mode. Otherwise it expects 
http/CGI input from STDIN. Why you're getting this behavior in your 
Mac OSX installation but not in others, I don't know, but I'd suggest 
starting with your usage of CGI.pm. Then maybe how your OSX command 
line takes args.

HTH

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



good practice in list civility

2002-04-15 Thread Bruce Van Allen

At 1:01 AM -0400 4/16/02, Chris Devers wrote:
>On Mon, 15 Apr 2002, Puneet Kishor wrote:
>>  sorry guys, maybe I'll lurk, maybe I'll leave, maybe I'll go back to my
>No no no, please don't leave.
>Please accept my deep & sincere apologies for what I wrote.
>Chris Devers

May I say that:
1.  Chris' comments were inappropriate, and those he named should not 
feel that he represents a majority, or even substantial portion, of 
the subscribers to this list.
2.  Chris has promptly and forthrightly apologized; any further 
discussion that does not acknowledge this would seem inappropriate.
3.  Of the several hundred posts to this list so far in 2002, all but 
a few have been constructive and useful to some subscribers.
4.  While Chris has learned a particular lesson in list civility, 
others in this thread might learn the lesson that they were rudely 
treated just for joining in the conversation -- but I wish they would 
consider a different lesson: that focused questions lead to more 
interesting answers and wider participation.
5.  As I read the thoughtful posts in this thread I found myself 
growing impatient. The original question was so broad that it lost 
its anchor almost immediately. This is the only problem with the 
early posts; the mistake in the later posts was to not see that a 
very small number of folks were taking a lot of air time circling 
around a vague topic.
6.  These mistakes don't reflect the ideas or programming skills of 
the posters.
7.  Mistakes were made, and when we want to learn, mistakes are our friends.

Cheers,
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: Time::HiRes

2002-04-24 Thread Bruce Van Allen

At 11:43 AM -0700 2002-04-24, drieux wrote:
>volks,
>
>I am just starting on with the process of
>
>   use Benchmark;
>
>and have stumbled myself into the problem that
>I need to run 'Time::HiRes' like resolutions to
>get a better sub-second resolution to resolve
>the delta's - does anyone know of any problems
>with doing the Time::HiRes on an old G4 running OSX?

Another approach might be to increase the number of repetitions 
performed by Benchmark. A factor of 10^3 raises milliseconds to 
seconds, etc. Sub-seconds would be important in high-volume 
applications, so more repetitions might be more realistic anyway...
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: file uploads using CGI.pm

2002-05-24 Thread Bruce Van Allen

At 2:55 PM -0700 2002-05-24, Chris Angelli wrote:
>difficulty doing something very simple.   For some
>reason I can't get file uploads to work. I am doing
>nothing fancy, but my uploads just don't work.

I moved the rest of Chris's post to the end, in case someone wants to 
look at it.

I've had several file upload sites going for a few years. The code 
you quoted seems slightly different from what I'm now using. I 
started from Lincoln Stein's book, but I know my stuff has evolved 
over the years to handle various contingencies.

Below is an excerpt that covers the basics. It's taken from a 
subroutine that is in my standard library for dispatch via a CGI 
script's state machine, but I've tried to simplify it down to what's 
important.

A few other comments, if I may:

1. Your comment that 'use constant' isn't working is of concern. Do 
you have other CGIs working on this setup?

2. My development site is a vanilla OS X 10.1.4 w/ developer tools 
(Perl 5.6.0, CGI.pm 2.56) installed. I'm not running mod_perl on it, 
and mod_perl affects the persistence of variables, so there might be 
something the look for there.

3. We get the handy computing experience of the Mac interface using 
BBEdit, one of whose benefits is direct Perl syntax checking. 
However, in a web context, there is really no way to avoid checking 
your webserver error log, if you're serious about your work. (Even 
using strict.pm and the '-w' switch won't tell you everything.) In 
this modern age, one may simply open a Terminal window, and type in 
the command

% tail -f -n20 /private/var/log/httpd/error_log

and get the last 20 lines of their ht error log, continuously 
updating itself as a script is tested on their server.

Ain't it the OS X life?

If at first you are dismayed to see MANY lines of error messages 
scroll by every time you call your script, just remember that 
mistakes are our friends. For hardcore logic poets, watching an 
eventless error log during testing has a certain satisfaction...

4. Here's my example:

## File upload example

# Excerpted from a production script
# deployed on Solaris, Mac OS X, NT, & Win 2000 servers

# Utilize 'for' loop for control flow
# In this case there is only one file upload field in the HTML form.
# It's named 'img_file' -- the user has uploaded an image file.
# The hash %input_vals holds cleaned-up input obtained via CGI.pm
# For clarity, methods from CGI.pm are shown in the form CGI::method()
# Other methods here are from my modules, but their names suggest what they do
# Sorry about the outermost 'if' structure -- it's a vestige.

for my $file_fld ('img_file') {
 if ($input_vals{$file_fld} ne '') {
 # Get the file upload object directly from CGI.pm
 my $image_file  = CGI::param($file_fld);

 ## Check file type and generate a conforming file suffix
 my $type= CGI::uploadInfo($image_file)->{'Content-Type'};
 my $suf = '';
 {
 local $_ = $type;
 $suf = /gif/i ? 'gif' :
  /jpeg/i ? 'jpg' :
  /png/i ? 'png' :
   '';  # $suf ends up blank if no match
 }
 ## Not a desired file type? Ask the user again
 unless ($suf) {
 oops('wrong_file_type', $type) # script exits here
 }

 ## Check file size
 # set maximum file upload size, in kB.
 my $max = 100;
 # start a counter
 my $length  = 0;
 # puff a buffer
 my $buf = '';
 # read through the tmp file, chunking 1 k at a time
 while (read($image_file, $buf, 1024)) {
 $length++;
 }
 ## File too large? Ask the user again
 if ($length > $max) {
 oops('file_too_large', $length) # script exits here
 }

 ## OK. Save the file
 # Rewind
 seek $image_file, 0, 0;
 # Make up a name for the permanent file, using suffix from above.
 # For security and glitch-avoidance,
 # don't accept user input for a filename
 my $img_file_name = "/path/images/$user_id.$suf";
 # Open the permanent file
 open IMAGE, ">$img_file_name" or oops('file_write_failed', $!);
 # Write to the permanent file from the tmp file
 while (read($image_file, $buf, 1024)) {
 print IMAGE $buf;
 }
 close IMAGE;
 $input_vals{$file_fld} = "$user_id.$suf"; # non-tainted filename
 } else {
 # This prevents overwriting existing filename if nothing new submitted;
 # only needed for file uploads because other types of input field allow
 # use of defaults. HTML file upload fields don't accept default values.
 delete $input_vals{$file_fld}
 }
}
# After this, %input_vals is handed to the database interface
# to create or update this user's record
# The temp file is auto-deleted

## End of Example

HTH

1;

   - Bruce

__bruce_van_allen__sant

Re: Dumb Bunny Future Time Problem

2002-06-26 Thread Bruce Van Allen

on 2002-06-26, drieux wrote:
>Well here is the problem in more unpleasantry.
>
>   I do the
>   make dist
>   load the *.gz it up to the server
>
>then download it - and let the StuffIt unwrap it - and
>i have a folder on my desktop - I use a terminal to go
>in and check the date stamps - they are - on average about
>7 hours into the future from when the date stamps are on

Just a thought: what time zone are you in? Is 7 hours the differential between your 
local time and GMT? Might be something to poke into...

>the folder I would generate by hand from the tarball with
>
>   zcat *.gz | tar -xf -
>
>This is only a problem when we are doing 'hot turn arounds'
>where I code up a fix - and hurl it It really does not
>matter today that the time stamps will be off on yesterday's
>tarball but today's tarball will unwrap with the same problem.

HTH

1;




Re: [OT] how to use a constant in regex?

2002-08-30 Thread Bruce Van Allen

At 1:20 PM -0400 2002-08-30, Warren Pollans wrote:
>Hi Folks,
>
>This is not OSX-related, but I'm hoping that some OSXer could point 
>me in the right direction.  This has to have a RTFM answer but I 
>haven't been able to find the FM to R.

With Perl, there is always its own internal documentation, in this 
case the POD of constant.pm.

However, :-), a quick scan didn't confirm that this was where I 
learned the answer to your question, which is to de-reference a 
reference to the constant (!!).

#!/usr/bin/perl -w
use strict;
use constant FS => '##';

my $x = 'sadfjsfh##fskdjfa;s##dfjhasfjh';

$x =~ s/${ \FS }/ZZ/g;  # or ${ \FS() }
#   ^^ ^   ^
print "1:$x\n";

__END__

>I can't figure out how to use a constant in a regular expression 
>without having to assign it to a variable first.  Here's what I mean:
>
>#!/usr/bin/perl -w
>
>use strict;
>use constant FS => '##';
>
>my $x = 'sadfjsfh##fskdjfa;s##dfjhasfjh';
>
>my $y = FS;
>$x =~ s/FS/ZZ/g;
>print "1:$x\n";
>$x =~ s/FS()/ZZ/g;
>print "2:$x\n";
>$x =~ s/$y/ZZ/g;
>print "3:$x\n";
>print FS,"\n";
>print FS(),"\n";
>
>
>Output is:
>
>1:sadfjsfh##fskdjfa;s##dfjhasfjh
>2:sadfjsfh##fskdjfa;s##dfjhasfjh
>3:sadfjsfhZZfskdjfa;sZZdfjhasfjh
>##
>##
>
>
>Thanks,
>
>Warren

-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: [OT] how to use a constant in regex?

2002-08-30 Thread Bruce Van Allen

At 4:55 PM +1000 2002-08-31, Ken Williams wrote:
>On Saturday, August 31, 2002, at 04:31 AM, Bruce Van Allen wrote:
>
>>  At 1:20 PM -0400 2002-08-30, Warren Pollans wrote:
>>>  Hi Folks,
>>>
>>>  This is not OSX-related, but I'm hoping that some OSXer could point me in

[snip]

>answer to your question, which is to de-reference a reference to the 
>constant (!!).

>>
>>  #!/usr/bin/perl -w
>>  use strict;
>>  use constant FS => '##';
>>
>>  my $x = 'sadfjsfh##fskdjfa;s##dfjhasfjh';
>>
>>  $x =~ s/${ \FS }/ZZ/g;  # or ${ \FS() }
>>  #   ^^ ^   ^
>>  print "1:$x\n";
>>
>>  __END__
>
>
>That's probably not the best solution.  The reason is that perl 
>can't compile your regular expression statically, because now 
>there's a variable in it, and perl will have to find this "constant" 
>value every time it searches through the target string.  This 
>negates the presumed performance benefits of using the constant.

>  my $rx = qr{##};  # or my $rx = qr{${\FS}}; if you want to use FS
>  $x =~ s/$rx/ZZ/g;
>  print "1:$x\n";

Yes, that's the way I'd do it. Warren explicitly didn't want to use 
another variable, such as your $rx.

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: question on ssh and peeve on editors

2002-10-04 Thread Bruce Van Allen

At 9:01 PM -0500 2002-10-03, Puneet Kishor wrote:
>I have Golive 5, but didn't invest in 6 because I discovered it 
>didn't do anything for Perl. Is the SDK GL6 specific? I have no idea 
>what knowledge it
>On Thursday, October 3, 2002, at 01:18  PM, Troy Davis wrote:
>>  I use GoLive to create websites. But I use BBEdit to work with 
>>perl. The two can co-exist, but you're right in that they're not 
>>very good roommates.
>>  I'd love to see a module to replace the php dynamic database stuff 
>>with perl...
>>Puneet:
>>>  The reason I need something like Dreamweaver or Golive is because 
>>>I don't want to use my finite braincells remembering syntax for 
>>>silly html for making tables, frames, hex colors, and other such 
>>>stupidities. Doing that nonsense visually makes developing web 
>>>apps tolerable. Even more so when you have to go back and edit 
>>>some convoluted frames and/or tables code.


Perhaps because I taught HTML for five years in the early days, and 
insisted that my students work without visual HTML composers (which 
were terrible, besides), I never adopted GL, DW, etc into my own 
workflow. When my projects have web output, all the HTML is generated 
by my software, i.e., Perl.

Maybe this doesn't get at the problem you're trying to solve, but 
with a modest investment of time you could equip yourself with Perl 
tools to do everything you need, including eliminating the tedium of 
composing in raw HTML.

There are several versatile HTML-generating modules on the CPAN, and 
most use some form of templating. I've built my own templating and 
output module, so I can't make a recommendation, but others on this 
list would happily.

A complete "web application" development library could be assembled 
from a set of well-maintained Perl modules from CPAN. Your module 
would 'use' or 'require' DBI.pm, CGI.pm, File::Spec, etc, collecting 
these powers together to be harnessed in your own methods.

That wisdom aside, Puneet's posts suggest interest in a programming 
challenge to learn from, which was the impulse I followed...

For my projects, I have to be able to send output in many formats, 
often not HTML, not even network-related (database, spreadsheet, page 
layout, postscript). So I wrote a templating module that can dispatch 
methods from external libraries in response to whatever string of 
tokens it's fed. For HTML output, I have a module whose methods dress 
up the data they're passed in the HTML format evoked by the token; if 
an output method fails, the token is output as an HTML comment.

Thus the only place in my programs that any HTML appears is in the 
methods (subroutines) specifically employed to produce output in this 
format. Program control, state transitions, database operations, 
math, date-time calcs, image generation, and so on, have none. This 
is where I see the dividing line between logic and presentation. It's 
a thinko to look at the code and the template as representing that 
distinction.

Speaking of templates, I have HTML templates of all types and sizes: 
one-line dynamic input widgets; whole 'pages' with headers n' 
everything; standard input forms; sub-templates nested within master 
templates; dynamic style sheets...

The output from my html-generating methods is also beautiful :-) That 
is, it's just the way I like it: correct HTML usage, easy to scan if 
I view source, follows my prefs for indentation, capitalization, etc.

I also have templates for use during development, e.g., to throw the 
necessary data and control buttons onscreen, but without the ultimate 
art and typography. Sometimes all it takes is a style sheet to spruce 
it up.

Forgive me for going on if you know all this, but let me add one more 
thing about Perl-generated HTML: it has two distinct uses: direct 
dynamic output, which the web server returns to the client; and 
output to file, for web resources that update on a time period or 
upon some event other than an http request.

The latter is, in effect, what the visual editors do: output to a 
file to be used as static HTML. Why not build your own?

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: dos2unix... and other

2002-10-07 Thread Bruce Van Allen

At 1:01 PM -0500 2002-10-07, Puneet Kishor wrote:
>s/ +/ /g;
>
>seems to work just as well. Which begs the question... why even have
>\s? maybe because tmtowtdi?!
>

\s stands for "white space": [ \t\n\r\f].

HTH

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: dos2unix... and other

2002-10-07 Thread Bruce Van Allen

At 1:23 PM -0500 2002-10-07, Puneet Kishor wrote:
>Bruce Van Allen wrote:
>>  At 1:01 PM -0500 2002-10-07, Puneet Kishor wrote:
>>
>>>  s/ +/ /g;
>>>
>>>  seems to work just as well. Which begs the question... why even have
>>>  \s? maybe because tmtowtdi?!
>>>
>>  \s stands for "white space": [ \t\n\r\f].
>
>yes, I know that ;-)
>
>which is why I am asking why do we even need \s since simply " " 
>seems to work just as well. I mean, it is kinda hard to put a tab or 
>a newline or a carriage return, etc., in a regexp... but a space is 
>easy...

Hmmm?

" " doesn't match \t, \r, \n, or \f.

Or are you talking about using '\s' in the replacement expression, 
i.e., B in "s/A/B/"? If so, '\s' is just 'backslash s'.

1;
-- 

   - Bruce

__bruce_van_allen__santa_cruz_ca__



Re: Check for root level access in a Perl script

2002-10-26 Thread Bruce Van Allen
At 8:28 PM -0400 10/26/02, Mark Knipfer wrote:

On 10/26/02 1:25 PM, Trey Harris wrote:

 Did you test this code snippet it?  It won't work.  You can't use 
a numeric comparison to test for stringwise equality.  (Sorry to be 
nitpicky, but it matters here.)

No problem.  After I pasted the Perl code in my message, it was Perl
code that I copied to the clipboard and did not copy the latest code
revision I was working on that time.

I don't mind nitpicky, because errors do not run/work in Perl.


Actually, if you run without warnings, that code snippet would appear to work.

#!/usr/bin/perl

$login	= 0;
print $login == "root" ? 'root it is' : 'root is it?';
__END__
#root it is

compare to:

#!/usr/bin/perl  -w

$login	= 0;
print $login == "root" ? 'root it is' : 'root is it?';
__END__
#File "eq_test.pl"; Line 4:  Argument "root" isn't numeric in numeric eq (==)

If forced to treat a string as a number, Perl gives it the value 0. 
Use 'eq' for string comparisons.

(Maybe you knew all this, but it wasn't clear from the comment above :-)

HTH

1;
--

  - Bruce

__bruce_van_allen__santa_cruz_ca__


Console problem

2002-11-26 Thread Bruce Van Allen
At 10:02 PM -0400 10/23/02, Sherm Pendley wrote:

Here's a tip: If you're doing web development, Console.app is 
insanely great. Start it up, open the "/var/log/httpd/error_log" 
file, and then hide the app. Whenever an error is logged, 
Console.app automatically unhides itself to show you the error.

This was working fine for me (and it *is* insanely great) until a few 
days ago. Now what shows up in Console is the system log. When I try 
to open the httpd logs, they're greyed out in the Console Open 
dialog; most other logs seem accessible.[1]

The only thing I can think of that might have changed something was 
that I innocently tried out the latest BBEdit shell worksheet's 
sample to build Chimera. After a long process, the build failed, and 
I deleted the directory I'd created for it. Might be irrelevant, but 
I have no other leads.[2]

I've gone back to Terminal.app, using
 % tail -f -n20 /var/log/httpd/error_log
This works fine, and is almost as handy as using the Console, but the 
latter's ability to jump to the front when an error happens is ideal.

Any thoughts?

Notes:
[1] Looking at the files,
[Franklin:var/log/httpd] bva% ls -l
total 24176
-rw-r--r--  1 root  wheel411816 Nov 25 21:28 access_log
-rw-r--r--  1 root  wheel  11963403 Nov 26 09:39 error_log


[2] The worksheet has this:
 BBEdit worksheet quote ###
# You can also "batch" operations together.
#
# Build a copy of Chimera:

cd ~/Projects
setenv CVSROOT :pserver:[EMAIL PROTECTED]:/cvsroot
cvs login
# when prompted for the password, select 'anonymous' and press 
Command+Return to send it
cvs co mozilla/client.mk
cd mozilla
make -w -f client.mk
cd embedding/config
make
cd ../../..
cvs co mozilla/chimera
cd mozilla/chimera
pbxbuild -buildstyle "Deployment" install
### End BBEdit worksheet quote ###
--

  - Bruce

__bruce_van_allen__santa_cruz_ca__


Re: OT praise for the cookbook

2002-11-27 Thread Bruce Van Allen
At 1:31 PM -0500 11/27/02, Dan Sugalski wrote:

At 12:59 PM -0500 11/27/02, Chris Devers wrote:

On Wed, 27 Nov 2002, Nathan Torkington wrote:
\> I've been working with other editors at O'Reilly to free up my time so

  that I can work on the second edition.  Tom's been doing a lot of the



Cool. It may be silly to ask, but has there been any thought as to how the
release of a Perl Cookbook second edition will coincide with Perl6?


I don't think you want to wait that long. The cookbook for perl 6 
would likely lag behind perl 6's first major release by at least 18 
months--it's tough to document useful best practices for a language 
that's not out yet!

new version of the book would be nice -- if by the time Cookbook2 is ready
it looks like Perl6 will be right behind it, I'm not sure that I
personally would get a copy because I'd be worried about its shelf life.


I think we're safe there. Could be wrong, but I think we're safe.


At 12:41 PM -0700 11/27/02, Nathan Torkington wrote:


Yes.  We're not holding up any of the revisions to our Perl books for
Perl 6.  As we've all learned over the past years, it's impossible to
predict the pace...


I'd go further than that: it's not even about Larry's pace or the 
eventual release date.


Anyone reading this thread might want to keep in mind that Perl 5.x 
will be out there for *years* after Perl 6 is released. Language 
upgrades just aren't like getting the latest upgrade of BBEdit or 
your fave OS software.

There are Perl 4 programs still doing heavy lifting today all over 
the world, both on and off the Internet. Many installations of v. 5.x 
are still below 5.6.1, much less 5.8.

Yes, the proportions are shifting, especially with ActiveState's 
excellent packaging of Perl for Win32, and Apple's mass distribution 
of Perl in Mac OS X. And this is a good argument, Nat & Tom, for 
including sections specific to Mac and Windows: much of the growth in 
usage of Perl will be in those worlds. (My own request would be the 
converse: ample treatment of cross-platform issues. I avoid 
platform-unique stuff because I prefer my code to work wherever it 
lands.)

Despite what I expect will be a brilliant set of transition utilities 
for converting code to Perl 6 :-), very few sys admins will agree to 
switch; instead, at best, they'll install Perl 6 *and* maintain 5.x. 
So very few networked machines will be exclusively Perl 6. Mac OS X 
uses Perl for some of its internal ops, so that distribution won't 
change precipitously. This leaves local installations on developers' 
machines.

In my work today, even Perl 5.8 is irrelevant, because most of my 
software is deployed on other companies' machines, so I haven't 
bothered with installing it in my own (OS X) system.


Anyway, I heartily agree that the Cookbook is very valuable. Go Nat 
and Tom!! Ask us for help as you proceed!

1;
--

  - Bruce

__bruce_van_allen__santa_cruz_ca__


Re: dmg of perl 5.8.0 on Mac OS X

2003-02-06 Thread Bruce Van Allen
Hey Nat -- Thanks. Downloaded and installed just fine on my t?rusty 
G4-350, OS X 10.2.3.

I've been under a major deadline until last week, so I've just been 
watching everyone's travails with upgrading their OS X Perl 
installation. I took the risk of upgrading to Jaguar when it came out, 
but decided to wait on messing with Perl, even though I'd been running 
5.6.1 pre-jag.

This week I had just replaced my system Perl with 5.6.1 when you posted 
this. So now I have both 'good' versions of Perl available. For now 
5.8.0 is just for fun and my own local tools -- my applications are on 
too many machines with older distributions -- pre-millennial, even...

After all the comments about downloading and wget/curl problems, I just 
wanted to let you know that, at least for one person, it worked out of 
the box, er, dmg.

Did notice the DB_File version is:
# /usr/local/perl5-8/Library/Perl/5.8.0/darwin/DB_File.pm
# last modified 22nd October 2002
# version 1.806

Typo in your announcement?
On Wednesday, February 5, 2003, at 05:03  PM, Nathan Torkington wrote:
It installs Perl, Berkeley DB 4.1.25, DB_File 1.42 and Time::HiRes
1.42 into /usr/local/perl5-8.  You'll need to add


Thanks!

  - Bruce

__bruce__van_allen__santa_cruz__ca__




Re: Form feed

2003-02-17 Thread Bruce Van Allen
I was hoping someone could offer some useful advice here. I've just 
begun fiddling with lpr recently, and am still very ignorant, so after 
the OP's first query, I immediately tried to print something with a 
form feed on my laser printer Speedy (OS X 10.2.4, Perl 5.6.1):

#!/usr/bin/perl -w
open LPR, "|lpr -P Speedy >/dev/null 2>&1"
	or die "Can't open printer: $!";
print LPR $_ . "\n" for qw/AAA BBB CCC DDD/;
print LPR "\f";
print LPR "EEE", "\n";
close LPR
__END__

Speedy prints everything on one page:
AAA
BBB
CCC
DDD
   <-- what happened to form feed?
EEE

I also tried the -p and -l (ell, not one) switches, and watched the 
process using Print Center. With -p (pretty print header) I saw a 
message flash by saying "nstextopdf pretty print not supported", and 
then the above printed (on one page). With -l, a message flashed by 
saying "Sending print file, 21 bytes", but *nothing* printed.

If printed to STDOUT, the rectangle junk character printed for the \f 
is correctly identified by BBEdit as a form feed.

So this question is not about whether I (or the OP) can get something 
to print -- it's specifically about lpr printing a form feed, known as 
\f in Perl. As the above shows, \n prints newlines. I also tested \t, 
and get tabs just fine.

Secondarily, at least for me, is there more to know about darwin's lpr 
here?

Thanks.

On Monday, February 17, 2003, at 07:59  AM, drieux wrote:
On Sunday, Feb 16, 2003, at 14:52 US/Pacific, Tom McDonough wrote:

On 2/15/03 21:56, "drieux" <[EMAIL PROTECTED]> wrote:

On Saturday, Feb 15, 2003, at 14:40 US/Pacific, Tom McDonough wrote:

I'm trying to force a form feed using perl 5.6 and os x.2  without
using the
format command.

LPR is the line printer and it is OPEN.  My program is printing 
continuous
lines and I want to control the page break.
I presume that you are using a printer with a tractor feed?
As opposed to the laser-printer style? yes? and that it is
locally attached?

Have you pulled out the manual for it, as to what it uses
for 'control sequences'.

you may want to read

	man printcap

Since what you want to ship to the printer, if it is
defined in the 'ff' argument, is what you will need to
ship to the printer to make it follow instructions.

I think what the '\f' is talking about is the 8-bit pattern
007 or the sixteen bit pattern 017...


  - Bruce

__bruce__van_allen__santa_cruz__ca__




Problems installing Event.pm

2003-02-17 Thread Bruce Van Allen
Has anyone successfully installed Event.pm on darwin's Perl? I have OS 
X 10.2.4, with Perl 5.6.1 replacing Apple's install of 5.6.0. I need 
Event for Net::Z3950.

Poking around, I've found that Event.pm has problems installing on 
Windows.

The installation (via CPAN; also tried via CPANPLUS) fails for me 
because all tests return 'dubious' ('dyld: /usr/bin/perl Undefined 
symbols:
_PERL_UNUSED_VAR'), and then it sighs, 'alas--no output ever seen'.

Not at all clear to me whether this would be due to my system's config, 
intricacies I haven't learned with CPAN, or some obtuseness of Event.pm 
itself (or its tests).

Any suggestions?

  - Bruce

__bruce__van_allen__santa_cruz__ca__



Re: Form feed

2003-02-19 Thread Bruce Van Allen
Thanks Matt and drieux for the background and leads for exploring this 
further, especially along the lines of translating to Postscript, an 
area I was already wanting to learn more about.

On Wednesday, February 19, 2003, at 10:06  AM, Matthew Langford wrote:
The problem may not be with Perl's \f.  Print to a file, and see if \f
produces 0x0C characters in the file.  If it does, perl is fine.


As my experiments confirmed (earlier msg), Perl in all my installations 
(MacPerl, 5.6.0, 5.6.1, 5.8.0) does indeed output \f correctly.

Also, using Perl formats gave me linebreaks the last time I needed 
them, so this question isn't as pressing for me as it was for the OP, 
who sought to avoid using formats.

The problem was somewhere in the next steps down the way toward the 
printer: OS X, lpr, CUPS, filters, etc. When I found that lpr under 
darwin didn't implement some documented switches & options, that seemed 
like the culprit.

Matthew:
It seems you are expecting \f to be universally recognized by printer
drivers, and converted to whatever the printer actually uses to end one
page and start another.  ... [but] you cannot
expect line printer control codes in ASCII to work in a modern,
multi-language, batch-printing environment.


Ah.

My interest in this question lies in the need by some of my clients 
(such as political campaigns) for printed outputs long with the data 
enrichment and analysis I provide: things like mailing labels, precinct 
sheets, and phone lists. My practice has been to do most of my data 
work using Perl, and then at the end import the data into a commercial 
program like FileMaker for greater control than Perl formats provide 
over print layout and typography.

Data search and retrieval, counts, and tasks like address normalization 
are way easier and faster with my Perl tools than with FileMaker, 
Access, etc. So I'd love to handle my own output via Perl as well. 
Anyone care to recommend their favorite Postscript-related modules?

  - Bruce

__bruce__van_allen__santa_cruz__ca__



Re: [OT] More Terminal/Finder cooperation

2003-02-26 Thread Bruce Van Allen
Cool.

On Wednesday, February 26, 2003, at 08:46  AM, Ken Williams wrote:
Awesome - I'm now adding a little perl script around it to get the 
absolute path and to activate the Finder:
Thanks Ken (and Ted Brown)!

I save it as ~/bin/select, and now I can just do 'select Perl.tar' and 
I see the icon in the Finder. =)
I saved it as /usr/bin/select, chmod'ed to 0755, and said goodbye to OS 
X Finder file-opening obtuseness (like not showing . and / files)!

  - Bruce

__bruce__van_allen__santa_cruz__ca__



Re: A Wheeler by anyother name...

2003-03-15 Thread Bruce Van Allen
On Saturday, March 15, 2003, at 12:25  PM, Chris Nandor wrote:
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Randal L. Schwartz) wrote:
You don't make fun of a man's name.  Period.
That is your opinion, it is not a rule, and stating it as a rule 
doesn't
make it one.  Your Jedi mind tricks won't work on us, no matter how 
much you

Isn't it a matter of respect for others?

I can imagine a context where that name would be fine -- like a 
humorous skit about prominent figures in the open source movement. But 
in OP's message, with no clear context to shape our understanding of 
the distorted name, we wonder, what does the OP mean by that? Was that 
like writing "Micro$oft"?

The Perl community, which, like the open source community, depends on 
mutual respect, has gone through some argumentation before about this 
subject.

The conclusion, I thought, was the same as in many other communities: 
out of respect for others, whether they be prominent publishers, 
accomplished programmers, earnest novices, cloaked gamers, or even 
clueless FAQ-ignorers, one addresses and refers to people as they name 
themselves.

  - Bruce

__bruce__van_allen__santa_cruz__ca__



Re: File Writing and CGI

2003-11-21 Thread Bruce Van Allen
OK, one more thing to add to the tutorial the OP just got on CGI scripting:

In the CGI execution context (webserver), it's best to put your output last. As soon 
as you do this:

print "Content-type: text/html\n\n"; 
print "... ";  

don't rely on the webserver to do much more for you after it's done printing the http 
output.

My experience across about many different commercial and institutional web servers 
leads me to at minimum wrap up all system-related actions -- like file ops -- before 
printing output. And the best approach is: output last. Otherwise, I find webservers 
inconsistent as far as when they to let go of a CGI process. Perhaps someone who knows 
more about Apache or IIS could comment.


  - Bruce

__bruce__van_allen__santa_cruz__ca__


Re: File Writing and CGI

2003-11-21 Thread Bruce Van Allen
On 11/21/03 Chris Devers wrote:

>On Fri, 21 Nov 2003, Bruce Van Allen wrote:
>
>> My experience across about many different commercial and institutional
>> web servers leads me to at minimum wrap up all system-related actions 
>> like file ops -- before printing output. And the best approach is:
>> output last. Otherwise, I find webservers inconsistent as far as when
>> they to let go of a CGI process. Perhaps someone who knows more about
>> Apache or IIS could comment.
>
>I thought it was considered best to try to send back data early & often,
>and to flush output by setting $| to 1 -- the idea being that a script
>that takes a long time to produce results might lead to timeout errors 
>if
>the web client gives up, but if you keep sending back data as it becomes
>available then the client will tend to keep the connection open.
>
>Have I had this wrong? 

Well, that's all correct. 

>Is it better to save up all output for the end?

Most of my web apps have 100% dynamic output, and the main way I cope with timeout 
issues is to keep things fast. It could be that my experience is from particular 
combinations of web server, web browser, and my scripts' operations. Or maybe I've 
drawn a wrong conclusion.

To be more specific, I noticed inconsistencies with some web apps that logged state & 
activity; if I waited to write to the logs after all http output was printed, my tests 
seemed to show that not every action was properly logged; if the actions were logged 
before final http output, no problems. If my logging routines involved time-consuming 
things like looking up and manipulating data, especially over a network, things would 
get worse. I always $|++, use strict, check return values, and I test relentlessly. 
The inconsistent results lead me to conclude that factors outside my control were 
causing the web server to sometimes drop or ignore the trailing parts of my scripts 
after printing output.

"Inconsistent" means I don't see the pattern, not that there isn't one.

Thinking about it, another reason I habitually delay printing even http headers is 
that a script's result state might be expressed as a redirect, an image, or as plain 
text, rather than html. OTOH, a quick look shows that I have a bunch of CGIs deployed 
whose first action is to print the usual "Content-type: text/html\n\n" line, long 
before doing anything with the input or any data, which follows the standard CGI 
advice.

So, no, Chris, you're not wrong. But my "what works" practice is to do as much as 
possible before output. Maybe it's more correct to say "before final output" but I 
don't know how the webserver would know that a script has no more output. Is it 
because the client breaks the connection once it gets the html output?

Again, perhaps someone who understand more about how Apache (or IIS) controls CGI 
execution could comment.


  - Bruce

__bruce__van_allen__santa_cruz__ca__


Re: error catching and hashes

2004-01-10 Thread Bruce Van Allen
On 1/10/04 wren argetlahm wrote:
>--- Piers Cawley <[EMAIL PROTECTED]> wrote:
>> This is because 'return undef;' is good, but 'return;' is better. It
>> returns the correct, context dependent representation of false.
>
>That seems to have fixed my problem, but I'm not sure why it works. My
>&error($error) is now something to the effect of {print shift;
>return;}, but why does that return false?

See below. If the stuff about context isn't totally clear to you, that would be a good 
area of Perl to study. That's what Piers was referring to above.

from perldoc -f return

return EXPR
return
Returns from a subroutine, "eval", or "do FILE"
with the value given in EXPR.  Evaluation of EXPR may be in list,
scalar, or void context, depending on how the return value will be
used, and the context may vary from one execution to the next (see
"wantarray").  If no EXPR is given, returns an empty list in list
context, the undefined value in scalar context, and (of course) nothing
at all in a void context.

(Note that in the absence of an explicit "return", a subrou- tine,
eval, or do FILE will automatically return the value of the last
expression evaluated.)
(END) 


1;


- Bruce

__bruce__van_allen__santa_cruz__ca__


macosx@perl.org

2004-03-04 Thread Bruce Van Allen
On 3/4/04 Baiss Eric Magnusson wrote:
>I went back and removed files and then tried a clean install of 
>.

[snipped description of errors]

>The errors most certainly relate to the way Base64 and QuotedPrint were 
>installed, now if I can just find the versions of those modules to go 
>with my current version of .

This is where you missed a key bit of advice -- have the CPAN do the
installation for you.

Many Perl modules have dependencies on other modules, which themselves
may have dependencies.

In your Terminal, type 'cpan' without the quotes. You'll get the CPAN
shell, and the first time you'll be taken through its configuration. On
Panther/darwin, you can safely accept the config defaults (when picking
archive sites, stick to your own continent).

At the cpan shell prompt, type 'h' (no quotes) to see the available
commands.

Here's what will work most times:

1. at the cpan> shell prompt, type 'i' and the name of the module as a
regular expression, and hit return (you'll get something like what
follows here:

cpan> i /Mail::Sendmail/
Module  Mail::Sendmail (M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz)
Module  Tindermail::Sendmail
(Z/ZL/ZLIPTON/Devel-Tinderclient-1.2.zip)
2 items found

OK, the first one looks like what we want. For more info, search on
/Mail-Sendmail/ , which will match the filename of the archive.

cpan> i /Mail-Sendmail/
Distribution id = M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz
CPAN_USERID  MIVKOVIC (Milivoj Ivkovic <[EMAIL PROTECTED]>)
CALLED_FOR   M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz
CONTAINSMODS Mail::Sendmail
MD5_STATUS   OK
archived tar
build_dir/Users/bva/.cpan/build/Mail-Sendmail-0.79
incommandcolor 0
install  YES
localfile
/Users/bva/.cpan/sources/authors/id/M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar
.gz
make YES
make_testYES
prereq_pm
prereq_pm_detected 1
unwrappedYES
writemakefile YES


Yes, that's it. Now, copy the Distribution id, type 'install ' at the
cpan> prompt, paste in the id, and press return:

cpan> install  M/MI/MIVKOVIC/Mail-Sendmail-0.79.tar.gz

CPAN will do the necessary prerequisite (dependency) checks, downloads,
unpacks, etc., for you. Just watch it go by. Then, when everything it
needs is there, it will make, test, and install the module.

If something isn't right, test, make, make test, or make install will
fail and let you know what happened. Send THAT to this list for advice.
At that point you and we will have a much better of solving any
problems.

I just did it on Panther 10.3.2. I allowed Mail::Sendmail to install
without changing the test script, test.pl.

Copying the sample in the README (also at
),

I wrote this script (substitute your own to, from, and smtp server.):

#!/usr/bin/perl -w

use strict;

use Mail::Sendmail;

my %mail = (
To  => '[EMAIL PROTECTED]',
From=> '[EMAIL PROTECTED]',
Message => "This is a very short message",
smtp=> 'my.mail-smtp.server.com',
   );

sendmail(%mail) or die $Mail::Sendmail::error;

print "OK. Log says:\n", $Mail::Sendmail::log;

 __END__

Worked out of the box.

##
OK. Log says:
Mail::Sendmail v. 0.79 - Thu Mar  4 19:25:09 2004
Date: Thu, 4 Mar 2004 19:25:09 -0800
Server: my.mail-smtp.server.com Port: 25
From: [EMAIL PROTECTED]
Subject: Sendmail Test
To: [EMAIL PROTECTED]

Result: 250 2.0.0 i253PGnJ084630 Message accepted for delivery
##

And I received the message a moment later.

Give it a try. 

- Bruce

__bruce__van_allen__santa_cruz__ca__


macosx@perl.org

2004-03-04 Thread Bruce Van Allen
On 3/4/04 Bruce Van Allen wrote:
>In your Terminal, type 'cpan' without the quotes. You'll get the CPAN
>shell, and the first time you'll be taken through its configuration. On

Sorry, less grief if you type 'sudo cpan' at your Terminal/command line
prompt.

Use your administrative password.

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Copying files

2004-04-27 Thread Bruce Van Allen
On 4/27/04 Mark Wheeler wrote:

>Yup. You're right. I missed that one. Here's what I did to simplify the 
>testing of the script.

>copy("/Users/xx/Documents/db1.txt", 
>"/Users/xx/Documents/db1.txt.bak") or warn "Can't copy file: $!";

>-
>I know the cron is firing off the request, because when first tried it, 
>I got Permission Denied in my email box. So I changed the permission to 
>755 and it still doesn't copy the file. And I get nothing in my email 
>box. I'm a little confused. What am I missing?

Is that "Permission Denied" for execution of your script? Perhaps it's
for writing the file. Check the write permissions of the
"/Users/xx/Documents" directory.

1;


- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Copying files

2004-04-27 Thread Bruce Van Allen
On 4/27/04 Mark Wheeler wrote:
>Good question. Here are the results.
>The permissions for the /Users/xx/Documents directory is:
>drwx--   7 xx  xx   238 27 Apr 15:08 Documents
>
>The permission for the /Users/xx/Library/Scripts directory is:
>
>drwxr-xr-x   3 xx  xx   102 27 Apr 14:22 Scripts
>
>Does that look right? Or should the Documents directory be the same as

Most likely your script is not running as owner, so you probably want 
drwxrwxrwx
for the Documents directory ( chmod 0777, '/Users/xx/Documents' ).

The Scripts directory is correct.

>On Apr 27, 2004, at 3:24 PM, Bruce Van Allen wrote:
>> Is that "Permission Denied" for execution of your script? Perhaps
>> it's for writing the file. Check the write permissions of the
>> "/Users/xx/Documents" directory.


1;
- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Copying files

2004-04-27 Thread Bruce Van Allen
On 4/27/04 Mark Wheeler wrote:
>OK... I changed the permissions. Still no change. The file is not being 
>backed up. 

One more permission to check, which is whether the original file may be
read & 'executed' by your script. Should be:
  -rwxr-xr-x
  
>How do I check to see if the script is even executing? Is 
>there a log I can look at? I haven't changed anything from the standard 
>install for 10.3. I'm the only person on the machine. Do I need to 
>"activate" perl like I need to when running apache?

Always test the result of actions taken in your script, especially
things that the operating system gets involved in, like filesystem
calls.

Get back to a simple starting point. Set aside the cron stuff for a
minute. Just see if you can execute the script from the command line, an
Apache CGI call, or perhaps a BBEdit shell worksheet. Also, try a script
that doesn't do anything to any files, like the classic:

#!/usr/bin/perl -w

print "Hello, World";

__END__


Now try to *open* your original file, testing for open()'s result.
If successful, then read and print out the first four lines of the file.

#!/usr/bin/perl -w

use strict;

my $file= '/Users/xx/Documents/file.txt';

open FILE, $file
or die "Can't open $file:\n$!\n";

for (1..4) {
print 
}

close FILE;

__END__


Note that you don't need the '__END__'; I've put them above to make
clear where each little script ends.

In some situations, you'd even want to test the result of close(FILE).

You can access your various OS X logs with the Console app, the latest
(Panther) version of which is nice enough to already know where the logs
are.

But you can learn lots just by making use of die() and other Perl
functions and pragmas (plus your logged error messages will have more
info in them). In the words of programmer and regex adept Ronald J.
Kimball, "Leave a useful error message when you die."

For myself, something short of Tim Leary's "Why not? Why not! Why not."
will do. For my coding heirs, I promise
Can't open /Users/xx/Documents/file.txt:
No such file or directory

The "No such file or directory", "Permission denied", etc. messages come
from the system, expressed via the Perl special variable $!.  

 
1;



- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Copying files

2004-04-27 Thread Bruce Van Allen
On 4/27/04 Ken Williams wrote:
>On Apr 27, 2004, at 5:46 PM, Bruce Van Allen wrote:
>> Most likely your script is not running as owner, so you probably want
>> drwxrwxrwx
>> for the Documents directory ( chmod 0777, '/Users/xx/Documents'
).
>That's a bad idea.  I wouldn't want *my* Documents directory 
>world-writable.

Of course you're right. I wasn't thinking of it as THAT Documents
directory, even though I reproduced the OP's path with '/Users' in it...

>The cron script is going to run as the user who sets it up, so it's not 
>necessary either.

Ah. Thanks.

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: passing a function and then calling the function with parameters

2004-05-19 Thread Bruce Van Allen
Try this (working from your code as much as possible):

#!/usr/bin/perl -w
use strict;

sub solve
# solves any given function
{
 my ($funct) = @_;
 return "f(3) = " . $funct->(3);
}

sub foo
# a function to solve
{
 my ($x) = @_;
 return "This should print 6: " . ($x + 3);
}

print "Solving for foo:\n" . &solve(\&foo) . "\n";

# Solving for foo:
# f(3) = This should print 6: 6

__END__

The key difference is where you call the function inside solve(). The
construct "$funct->(3)" is what you want, de-referencing the code
reference and handing it the arg 3. You could do without the variable
$funct by just using "$_[0]->(3)" (no quotes).

The other changes I made were to take the print() statements out of the
subs, and instead returning the concatenated phrases. Otherwise, your
print statements will be output in the wrong order as the subs execute
from inside to out.

For general-purpose function solving, you might consider using eval(),
in case someone provides a function that blows up.

HTH

1;

On 5/19/04 Joseph Alotta wrote:
>#!/usr/bin/perl -w
>use strict;
>
>
>sub solve
># solves any given function
>{
> my ($funct) = @_;
>
> print "f(3) = ", @{$funct}(3), "\n";
>
>}
>
>sub foo
># a function to solve
>{
> my ($x) = @_;
>
> print "This should print 6",  $x + 3, "\n";
>}
>
>
>print "Solving for foo", &solve(\&foo), "\n";
- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: CPAN Question

2004-05-27 Thread Bruce Van Allen
On 5/27/04 Timothy Bailey wrote:
>Hmm, I did buy the computer used, and reinstalled the OS that came 
>with it (10.2, two CDs), and I thought I had installed everything off 
>of them.  (Of course, this =is= my first experience with OSX.)  Is 
>there a third CD I should have gotten with Jaguar?

Yes. With Jaguar it's called the Developer Tools Disk. It has its own
installer, so you would have noticed.

You can also download it from Apple. You have to join as a developer,
but that's no big deal. Then just make sure you get the Developer Tools
appropriate for your version of OS X.

(With Panther, the Developer Tools became XTools.)

Just install the whole thing.

Then you'll be able to do the fun things discussed on this list.




- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: CPAN Question

2004-05-29 Thread Bruce Van Allen
On 5/29/04 Timothy Bailey wrote:

>On Thu, 27 May 2004 20:24:28 -0700, someone going by the name of 
>Bruce Van Allen <[EMAIL PROTECTED]> spoke:
>
>>You can also download it from Apple. You have to join as a developer,
>>but that's no big deal. Then just make sure you get the Developer
Tools
>>appropriate for your version of OS X.
>
>I downloaded the December 2002 version, and installed it. I am still 

That's old. Did you say you have OS X 10.2?

>(Trying "install Bundle::libnet", among other things, attempted an 
>install of Perl 5.8.4 - I'm not certain if it was successful, but I 

Oh, there's a hint. There was a version of CPAN.pm in early Jaguar that
would force an install of the latest Perl. Not what you want. I think
the immediate solution was to install a newer CPAN (but not
Bundle::CPAN). Search this list -- lots of talk over a year ago...

>Any other ideas?  Do I blank out the ~/.cpan directory?  How do I 
>determine that the Developer Tools took?  The errors seem to be 
>slightly different now, but I'm not certain of the specifics.

I've installed Dev Tools routinely since the Public Beta, so I don't
know what it's like without them, but it seems like I first tested them
using Terminal, running tools and Perl code from the command line...

Could you reinstall your system, maybe upgraded to later Jaguar, and get
a later version of the Developer Tools? And if you want a later version
of Perl, DO NOT replace the system's Perl -- again, search this list for
discussion. (I'm assuming you have a reason not to buy Panther, w/ Perl
5.8.1.)

Then start fresh with cpan, beginning with its own config.

HTH

1;

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Console.app tool

2004-10-13 Thread Bruce Van Allen
On 2004-10-13 Bill Stephenson wrote:

>On Sep 9, 2004, at 2:06 PM, Sherm Pendley wrote:
>
>> I can configure Console.app to automagically pop itself to the front 
>> of the window stack whenever anything gets appended to Apache's (or 
>> some other) error log.
>
>Hey Sherm,
>
>I've been thinking about that since you mentioned it and I really want 
>that feature in my toolbox
>
>Can you make a "CamelBones" app that let's you turn it on an off? A 
>pull down list of log files to select from would be cool too.
>
>I'd gladly make another little donation for a cool little tool that had 
>a button to make my Console.app do that.
>
>Bill

??? Mine's called Console.app.  (Panther)

Open it (it's probably in your Utilities subdirectory of Applications).
At the left edge, pull the little dimple to the right and you'll see a
hierachical list of logs beyond counting. Pick one or more and open
windows for them. Let's say console.log and var/log/httpd/error_log.

Then go to Preferences and check the boxes under "When an open log is
updated...".

Put your windows in th Dock or hide Console.app.

Make an error, or go to Terminal.app and restart Apache, and watch.

Or did you mean something different?

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Options for control of output in Terminal?

2004-11-22 Thread Bruce Van Allen
On 2004-11-22 Dan Buettner wrote:
>Ideally, I'd like to have the window have a fixed display (no
>scrolling) and always output the information from a specific thread in
>a specific position.  In other words, Thread 1 gets the first 2 lines,
>Thread 2 gets lines 3 and 4, etc.

Maybe you could extrapolate from this, a simplified version of a
subroutine in my own local ::Utils module. The subroutine make_counter()
takes two arguments, a fixed initial part, here called $label, and a
starting number. It returns a closure that you use inside your loop. 

Note the $|++, which assures immediate output (to the terminal screen).

For your use, what you especially want to get from this example is the
use of the Perl character "\b", which outside of regular expressions
means "backspace". The point is to print "\b" the same number of times
as the number of characters you want to back up before printing the
updated output. I believe you should be able to stack fixed and varying
lines with a little practice...

#!/usr/bin/perl

# trivial_count.pl
 
use strict;
use warnings;

$|++;

my $max = $ARGV[0] || 1;

print "Searching...\n";

my $counter = make_counter("Here's how many I've found: "); 

for (1..$max) {
print $counter->() 
}

print "\n";

sub make_counter {
my ($label,$start)  = @_;
$label  ||= 'Count:';
my $count   = $start ||= 1;
my $flag= 1;
return sub {
$flag ? 
   $flag-- && "$label  " . $count :
   "\b" x length($count) . ++$count;
}
}
__END__


bva$ perl /Volumes/Programming/trivial_count.pl 678
Searching...
Here's how many I've found:   678
bva$ 



HTH

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: TextWrangler

2005-01-20 Thread Bruce Van Allen
On 2005-01-21 John Horner wrote:

>At 9:34 PM -0800 20/1/05, Chris Nandor wrote:
>>it handles all the same Perl stuff as its bigger sibling: syntax
>>coloring, running scripts, filters, debugging, viewing POD, etc.
>
>How does BBEdit view POD? I never knew about that.

Open a Perl script or module in BBE or TW, and check the #! menu.

This might require that your settings recognize Perl files by .pl, .pm,
.plx, etc., under Preferences -> Languages.

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Variables in external file

2005-02-18 Thread Bruce Van Allen
On 2005-02-18 Mark Wheeler wrote:
>Ok... I made the changes, but still no luck. Here is the script as it 
>is, now.
>
>--
>test.cgi
>--
>
>#!/usr/bin/perl -w
>
>use strict;
>
>our @list;
>require 'variables.conf';
>
>foreach (@list) {
>print;
>}
>
>exit;
>
>---
>variables.conf
>---
>
>$list[0] = '0';
>$list[1] = '1';
>$list[2] = '2';
>$list[3] = '3';
>$list[4] = '4';
>
>1;
>
>---
>
>What am I missing here? Thanks for your help.

That works here. What errors or warnings are you getting? Did you get
rid of the "my @list;" declaration in the require()ed file
(variables.conf)? Permissions OK?

If you're running an earlier version of Perl, instead of 
our @list;
write this:
use vars qw/@list/;
before the require() statement.

In the bigger picture, yes, storing Perl code and data structures in
separate files is a widespread practice, rightly so as part of Perl's
easy extensibility.

For a learning path that gives the most solid foundation to this
practice, consider starting now with always running your scripts in
taint mode. What you read in from external files is not secure in many
situations, especially networks -- e.g., the Internet.

Some common script operations, such as open()ing a file with a path
stored in an external config file, could cause severe security issues.

If you incorporate the simple steps required to untaint external data
from the beginning, your programs will more strongly handle increased
complexity and public exposure.

And you will avoid the stress of combing back through a program you need
to make secure, trying to find the elusive points where the -T switch
tenaciously challenges you, an enterprise in which you may risk losing
your appreciation of logically organized electron flows.

HTH

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Any GUI tools that can set execute bit?

2005-03-03 Thread Bruce Van Allen
On 2005-03-03 Tommy Nordgren wrote:

>Are there any Graphical User Interface Tools that can set the 
>executable bits in the file info on disk?
>"Home is not where you are born, but where your heart finds peace" -
>Tommy Nordgren, "The dying old crone"
>
>

I suggest SuperGetInfo from Barebones Software (www.barebones.com).

But I will NOT debate, advocate, challenge, argue, disparage, promote,
one-up, put down, ...

1;

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: ANN: ShuX 3.0-beta1

2005-03-19 Thread Bruce Van Allen
On 2005-03-18 Sherm Pendley wrote:
>On Mar 18, 2005, at 5:02 PM, john horner wrote:
>> Downloaded, installed, didn't work, ran the Terminal command, works
>> just fine
>I'm beginning to wonder if *anyone* is still using the Perl that came
>with Panther. ;-)

Worked out of the box over here -- but I'm fortunate to have left
Apple's 5.8.1 install as my default Perl.

Sherm, this is sweet, both as Shuck reduX and as demonstration of the
usefulness of CamelBones.

Up 'til now, I was only thinking of using CB as a way to provide a rich
GUI for the stuff I run in my own machine for my own work. That's
plenty, about half of my use of Perl, so I planned to build my next
local app using CB.

No doubt you planned this all along, but you've just taken it a big step
further, and I can now imagine handing my tools to non-programmers.

"This changes everything."

Thanks!

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: "Tiger" version - Please stop

2005-04-11 Thread Bruce Van Allen
On 2005-04-11 various people addressed the question:
>>> Does anyone know when Tiger itself will be shipping?

Will those suffering from can't-wait-for-the-next thing please not
infect this list?

Thanks,

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: ActiveState is announcing support for Mac OS X

2005-06-08 Thread Bruce Van Allen
On 6/8/05 Sherm Pendley wrote:
>On Jun 8, 2005, at 11:38 AM, John Delacour wrote:
>> To "use the Perl that came with the OS", as Sherm recommends, is  
>> simply not satisfactory when important developments are happening  
>> within Perl.
>I recommended no such thing. I simply pointed out that a Windows user  
>who wants to run a Perl script doesn't have the option of using the  
>built-in Perl, because there is none.
>
>Mac OS X users *do* have that option, and for many it's a perfectly  
>viable choice.

In fact, it's a better choice for many who develop for deployment on
others' machines. Proportionally, very few machines in the world have
the latest Perl.

For my own self-use stuff, John's point about new developments in Perl
(like Unicode) is relevant.

But I have scripts running in several clients' old boxes that do their
jobs with no need to improve. And I still maintain some CGI scripts
using Perl 4 at some ISPs who keep the older Perl (alongside newer) as a
legacy courtesy to longtime customers. In this case 'maintain' means
"Don't cost them any money unless it directly benefits productivity."

With OS X, many Mac owners might want my data utilities to work without
having to upgrade their Perl beyond the system install, and to keep
working without my help when they upgrade to Ocelot or Cheshire Cat or
whatever in a few years. 

It's just a reality. Arguing about whether I would/could/should try to
persuade these folks to upgrade their Perl is non-productive :-)

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: CamelBones on Intel

2005-11-04 Thread Bruce Van Allen
On 11/4/05 Sherm Pendley wrote:

>Here's some good news. I just heard from someone who's been helping  
>me test CamelBones on Intel, ...
>And here's what he had to say about it:
>> I spent a few minutes clicking around in this latest version on my  
>> Intel box with no apparent failures of any kind. It also appeared  
>> identical to the same version on my PPC machine.
>I'll be rolling a new release package soon - probably later tonight -  
>but in the meantime I wanted to share the good news.

To the future and beyond!

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: CamelBones on Intel

2005-11-10 Thread Bruce Van Allen
On 11/10/05 Sherm Pendley wrote:
>> To the future and beyond!
>
>Is that from a movie, tv show, book, etc.? It sounds familiar, but I  
>can't quite place it... it's been bugging me for days... ;-)
>

"To infinity and beyond!" was from Toy Story.

Best,

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: CamelBones on Intel

2005-11-10 Thread Bruce Van Allen
On 11/10/05 Bruce Van Allen wrote:
>On 11/10/05 Sherm Pendley wrote:
>>> To the future and beyond!
>>
>>Is that from a movie, tv show, book, etc.? It sounds familiar, but I  
>>can't quite place it... it's been bugging me for days... ;-)
>>
>
>"To infinity and beyond!" was from Toy Story.
>

And let me add that I genuinely think my variation belongs to you
(Sherm) and Camelbones -- both because you've bridged to the new Mac
chipset, and also in the bigger sense that Camelbones provides a path to
the future for Perl programmers to do cool things with Cocoa and OS X.

To the future and beyond!

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: return status code from sendmail in macosx

2006-01-18 Thread Bruce Van Allen
On 1/18/06 Riccardo Perotti wrote:

>Hi all:
>
>I have a typical mail cgi script written in perl and can't figure out
>why I don`t get an error when the message is not sent.
> ...
>The problem is that it does not die even though the message is not
>sent.
>
>I've tried checking $? (child error) but nothing (it is '0').
>
>I have read the sendmail and postfix man pages to no avail.
> ...
>What is it that I'm missing? Is there another way of checking for
>sendmail's success from your script?

I'm not sure what the problem is, but when my mail scripts don't work, I
find the undeliverable messages in ~/mbox. Might be some hints there.

HTH

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Formatting uploaded images

2006-02-16 Thread Bruce Van Allen
On 2/17/06 John Horner wrote:

>>> Nobody's yet mentioned the Image::Size module?
>>
>>If installing a module is hard, then it doesn't seem sensible to
>>advise using a different module!
>
>There is an *enormous* difference between installing ImageMagick
>(which isn't a module, although you get a perl module with it) and
>installing Image::Size. I just installed Image::Size with cpan --
>blink and you missed it.
>

And its dependencies seem to be in the standard distibution, so you use
cpan to get it, then upload it to web space provided by your ISP; just
use lib '...' appropriately in your script.


- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: When does a hash of lists get defined?

2006-04-04 Thread Bruce Van Allen
On 4/4/06 Doug McNutt wrote:

>While messing with CGI POSTed data I got trapped by this one.
>
>Version 5.8.1-RC3 for Mac OS 10.3.9
>
>It appears that the hash element "D" gets defined in the process of
>testing to see if an element in the associated string is defined. The
>last if below takes the else route.
>
>Is that normal? Does it somehow make sense?
>
>%phash = (); foreach $jill ("A", "B", "C")
> { for ($lynn = 0; $lynn<3; $lynn++) { $phash{$jill}[$lynn] =
> "$jill$lynn"; print "\$phash{$jill}[$lynn] = $phash{$jill}[$lynn]\n";
>}
>}
>if (! defined $phash{"D"})
> { print "\$phash{D} is undefined, We expected that.\n";
>}
>if (! defined $phash{"D"}[3])

It happened right here.

See perldoc perlref, especially "autovivification".



- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: When does a hash of lists get defined?

2006-04-04 Thread Bruce Van Allen
On 4/4/06 Stewart Leicester wrote:
>>if (! defined $phash{"D"})
>> {
>> print "\$phash{D} is undefined, We expected that.\n";
>> }
>
>
>Instead of
>
>defined $phash{"D"}
>
>use
>
>exists $phash{"D"}

Actually, those mean different things. Neither autovivifies, which was
what Doug was seeking to understand.

Both
defined $phash{"D"}[3]
and
exists $phash{"D"}[3]

autovivify $phash{"D"}.

1;
- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: When does a hash of lists get defined?

2006-04-05 Thread Bruce Van Allen
On 4/5/06 Stewart Leicester wrote:
>Bruce Van Allen wrote:
>>Both
>> defined $phash{"D"}[3]
>>and
>> exists $phash{"D"}[3]
>>
>>autovivify $phash{"D"}.
>>
>>- Bruce
>
>'defined' will autovivify, 'exists' will not. I'll leave it up to 
>Doug to decide if knowing that helps.

Oh? Try this:

#!/usr/bin/perl -w

use strict;

my %hash= (
A   => [qw/a0 a1 a2/],
);

# $hash{A}
if (defined $hash{A}[2]) {
print "OK \$hash{A}[2] defined\n"
}
if (exists $hash{A}[2]) {
print "OK \$hash{A}[2] exists\n"
}

# test defined() on $hash{B}
if (defined $hash{B}[2]) {
print "OK \$hash{B}[2] defined\n"
} elsif (exists $hash{B}) {
print "OK \$hash{B} exists: autovivified from defined()\n"
}

# test exists() on $hash{D}
if (exists $hash{D}[2]) {
print "OK \$hash{D}[2] exists\n"
} elsif (exists $hash{D}) {
print "OK \$hash{D} exists: autovivified from exists()\n"
}

__END__

prints:
OK $hash{A}[2] defined
OK $hash{A}[2] exists
OK $hash{B} exists: autovivified from defined()
OK $hash{D} exists: autovivified from exists()


The autovivification is happening when the values are dereferenced.

The expression
exists $hash{D}[2]
is testing the existence of the third element in the array ref
ostensibly stored in $hash{D}, so $hash{D} gets autovivified to allow
the test.


1;

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Regex and Mac vs UNIX line endings

2006-07-20 Thread Bruce Van Allen
Peter gave some good examples, so I shortened this to supplement his
suggestions.

I prefer to determine what the end-of-line (eol) "character" is using
something less slippery than \r and \n. In Perl, \n is the native eol
for the OS that Perl is executing under, so it could any of the \n, \r,
\r\n, etc., constructs.

Instead, use the octal characters, which for this are:

Mac CR (Carriage Return)  "\015"
UNIX, Linux, VMSLF (Line Feed)"\012"
Win CRLF  "\015\012"

BTW, many apps in Mac OS X (Excel, Filemaker Pro) continue to use the
eol used in OS 9 and before (CR), not the UNIX eol (LF).

Here's my favorite way to get the eol and convert it to native, no
matter what's in the original file (at least in the popular OSes):

$text   =~ s/(\015?\012|\015)/\n/gs;

You could also specify what you want, if that isn't simply the native
eol:
my $new_eol = "\015";  # or "\012" or "\015\012"
$text   =~ s/(\015?\012|\015)/$new_eol/gs;

If the file is large, then you may need to use a heuristic (that is,
test some of the text trying to detect a pattern), as Doug suggests,
testing the first x characters of the file to find one of the above eol
constructs, and then seeing whether it shows up again, and then backing
up and processing the whole file. Or use the look-ahead/behind
approaches that Peter suggests.

1;


- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: pdf2text ?

2007-03-22 Thread Bruce Van Allen
On 3/22/07 John Delacour wrote:

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

Just make sure Preview has Text Tool chosen, or add that to the script, 
  keystroke "2" using command down 
  
Also, with larger documents, the delay might have to be longer.

In a completely programmed usage, you might also want to make sure that
the clipboard is empty before running this script. When I copied the
script from John's message into Script Editor and ran it on a large PDF
(5.7 MB) doc, Preview hadn't finished selecting the whole text when the
script copied, so what was pasted into trash.txt was the script, because
that was in my clipboard just before I ran the script. The longer delay
took care of that, but careful data handling can save lots of grief
later...

John's script, slightly modified:

tell application "System Events"
set the clipboard to "" -- no spurious clipboard content
tell process "Preview"
set frontmost to true
keystroke "2" using command down -- use text Tool
keystroke "a" using command down
delay 1 -- or longer for large docs 
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"

HTH,


- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Speaking of support for Camel Bones

2007-05-08 Thread Bruce Van Allen
On 5/7/07 Chris Nandor wrote:
>Have you considered a Perl Foundation Grant? 

On 5/7/07 Tim Bunce wrote:
>Seconded, FWIW.

On 5/8/07 Tom Yarrish wrote:
>This just came through on my RSS reader.
>http://news.perl-foundation.org/2007/05/calls_for_proposals.html

Let's get behind this. Sherm could do some work that moves CB forward,
maybe the ".scriptingbridge" metadata.

I can't send money right now -- I freelance and am also currently in a
trough. But I've done lots of editing and grant-writing, so if you need
that kind of help to tighten up a proposal, let me know. 

Also, I notice that the Perl Foundation guidelines don't mention letters
of support, but if Sherm submits a proposal, letters to vouch for him &
CB would probably help (now Chris, don't auto-bury them ;-). 

I think we can confidently answer the "Benefits to the Perl Community"
issue. 

Maybe Apple could make a grant to TPF -- tax-deductible 'n' all --
designated for this project...

Best,

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: CamelBones: Will hack for food!

2007-05-09 Thread Bruce Van Allen
On 5/9/07 Jeremiah Foster wrote:
>I have blogged a bit about Camel Bones here on O'Reilly. Please
>comment if you would so that the python person who commented is not
>the sole comment. Nothing personal against python but it sucks.

But let's not turn this into a battle in the "best language" wars.

All tools to all people, as needed, where useful!

Best,

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: CamelBones: Will hack for food!

2007-05-09 Thread Bruce Van Allen
On 5/9/07 Jeremiah Foster wrote:

>Wed, May 09, 2007 at 08:55:54AM -0700:  Bruce Van Allen mangled some
bits into this alignment:
>> On 5/9/07 Jeremiah Foster wrote:
>> >I have blogged a bit about Camel Bones here on O'Reilly. Please
>> >comment if you would so that the python person who commented is not
>> >the sole comment. Nothing personal against python but it sucks.
>> 
>> But let's not turn this into a battle in the "best language" wars.
>> 
>> All tools to all people, as needed, where useful!
> 
>Absolutely Bruce. I didn't mean to turn this into a language war. Just
>trying to be funny and glib. I apologize.

Accepted.

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: Speaking of support for Camel Bones

2007-05-09 Thread Bruce Van Allen
On 5/8/07 Tim Bunce wrote:
>On Tue, May 08, 2007 at 05:38:42PM -0400, Sherm Pendley wrote:
>> On May 8, 2007, at 5:23 PM, Bruce Van Allen wrote:
>> >I think we can confidently answer the "Benefits to the Perl
Community" issue.
>> That's my biggest concern. CB is mostly of use to the subset of the  
>> community who are using Macs, and need to write GUI apps. My concern  
>> is whether that's a big enough subset to warrant a grant.
>Don't just think about the "Benefits to the Perl _Developer_
Community".
>
>Also think in terms of increasing the size of the Perl _User_ Community
>by enabling quality Mac apps to be implemented in/with perl.
>Tim.

Exactly. I don't have an actual count, but what comes to mind is the
"huge" number of people now dipping their toes into SQL and programmable
database systems simply because of the (L)AMP connection of mySQL and
PHP.

Appreciate what they're missing (besides being limited to a Web
framework): CB + DBI = the real thing. And there would be plenty of
other growth vectors opened up.

But moving past the "why", some work needs to be done before the sales
pitch/evangelism.

Sherm will need to write a proposal and submit it to the Perl
Foundation. The rest of this message has my suggestions for how this
could happen.

The next deadline for submissions is June 8, 2007. Per TPF guidelines,
the proposal needs to include some things that have to be thought
through and written out: 

- Synopsis
  A short description.

- Benefits to the Perl Community

- Deliverables
  Quantifiable results e.g. "Improve X modules in ways Y and Z",
  "Write 3 articles for X website".

- Project Details
  A more detailed description.

Additional non-trivial items are a schedule for the project and a
description of Sherm's background and qualifications to do the project.
  
A quick look at recently funded TPF grants suggests that this might take
a total of 2500 to 4000 words -- the length of a serious journal
article. To do this in one month, it would be handy to have some
milestones that give Sherm a timeline for writing, and provide those of
us who want to help a structure for some parallel processing. 
  
1. Project Definition.
To start, the "project" will need to be defined; in my view this should
be the realistic next set of steps in CB's development. The rest of the
proposal follows from the project definition. 
- Sherm's part: I imagine Sherm has next steps in mind, so the task now
would be for him to write out a description and circulate it. 
- Our part: We can help if he needs encouragement to think big or if he
needs to choose what to take _off_ the plate for now.

2. Outlines, lists, or blurts for the sections listed above.
This is just to get started; the point is to see what needs to be said
and where it should be said in the sections of the proposal.
- Sherm's part: Sherm should do this in whatever way he's most
comfortable putting ideas into words. Concreteness and clarity more
important than golden sentences. Ask for support where you have gaps.
- Our part: Review and especially check for what's missing/incomplete in
the _ideas_ for each section. Conceive of examples. Check references. 

3. Writing
Writing is re-writing.
- Sherm's part: Develop drafts. Write to an audience that is both
demanding of you and also believes in you.
- Our part: review drafts, feed back quickly, stay on topic.

4. Proposal Composition
The written pieces need to be strung together in order and printed out
in a format different from the previous composition, so the emerging
proposal may be read with fresh eyes.
- Sherm's part: Piece it together, send it out, and then take a break.
- Our part: Read, review, encourage, stay on topic.

5. Credentials
This is a part that is important but outside the particulars of the
proposed project, namely Sherm's qualifications. 
- Sherm's part: circulate something. Don't be modest, don't BS.
- Our part: Read and review; also write our own brief and focused
support notes/letters.

6. Project Schedule & Budget
The proposal will need a schedule for the project that makes sense, and
a budget for Sherm's time that is credible. At this starting point (May
9), I think attention should be on conceiving a sufficiently large
project to move CB forward -- but I don't know what that is, or how long
it would take. Looking at past TPF grants will give some context for
this. But focus on the project for now, and come back to this after
progress on the above steps.

OK, those are enough milestones for now. All meant in the spirit of
creating a framework, nothing rigid or "right" about it.

How about some dates?
1. Project Definition. 
Mon, May 14.
2. Outlines, lists, or blurts for the sections listed above. 
Fri May 18.
3. Writing
Fri May 25
4. 

Re: CamelBones: Will hack for food!

2007-05-09 Thread Bruce Van Allen
On 5/9/07 Peter N Lewis wrote:

>Perhaps folks have some ideas for apps that could be written in 
>CamelBones? Something that would presumably use some of the vast CPAN 
>facilities to make something cool with minimal programming effort.

Mine would not be as flashy as games, but I'm working toward two related
CB goals: 

- a GUI for a bunch of data-handling and text processing stuff that I
now do in Perl using cli or BBEdit worksheets and then import to
Filemaker for some outputs and also for lookups and data input by
non-technical users; and

- a spreadsheet GUI that is nothing but a means of accessing and
displaying the cells of a table, no built-in functions, with an API
capable of accepting libraries of whatever Perl code I need to use
(math, text, network) for operations by cell, row, column, sub-table.

Adelante!

- Bruce

__bruce__van_allen__santa_cruz__ca__


Re: "my variable" at global level not being passed

2007-10-04 Thread Bruce Van Allen
On 10/4/07 Michael Barto wrote:

>I am working with an old Perl Library (program module) written in
>Perl4 and Perl  5 depending who was "hacking the code". My program
>that calls it, uses -w and strict and has identified many syntax
>errors and so forth in the old library which I fixed. My problem is
>that this library needs two variables passed as globals to it to use
>in one of the subroutines, One of them is the $dbh variable created
>when the database is open. Another is a hash. Both these variables
>were initiated at the Main top most level of the program with "my".
>Unfortunately, this causes an error and the libraries does not see the
>global. If I turn off strict and the -w options and remove the "my"
>from these variables assignments, the program works. What is going on?
>I might point out that the start of the subroutine that is causing the
>problem starts like this.

What version of perl is the revised program going to run under?

Did you add the my() declaration to the two variables, or was it already
there?

What happens if you declare them with 
use vars qw/$dbh %hash/;
instead?


Best,

 - Bruce
 
__bruce__van_allen__santa_cruz__ca__


Re: Proposed Mac::Pasteboard

2008-01-27 Thread Bruce Van Allen


On Jan 27, 2008, at 10:53 AM, [EMAIL PROTECTED] wrote:


On Jan 27, 10:49 am, [EMAIL PROTECTED] (Chas. Owens) wrote:

On Jan 26, 2008 10:46 PM,  <[EMAIL PROTECTED]> wrote:


On Jan 22, 2:31 am, [EMAIL PROTECTED] (Brian D Foy) wrote:

[[ This message was both posted and mailed: see
  the "To," "Cc," and "Newsgroups" headers for details. ]]



In article
<
012120080315.17779.47940E4B0005B034457322007507440B0B9A0300979D9D0E



[EMAIL PROTECTED]>, <[EMAIL PROTECTED]> wrote:
Is there a module that will let one manipulate a Mac OS X  
pasteboard? There
does not seem to be anything on CPAN that strikes me as being  
for that

purpose.



I'd like to have such a thing, although you should call it
Mac::Clipboard :)



I dithered about this. The arguments as I see them are:



For Mac::Clipboard



1) That's what most people call the thing.



For Mac::Pasteboard



1) It's what the Apple documentation calls it.



2) There's a lot more to it than (e.g.) Win32::Clipboard. For one
thing, there's more than one of them -- in fact, as many as you  
like.

Each can have multiple data items, with data in multiple flavors.


snip

Why choose?  Write Mac::Pasteboard with all of the bells and whistles
and then write Mac::Clipboard using Mac::Pasteboard to expose only  
the

clipboard.  In the SEE ALSO section you can reference Mac::Pasteboard
and people who need the advanced functionality can find it.


Interesting thought. The straightforward implementation would be to
have Mac::Clipboard depend on Mac::Pasteboard (since there's no
simplified clipboard interface that I have found). But it seems un-
parsimonious to me to use namespace for maybe a dozen lines of Perl,


[snip]

Maybe that's not a bad thing. And it wouldn't really limit the  
potential of the namespace. Starting with your Mac::Clipboard (which  
would inherit from Mac::Pasteboard) we might see:
	Mac::Clipboard::Persistent - provide the ability to cache the  
clipboard;
	M::C::History - store clipboard values cumulatively with meta-data  
(time-stamp, ...);

M::C::Multiple - provide multiple clipboards a la some GUI apps
	M::C::Calculate - provide a stack for calculations with multiple  
copied values

...
All of these would work in the "functionality-space" of "The  
Clipboard", which isn't quite the same as accessing other features of  
the Pasteboard, from the user's POV.


Regardless of the name, thanks for alerting me and others to the  
interesting capabilities of the OS X Pasteboard.


Best,

- Bruce

__bruce__van_allen__santa_cruz__ca__





Re: Ann: CamelBones 1.1.0

2009-11-23 Thread Bruce Van Allen
On 2009-11-23 at 11:08 AM, sherm.pend...@gmail.com (Sherm 
Pendley) wrote:



http://www.camelbones.org/node/4



"The requested URL /CamelBones/1.1/CamelBones-1.1.dmg was not 
found on this server."


The link worked when I changed it to:
 /CamelBones/1.1/CamelBones-1.1.0.dmg

 Note the zero.


   - Bruce

_bruce__van_allen__santa_cruz_ca_



SQLite over MySQL?

2011-06-17 Thread Bruce Van Allen

Hey John (or anyone else),

On 2011-06-17, John Delacour wrote:

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


This aroused my curiosity because I have to switch some Perl 
programs written long ago with various flat-file data tables 
accessed via howe-brew parsing to something more transferable. 
None of my uses has more than a few hundred thousand records, 
and most have far fewer.


Would you care to say a bit more about your preference? Do you 
use the Perl DBI with SQLite? If something that reflects your 
views can be read elsewhere, please point.


CAUTION: I'm not interested in enflaming a huge debate about the 
merits and demerits of these and other database systems, their 
developers, companies that "own" them, etc. Just a bit of 
practical curiosity...


Thanks.


   - Bruce

_bruce__van_allen__santa_cruz_ca_



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

2011-09-28 Thread Bruce Van Allen

On 2011-09-28, Lola Lee Beno wrote:


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


Other than the huge download of a bunch of XCode stuff you might 
never use, that's probably the best way to install make.




   - Bruce

_bruce__van_allen__santa_cruz_ca_



Need for Case-Sensitive File System?

2012-01-15 Thread Bruce Van Allen

Hi Friends,

I've been developing in Perl on OS X ever since the OS X Public 
Beta. Somewhere along the line I came to believe that I should 
set up my system with the boot drive formatted as Max OS 
Extended (Case-sensitive, Journaled).


Emphasis here on "Case-sensitive".

My question is: Is this practice (still) needed?

Background
--
I started doing this after some discussions on this list several 
years ago; the issue was that some Perl modules assume(d) 
file-system case-sensitivity. For example, here's a quote from a 
message by Ari Kahn on Mar 8 2002:


"... difficulties when installing a software package that was 
designed for a
case-sensitive system. For example, libwww-perl by default 
installs an HTTP
script called HEAD, which is used to make an HTTP HEAD request. 
If this is

installed to /usr/bin, it can overwrite the BSD built-in /usr/bin/head
command, used for reading the beginnings of files. To prevent 
this kind of
collision when using HFS+, it's necessary to configure CPAN.pm 
to install

modules to a private directory. "

I didn't choose the recommended solution at the time of always 
installing CPAN modules in a private directory. Instead, every 
time I formatted a new boot drive, I made it case-sensitive.


Over the years this has caused a few difficulties, particularly 
with some commercial software such as Quark Xpress refusing to 
install, but I only use case-sensitive formatting on my dev 
machine, so it's not usually a problem.


I am about to set up a Mac Mini OS X 10.7 server as a new dev 
machine, and am wondering whether I still need to re-format as 
case-sensitive before proceeding. I'd like to avoid the 
limitations of case-sensitivity if possible. If I format as 
case-INsensitive, will CPAN now help me do the right thing?


Thanks.





   - Bruce

_bruce__van_allen__santa_cruz_ca_