[29209] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 453 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 23 06:10:11 2007

Date: Wed, 23 May 2007 03:09:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 23 May 2007     Volume: 11 Number: 453

Today's topics:
    Re: converting code via regex <tadmc@augustmail.com>
    Re: converting code via regex <davedontmind@gmail.com>
        DCC Chat in irssi. <ceil420@gmail.com>
    Re: executing an sql statement in perl <rvtol+news@isolution.nl>
    Re: executing an sql statement in perl <rvtol+news@isolution.nl>
    Re: listing all available methods <skye.shaw@gmail.com>
    Re: localtime(time()) <t-use@gmx.net>
    Re: localtime(time()) <rvtol+news@isolution.nl>
        make money by visiting websites <tpraja@gmail.com>
        new CPAN modules on Wed May 23 2007 (Randal Schwartz)
    Re: parsing a variable length record from a mixed forma <rvtol+news@isolution.nl>
    Re: Passing variables into another script <joe@inwap.com>
    Re: Passing variables into another script <csoon@xilinx.com>
    Re: Passing variables into another script <joe@inwap.com>
    Re: Passing variables into another script <csoon@xilinx.com>
    Re: Perl and German Umlauts <idontlikespam@denniswinter.de>
    Re: Unicode in regexp gypark2@gmail.com
        What's the point of these lines of code? <cdalten@gmail.com>
    Re: What's the point of these lines of code? <cdalten@gmail.com>
    Re: What's the point of these lines of code? <scobloke2@infotop.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 22 May 2007 20:08:16 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: converting code via regex
Message-Id: <slrnf57500.87g.tadmc@tadmc30.august.net>

Jerry <jpreston@general-steel.com> wrote:


>       s/then//;


You want "authenticate" to become "auticate" ?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 23 May 2007 00:40:36 -0700
From: "davedontmind@gmail.com" <davedontmind@gmail.com>
Subject: Re: converting code via regex
Message-Id: <1179906035.999819.88360@k79g2000hse.googlegroups.com>

Please don't top-post. If you're replying to someone, trim their
message to
something small enough to provide context for your post, and put your
replies
*below* the relevant parts of the post you're replying to.


Jerry <jpres...@general-steel.com> wrote:
>         my $wordCNT = 0;
>         my ( @Word ) = /\.(\w+)/g;
 ...

That is not a *short* but *complete* program that exhibits your
problem.
When I run it it outputs nothing. What did you expect?


>  foreach my $Word ( @Word) {
>
>    my %WordList = (  "footage"       => "footage",
>                      "qty"           => "qty",
>                      "total"         => "total",
> 		    #  ... snip words ...
>                      "pt"            => "pt",
>                   );

So the only point of %WordList is to see if a word in the original $_
is
'valid' ?  There's no need to initialize %WordList each time through
the loop,
and there are less verbose ways to initialize it:

    my %WordList = map { $_ => 1 } qw(footage qty total ... pt);
    for my $Word ( /\.(\w+)/g ) {
	...
    }

>   if( $WordList{ $Word } )
>   {
>
>   s/(\w)\.\b$WordList{ $Word }\b \);/$1\.$WordList{ $Word }\[ $1.L_NO_ \] \n/g if /get/;

By the very nature of your code, if you get here $WordList{$Word} will
always
be the same as $Word, so why use the more verbose form?

    s/(\w)\.\b$Word\b \);/$1\.$Word\[ $1.L_NO_ \] \n/g if /get/;

Also (as I mentioned in my previous post) you don't need all those
back-slashes
in the right-hand side of the s///: So that line can become:

    s/(\w)\.\b$Word\b \);/$1.${Word}[ $1.L_NO_ ] \n/g if /get/;

The \b's in the left-hand side are redundant too, given your word list
above:

    s/(\w)\.$Word \);/$1.${Word}[ $1.L_NO_ ] \n/g if /get/;

There - that's a little more readable than your original line.


>  s/(\w)\.\b$WordList{ $Word }\b/$1\.$WordList{ $Word }\[ $1.L_NO_ \]
>           ToString\(\)/g if( /= \"/ || /!= \"/ || /== \"/ ) && !/\[/ && !/\*\w\./g;

What's the "/g" on the last pattern match for?

  if( /= \"/ || /!= \"/ || /== \"/ )

is exactly the same as:

   if /= "/

because if your string contains '!= "' or '== "' it will still match
the first
pattern.  And double quotes don't need to be escaped in a regex.

I find the "and" "or" and "not" operators to be much more readable
than "&&"
"||" and "!":

    ... if /= "/ and not /\[/ and not /\*\w\./;



>   s/(\w)\.\b$WordList{ $Word }\b /$1\.$WordList{ $Word }\[ $1.L_NO_ \]
>                       ToString\(\) /g if( /!= \"n\"/i && $wordCNT > 0 );

    s/(\w)\.$Word /$1.${Word}[ $1.L_NO_ ].ToString() /g if /!= "n"/i
and $wordCNT > 0;

If you're still having problems, post a *short* but *complete* program
(which
uses 'strict' and 'warnings' and includes some sample data) that
demonstrates
your problem. Tell us what output you see, and what you're expecting
to see.




------------------------------

Date: Wed, 23 May 2007 02:35:12 -0500
From: Ceil <ceil420@gmail.com>
Subject: DCC Chat in irssi.
Message-Id: <f30qv0$qeu$1@registered.motzarella.org>

Can someone walk me through managing DCC Chat sessions using perl in 
irssi, or show me a site that can help? I checked the irssi site, which 
is how I got the 'signals' I'll show below.

Specifically, what I'm trying to do is make a sort of game bot that uses 
DCC Chat (multiple lines without flooding ftw). I know how to intercept 
a DCC Chat message in the script, but not how to use it. Here's the 
script I've got at the moment (the relevant part, anyway):

 >signal_add("message dcc", "onCHAT");
 >sub onCHAT {
 >  print "onCHAT: @_";
 >  my ($dcc, $message) = @_;
 >  print "onCHAT; DCC: $dcc Message: $message";
 >  return;
 >}

And the output from that:

 >onCHAT; DCC: Irssi::Irc::Dcc::Chat=HASH(0x82b209c) Message: Testing.

Is there a way to get the username or IP or something from $dcc there? 
If so, how do I send a DCC Chat message to the user in response? The 
similar output from the "message dcc own" signal isn't much help:

 >onCHATOWN; DCC: Irssi::Irc::Dcc::Chat=HASH(0x82b2054) Message: testing 
again

I notice that the HASH() number changes with the time of the message, 
but I don't know the significance of that. Any help?

Thanks,
C


------------------------------

Date: Tue, 22 May 2007 22:00:10 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: executing an sql statement in perl
Message-Id: <f2vp6p.1jo.2@news.isolution.nl>

xhoster@gmail.com schreef:

> (As a hint, if you have no \%attr to pass, just use undef instead.)

And some people prefer to pass {}. 

-- 
Affijn, Ruud (I don't)

"Gewoon is een tijger."


------------------------------

Date: Tue, 22 May 2007 21:57:36 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: executing an sql statement in perl
Message-Id: <f2vp6p.1jo.1@news.isolution.nl>

Dennis Roesler schreef:

> I don't think place holders will work with $dbh->do because 
> that does a prepare and execute in one go.

Why prepare without placeholders? 

(Your one go has at least two steps.) 

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: 23 May 2007 00:34:19 -0700
From: "Skye Shaw!@#$" <skye.shaw@gmail.com>
Subject: Re: listing all available methods
Message-Id: <1179905659.227092.293020@q69g2000hsb.googlegroups.com>

On May 22, 12:31 am, "Mumia W." <paduille.4061.mumia.w
+nos...@earthlink.net> wrote:
> On 05/22/2007 01:27 AM, Joseph Brenner wrote:
>
> > Can someone point me at a good way of getting a list of all
> > methods available to an object?  

A good way, well, I'm sure some would argue as to the goodness of
this:

~ > perl -MCarp -le'for(keys %{Carp::}) { print $_ if defined &{"Carp::
$_"} and $_ !~ /^_/ }'

Replace Carp with the desired module.
This will also print constants, which are really subs anyways.



------------------------------

Date: 22 May 2007 19:16:59 GMT
From: Martin Trautmann <t-use@gmx.net>
Subject: Re: localtime(time())
Message-Id: <slrnf56gdb.5p4.t-use@ID-685.user.individual.de>

On Tue, 22 May 2007 14:29:57 GMT, Uri Guttman wrote:
>  ever heard of perldoc.perl.org?

no, not yet.

Thanks,
Martin


------------------------------

Date: Tue, 22 May 2007 22:06:28 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: localtime(time())
Message-Id: <f2vppk.1i0.1@news.isolution.nl>

Martin Trautmann schreef:

> my $date =($year+1900)."-".  
> sprintf("%02d", $mon) ."-".
> sprintf("%02d", $mday);
>     print $date;'

  my $date = sprintf( q[%s-%02d-%02d],
                      $y + 1900,
                      $m + 1,
                      $d,
             );
  print $date;

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: 23 May 2007 02:00:22 -0700
From: palanivel <tpraja@gmail.com>
Subject: make money by visiting websites
Message-Id: <1179910822.719469.221710@u30g2000hsc.googlegroups.com>

As the name implies, you make money by simply visiting websites for at
least 30 seconds/visit. We will pay you $0.01 for each website you
visit and $0.01 for each website your referrals visit. The best part
is you can have an unlimited amount of referrals!
visit:
http://classifieds.byindia.com/detail.php?siteid=6135&cityid=168&show_still=1&citydetail=1




General details
Sold by 	Joseph George
Email 	Contact seller
Location	Ariacheril house, Kolothum Kadava



------------------------------

Date: Wed, 23 May 2007 04:42:11 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed May 23 2007
Message-Id: <JIH92B.1HDB@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Bio-DOOP-DOOP-0.22
http://search.cpan.org/~tibi/Bio-DOOP-DOOP-0.22/
DOOP API main module
----
Bot-BasicBot-Pluggable-Module-Search-1.0
http://search.cpan.org/~simonw/Bot-BasicBot-Pluggable-Module-Search-1.0/
various search plugins for Bot::BasicBot::Pluggable
----
Brackup-1.02
http://search.cpan.org/~bradfitz/Brackup-1.02/
Flexible backup tool. Slices, dices, encrypts, and sprays across the net.
----
CGI-Ex-2.13
http://search.cpan.org/~rhandom/CGI-Ex-2.13/
CGI utility suite - makes powerful application writing fun and easy
----
CGI-Ex-Template-XS-0.03
http://search.cpan.org/~rhandom/CGI-Ex-Template-XS-0.03/
XS version of key parts of CGI::Ex::Template
----
CGI-Simple-0.082
http://search.cpan.org/~andya/CGI-Simple-0.082/
A Simple totally OO CGI interface that is CGI.pm compliant
----
CGI-Simple-0.83
http://search.cpan.org/~andya/CGI-Simple-0.83/
A Simple totally OO CGI interface that is CGI.pm compliant
----
Catalyst-Helper-Dojo-0.02000
http://search.cpan.org/~cfranks/Catalyst-Helper-Dojo-0.02000/
Helper to generate Dojo JavaScript / AJAX library
----
Catalyst-Model-RDBO-0.04
http://search.cpan.org/~karman/Catalyst-Model-RDBO-0.04/
base class for Rose::DB::Object model
----
Config-Abstract-0.14
http://search.cpan.org/~avajadi/Config-Abstract-0.14/
Perl extension for abstracting configuration files
----
DBIx-Class-Schema-Loader-0.03012
http://search.cpan.org/~blblack/DBIx-Class-Schema-Loader-0.03012/
Dynamic definition of a DBIx::Class::Schema
----
DBIx-Class-Schema-Loader-0.03999_02
http://search.cpan.org/~blblack/DBIx-Class-Schema-Loader-0.03999_02/
Dynamic definition of a DBIx::Class::Schema
----
DateTime-Format-Pg-0.16001
http://search.cpan.org/~dmaki/DateTime-Format-Pg-0.16001/
Parse and format PostgreSQL dates and times
----
Device-Jtag-PP-0.01
http://search.cpan.org/~tdeitrich/Device-Jtag-PP-0.01/
Perl extension for communicating with JTAG devices via PC parallel port.
----
Erlang-Port-0.04
http://search.cpan.org/~hio/Erlang-Port-0.04/
Erlang External Port
----
Event-1.09
http://search.cpan.org/~jprit/Event-1.09/
Event loop processing
----
Fatal-Exception-0.01
http://search.cpan.org/~dexter/Fatal-Exception-0.01/
succeed or throw exception
----
File-Extractor-0.01
http://search.cpan.org/~flora/File-Extractor-0.01/
Extract meta-data from arbitrary files
----
Finance-Card-Citibank-1.05
http://search.cpan.org/~mgrimes/Finance-Card-Citibank-1.05/
Check your Citigroup credit card accounts from Perl
----
Finance-QuoteOptions-0.10
http://search.cpan.org/~kbocek/Finance-QuoteOptions-0.10/
Perl extension for retrieving options pricing and series information from the web.
----
FrameNet-WordNet-Detour-1.0
http://search.cpan.org/~reiter/FrameNet-WordNet-Detour-1.0/
a WordNet to FrameNet Detour.
----
HTML-Dojo-0.0403.0
http://search.cpan.org/~cfranks/HTML-Dojo-0.0403.0/
Provides the Dojo JavaScript / AJAX distribution 0.4.3 files.
----
Hook-Filter-0.04
http://search.cpan.org/~erwan/Hook-Filter-0.04/
A runtime firewall for subroutine calls
----
IP-QQWry-v0.0.14
http://search.cpan.org/~sunnavy/IP-QQWry-v0.0.14/
a simple interface for QQWry IP database(file).
----
InlineX-C2XS-0.11
http://search.cpan.org/~sisyphus/InlineX-C2XS-0.11/
Convert from Inline C code to XS.
----
InlineX-CPP2XS-0.11
http://search.cpan.org/~sisyphus/InlineX-CPP2XS-0.11/
Convert from Inline C++ code to XS.
----
Lingua-ZH-Summary-0.01
http://search.cpan.org/~clsung/Lingua-ZH-Summary-0.01/
Extract summary from Chinese text
----
Locale-PO-0.17
http://search.cpan.org/~alansz/Locale-PO-0.17/
Perl module for manipulating .po entries from GNU gettext
----
Log-Handler-0.34
http://search.cpan.org/~bloonix/Log-Handler-0.34/
A simple handler to log messages to log files.
----
MozRepl-0.03
http://search.cpan.org/~zigorou/MozRepl-0.03/
Perl interface of MozRepl
----
MozRepl-Plugin-Restart-0.01
http://search.cpan.org/~zigorou/MozRepl-Plugin-Restart-0.01/
Restart Firefox/Thunderbird
----
MozRepl-Plugin-Restart-0.02
http://search.cpan.org/~zigorou/MozRepl-Plugin-Restart-0.02/
Restart Firefox/Thunderbird
----
Net-Daemon-0.40
http://search.cpan.org/~mnooning/Net-Daemon-0.40/
Perl extension for portable daemons
----
Net-SIP-0.27
http://search.cpan.org/~sullr/Net-SIP-0.27/
Framework SIP (Voice Over IP, RFC3261)
----
Net-SIP-0.28
http://search.cpan.org/~sullr/Net-SIP-0.28/
Framework SIP (Voice Over IP, RFC3261)
----
Net-SMS-MyTMN-0.02
http://search.cpan.org/~msantinho/Net-SMS-MyTMN-0.02/
Send SMS trough MyTMN!
----
Net-SMS-MyTMN-0.03
http://search.cpan.org/~msantinho/Net-SMS-MyTMN-0.03/
Send SMS trough MyTMN!
----
Net-SMS-MyTMN-0.04
http://search.cpan.org/~msantinho/Net-SMS-MyTMN-0.04/
Send SMS trough MyTMN!
----
Net-Whois-Raw-1.23
http://search.cpan.org/~despair/Net-Whois-Raw-1.23/
Get Whois information for domains
----
Object-Exercise-1
http://search.cpan.org/~lembark/Object-Exercise-1/
Generic execution & benchmark harness for method calls.
----
Object-Exercise-1.01
http://search.cpan.org/~lembark/Object-Exercise-1.01/
Generic execution & benchmark harness for method calls.
----
POE-Component-Client-MPD-0.5.0
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.5.0/
a full-blown mpd client library
----
POE-Component-Client-MPD-0.5.1
http://search.cpan.org/~jquelin/POE-Component-Client-MPD-0.5.1/
a full-blown mpd client library
----
Perlbal-1.59
http://search.cpan.org/~bradfitz/Perlbal-1.59/
Reverse-proxy load balancer and webserver
----
PlRPC-0.2019
http://search.cpan.org/~mnooning/PlRPC-0.2019/
A bundle to install PlRPC-Server, Client and prerequisites.
----
Set-IntSpan-Fast-v1.0
http://search.cpan.org/~andya/Set-IntSpan-Fast-v1.0/
Fast handling of sets containing integer spans.
----
Template-Declare-0.21
http://search.cpan.org/~jesse/Template-Declare-0.21/
Perlish declarative templates
----
Test-Unit-Lite-0.03
http://search.cpan.org/~dexter/Test-Unit-Lite-0.03/
Unit testing without external dependencies
----
Text-CSV_PP-1.02
http://search.cpan.org/~makamaka/Text-CSV_PP-1.02/
comma-separated values manipulation routines (PP version)
----
TheSchwartz-1.04
http://search.cpan.org/~bradfitz/TheSchwartz-1.04/
reliable job queue
----
TipJar-MTA-0.21
http://search.cpan.org/~davidnico/TipJar-MTA-0.21/
outgoing SMTP with exponential random backoff.
----
VCS-CMSynergy-1.30
http://search.cpan.org/~rschupp/VCS-CMSynergy-1.30/
Perl interface to Telelogic SYNERGY/CM (aka Continuus/CM)
----
WWW-Mechanize-1.29_01
http://search.cpan.org/~petdance/WWW-Mechanize-1.29_01/
Handy web browsing in a Perl object
----
XML-Grammar-Screenplay-0.03
http://search.cpan.org/~shlomif/XML-Grammar-Screenplay-0.03/
CPAN distribution implementing an XML grammar for screenplays.
----
eGuideDog-Festival-0.1
http://search.cpan.org/~hgneng/eGuideDog-Festival-0.1/
Wrapper of common functions of Festival TTS.


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Tue, 22 May 2007 22:09:23 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: parsing a variable length record from a mixed format file
Message-Id: <f2vppl.1i0.1@news.isolution.nl>

Tad McClellan schreef:

>    if ( not -f $ifname or not -r _ ) {

Variant:

     unless ( -f $ifname and -r _ ) {

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: Tue, 22 May 2007 12:19:01 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Passing variables into another script
Message-Id: <uOGdnf2eKc-3387bnZ2dnUVZ_oupnZ2d@comcast.com>

Ken Soon wrote:

> Oh yah I wanted to sub modules both the side1.pl and side2.pl into main.pl 
> but I ran into problems of dynamic hashes not being to hold any data so I 
> have to restart the operations for both side scripts.\

Don't use hash variables whose names are variable.  Use a hash of hashes instead.
Use a global (static) variable, not a lexical (my) variable.

Instead of creating %user and %group on the fly:

package main;
   our %data;
   $data{'user'}{'joe'} = 'System admin';
   $data{'group'}{'power'} = 'Power users';

package side1;
   print "User $user is $main::data{'user'}{$user}\n";
   print "Group $group is $main::data{'group'}{$group}\n";


------------------------------

Date: Wed, 23 May 2007 08:44:48 +0800
From: "Ken Soon" <csoon@xilinx.com>
Subject: Re: Passing variables into another script
Message-Id: <f3030j$6e81@cnn.xilinx.com>

> Don't use hash variables whose names are variable.  Use a hash of hashes 
> instead.
> Use a global (static) variable, not a lexical (my) variable.
>
> Instead of creating %user and %group on the fly:
>
> package main;
>   our %data;
>   $data{'user'}{'joe'} = 'System admin';
>   $data{'group'}{'power'} = 'Power users';
>
> package side1;
>   print "User $user is $main::data{'user'}{$user}\n";
>   print "Group $group is $main::data{'group'}{$group}\n";

Yup, have used global variable and not (my) variable for my script

Hmm, $data{'user'}{'joe'} = "System admin' is something like a 2D hash or 
something? 




------------------------------

Date: Wed, 23 May 2007 00:13:07 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Passing variables into another script
Message-Id: <jJ-dnZKEqJQZdM7bnZ2dnUVZ_qemnZ2d@comcast.com>

Ken Soon wrote:
>> Don't use hash variables whose names are variable.  Use a hash of hashes ...
>>   $data{'user'}{'joe'} = 'System admin';
>>   $data{'group'}{'power'} = 'Power users';
> 
> Hmm, $data{'user'}{'joe'} = "System admin' is something like a 2D hash or 
> something? 

Yes, that is what I meant by a "hash of hashes".  See "perldoc perlref".
	-Joe

$data{user}{'joe'} = 'System Admin';
$data{user}{'guest'} = 'Guest User';
$data{group}{'Administrators'} = 544;
$data{group}{'Power Users'} = 547;

sub print_sorted {
   my %hash = @_;
   print "  $_ = $hash{$_}\n" for sort keys %hash;
   print "  $hash{$_} = $_\n" for sort {$hash{$a} cmp $hash{$b}} keys %hash;
}

print "Users:\n";  print_sorted %{$data{user}};
print "Groups:\n"; print_sorted %{$data{group}};


------------------------------

Date: Wed, 23 May 2007 16:58:06 +0800
From: "Ken Soon" <csoon@xilinx.com>
Subject: Re: Passing variables into another script
Message-Id: <f30vti$6d41@cnn.xilinx.com>

> Yes, that is what I meant by a "hash of hashes".  See "perldoc perlref".
> -Joe
>
> $data{user}{'joe'} = 'System Admin';
> $data{user}{'guest'} = 'Guest User';
> $data{group}{'Administrators'} = 544;
> $data{group}{'Power Users'} = 547;
>
> sub print_sorted {
>   my %hash = @_;
>   print "  $_ = $hash{$_}\n" for sort keys %hash;
>   print "  $hash{$_} = $_\n" for sort {$hash{$a} cmp $hash{$b}} keys 
> %hash;
> }
>
> print "Users:\n";  print_sorted %{$data{user}};
> print "Groups:\n"; print_sorted %{$data{group}};

ahhh.. Thanks alot Joe, will try it out in future scripts :) 




------------------------------

Date: Wed, 23 May 2007 08:54:52 +0200
From: Dennis Winter <idontlikespam@denniswinter.de>
Subject: Re: Perl and German Umlauts
Message-Id: <f30ogt$i51$1@murphy.mediascape.de>

Ben Bacarisse schrieb:
>> binmode STDOUT, ':encoding(cp850)';
>> binmode STDIN, ':encoding(cp850)';
> 
> That looks wrong.  You say the files are UTF-8 encoded so why not give
> ':utf8' as the layer, at least for input?

I did that at the top of the script. That helped me with nearly every 
appearance of Umlauts.

When I try to set binmode STDIN, STDOUT temporarily to utf-8 right 
before the text file is read, the code

************* ORIGINAL ************
binmode STDIN, ':encoding(utf-8)';
binmode STDOUT, ':encoding(utf-8)';
open (RJ, $wdir.$readjob) || die "ERROR: could not read $wdir$readjob: 
$!\n";
while (<RJ>) {
    my $dir = $_;
*********** ORIGINAL END **********

produces

************* ORIGINAL ************
"\x{0084}" does not map to cp850 at actiontaker.pl line 227, <RJ> line 1.
!E:\Freigaben\FILESERVER\allshares\austausch\anke\Vertriebs und 
Marketingans\x{0084}tze Everyone:(OI)(CI)F!
*********** ORIGINAL END **********

It appears to me that binmode can only be set once. Is there a way to 
temporarily change the binmode for the time during the file is read? Or 
even to determine which charset is used in the file an switch to that 
"on the fly and back"?

Thanks
dennis


------------------------------

Date: 22 May 2007 15:24:07 -0700
From: gypark2@gmail.com
Subject: Re: Unicode in regexp
Message-Id: <1179872647.760161.254410@a26g2000pre.googlegroups.com>

On 5=BF=F923=C0=CF, =BF=C0=C0=FC2=BD=C324=BA=D0, Brian McCauley <nobul...@g=
mail.com> wrote:
> On May 21, 1:37 pm, gypa...@gmail.com wrote:
>
> > use Encode;
> > $octets =3D decode("UTF-8", $str);
>
> Your variable naming is confusing. decode() takes an byte (aka octet)
> string as an argument and returns a string of Unicode characters (not
> a string of bytes).

Oops,

You are right. I copied that code from "perldoc Encode" but I made the
mistake and wrote the names the wrong way about. :'(

Thanks for pointing it.



------------------------------

Date: 22 May 2007 18:13:49 -0700
From: grocery_stocker <cdalten@gmail.com>
Subject: What's the point of these lines of code?
Message-Id: <1179882829.215018.10710@k79g2000hse.googlegroups.com>

This person has like 20 perl scripts related to Audio/Video streaming
his stuff on the web. Just about every script has this near the top of
it

my $progname = $0; $progname =~ s@.*/@@g;
my $version = q{ $Revision: 1.27 $ }; $version =~ s/^[^0-9]+([0-9.]+).*
$/$1/;

I thought he might be parsing some kind of RCS file to get the current
version, but then that would  explain

my $version = q{ $Revision: 1.27 $ };

Can someone clarify this for me please.



------------------------------

Date: 22 May 2007 21:00:56 -0700
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: What's the point of these lines of code?
Message-Id: <1179892856.479137.321690@q75g2000hsh.googlegroups.com>

On May 22, 6:13 pm, grocery_stocker <cdal...@gmail.com> wrote:
> This person has like 20 perl scripts related to Audio/Video streaming
> his stuff on the web. Just about every script has this near the top of
> it
>
> my $progname = $0; $progname =~ s@.*/@@g;
> my $version = q{ $Revision: 1.27 $ }; $version =~ s/^[^0-9]+([0-9.]+).*
> $/$1/;
>
> I thought he might be parsing some kind of RCS file to get the current
> version, but then that would  explain
>
> my $version = q{ $Revision: 1.27 $ };
>
> Can someone clarify this for me please.


Never mind. I found my answers via Google.



------------------------------

Date: Wed, 23 May 2007 09:57:14 +0100
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: What's the point of these lines of code?
Message-Id: <465401ee$0$10726$db0fefd9@news.zen.co.uk>

grocery_stocker wrote:
> On May 22, 6:13 pm, grocery_stocker <cdal...@gmail.com> wrote:
> 
>>This person has like 20 perl scripts related to Audio/Video streaming
>>his stuff on the web. Just about every script has this near the top of
>>it
>>
>>my $progname = $0; $progname =~ s@.*/@@g;
>>my $version = q{ $Revision: 1.27 $ }; $version =~ s/^[^0-9]+([0-9.]+).*
>>$/$1/;
>>
>>I thought he might be parsing some kind of RCS file to get the current
>>version, but then that would  explain
>>
>>my $version = q{ $Revision: 1.27 $ };
>>
>>Can someone clarify this for me please.
> 
> 
> 
> Never mind. I found my answers via Google.
> 

Maybe you'd like to post the answers here so that anyone else with a 
similar problem who finds this thread isn't frustrated by the omission 
of the answers they seek.

My guesses:

1) `my $progname = $0; $progname =~ s@.*/@@g;`
removes the path from the program name

2) `my $version = q{ $Revision: 1.27 $ };`
allows the program to know and report its version, where the version 
number is maintained by checking changes to the file into the Revision 
Control System (RCS). RCS looks for and edits strings like "... 
$Revision: n.nn $ ..." which are usually placed in comments but can be 
placed in code statements if care is taken with the metacharacters.

3) `$version =~ s/^[^0-9]+([0-9.]+).*$/$1/;`
strips out the word "Revision:" and the major part of the version 
number. RCS never increments the major number unless the developer 
explicitly sets it.


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 453
**************************************


home help back first fref pref prev next nref lref last post