[27873] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9237 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 21 18:06:03 2006

Date: Sun, 21 May 2006 15:05:05 -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           Sun, 21 May 2006     Volume: 10 Number: 9237

Today's topics:
    Re: How to detect text file encoding in Perl (Anno Siegel)
    Re: How to detect text file encoding in Perl <noreply@gunnar.cc>
    Re: How to detect text file encoding in Perl (Anno Siegel)
    Re: How to match characters in different locations with <nobull67@gmail.com>
    Re: How to match characters in different locations with <nobull67@gmail.com>
        Localising $_ (was: How to match...) <noreply@gunnar.cc>
    Re: Need help with Perlfect <ibvalentine@hotmail.com>
    Re: Need help with Perlfect <bik.mido@tiscalinet.it>
        new CPAN modules on Sun May 21 2006 (Randal Schwartz)
        Perl got sth. from Python, but what? <wahab@chemie.uni-halle.de>
    Re: printing css <nospam@home.com>
    Re: printing css <××DBraughler××@××bwcc·com>
    Re: printing css <john@castleamber.com>
    Re: Text parsing and substitution (Anno Siegel)
    Re: Use of initialized value in pattern match (Anno Siegel)
    Re: What is the RHS of a substitution? <nobull67@gmail.com>
    Re: What is the RHS of a substitution? <rvtol+news@isolution.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 20 May 2006 16:24:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to detect text file encoding in Perl
Message-Id: <4d8u50F18vg4nU2@news.dfncis.de>

cnhackTNT  <cnhacktnt@perlchina.org> wrote in comp.lang.perl.misc:

[Please don't top-post, and leave some attribution.  Text re-arranged]

> > Hello all,
> >
> > If I have a bunch of text files in the same directory and their
> > encodings could UTF-16, UTF-8, or ASCII, is there any way of quickly
> > detecting the exact encoding of each of them?

> Maybe Encode::GUESS could help :-)

Without even looking at it, I'd say a module with its name in all-caps
is suspect.  Supposing it is actually spelled that way.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Sat, 20 May 2006 18:34:11 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How to detect text file encoding in Perl
Message-Id: <4d8uo6F19i5k2U1@individual.net>

Anno Siegel wrote:
> cnhackTNT  <cnhacktnt@perlchina.org> wrote in comp.lang.perl.misc:
>> 
>>Maybe Encode::GUESS could help :-)
> 
> Without even looking at it, I'd say a module with its name in all-caps
> is suspect.

Yeah, it makes you think of creations like POSIX and CGI. ;-)

> Supposing it is actually spelled that way.

It's not.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 20 May 2006 17:16:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to detect text file encoding in Perl
Message-Id: <4d916sF1999p2U1@news.dfncis.de>

Gunnar Hjalmarsson  <noreply@gunnar.cc> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > cnhackTNT  <cnhacktnt@perlchina.org> wrote in comp.lang.perl.misc:
> >> 
> >>Maybe Encode::GUESS could help :-)
> > 
> > Without even looking at it, I'd say a module with its name in all-caps
> > is suspect.
> 
> Yeah, it makes you think of creations like POSIX and CGI. ;-)

Well, those are acronyms that weren't invented by the authors.

If GUESS were an acronym, the module would be more than suspect of
cutesiness.

> > Supposing it is actually spelled that way.
> 
> It's not.

Good to know :)

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: 21 May 2006 04:17:51 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to match characters in different locations within string
Message-Id: <1148210271.214568.296380@j73g2000cwa.googlegroups.com>


Gunnar Hjalmarsson wrote:
> Jack wrote:
> >
> > $temp = 'with 855 and 990';
> >
> > How do I return true or false (ideally through a regular expression)
> > the existence of both 'with' and 'and' inside the string ?
>
>      sub isWords {
>          local $_ = $_[0];

This is a bug waiting to happen.

If isWords() is called in a contest where $_ happens to be alaised to
an element of a tied aggregate then nasty things happen when you do
local($_).

Always use for() or local(*_) to localise changes to $_.



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

Date: 21 May 2006 04:20:33 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to match characters in different locations within string
Message-Id: <1148210433.114849.44230@38g2000cwa.googlegroups.com>


Dr.Ruud wrote:
> Is there a clear way to make $_ a localized alias of $_[0]?
> With "clear" I mean much clearer than an enclosing "for ( $_[0] ){}"
> would.

I find that perfectly clear.  It's just a mindset thing I guess.



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

Date: Sun, 21 May 2006 14:07:47 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Localising $_ (was: How to match...)
Message-Id: <4db3gmF19l6o0U1@individual.net>

Brian McCauley wrote:
> Gunnar Hjalmarsson wrote:
>>
>>     sub isWords {
>>         local $_ = $_[0];
> 
> This is a bug waiting to happen.
> 
> If isWords() is called in a contest where $_ happens to be alaised to
> an element of a tied aggregate then nasty things happen when you do
> local($_).

I don't understand that. This code:

     my $temp = 'with 855 and 990';

     sub isWords {
         local $_ = $_[0];
         /\bwith\b/ && /\band\b/ ? 1 : 0;
     }

     for ('hello') {
         print "True\n" if isWords($temp);
         print "$_\n";
     }

outputs:
True
hello

as I would have expected.

> Always use for() or local(*_) to localise changes to $_.

If I exchange 'local $_' in the above example for 'local *_', the $_ 
variable is empty within the isWords() function.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sat, 20 May 2006 15:44:43 GMT
From: "Michael" <ibvalentine@hotmail.com>
Subject: Re: Need help with Perlfect
Message-Id: <LPGbg.4945$G95.1158@tornado.socal.rr.com>

David,

You're an ass!


<usenet@DavidFilmer.com> wrote in message 
news:1148106800.463163.164740@j33g2000cwa.googlegroups.com...
> Michael wrote:
>> why  the Perlfect (indexing) program will not work.
>
> Do you ever play computer games?  Chances are they are written in C++.
> If you have a problem installing a computer game, do you post a
> question in a C++ programmer's newsgroup?
>
> This is a forum to discuss Perl programming, not problems with
> applications which just happen to be written in Perl.
>
> You mentioned some type of support for this program.  I suggest that
> may be your best follow-up resource.
>
> -- 
> http://DavidFilmer.com
> 




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

Date: Sun, 21 May 2006 14:28:17 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Need help with Perlfect
Message-Id: <drl072lcsqn9mung6jqsedjg4rdsdi91o9@4ax.com>

On Sat, 20 May 2006 15:44:43 GMT, "Michael" <ibvalentine@hotmail.com>
wrote:

>David,
>
>You're an ass!

No, he isn't! OTPH from what I've read thus far you seem to be working
hard to give exactly that image of youself.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Sun, 21 May 2006 04:42:06 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun May 21 2006
Message-Id: <IzLME6.1wnq@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.

WWW-YouTube-2006.0520
http://search.cpan.org/~ermeyers/WWW-YouTube-2006.0520/
YouTube Developer Interface
----
WWW-Blogger-2006.0520
http://search.cpan.org/~ermeyers/WWW-Blogger-2006.0520/
----
Bundle-Modules-2006.0520
http://search.cpan.org/~ermeyers/Bundle-Modules-2006.0520/
All current *stable* bundles of modules in CPAN
----
POE-Component-Client-Keepalive-0.08
http://search.cpan.org/~rcaputo/POE-Component-Client-Keepalive-0.08/
manage connections, with keep-alive
----
POE-Filter-Snort-0.02
http://search.cpan.org/~rcaputo/POE-Filter-Snort-0.02/
a POE stream filter that parses Snort logs into hashes
----
CGI-FormBuilder-3.0301
http://search.cpan.org/~nwiger/CGI-FormBuilder-3.0301/
Easily generate and process stateful forms
----
POE-Component-Client-Ping-1.11
http://search.cpan.org/~rcaputo/POE-Component-Client-Ping-1.11/
a non-blocking ICMP ping client
----
DBIx-Class-Schema-Loader-0.02999_08
http://search.cpan.org/~blblack/DBIx-Class-Schema-Loader-0.02999_08/
Dynamic definition of a DBIx::Class::Schema
----
XML-TreePP-0.16
http://search.cpan.org/~kawasaki/XML-TreePP-0.16/
Pure Perl implementation for parsing/writing xml files
----
Class-Superclasses-0.01
http://search.cpan.org/~reneeb/Class-Superclasses-0.01/
Find all superclasses of a class
----
Pugs-Compiler-Rule-0.03
http://search.cpan.org/~fglock/Pugs-Compiler-Rule-0.03/
Compiler for Perl 6 Rules
----
XML-TreePP-0.15
http://search.cpan.org/~kawasaki/XML-TreePP-0.15/
Pure Perl implementation for parsing/writing xml files
----
Term-Size-Win32-0.204
http://search.cpan.org/~ferreira/Term-Size-Win32-0.204/
Perl extension for retrieving terminal size (Win32 version)
----
Term-Prompt-0.02
http://search.cpan.org/~dazjorz/Term-Prompt-0.02/
Perl extension for asking questions at the terminal
----
Number-Tolerant-1.550
http://search.cpan.org/~rjbs/Number-Tolerant-1.550/
tolerance ranges for inexact numbers
----
DBIx-Log4perl-0.03
http://search.cpan.org/~mjevans/DBIx-Log4perl-0.03/
Perl extension for DBI to selectively log SQL, parameters, result-sets, transactions etc to a Log::Log4perl handle.
----
version-0.60
http://search.cpan.org/~jpeacock/version-0.60/
Perl extension for Version Objects
----
Data-Table-1.46
http://search.cpan.org/~ezdb/Data-Table-1.46/
Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc.
----
Archive-StringToZip-1.00
http://search.cpan.org/~robbiebow/Archive-StringToZip-1.00/
Transforms a string to a zip
----
PAR-Dist-0.09
http://search.cpan.org/~smueller/PAR-Dist-0.09/
Create and manipulate PAR distributions
----
Devel-PPPort-3.08_01
http://search.cpan.org/~mhx/Devel-PPPort-3.08_01/
Perl/Pollution/Portability
----
Module-Release-1.08
http://search.cpan.org/~bdfoy/Module-Release-1.08/
Automate software releases
----
Net-MAC-Vendor-0.24
http://search.cpan.org/~bdfoy/Net-MAC-Vendor-0.24/
look up the vendor for a MAC
----
Astro-FITS-CFITSIO-1.04
http://search.cpan.org/~pratzlaff/Astro-FITS-CFITSIO-1.04/
Perl extension for using the cfitsio library
----
SOAP-Data-ComplexType-0.041
http://search.cpan.org/~rybskej/SOAP-Data-ComplexType-0.041/
An abstract class for creating and handling complex SOAP::Data objects


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.

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: Sat, 20 May 2006 13:21:38 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Perl got sth. from Python, but what?
Message-Id: <e4mub2$nfv$1@mlucom4.urz.uni-halle.de>

Hi,

according to some Larry-Wall speech (about 10 years ago),
perl 'borrowed' some Ideas from Python(?), see:

http://www.wall.org/~larry/pm.html
   ...
   I lovingly reused features from many languages.
   (I suppose a Modernist would say I stole the features,
   since Modernists are hung up about originality.)
   Whatever the verb you choose, I've done it over
   the course of the years from C, sh, csh, grep, sed,
   awk, Fortran, COBOL, PL/I, BASIC-PLUS, SNOBOL, Lisp,
   Ada, C++, and Python. To name a few.
   To the extent that Perl rules rather than sucks,
   it's because the various features of these languages
   ruled rather than sucked.
   ...

So what exactly would he have had in mind then?

(Sorry if this has already been disussed here.)

Regards

Mirco


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

Date: Sat, 20 May 2006 11:41:28 GMT
From: "Nospam" <nospam@home.com>
Subject: Re: printing css
Message-Id: <IfDbg.2456$Dd1.301@newsfe1-win.ntli.net>

My mistake, I hadn't updated the right perl file, however I am trying  to
show an image directly from the perl script

#!usr/bin/perl

print "Content-type:text/html\n\n";
print "<html>\n";
print "<body>\n";

print "<style type = 'text/css'>";

print "body{background-image:url(http://www.example.com/image1.jpg);";

print "</style>";

print "</body>";

print "</html>";

doesn't launch the image at all




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

Date: Sat, 20 May 2006 10:22:48 -0400
From: Denver <××DBraughler××@××bwcc·com>
Subject: Re: printing css
Message-Id: <126u9hrf5f5khe7@corp.supernews.com>

Anonymous <Nospam@ntli.net> wrote:
> My mistake

Yes.

> I am trying  to show an image directly from the perl script

No, you are not.


> #!usr/bin/perl
> 
> print "Content-type: text/html\n\n";
	print "<html><head><title>don't know</title>\n";
	print '<style type="text/css">';

	print 'body{background-image:url(http://www.example.com/image1.jpg)}';
# The URL is not valid.
	print '</style></head>';
> print "<body>\n";
> print "</body>";
> 
> print "</html>";
> 
> doesn't launch the image at all

Of course not.

You need to learn HTML/XHTML/CSS in addition to Perl.
What you wrote is not valid.  I've rearranged your code somewhat to correct the most severe errors such as having the style element after the body element that it is supposed to modify and unbalanced braces.

Note also that you can't just put whitespace wherever you feel like it inside SGML tags.
Somehow you created an additional error subsequent to your original post.
Don't change anything else.  Next time you post a problem, post your *actual* code.


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

Date: 20 May 2006 15:04:53 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: printing css
Message-Id: <Xns97C9668DB1B35castleamber@130.133.1.4>

"Nospam" <nospam@home.com> wrote:

> My mistake, I hadn't updated the right perl file, however I am trying 
> to show an image directly from the perl script
> 
> #!usr/bin/perl
> 
> print "Content-type:text/html\n\n";
> print "<html>\n";
> print "<body>\n";

So you decided to ignore my advice? Thanks for wasting my time then.

> print "<style type = 'text/css'>";
> 
> print "body{background-image:url(http://www.example.com/image1.jpg);";
> 
> print "</style>";
> 
> print "</body>";
> 
> print "</html>";
> 
> doesn't launch the image at all

Does the above HTML launch the image if you copy and paste it into an
empty .html file? If not, your mistake is in the HTML and has nothing to
do with Perl, and hence, wrong group. Also, style should be IIRC in the
head section, not the body. 

-- 
John Bokma          Freelance software developer
                                &
                    Experienced Perl programmer: http://castleamber.com/


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

Date: 20 May 2006 16:55:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Text parsing and substitution
Message-Id: <4d9006F194ttlU1@news.dfncis.de>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> maheshpop1@gmail.com <maheshpop1@gmail.com> wrote:

[...]

> > pseudocode only
> 
> 
> Why?
> 
> It takes only a tiny bit of effort to bypass the confusion
> caused by the pseudoness.

Unfortunately, the label "pseudocode" is often used as a license to
write anything that comes to mind and let the reader figure out how
the parts fit together.

Unless you are acquainted with a specific pseudo-language you use, writing
decent pseudocode is *harder*, not easier, than using an existing language.
You'll find yourself inventing the language as you go along.  Language
design is serious business, pseudo or not.  You won't come up with anything
consistent that way.

Pseudocode is for books, not for casual communication.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: 20 May 2006 16:18:17 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Use of initialized value in pattern match
Message-Id: <4d8tq9F18vg4nU1@news.dfncis.de>

Ben Morrow  <usenet@morrow.me.uk> wrote in comp.lang.perl.misc:

[...]

> And I would always use something like
> 
> my $month = 
>     map qr/$_/,
>     join '|',
>     map quotemeta,
>     qw/JAN FEB ... DEC/;
> 
> just because then you can get the list from somewhere else (l10n, maybe)
> later, if you need to.

The one-shot map is nice, but it needs list context:

    my ( $month) = 
        map qr/$_/,
        join '|',
        map quotemeta,
        qw/JAN FEB ... DEC/;

Alternatively,

    $month = qr/$_/ for
        join '|',
        map quotemeta,
        qw/JAN FEB ... DEC/;

Can't have enough tricks to smuggle a computed expression inside a qr//.

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: 21 May 2006 04:03:54 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: What is the RHS of a substitution?
Message-Id: <1148209434.501926.257400@i40g2000cwc.googlegroups.com>

Ben Bullock wrote:

> This question is about substitutions like
>
> s/XYZ/ABC/;
>
> Is there a variable which contains the right hand part (ABC) of the most
> recent substitution?

I don't believe so.  It seems a rather unusual requirement.

>I have a series of complex substitutions as part of a
> while ( .. ) statement, and I would like to be able to use the right hand
> part of the most recent match, but I'm not sure whether there is a simple
> way to do this.

Using the /e qualifier you can put arbitrary Perl code in the RHS, for
example:

use strict;
use warnings;
$_='abc';

my $rhs;
while ( s/([[:lower:]])/$rhs=uc($1)/e ) {
    print "$1 => $rhs\n";
}



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

Date: Sun, 21 May 2006 13:46:07 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: What is the RHS of a substitution?
Message-Id: <e4pr1d.1mc.1@news.isolution.nl>

Ben Bullock schreef:

> This question is about substitutions like
>
> s/XYZ/ABC/;
>
> Is there a variable which contains the right hand part (ABC) of the
> most recent substitution? I have a series of complex substitutions as
> part of a while ( .. ) statement, and I would like to be able to use
> the right hand part of the most recent match, but I'm not sure
> whether there is a simple way to do this. Thanks for any help.

You could put the substitutions in an array, like this:

#!/usr/bin/perl
  use strict ;
  use warnings ;

  use re 'eval' ;  # check perlre!

  use Data::Dumper ;

  my @subst =
     ( ['ABC', '123'],
       ['DEF', 'GHI'],
       ['GHI', '789'],
       ['XYZ', 'ABC'],
     ) ;

  my @done ;

  while (<DATA>)
  {
    chomp ;

    for my $i (0 .. $#subst)
    {
      my ($f, $t) = ( $subst[$i]->[0],
                      $subst[$i]->[1],
                    ) ;

      s~ $f (?{ push @done,
                     [
                       "line $.: $_",
                       "todo $i: s/$f/$t/",
                     ]
            })
       ~$t~xg
      and push @{$done[$#done]}, "result: $_" ;
    }
  }

  print Data::Dumper->Dump( [  \@subst, \@done ],
                            [qw(*subst   *done)]
                          ) ;

__DATA__
wqefewq XYZ skjd
gg g grewg gwg ewrgrewgrewg eagf
qfh GHI qfe ABC ewq DEF ddsf XYZ wfsqf
qckjqcd ABC qlkfjwqf

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

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 9237
***************************************


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