[26689] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8795 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 25 00:05:51 2005

Date: Sat, 24 Dec 2005 21:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 24 Dec 2005     Volume: 10 Number: 8795

Today's topics:
    Re: BEGIN { package Foo; use Foo } <sdn.girths00869@zoemail.net>
    Re: BEGIN { package Foo; use Foo } <socyl@987jk.com.invalid>
    Re: BEGIN { package Foo; use Foo } <sdn.girths00869@zoemail.net>
    Re: BEGIN { package Foo; use Foo } <socyl@987jk.com.invalid>
        Blather-Adjusting Programs vjp2.at@at.BioStrategist.dot.dot.com
        Convert utf-8 to latin1 <dreamer@cox.net>
        How to automatically submit html for data? <itfred@cdw.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 24 Dec 2005 13:38:44 -0600
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: BEGIN { package Foo; use Foo }
Message-Id: <Xns9736957721532sdn.comcast@216.196.97.136>

kj <socyl@987jk.com.invalid> wrote in news:dok579$itq$1
@reader1.panix.com:

> One of the things I find most infuriating about Config::Std (aside
> from the fact that there's nothing standard about it) is that it
> imports the subroutine read_config into the invoking namespace,
> whether it is requested or not.  I.e. even after
> 
> package MyPackage;
> use Config::Std ();
> 
> one still ends up with a MyPackage::read_config subroutine that
> one explicitly did not want.

That is not true.  If you include an empty list after the package name, 
the module's import() subroutine isn't even called.  Did you try this?

[...]
> Is there a better work-around to prevent Config::Std from defecating
> all over my namespace (other than avoiding Config::Std altogether)?

Config::Std exports a grand total of two (count'em, two!) symbols into 
your namespace.  Did you really need to use read_config and write_config 
yourself?

If this truly is a problem, I would suggest inventing a namespace for 
holding the Config::Std symbols.

    package HoldingPen;
    use Config::Std;
    package MyPackage;
    ....
    HoldingPen::read_config 'file.cfg' => my %config;

-- 
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`


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

Date: Sat, 24 Dec 2005 19:58:04 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Re: BEGIN { package Foo; use Foo }
Message-Id: <dok98c$hc6$1@reader1.panix.com>

In <Xns9736957721532sdn.comcast@216.196.97.136> "Eric J. Roode" <sdn.girths00869@zoemail.net> writes:

>kj <socyl@987jk.com.invalid> wrote in news:dok579$itq$1
>@reader1.panix.com:

>> One of the things I find most infuriating about Config::Std (aside
>> from the fact that there's nothing standard about it) is that it
>> imports the subroutine read_config into the invoking namespace,
>> whether it is requested or not.  I.e. even after
>> 
>> package MyPackage;
>> use Config::Std ();
>> 
>> one still ends up with a MyPackage::read_config subroutine that
>> one explicitly did not want.

>That is not true.  If you include an empty list after the package name, 
>the module's import() subroutine isn't even called.  Did you try this?

Of course I did.  And I also read the source code of Config::Std.
Did you?  Do you realize that what you describe, though it does
apply to modules that inherit from Exporter, is not true in general?
One can make import do whatever one wants.

kj
-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


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

Date: Sat, 24 Dec 2005 15:31:47 -0600
From: "Eric J. Roode" <sdn.girths00869@zoemail.net>
Subject: Re: BEGIN { package Foo; use Foo }
Message-Id: <Xns9736A88E62E00sdn.comcast@216.196.97.136>

kj <socyl@987jk.com.invalid> wrote in
news:dok98c$hc6$1@reader1.panix.com: 

> In <Xns9736957721532sdn.comcast@216.196.97.136> "Eric J. Roode"
> <sdn.girths00869@zoemail.net> writes: 
> 
>>kj <socyl@987jk.com.invalid> wrote in news:dok579$itq$1
>>@reader1.panix.com:
> 
>>> One of the things I find most infuriating about Config::Std (aside
>>> from the fact that there's nothing standard about it) is that it
>>> imports the subroutine read_config into the invoking namespace,
>>> whether it is requested or not.  I.e. even after
>>> 
>>> package MyPackage;
>>> use Config::Std ();
>>> 
>>> one still ends up with a MyPackage::read_config subroutine that
>>> one explicitly did not want.
> 
>>That is not true.  If you include an empty list after the package
>>name, the module's import() subroutine isn't even called.  Did you try
>>this? 
> 
> Of course I did.  And I also read the source code of Config::Std.
> Did you?

I not only read the Config::Std source code before posting, I also wrote 
two short test programs.

    perl -e 'package Foo; use Config::Std; print "defined\n"
                 if defined &Foo::read_config'

    perl -e 'package Foo; use Config::Std (); print "defined\n"
                 if defined &Foo::read_config'

The first prints "defined".  The second does not.

>  Do you realize that what you describe, though it does
> apply to modules that inherit from Exporter, is not true in general?
> One can make import do whatever one wants.

One thing one cannot make import do: make things happen when it isn't 
even called.

Try this:

    # (in file Foo.pm)
    package Foo;
    sub import
    {
        print STDERR "Wahoo!!\n";
    }

then:
    perl -e 'use Foo'
then:
    perl -e 'use Foo ()'

-- 
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$\$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$\$,$/$:$;$~$*$%[$?]$.$~$*${#}$%[$?]$;$\$"$^$~$*.>&$=`


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

Date: Sun, 25 Dec 2005 04:29:37 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Re: BEGIN { package Foo; use Foo }
Message-Id: <dol77h$9kl$1@reader1.panix.com>

In <Xns9736A88E62E00sdn.comcast@216.196.97.136> "Eric J. Roode" <sdn.girths00869@zoemail.net> writes:

>kj <socyl@987jk.com.invalid> wrote in
>news:dok98c$hc6$1@reader1.panix.com: 

>> In <Xns9736957721532sdn.comcast@216.196.97.136> "Eric J. Roode"
>> <sdn.girths00869@zoemail.net> writes: 
>> 
>>>kj <socyl@987jk.com.invalid> wrote in news:dok579$itq$1
>>>@reader1.panix.com:
>> 
>>>> One of the things I find most infuriating about Config::Std (aside
>>>> from the fact that there's nothing standard about it) is that it
>>>> imports the subroutine read_config into the invoking namespace,
>>>> whether it is requested or not.  I.e. even after
>>>> 
>>>> package MyPackage;
>>>> use Config::Std ();
>>>> 
>>>> one still ends up with a MyPackage::read_config subroutine that
>>>> one explicitly did not want.
>> 
>>>That is not true.  If you include an empty list after the package
>>>name, the module's import() subroutine isn't even called.  Did you try
>>>this? 
>> 
>> Of course I did.  And I also read the source code of Config::Std.
>> Did you?

>I not only read the Config::Std source code before posting, I also wrote 
>two short test programs.

>    perl -e 'package Foo; use Config::Std; print "defined\n"
>                 if defined &Foo::read_config'

>    perl -e 'package Foo; use Config::Std (); print "defined\n"
>                 if defined &Foo::read_config'

>The first prints "defined".  The second does not.

I stand corrected.  My apologies.

The fact remains, however, that one cannot refer to
"Config::Std::read_config" because it doesn't exist.  One must
either accept the importation of read_config into some namespace
or else go behind the API and refer to Config::Std::Hash::read_config.

The workaround I cited is

BEGIN { package Config::Std; use Config::Std }

but I think it has a lot of problems.  My original question then
remains: what's the best way to avoid having read_config imported
and still know how to refer to it?

Another possibility is

BEGIN { package Config::Std::Some::Crazy::Name; use Config::Std }

Then the desired function is reliably
Config::Std::Some::Crazy::Name::read_config, though I have to hope
that I have not inadvertently introduced a collision.

kj

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


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

Date: Sun, 25 Dec 2005 02:33:43 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Blather-Adjusting Programs
Message-Id: <dol0e7$o6c$1@reader1.panix.com>

   You folks mean to tell me there's no program out there that would
take a file of simple text and blatherise it to the level of another
"reference" file? Or Adjust the "Fog Index" of a text file up or down
from its input level. I'm totally serious. I'm tired of fighting.
I just want to "get along".

Message-ID: <dn55rq$mov$1@reader2.panix.com>

   I'm sure I've seen programs that generate blather but now I
can't find one.  I'm stuck in a wierd situation that comes up often
enough:  Some third-worlders insist you write pretentious casuistry
when a few simple words are enough. It is sad in these day of "Fog
Index" that we have people who are commitedly ideological and even
theologically dogmatic about making prose incomprehensibly obfuscated
and complicated. I want it in perl so it can be extremely portable.

   However, I want something I can control. For example, when it sees
the word "customer" or "strategy" it should randomly chose one of
three flowing phrases.  I can write a simple one-to-one in sed, but I
really hope some ingenious soul has already compiled a blatherisation
table that I only need to tweak.  The issue is the text should require
no more than, say, ten percent editing to make it seem like it came
from a genuinely glib casuistrous bullshit artist.

   I wouldn't mind if the program is ingenious enough to go both ways,
or even to be adjustable (ie, "please set the fog index").  I am
confronted with enough blathermaniacs and antiblathermaniacs to make
my life way too complicated. By the time I get used to one lunatic, I
have to instead conform to the other.  

Message-ID: <do5j5i$2da$3@reader1.panix.com>

I think you could broadly generalise the most common writing styles are:

   1. Cryptic misappropriated connotation (demanded by "scholars")
   2. Telegraphic commercial (Taught by "Communications" programs)
   3. Latinate bureaucratic (demanded by 3rd world bureaucrats)
   4. Literary Synonymania (demanded by "English" professors/teachers)

   And these variances seem to be used to discriminate and segregate
dogmatically and unfairly. "Can't we just all get along?"

Message-ID: <dnvsup$p3u$1@reader1.panix.com>

   I went hunting on google for "chatterbot perl knowledge base". I
"knew" Hugh Kenner back on BiX ca 1988.  Foggy is a riot, but not what
I needed, though I think sometime it may prove valuable when 
frustration with fools triggers my evil streak.  I need foggy with a
twist - a knowledge base I can tweak like foggy, but it should take a
simple paragraph and turn it into a long blatherous paper that I can
then spend a few minutes editing and it will say pretty much the same
thing as my simple paragraph.  For example I write "The customer is a
petunia" and it writes "Our customers are very important to us. One of
our multifarous customers has proven to be a petunia. Wheretofore and
heretofore, this important,vaulabel and significant datum will be
assessed strategically and applied to our models wherefrom we shall
therefore optimise our tactics, strategy and operations so that we
fully capture the economic benefits derivable from this customer."
One form would work with a knowledge base where it is triggered by
words like customer and petunia into random but reasonably meaningful
ramblings. The other would be even better if it took a file with
writing similar to the target and transformed the source using the
target as a model (for style and size). I would really wish this was
in perl so I could use it on the fly anywhere!


nyc.transit Tue, 20 Dec 2005 23:19:28 +0000 (UTC)

   You remind me of how my folks got mistreated. They spoke with a
heavy accent but at the university level.  A lot of academics would
love to converse endlessly with their precise and inquiring minds.
Some "customer service" types would just hang up the phone when they
heard the accent. One of my English teachers couldn't get over it how
my folks had the nerve to correct her spelling.

   I was born here and once I had a boss say that the reason I
disgreed on policy issues was I needed to improve my writing since I
was Greeks and sent me to a writing class (she was Cuban and spoke
with an accent, but I don't have an accent). Once someone asked me
"You speak English so well, when did you come here" I looked at my
watch and said "Oh, about 120 yrs ago." (Technically true, though my
stowaway ancestors got sent back a month later) I once went to speak
to a dean about something and he mentioned the essence of the
conversation to a reporter and I saw in print that he described me as
a foreign student (he, too, had an accent and was foreign born). When
a previous president of my alma mater was introduced to alums, he saw
my name badge and said "Ohhhh, Greek" shaking his head knowingly as I
was seriously thinking of swatting him on the head like a fly.




				- = -
    Vasos-Peter John Panagiotopoulos II, Columbia'81+, Bio$trategist
	      BachMozart ReaganQuayle EvrytanoKastorian
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
		       Pataki+JebBush in 2008!



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

Date: Sat, 24 Dec 2005 15:17:27 -0800
From: Fred Hare <dreamer@cox.net>
Subject: Convert utf-8 to latin1
Message-Id: <C5udnSF73v6XSjDeRVnyiA@giganews.com>

Hello there,
I am working on a script to convert utf-8 to latin1. What I have so far 
works fine if there is only one utf-8 per line, but a second one does 
not get converted.  Would it be better to to split the <DATA> at /Ã./ 
and process the $chunks one after the other? Or is there a better way?

    use strict ;
    use warnings ;
    use Unicode::String;

    my ($latin1, $string, $ustr) ;

    my $outfile = shift || 'D:\aa\out.txt' ;
    open(OUT, "> $outfile")
         or die "Could not open $outfile for writing: $!\n";

   while(<DATA>){

       if (m/(Ã.)/) {
           $string =$1 ;
           $ustr = Unicode::String::utf8($string);
           $latin1 = $ustr->latin1();
           s/$string/$latin1/ ;
      }
           print OUT $_ ;
   }

           close(OUT)       or die "could not close OUT: $!";

__DATA__

<dt><b>Gemeinde Füllinsdorf (Übersicht):</b> 
www.bl.ch/docs/gemeinden/füllinsdorf/main_füllinsdorf.htm</dt>

<dt><b>HEIZÖLPREISE / Der aktuelle Heizölpreis / 
Preis-Entwicklung:</b> home.t-online.de/home/tecson/pheizoel.htm</dt>



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

Date: Sat, 24 Dec 2005 22:45:58 -0500
From: Fred <itfred@cdw.com>
Subject: How to automatically submit html for data?
Message-Id: <pan.2005.12.25.03.45.57.781574@cdw.com>

We have an html page at work that we can access to allow
us temporary access through the firewall.  This is fine 
from a workstation, but we need to do this on some Unix
servers as well.  Is there any way with perl I could
generate the page below, and perform the submit, using
a perl script?  This particular html page prompts for a 
user name, then the next page prompts for the password.

-Thanks



<html><head>
<title>
  Authentication Form 
</title> 
</head> 
 
<BODY BGCOLOR="#000000" TEXT="#00FF00"> 

<p> 
<h3 align=left><font face="arial,helvetica">Client Authentication Remote 
Service</font></h3> 

<FORM METHOD="POST" ACTION="176.35.214.143">

<INPUT TYPE="hidden" NAME="ID" VALUE="d50bf20da094c2887356296"> <P>
<INPUT TYPE="hidden" NAME="STATE" VALUE="1"><P>
FireWall-1 message: User: <p> <P>
 
User name: <INPUT NAME="DATA"> <P> 
 
Press 'Submit' when done: <INPUT TYPE="submit" 
VALUE="Submit">. <P> 
 
</FORM>
<p> <P>
</BODY>
</html>


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

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 V10 Issue 8795
***************************************


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