Enconding, locate, etc.
Hi, I am a new member of this list and have many many questions I would like to do... but also I am worried about being not on topic But, anyway, here is a issue I have been fighting with for weeks... The next is a small prototype of an AddressBook I want to manage with Perl. The data are in a small ASCII file and any word in it can be the target of search. You only need to put one or more utf8 words in the command line and then the script should shows to you the lines that content them... (like grep, but potentially improvable). The data file is in MacRoman encoding... The problem is: 1) How to manage utf8 high bytes words to be recognized (I would like to find Ángeles Angeles ángeles or angeles with any of this words!) I have used utf8::decode($_) but it seems not to work. use encoding utf8 seems to not affect in any way. When I use utf8::decode of the @ARGV, it finds all, not filtering at all... Thanks for any clue. #!/usr/bin/env perl # # telefonos.pl # # me 2006-04-07 # # binmode STDOUT, :utf8; use encoding 'utf8'; my $listin = /Users/me/Documents/documentos/Familia/Casa/Telistin.txt; my $alphax = /Applications/Alpha/AlphaX.app; if ([EMAIL PROTECTED]) { exec open -a $alphax $listin; } if (! -e $listin){ print strange! file not found: $listing \n; exit 1; } open my $f, :encoding(MacRoman), $listin or die $listin no abre: $!; my @todo = $f; close $f; # PROBLEM my @args = map {utf8::decode($_)} @ARGV; my $re = join(|, @ARGV); print grep(/$re/i, @todo), \n; # also look in the Apple AddressBook foreach my $a (@ARGV) { system(abtool $a); } ende
Terminal (spurious command line) problem
A weird problem with Terminal.app has arisen in which a command line (of the form perl file1.plx file2.txt )gets written to the Terminal window each time a new Terminal window is opened (File-New Shell). The problem seems to owe its origins to some experiments with ScriptGUI to see if that app would create a 'droplet' to fulfil the function of the command line above. Somehow a file (?) seems to have got left somewhere (?) in the bowels of system which is 'read' by Terminal each time a new window is opened. ScriptGUI itself has subsequently been deleted. Can anyone suggest where to look for such a file? Where could any 'command string' be kept in the system which would be 'written' to the Terminal window on launch? The machine BTW is a G4 running Tiger 10.4.6. and for what it's worth, both of the files referenced in the spurious command line have been deleted. I would be deeply grateful to anyone for some clues as to where to look or what to do to mitigate the nuisance (and apologise if this is too far off-topic for this list). Alan Fry
Re: Terminal (spurious command line) problem
Have you tried looking in ~/.profile? Sorry if that's too obvious... Thanks, Boysenberry boysenberrys.com | habitatlife.com | selfgnosis.com On Apr 18, 2006, at 12:55 PM, Alan Fry wrote: A weird problem with Terminal.app has arisen in which a command line (of the form perl file1.plx file2.txt )gets written to the Terminal window each time a new Terminal window is opened (File-New Shell). The problem seems to owe its origins to some experiments with ScriptGUI to see if that app would create a 'droplet' to fulfil the function of the command line above. Somehow a file (?) seems to have got left somewhere (?) in the bowels of system which is 'read' by Terminal each time a new window is opened. ScriptGUI itself has subsequently been deleted. Can anyone suggest where to look for such a file? Where could any 'command string' be kept in the system which would be 'written' to the Terminal window on launch? The machine BTW is a G4 running Tiger 10.4.6. and for what it's worth, both of the files referenced in the spurious command line have been deleted. I would be deeply grateful to anyone for some clues as to where to look or what to do to mitigate the nuisance (and apologise if this is too far off-topic for this list). Alan Fry
Enconding, locate, etc.
Hi, I am a new member of this list and have many many questions I would like to do... but also I am worried about being not on topic I've been working on Tcl for many years (I love it), Perl is a very different affair, you must believe me, and then it is a challenge for me. An issue I have been fighting with for weeks... The next is a small prototype of an AddressBook I want to manage with Perl. The data are in a small ASCII file and any word in it can be the target of search. You only need to put one or more utf8 words in the command line and then the script should shows to you the lines that content them... (like grep, but potentially improvable). The data file is in MacRoman encoding... The problem is: 1) How to manage utf8 high bytes words to be recognized (I would like to find Ángeles Angeles ángeles or angeles with any of this words!) I have used utf8::decode($_) but it seems not to work. use encoding utf8 seems to not affect in any way. When I use utf8::decode of the @ARGV, it finds all, not filtering at all... Thanks for any clue. (In bash: #!/bin/sh if [ $# = 0 ]; then open -a /Applications/Alpha/AlphaX.app /Users/juanfc/Documents/ documentos/Familia/Casa/Telistin.txt exit fi grep -i `echo $* | convert_utf82mac.pl` /Users/juanfc/Documents/ documentos/Familia/Casa/Telistin.txt | convert_mac2utf8.pl | sort abtool $* ) In Perl #!/usr/bin/env perl # # telefonos.pl # # me 2006-04-07 # # binmode STDOUT, :utf8; use encoding 'utf8'; my $listin = /Users/me/Documents/documentos/Familia/Casa/Telistin.txt; my $alphax = /Applications/Alpha/AlphaX.app; if ([EMAIL PROTECTED]) { exec open -a $alphax $listin; } if (! -e $listin){ print strange! file not found: $listing \n; exit 1; } open my $f, :encoding(MacRoman), $listin or die $listin no abre: $!; my @todo = $f; close $f; # PROBLEM my @args = map {utf8::decode($_)} @ARGV; my $re = join(|, @ARGV); print grep(/$re/i, @todo), \n; # also look in the Apple AddressBook foreach my $a (@ARGV) { system(abtool $a); } ende
Re: Terminal (spurious command line) problem
On 18/04/06, Alan Fry [EMAIL PROTECTED] wrote: A weird problem with Terminal.app has arisen in which a command line (of the form perl file1.plx file2.txt )gets written to the Terminal window each time a new Terminal window is opened (File-New Shell). The problem seems to owe its origins to some experiments with ScriptGUI to see if that app would create a 'droplet' to fulfil the function of the command line above. Somehow a file (?) seems to have got left somewhere (?) in the bowels of system which is 'read' by Terminal each time a new window is opened. ScriptGUI itself has subsequently been deleted. Can anyone suggest where to look for such a file? Where could any 'command string' be kept in the system which would be 'written' to the Terminal window on launch? The machine BTW is a G4 running Tiger 10.4.6. and for what it's worth, both of the files referenced in the spurious command line have been deleted. I would be deeply grateful to anyone for some clues as to where to look or what to do to mitigate the nuisance (and apologise if this is too far off-topic for this list). Alan Fry Start Terminal.app and check under preferences (apple-,) If you don't see it there, quit Terminal, backup and delete ~/Library/Preferences/com.apple.Terminal.plist Betcha that gets it. HTH Brian
Re: Terminal (spurious command line) problem
On Apr 18, 2006, at 2:30 PM, Brian McKee wrote: Start Terminal.app and check under preferences (apple-,) If you don't see it there, quit Terminal, backup and delete ~/Library/Preferences/com.apple.Terminal.plist It's not a great idea to manipulate preference files directly. Their location, filename, format, etc. are considered an implementation detail that's subject to change without notice. Apple has already made at least two changes, from old-style plists to XML-based plists, and then from that to a binary file format. The Apple-recommended way to deal with the user defaults database from a shell prompt is to use the defaults tool, like this: defaults delete com.apple.Terminal Naturally, there are both Cocoa and Carbon APIs to do this programatically also. sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: Terminal (spurious command line) problem
On Tue, 18 Apr 2006, Sherm Pendley wrote: On Apr 18, 2006, at 2:30 PM, Brian McKee wrote: Start Terminal.app and check under preferences (apple-,) If you don't see it there, quit Terminal, backup and delete ~/Library/Preferences/com.apple.Terminal.plist It's not a great idea to manipulate preference files directly. Their location, filename, format, etc. are considered an implementation detail that's subject to change without notice. Apple has already made at least two changes, from old-style plists to XML-based plists, and then from that to a binary file format. The Apple-recommended way to deal with the user defaults database from a shell prompt is to use the defaults tool, like this: defaults delete com.apple.Terminal Naturally, there are both Cocoa and Carbon APIs to do this programatically also. All of which is true. That said, I still find this easier potentially safer: mv ~/Library/Preferences/com.apple.Terminal.plist{,.MOVED} The main benefit being that if this doesn't actually solve the problem, you can trivially reverse the change with a mv ~/Library/Preferences/com.apple.Terminal.plist{.MOVED,} (And all that said, renaming preference files and deleting caches under your ~/Library/Caches tree are both common diagnostic tricks when things aren't working. In most cases, zapping files in either of these trees shouldn't cause any problems, since if the needed files are missing, the applications will regenerate a known-good version of the preference or cache file -- the same way it did the first time you used them. But then, at a glance, it doesn't look like Terminal uses caches, so that wouldn't apply here, but the broader point still stands -- preferences and caches are generally easy safe to rename or remove when trying to diagnose software problems.) -- Chris Devers who *ahem* does this sort of thing for people for a living :-)