Re: [OT] Israeli Daylight Saving enabled time zone for Windows

2004-04-09 Thread Guy Teverovsky
On Fri, 2004-04-09 at 07:59, Shachar Shemesh wrote:

 tzedit is only available through the Platform SDK, which in turn is only 
 truely available through MSDN, for which I payed full price. We tried to 
 get a discount for Hamakor members, but Microsoft didn't see us as an 
 interesting group to encourage. Strange, that.
You can't blame them for that :-)

[snip]
 3) If you want more creative solution, take a look at my post at Tapuz:
 http://www.tapuz.co.il/tapuzforum/main/Viewmsg.asp?forum=956msgid=29612710
 (sorry folks, it's in Hebrew)
   
 
 Why is it more creative? The guy uses an INF instead of a REG file, and 
 has a script. Otherwise, it's precisely the same solution.
The guy is me. 
Notice that I account the fact that W2K and XP by default store the
Israeli timezone settings under HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Time Zones\Israel Standard Time and not Jerusalem
Standard Time (as opposed to NT)

If you do not want to confuse the users by having double entry for
Israel, you need to get rid of Israel Standard Time.
More then that, your reg file will create on XP 2 timezone entries with
the same index of 0x87 (135) (one Jerusalem TZ and one Israeli TZ),
which has been proved in my tests to make XP very unhappy puppy.


Cheers,
Guy

-- 
Smith  Wesson - the original point and click interface


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Perl question

2004-04-09 Thread Shachar Shemesh
Shachar Shemesh wrote:

if( (($state[2]  ~)12) ==4 ) { # A directory - 
recurse

That's 0 of course, or even remove altogether and just leave the 
12 part. Same problem remains, however.

--
Shachar Shemesh
Lingnu OpenSource Consulting
http://www.lingnu.com/
=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]


Re: Perl question

2004-04-09 Thread Muli Ben-Yehuda
On Fri, Apr 09, 2004 at 10:54:04AM +0300, Shachar Shemesh wrote:

 1. I know, I write perl like a C programmer, I can't help it. Feel free 
 to show me how it's done.

Not a perl guru by any stretch of the imagination, but behold my
google foo! 

#!/usr/bin/perl

@ARGV = qw(.) unless @ARGV;
use File::Find;
find sub { print $File::Find::name, -d  '/', \n }, @ARGV;

(copied straight out of
http://iis1.cps.unizar.es/Oreilly/perl/cookbook/ch09_08.htm. You were
working at the wrong level of abstraction.)

 2. For some strange reason, the moment I recurse once, the entire loop 
 structure exits. I suspect it's because the DIR handle is global. Will 
 any perl guru comment on how it's supposed to be done?

No idea, but something looks funky about the usage of DIR indeed. 

 3. What the @$([EMAIL PROTECTED] is the difference between my and local? Which 
 one should I use here?

http://prometheus.frii.com/~gnat/yapc/2000-stages/slide21.html

Cheers, 
Muli 
-- 
Muli Ben-Yehuda
http://www.mulix.org | http://mulix.livejournal.com/



signature.asc
Description: Digital signature


Re: Perl question

2004-04-09 Thread Shlomi Fish
On Friday 09 April 2004 10:54, you wrote:
 Hi,

 I'm trying to create a perl program that will recurse into

 subdirectories. I have:
  sub scandir {
  local $dirname=shift;
 

You should use my $dirname = shift; instead of local here. It's safer.

  opendir DIR, $dirname or die Couldn't open ${dirname}: $!\n;
 

Just for safeness, it would be better if you localize DIR here:


local (*DIR);
opendir DIR...


  local $direntry;

Again -  my $direntry;

  while( $direntry=readdir(DIR) ) {

Instead of using readdir in a loop, I strongly recommend that you read all the 
entries into an array and then loop on it:

my @entries = readdir(DIR);
closedir(DIR);
foreach $direntry (@entries)
{
..
}

Otherwise, many dirhandles will be opened, and I'm not sure if the results 
will be very expectful. (with local and all)

  if( $direntry!~/^\./ ) {

Do you want to avoid only . and .. or any directory that starts with .? 
Your code does the latter.

  local @state=stat($dirname.$direntry);
  print $dirname$direntry $state[2]\n;
  if( (($state[2]  ~)12) ==4 ) { # A directory - recurse

This can be simplified into: 


if (-d $dirname.$direntry). { # A directory - recurse

-d is a file check that checks if a file is a directory. Check perldoc -f 
-X for more information.  

  scandir($dirname.$direntry./);

This is good. Albeit many people like to use interpolation:

scandir($dirname$direntry/);

  }
  }
  }
 
  closedir DIR;
  }

 1. I know, I write perl like a C programmer, I can't help it. Feel free
 to show me how it's done.

:-)

 2. For some strange reason, the moment I recurse once, the entire loop
 structure exits. I suspect it's because the DIR handle is global. Will
 any perl guru comment on how it's supposed to be done?

If you localize *DIR, it won't happen.

 3. What the @$([EMAIL PROTECTED] is the difference between my and local? Which
 one should I use here?


my declares a lexically-scoped variable. It is similar to (define) in 
Scheme. The value of this variable is not propagated to subsequent function 
calls (unless they are closures). So for example:


#!/usr/bin/perl -w

use strict;

my $myvar = 3;

sub my_called_function
{
print In called: \$myvar = $myvar\n;

$myvar = 10;
}

sub my_caller_function
{
my $myvar;

$myvar = 500;

my_called_function();

print In caller: \$myvar = $myvar\n;
}

my_caller_function();

print In Global: \$myvar = $myvar\n;


will print:


In called: $myvar = 3
In caller: $myvar = 500
In Global: $myvar = 10


local creates a dynmically scoped localization. The value of the variable is 
recorded when the local is encountered, and restored once the block exits. It 
is propogated to all subsequent function calls. So for example:


#!/usr/bin/perl -w

$myvar = 3;

sub my_called_function
{
print In called: \$myvar = $myvar\n;

$myvar = 10;
}

sub my_caller_function
{
local $myvar;

$myvar = 500;

my_called_function();

print In caller: \$myvar = $myvar\n;
}

my_caller_function();

print In Global: \$myvar = $myvar\n;


prints:


In called: $myvar = 500
In caller: $myvar = 10
In Global: $myvar = 3


Generally, my should be used for all regular variables (scalars, arrays and 
hashes) because it's safer, while local should be used for filehandles, and 
built-in variables. (the ones in perldoc perlvar) This is because they 
cannot be effectively scoped with my.

Hope it helps. There's more information about it on the Web and in the Perl 
documentation.

As others noted, you can use the File::Find Perl module to traverse a 
directory tree.

Regards,

Shlomi Fish

-- 

-
Shlomi Fish  [EMAIL PROTECTED]
Homepage:http://shlomif.il.eu.org/

Quidquid latine dictum sit, altum viditur.
[Whatever is said in Latin sounds profound.]

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Perl question

2004-04-09 Thread Oron Peled
On Friday 09 April 2004 11:27, Muli Ben-Yehuda wrote:
  3. What the @$([EMAIL PROTECTED] is the difference between my and local? Which 
  one should I use here?
 
 http://prometheus.frii.com/~gnat/yapc/2000-stages/slide21.html

I didn't like so much the dumbed down type of explatanion in this
slide, so here is my take:

1. my does early binding between variable name and variable 
   storage (when the variable is defined) while local does late binding
   (when the variable is used).

2. This is very similar to the logical difference between hard link and
   symbolic link in the file system.

3. Technically, my variables are allocated on the call stack and thus
   behaves just like automatic variables in C. local variables are
   actually global variables which are looked up through the symbol table.
   What the local keyword does is temporarily save the global value and
   restore it automatically when we exit the scope.

4. Until perl-5 arrived (circa 94) only local existed. That's the
   historical reason for the non-intuitive name. During perl-6 development
   it was suggested to create a better term, something like tempval
   which describes more accurately its semantics (I didn't follow
   through to check if it was accepted after all).

-- 
Oron Peled Voice/Fax: +972-4-8228492
[EMAIL PROTECTED]  http://www.actcom.co.il/~oron

Beware of bugs in the above code;
 I have only proved it correct, not tried it.
  -- Donald E. Knuth


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Perl question

2004-04-09 Thread Gabor Szabo
On Fri, 9 Apr 2004, Shachar Shemesh wrote:

 1. I know, I write perl like a C programmer, I can't help it. Feel free
 to show me how it's done.
Probably you should use File::Find
Try this code as a starter:

use File::Find;
$dirname = shift @ARGV;
find(\myfunc, $dirname);

sub myfunc {
printf %s  %s\n, $_, -d $_;
}

also look at
perldoc File::Find

 2. For some strange reason, the moment I recurse once, the entire loop
 structure exits. I suspect it's because the DIR handle is global. Will
 any perl guru comment on how it's supposed to be done?
wrong question :-)
TMTOWTDI


 3. What the @$([EMAIL PROTECTED] is the difference between my and local? Which
 one should I use here?

local is nearly obsolete, you should nearly always use my.
my- gives you lexical scoping (within the same {} block);
local - gives you a scoping within the current {} AND all the
functions called from within this {} block.

try reading
perldoc -f local
perldoc -f my


See also
  www.perl.org.il

Gabor

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Perl question

2004-04-09 Thread Shachar Shemesh
Gabor Szabo wrote:

On Fri, 9 Apr 2004, Shachar Shemesh wrote:

 

1. I know, I write perl like a C programmer, I can't help it. Feel free
to show me how it's done.
   

Probably you should use File::Find
Try this code as a starter:
use File::Find;
$dirname = shift @ARGV;
find(\myfunc, $dirname);
 

Suppose I wanted to write this myself, how would I go about doing it? Is 
there any way of recursively using a dir or file handle name?

 Shachar

--
Shachar Shemesh
Lingnu OpenSource Consulting
http://www.lingnu.com/
=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]


Re: XFree86 fonts with xfs

2004-04-09 Thread David Harel
This still does not say how to identify the actual file that is used 
when you select a font. All it says is where to look for. So many font 
names reside in so many different files and I want to identify the 
actual file when I select a font in a font dialog box like Sans 
Regular 12.

Diego Iastrubni wrote:

On Thursday 08 April 2004 16:38, David Harel wrote:
 

Hi all,

How can I find which is the phisical file used when selecting fonts by
name and size, like in KDE?
   

if you query the fonts from xfs you cannot.
otherwise, you should use fontconfig. (google)
 

--
Thanks.
David Harel,

==

Home office +972 4 6921986
Fax:+972 4 6921986
Cellular:   +972 54 534502
Snail Mail: Amuka
   D.N Merom Hagalil
   13802
   Israel
Email:  [EMAIL PROTECTED]


=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]


Re: Perl question

2004-04-09 Thread Shachar Shemesh
Ok, thanks everyone.

ONYAWIRNWSTG (Oh No, Yet Anohter, Was It Really Neccessary, WebSite from 
Template Generator) is now ready thanks to your help. Yes, it seems I 
too rewrote my own tool, despite having other tools to rely on. Nothing 
was an exact match to what I was looking for.

In case anyone is interested, my tool is attached to this email. I've 
had some hard time with the array of hash references thing. I kept 
reusing the same hash throughout the iterations. If any of the list's 
perl gurus want to have a look and remark on an easier way to do it, 
please let me know.

If anyone wants to use this tool - it takes three arguments. A template 
directory, a content directory, and the directory with the resulting 
site. The templates are in HTML::Template format - just RTFM that. The 
content begins with the template's name, and continues with three types 
of commands - s name=value, in which case it substitutes name for value 
as per HTML::Template man. s name terminator, in which case all the 
following lines are substituted for name, until a line carrying only the 
terminator, and m name loopterm wholeterm, which fills in values to 
loops. Each loop holds commands from the first type, terminated by 
loopterm. When the entire loop should be terminated, wholeterm is 
used. Example:

templatedir/template.tmpl:
headtitleTMPL_VAR name=title/title/head
bodyh1tmpl_var name=header/h1
Lines:br
tmpl_loop name=bodytmpl_var name=subject: tmpl_var name=objectbr
/tmpl_loop
/body
contentdir/index.html:
template.tmpl
s title=Page title
s header EOH
This is the page header
EOH
m body EOL EOAL
s subject=Behold
s object=Line 1
EOL
s subject=Line 2
s object END
This is the second linebr
It is two lines in one
END
EOL
EOAL
running mksite.pl templatedir contentdir website will create a file 
that looks like this:
website/index.html:
headtitlePage title/title/head
bodyh1This is the page header/h1
Lines:br
Behold: Line 1br
Line 2: This is the second linebr
It is two lines in onebr
/body

If this brief manpage proves useful, please drop me a note.

Shachar

--
Shachar Shemesh
Lingnu OpenSource Consulting
http://www.lingnu.com/
#!/usr/bin/perl

use HTML::Template;
use File::Find;

# Syntax - mksite.pl template_dir content_dir production_dir [clean]
# clean is not yet implemented.

$tmpldir=shift;
$contdir=shift;
$dstdir=shift;

$contdir=~'^(.*[^/])/*$' or die Error parsing content dir\n;
$contdir=$1./;

$tmpldir=~'^(.*[^/])/*$' or die Error parsing template dir\n;
$tmpldir=$1./;

$dstdir=~'^(.*[^/])/*$' or die Error parsing destination dir\n;
$dstdir=$1./;

find({ wanted = \process, follow_fast = 1, no_chdir= 1}, $contdir );

sub trim_prefix {
return substr shift, length( $contdir );
}
sub process {
# skip hidden files
$File::Find::name=~'/\.[^/]*$' and return;
$File::Find::name=~'/CVS(/[^/]*)?$' and return;

# Only files are interesting
if(-f $File::Find::name) { # A regular file
if( $File::Find::name=~/\.html?$/ ) {
	expand( trim_prefix($File::Find::name));
} else {
system cp $File::Find::name $dstdir.trim_prefix($File::Find::name);
}
} elsif( -d $File::Find::name ) { # a directory
	mkdir( $dstdir./.trim_prefix($File::Find::name) );
}
}

# Expands the template to a file with the corresponding name
sub expand {
my $filename=shift;
open (CONTENT_FILE, , $contdir.$filename) or
	die Error opening content file $filename: $!\n;

open (RES_FILE, , $dstdir.$filename) or
	die Error opening result file $filename: $!\n;

my $line=readline CONTENT_FILE;
$line or die Content file $filename empty\n;
chomp $line;
my $template = HTML::Template-new(filename = $tmpldir$line);
my $multi_delimit, $multi_delim2;
my @multi_params=();
my $multi_name;
my $currrow;

while( CONTENT_FILE ) {
	chomp;
	# Find out what form the command takes
	if( m/^s\s+(\w+)\s*=\s*(.*)\s*$/ ) {
	# A single line single var
	if( $multi_name ) {
		$currrow-{$1}=$2;
	} else {
		$template-param( $1 = $2 );
	}
	} elsif( m/^s\s+(\w+)\s+(\w+)\s*$/ ) {
	# A multi line single var
	my ($varname,$delimit)=($1,$2);
	my $data;
	while( $line=CONTENT_FILE and $line ne $delimit.\n ) {
		chomp $line;
		$data and $data.=\n;
		$data.=$line;
	}
	if( $multi_name ) {
		$currrow-{$varname}=$data;
	} else {
		$template-param( $varname = $data );
	}
	} elsif( !$multi_delimit  m/^m\s+(\w+)\s+(\w+)\s+(\w+)\s*$/ ) {
$currrow={};
	($multi_name, $multi_delimit, $multi_delim2)=($1,$2, $3);
	} elsif( $multi_name  $_ eq $multi_delimit ) {
	push ( @multi_params, {%$currrow});
	} elsif( $multi_name  $_ eq $multi_delim2 ) {
	$template-param( $multi_name = [EMAIL PROTECTED] );
	$multi_name=undef;
	%multi_params=undef;
	$multi_delimit=undef;
	} else {
	print nothing matched\n;
	}
}

print RES_FILE $template-output;

close RES_FILE;
close CONTENT_FILE;
}