Aug 04 2008

My Homer Maharadscha

Tag: Outter Worldberrisch @ 4:57 pm

Posted by mobile phone:
TDMDAJM
This little Homer is smiling to me each morning
in my little office in Paris!
File info:
Type: image jpg
Size: 228.30 kb
Homer Maharadscha


Jul 24 2008

File Tests

Tag: Perlberrisch @ 7:25 pm


If you want to test whether you can write to a file or if a direcory exists,
this may help a little when writing clean scripts with appropriate error messages

So here is a little collection of the most common file test operators in Perl:

File Test Operators
 
Test 	Meaning
 
-r 	File or directory is readable by this (effective) user or group
-w 	File or directory is writable by this (effective) user or group
-x 	File or directory is executable by this (effective) user or group
-o 	File or directory is owned by this (effective) user
-R 	File or directory is readable by this real user or group
-W 	File or directory is writable by this real user or group
-X 	File or directory is executable by this real user or group
-O 	File or directory is owned by this real user
-e 	File or directory name exists
-z 	File exists and has zero size (always false for directories)
-s 	File or directory exists and has nonzero size (the value is the size in bytes)
-f 	Entry is a plain file
-d 	Entry is a directory
-l 	Entry is a symbolic link
-S 	Entry is a socket
 
 
Test 	Meaning
 
-p 	Entry is a named pipe (a “fifo”)
-b 	Entry is a block-special file (like a mountable disk)
-c 	Entry is a character-special file (like an I/O device)
-u 	File or directory is setuid
-g 	File or directory is setgid
-k 	File or directory has the sticky bit set
-t 	The filehandle is a TTY (as reported by theisatty()system function; filenames can’t be tested by this test)
-T 	File looks like a “text” file
-B 	File looks like a “binary” file
-M 	Modification age (measured in days)
-A 	Access age (measured in days)

Apr 09 2008

Using translation tools: babelfish / google / yahoo

Tag: Perlberrisch @ 4:29 pm


Languages: Chinese-simp, Chinese-trad, Dutch, English, French, German, Greek, Italian, Japanese, Korean, Portuguese, Russian, Spanish

Requirements:

IO::String
WWW::Babelfish
#!/usr/bin/perl
 use strict;
 use warnings;
 use WWW::Babelfish;
 
 # text to translate
 my $text_source = 'I like to test this service.';
 
 # create the Babelfish service
 my $service = WWW::Babelfish->new(
     service => 'Babelfish',
 );
 
 # check for errors
 if (not defined $service) {
     die "Babelfish server unavailable";
 }
 
 # show text to be translated
 print "[EN] $text_source\n";
 
 # translate to Italian
 my $text_target = $service->translate(
     source          => 'English',   # source language
     destination     => 'Italian',   # destination language
     text            => $text_source,    # text to translate
 );
 if (not defined $text_target) {
     print "Error while translating to Italian";
 }
 else {
     print "[FR] $text_target\n";
 }

« Previous PageNext Page »