[24263] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6454 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 23 18:06:16 2004

Date: Fri, 23 Apr 2004 15:05:08 -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           Fri, 23 Apr 2004     Volume: 10 Number: 6454

Today's topics:
        $100 INVESTMENT. GUARANTEED RESULTS OR YOUR MONEY BACK. <roman21@rogers.com>
    Re: Asking for comments on this script (new version) <rvf_lists@fastmail.fm>
    Re: Ben and Tassilo: about calling subs with & (Chris Richmond - MD6-FDC ~)
        does any other language even have this feature? (valued customer)
    Re: does any other language even have this feature? <spamtrap@dot-app.org>
    Re: Huffman coding and Parse::RecDescent <Jon.Ericson@jpl.nasa.gov>
    Re: inefficient regex - please help! <Joe.Smith@inwap.com>
    Re: Insecure dependency in unlink while running with -T <Joe.Smith@inwap.com>
    Re: need a good module + what I'm trying to do <robin @ infusedlight.net>
        Object method and file handle creates "bareword" error. <lawshouse.public@btconnect.com>
    Re: Object method and file handle creates "bareword" er <xx087@freenet.carleton.ca>
    Re: Object method and file handle creates "bareword" er <ittyspam@yahoo.com>
    Re: Proper way to use an imported constant under 'use s <minter@lunenburg.org>
    Re: Proper way to use an imported constant under 'use s <rwxr-xr-x@gmx.de>
        Regex: How to ignore pairs of quotes?  (beginner level  (Tobias Weihmann)
    Re: Regex: How to ignore pairs of quotes?  (beginner le (Malcolm Dew-Jones)
    Re: RFC: Text similarity <bik.mido@tiscalinet.it>
    Re: RFC: Text similarity (Malcolm Dew-Jones)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 23 Apr 2004 20:41:12 GMT
From: THE BEST MONEY LIST<roman21@rogers.com>
Subject: $100 INVESTMENT. GUARANTEED RESULTS OR YOUR MONEY BACK.
Message-Id: <Ibfic.25194$w_E1.18676@news04.bloor.is.net.cable.rogers.com>

--------------
4 STEPS
--------------
1.Sign up for a free PayPal account and receive $5 as bonus credit. 
Click on my referal link to open a PayPal account.
https://www.paypal.com/row/mrb/pal=GUV5KT7C9DQCJ

2.Email $20 to each member on the list with PayPal. 
In Subject put "Best Money List".

***************************The Best Money List*********************************
---------------------------------------------------------------------------------------------------------
Email#1: kriz_chills@hotmail.com
---------------------------------------------------------------------------------------------------------
Email#2: steve_painter@hotmail.com
---------------------------------------------------------------------------------------------------------
Email#3: roman21@rogers.com
---------------------------------------------------------------------------------------------------------
Email#4: 4elbark@verizon.net
---------------------------------------------------------------------------------------------------------
Email#5: t.sprowl@insightbb.com
---------------------------------------------------------------------------------------------------------
************************************************************************************
Emails are checked and all correct.

3.Move everyones names up by 1 line and add your name on the bottom.
So now name that was on line #1 is finished their cycle .

4. When you are done adding your email to this list, you should post
it to as many newsgroups as you can. There are programs that you 
can download that let you post to several newsgroups at once.

5. This is my step. Once I receive the payment, I will add your email to The 
Money List  and witin a week you will see this message in thousands of
newsgroups with your email in it. =)
______________________________________________________________
If you dont receive atleast $20 within 30 days. I will refund the money you sent
to me within 30 days.
______________________________________________________________

Best of luck and have fun! 

Disclaimer: If you are one of those people that are against lists like this one
then please just ignore it and go on to the next message. Maybe someone 
else might be wanting to try it. This is not a scam of some kind because of the 
30 day money back guarantee. I am not affiliated with PayPal but as my 
personal preference I think their service is the most secure for sending and
receiving money with email.  




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

Date: Fri, 23 Apr 2004 13:49:41 -0500
From: Rafael Villarroel <rvf_lists@fastmail.fm>
Subject: Re: Asking for comments on this script (new version)
Message-Id: <w0ar7ueo7ga.fsfhello@somewhere.com>


Thanks a lot for your time taken, Tad. Just for the record, here is a
new version in which I tried to take care of your suggestions

----------------------- skakify.pl -------------------
#!/usr/bin/perl

# The purpose of this script is to typeset annotations done by the
# chess program Crafty (ftp://ftp.cis.uab.edu/pub/hyatt/), in LaTeX
# (http://www.latex-project.org/). Crafty already has a command to
# produce LaTeX annotations, but this script gives much prettier
# results!

# It requires the Perl module Chess::PGN::Parse, the non-standard
# LaTeX packages skak, chess-workshop-symbols, wrapfig, fullpage and
# needspace, which are available at CTAN, crafty and latex (of
# course), and the pgn-extract utility.

# To use it: starting with, say, games.pgn, use Crafty's annotate
# feature to get games.pgn.can. Then you will want to preprocess this
# file using pgn-extract
# (ftp://ftp.cs.ukc.ac.uk/pub/djb/Extract/About.html) in order to add
# an ECO (opening classification code) tag to each game and get the
# file back into standard PGN notation. You get then gamesann.pgn. You
# should then delete all instances of the comments of the like of
# {annotating both black and white moves.}  {using a scoring margin of
# +0.20 pawns.}  {search time limit is 1.00}, since they confuse the
# Chess::PGN::Parse module. Say you have now a file gamesann.pgn, you
# are now ready to apply this script, say 'perl skakify.pl
# gamesann.pgn', to obtain gamesann.pgn.tex which you can now process
# with LaTeX

# Thanks to people of comp.lang.perl.misc for suggestions

use warnings;
use strict;
use Chess::PGN::Parse;

# We could put most of the LaTeX commands in a separate package. I
# prefer not to do that in order maintain and move around only one
# file. Main program starts at line 163.

my $preamble = <<'PREAMBLE';
\documentclass[twocolumn]{article}
\usepackage[T1]{fontenc}
\usepackage{fullpage,ifthen}
\usepackage{skak,chess-workshop-symbols}
\usepackage{wrapfig,needspace}
\setlength{\columnsep}{7mm}
\setlength{\parindent}{0pt}
\setlength{\intextsep}{0pt}

\makeatletter
\newcommand{\@event}{} \newcommand{\@site}{} \newcommand{\@dategame}{}
\newcommand{\@round}{} \newcommand{\@whiteplayer}{}
\newcommand{\@blackplayer}{} \newcommand{\thisresult}{}
\newcommand{\@eco}{} 

\newcommand{\event}[1]{\renewcommand{\@event}{#1}}
\newcommand{\site}[1]{\renewcommand{\@site}{#1}}
\newcommand{\dategame}[1]{\renewcommand{\@dategame}{#1}}
\newcommand{\round}[1]{\renewcommand{\@round}{#1}}
\newcommand{\whiteplayer}[1]{\renewcommand{\@whiteplayer}{#1}}
\newcommand{\blackplayer}[1]{\renewcommand{\@blackplayer}{#1}}
\newcommand{\result}[1]{\renewcommand{\thisresult}{#1}}
\newcommand{\eco}[1]{\renewcommand{\@eco}{#1}}

\setlength{\parindent}{0pt}

\newcounter{gameno}
\setcounter{gameno}{1}

\newcommand{\gameheader}%
{\parbox{\linewidth}{%
    \begin{center}
      \textbf{\thegameno.}
    \end{center}
    \begin{flushleft}
      $\circ$ \textsc{\@whiteplayer}\par%
      $\bullet$ \textsc{\@blackplayer}\par%
      \smallskip%
      \@event \ifthenelse{\equal{\@round}{}}%
      {}{, Round \@round}\hspace{\stretch{1}}\textit{\@eco}\par%
      \@site\hspace{\stretch{1}}\@dategame\par
    \end{flushleft}
    \nopagebreak
  }%        END PARBOX
  \addtocontents{toc}{\thegameno. \@whiteplayer--\@blackplayer\dotfill\thepage\par}
  \addtocounter{gameno}{1}
  \renewcommand{\@event}{} \renewcommand{\@site}{} \renewcommand{\@dategame}{}
  \renewcommand{\@round}{} \renewcommand{\@whiteplayer}{}
  \renewcommand{\@blackplayer}{}
}%          END GAMEHEADER

% this next macro by Donald Arsenau, see
% <4008a73c$0$22624$61ce578d@news.syd.swiftdsl.com.au>
\def\wrapfill{\par
   \ifx\parshape\WF@fudgeparshape
     \nobreak
     \ifnum\c@WF@wrappedlines>\@ne
       \advance\c@WF@wrappedlines\m@ne
       \vskip\c@WF@wrappedlines\baselineskip
       \global\c@WF@wrappedlines\z@
     \fi
     \allowbreak
     \WF@finale
   \fi
}
\makeatother

\begin{document}
\tinyboard
\notationOff
\tableofcontents
\bigskip

PREAMBLE


my $enddoc='\end{document}';

my $pgnfile = shift || die "filename required\n";
my $pgn = new Chess::PGN::Parse $pgnfile 
    or die "can't open $pgnfile\n";
my $output = "$pgnfile.tex";

sub printboard
{
    print OUT <<'PRINTBOARDCOMMANDS';

\smallskip
\needspace{50pt}
\begin{wrapfigure}[8]{r}{78pt}
\showboard
\end{wrapfigure}
PRINTBOARDCOMMANDS
}

# In this subroutine, we want to convert a string like: "({7:+0.42} 10. ... c6 11. O-O-O
# $14) ({0:+0.00} 10. ... dxc4 $10)" into
#  \textit{[7:+0.42]} \movecomment{ 10... c6 11. O-O-O }\wbetter 

#  \textit{[0:+0.00]} \movecomment{ 10... dxc4 }\equalp

sub fix_variation
{
    $_=$_[0];
    s/ \( { / {   /gx;
    s/  }   / } \( /gx;       
    s/{/\\textit{\[/g;
    s/}/\]}/g;
    s/\(/ \\movecomment{/g;
    s/\)/}\n/gx;
    s/}\n  \\textit{/}\\par\n\\textit{/g;                               
    s/\$18 ?}/}\\wdecisive/g;
    s/\$16 ?}/}\\wupperhand/g;
    s/\$14 ?}/}\\wbetter/g;
    s/\$19 ?}/}\\bdecisive/g;
    s/\$17 ?}/}\\bupperhand/g;
    s/\$15 ?}/}\\bbetter/g;
    s/\$10 ?}/}\\equalp/g;
    s/ +\]/\]/g;
    s/\[ +/\[/g;
    s/ +}/}/g;
    s/{ +/{/g;
    s/^  \\/\\/g; 
    return $_;
}

################### MAIN PROGRAM

open(OUT, ">$output") or die "Could not open $output: $!\n";

print OUT $preamble;

while ($pgn->read_game()){
    $pgn->parse_game({save_comments => 'yes'});
    my $comments = $pgn->comments;
    print OUT "\\event{",$pgn->event,"}\n"
        . "\\site{",$pgn->site,"}\n"
        . "\\dategame{",$pgn->date,"}\n"
        . "\\round{",$pgn->round,"}\n"
        . "\\whiteplayer{",$pgn->white,"}\n"
        . "\\blackplayer{",$pgn->black,"}\n"
        . "\\result{",$pgn->result,"}\n"
        . "\\eco{",$pgn->eco,"}\n\n"
        . "\\gameheader\n"
        . "\\newgame\n"
        . "\\mainline{";
    my $total_plys = @{$pgn->moves};
    my $ply = 0;
    while ( $ply < $total_plys ) {
        my $move = int($ply/2) + 1;
        if ( $ply % 2 == 0) # even plies correspond to white moves
        {
            print OUT "$move. @{$pgn->moves}[$ply] ";
            if ( $$comments{"${move}w"} )
                 {
                     print OUT "}";
                     printboard();
                     print OUT fix_variation($$comments{"${move}w"});
                     print OUT "\\wrapfill\n";
                 }
             }
        else
        {
            if ( $$comments{"${move}w"} ) {
                 print OUT "\\smallskip\n\\mainline{$move... @{$pgn->moves}[$ply] "}
             else {
                print OUT "@{$pgn->moves}[$ply] "
                }
            if ( $$comments{"${move}b"} )
            {
                print OUT "}";
                printboard();
                print OUT fix_variation($$comments{"${move}b"});
                print OUT "\\wrapfill\n"
                    . "\\smallskip\n\\mainline{"
            }
        }
        ++$ply;
    }
    print OUT "}\\hspace{\\stretch{1}} \\textbf{[\\thisresult]}\n\n";
}

print OUT "\n$enddoc";
close(OUT);



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

Date: Fri, 23 Apr 2004 19:12:16 +0000 (UTC)
From: crichmon@filc8604.fm.intel.com (Chris Richmond - MD6-FDC ~)
Subject: Re: Ben and Tassilo: about calling subs with &
Message-Id: <c6bpqg$8mg$1@news01.intel.com>

In article <pan.2004.04.23.15.56.48.128604@aursand.no>,
 Tore Aursand <tore@aursand.no> writes:
>On Fri, 23 Apr 2004 08:44:15 -0700, Rex Gustavus Adolphus wrote:

From:
>  perldoc perlsub

Please correct this summarization if needed:

   You shouldn't use '&' when calling new-style subroutines that have been
   declared with prototypes because it disables arg checking.
   Otherwise, its still optional when calling with parens, required
   without, unless the subroutine is predeclared.

Chris

-- 
 Chris Richmond         | I don't speak for Intel & vise versa    



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

Date: 23 Apr 2004 11:45:55 -0700
From: scooterm@hotmail.com (valued customer)
Subject: does any other language even have this feature?
Message-Id: <1b347673.0404231045.592635b0@posting.google.com>

my  $variable = 'fill in blanks';
my  $question = q^
One of the very useful features of perl is the quotelike
operator, because it makes it very easy to create a
"subdocument within a document" ... which brings up
a question, does any other programming language have
anything even close to this functionality?

Python has the triple-quote feature, which is nice, but
still creates minor hassles if you want to want to output
a triple-quote inside your 'subdocument' (use-versus-mention).

XML has CDATA sections, which suck, and suffer from
(use-versus-mention) as well.

Moreover, none of them make it easy to ^.$variable.q^ with
variables.

Is there any other programming environment that has this
feature? Can anyone name even one??

Why doesn't every programming environment have a similar
feature? Adding 'escape sequences' to strings is
error-prone, less readable, and annoying!
^;

print $question;


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

Date: Fri, 23 Apr 2004 15:52:33 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: does any other language even have this feature?
Message-Id: <Wb2dnWPunbme6RTdRVn-ig@adelphia.com>

valued customer wrote:

> Is there any other programming environment that has this
> feature? Can anyone name even one??

Perl borrowed the "here document" idea from UNIX shells like Bash, CSH, etc.
I think it would be a bit of a stretch to refer to that as a "programming
environment," though. ;-)

I think Python and Ruby support the idea too.

> Why doesn't every programming environment have a similar
> feature?

It's arguably less useful than one might think at first. When you're dealing
with really large output strings - such as the one in your message - it
often makes more sense to use a template-oriented approach, with the
strings in an external file.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Fri, 23 Apr 2004 10:56:57 -0700
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: Huffman coding and Parse::RecDescent
Message-Id: <rcgekqed1cm.fsf@Jon-Ericson.sdsio.prv>

Uri Guttman <uri@stemsystems.com> writes:

>>>>>> "JE" == Jon Ericson <Jon.Ericson@jpl.nasa.gov> writes:
>
>   JE> Someone wrote an email with the suggestion:
>
>   JE>   home_run: /H(?![A-Z])/ | 'HR'
>
>   JE> That does the trick, I think.
>
> looks ok. if you gave a complete spec then we could help more. 

Ok.  http://www.retrosheet.org/datause.txt is a close to a spec as
exists.  There are quite a few things that are not documented.  I'm
looking at item 6. a., but that is fairly incomplete.  I've been
writing the grammar by trial and error. (Emphasis on error. :)

Mostly, however, this is an exercise in learning.  I suppose this
example is an aberration, but it really bothered me that adding an
uncommon case broke the frequent case.

Jon


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

Date: Fri, 23 Apr 2004 19:27:26 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: inefficient regex - please help!
Message-Id: <y6eic.12128$w96.1152496@attbi_s54>

Mothra wrote:

> /(.*Lost connection.*(\n.*)*{4}/
> 
> The above works and prints "yep" if 4 or more occurences are found; however,
> it's quite slow and if I want to match more occurences (e.g. 9) it takes
> forever: almost as if the length of time the script takes to run is being
> raised to the power of the number of occurences I'm trying to match!

Don't use consecutive asterisks.  The ")*{4}" part can't be right.

   /{Lost connection.*){4}/s

	-Joe


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

Date: Fri, 23 Apr 2004 19:53:28 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Insecure dependency in unlink while running with -T switch
Message-Id: <Tueic.9529$0u6.1700020@attbi_s03>

Regent wrote:

> Both the name of the file and that of the folder are variable scalar strings.

If the variables are set from user input, they are tainted.

> I always get the error message "Insecure dependency in
> unlink while running with -T switch". The relevant block of code:
> 		my $toDel = "$root/$uploadDir/$origfn";
> 		unlink ($toDel) or die "$!";

Imagine that $root or $uploadDir has "../../../etc".
Perl is saying that you haven't done enough to eliminate that possibility.

> How do I solve this problem? Thanks

Follow the suggestions in the docs that describe the -T switch.
	-Joe


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

Date: Fri, 23 Apr 2004 13:52:53 -0700
From: "Robin" <robin @ infusedlight.net>
Subject: Re: need a good module + what I'm trying to do
Message-Id: <c6c134$qt6$1@reader2.nmix.net>

Alright, and sorry about posting attachments, I forgot to take them out.

I finally figured out what I need to do, this but it shouldn't be that hard
to do, I just have to use the print redirect function in cgi.pm...or
autoload the layers

basically what I want to do is write a blogger that has two buttons that
show and hide comments dyanimically, ie: like a tab on windows, but the
comments have to be rendered dynamically...so I'll probably just autoload
the layers if this is possible... or redirect to the same script with the
layer shown.

Does anyone know a module that creates DHTML layers that are autoloaded with
the contents loaded (ie: from files) dynamically on the server side?

Thanks-
Robin




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

Date: Fri, 23 Apr 2004 19:21:05 +0100
From: Henry Law <lawshouse.public@btconnect.com>
Subject: Object method and file handle creates "bareword" error.  How to code?
Message-Id: <pumi8092eickod0jku4nloono75jd8bstc@4ax.com>

I can see from Googling that this is a common area of difficulty for
the inexperienced; but the workrounds that I have found don't produce
the expected results.  Can someone put me straight?

Using XML::Twig I am reading in an XML file, adding an element to it
and writing it out to a new file on disk.  The problem comes with the
coding of the file handle which represents the open file.  Here's a
distilled test case:
---------------------
use strict;
use warnings;

use XML::Twig;

# Get the XML file
my $fdtwig = new XML::Twig;
$fdtwig->parsefile('F:\p\NFConfig.XML');
my $fd = $fdtwig->root;

# Create a new twig and paste it into the XML doc
my $stuff = "somestuff";
my $elt = new XML::Twig::Elt('stuff',$stuff);
$elt->paste('last_child',$fd);

# Write the modified XML document to a new file
open (XMLOUT, 'F:\p\xmlout.xml');
unless ($fd->print(XMLOUT)) {
	print "Failed to write modified XML file:$!\n";
}
close XMLOUT;
---------------------

With the code as pasted above Perl objects to the "print" statement
with "Bareword "XMLOUT" not allowed while "strict subs" in use at
tryit.pl line 20."

But the three possible workrounds that Google found all produce error
messages; namely:

(1) Line 20 as 		unless ($fd->print(*XMLOUT)) {

Error: "invalid pretty print style '' at tryit.pl line 20" (Which is
an error from XML::Twig, who is assuming that *XMLOUT is a pretty
print specification.   That's odd too, since the first argument to the
twig's "print" method is the file handle)

(2) Line 20 as 		unless ($fd->print(\*XMLOUT)) {

Error: "Failed to write modified XML file:Bad file descriptor"

(3) Lines 20/21 as 	open ("XMLOUT", 'F:\p\xmlout.xml');
			unless ($fd->print("XMLOUT")) {

Error: "invalid pretty print style 'xmlout' at tryit.pl line 20"
again.

Can someone point me in the right direction to fix the coding problem?

Henry Law       <><     Manchester, England 


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

Date: 23 Apr 2004 18:44:49 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Object method and file handle creates "bareword" error.  How to code?
Message-Id: <slrnc8ip16.7o8.xx087@smeagol.ncf.ca>

Henry Law <lawshouse.public@btconnect.com> wrote:
[...]
>  use strict;
>  use warnings;
>  
>  use XML::Twig;
>  
>  # Get the XML file
>  my $fdtwig = new XML::Twig;
>  $fdtwig->parsefile('F:\p\NFConfig.XML');
>  my $fd = $fdtwig->root;
[...]
>  # Write the modified XML document to a new file
>  open (XMLOUT, 'F:\p\xmlout.xml');
>  unless ($fd->print(XMLOUT)) {
>  	print "Failed to write modified XML file:$!\n";
>  }
>  close XMLOUT;
[...]

The XML::Twig docs show:
     print            ($optional_filehandle, %options)
         Prints the whole document associated with the twig. To
         be used only AFTER the parse.

So, $optional_filehandle being a scalar, try this:

    my $xmlout;
    # you did want to *write* to this file, right?
    open $xmlout, '>', 'f:/p/xmlout.xml';
    $fd->print($xmlout);
    close $xmlout;

Oh, perhaps the filehandle is optional but the options are mandatory.
In that case add an empty hash to the end:

    $fd->print($xmlout, ());

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: Fri, 23 Apr 2004 14:45:30 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Object method and file handle creates "bareword" error.  How to code?
Message-Id: <20040423144321.L15178@dishwasher.cs.rpi.edu>

On Fri, 23 Apr 2004, Henry Law wrote:

> I can see from Googling that this is a common area of difficulty for
> the inexperienced; but the workrounds that I have found don't produce
> the expected results.  Can someone put me straight?
>
> Using XML::Twig I am reading in an XML file, adding an element to it
> and writing it out to a new file on disk.  The problem comes with the
> coding of the file handle which represents the open file.  Here's a
> distilled test case:
> ---------------------
> use strict;
> use warnings;
>
> use XML::Twig;
>
> # Get the XML file
> my $fdtwig = new XML::Twig;
> $fdtwig->parsefile('F:\p\NFConfig.XML');
> my $fd = $fdtwig->root;
>
> # Create a new twig and paste it into the XML doc
> my $stuff = "somestuff";
> my $elt = new XML::Twig::Elt('stuff',$stuff);
> $elt->paste('last_child',$fd);
>
> # Write the modified XML document to a new file
> open (XMLOUT, 'F:\p\xmlout.xml');
> unless ($fd->print(XMLOUT)) {
> 	print "Failed to write modified XML file:$!\n";
> }
> close XMLOUT;
> ---------------------
>
> With the code as pasted above Perl objects to the "print" statement
> with "Bareword "XMLOUT" not allowed while "strict subs" in use at
> tryit.pl line 20."
>
 Completely untested, the first thing I'd try is using a lexical
filehandle, rather than the bareword:

my $fh;
open ($fh, 'F:\p\xmlout.xml');
unless ($fd->print($fh)){
	pritn "Failed to write modified XML file: $!\n";
}
close $fh;

__END__

I honestly have no idea if it'd work, but it is definately what I'd try.

Paul Lalli


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

Date: Fri, 23 Apr 2004 18:05:44 GMT
From: "H. Wade Minter" <minter@lunenburg.org>
Subject: Re: Proper way to use an imported constant under 'use strict'?
Message-Id: <YVcic.52971$yv.1446305@twister.southeast.rr.com>

Richard Morse <remorse@partners.org> wrote:

> Completely untested, as I don't right now have access to a windows box, 
> but perhaps accessing it as Win32::Process::NORMAL_PRIORITY_CLASS?

Thanks for the suggestion, but it doesn't seem to work:

        my $object;
        Win32::Process::Create( $object, $config{'mp3player'}, '', 1,
            Win32::Process::NORMAL_PRIORITY_CLASS, "." );
        $mp3_pid = $object->GetProcessID();
        sleep(1);

[minter@localhost mrvoice]$ ./mrvoice.pl
Bareword "Win32::Process::NORMAL_PRIORITY_CLASS" not allowed while "strict 
subs" in use at ./mrvoice.pl line 3516.
Execution of ./mrvoice.pl aborted due to compilation errors.

--Wade


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

Date: 23 Apr 2004 19:17:56 GMT
From: Lukas Mai <rwxr-xr-x@gmx.de>
Subject: Re: Proper way to use an imported constant under 'use strict'?
Message-Id: <c6bq54$dn5$1@wsc10.lrz-muenchen.de>

H. Wade Minter schrob:
[...]

> Then, later in the code, I use an imported constant like:

>     if ( "$^O" eq "MSWin32" )
>     {

>         # Start the MP3 player on a Windows system
>         my $object;
>         Win32::Process::Create( $object, $config{'mp3player'}, '', 1,
>             NORMAL_PRIORITY_CLASS, "." );
>         $mp3_pid = $object->GetProcessID();
>         sleep(1);
>     }

> However, when strict subs are enabled, I get an error about barewords:
[...]
> My question is - what's the proper way to use this constant when strictures
> are enabled?

Constants are really just inlined subroutines, so writing
NORMAL_PRIORITY_CLASS() should work.

HTH, Lukas
-- 
use   warnings;                                    use      strict;
sub hacker'Perl        {     "Perl @_,"}           sub another'Just
                       {print"Just @_ "}
Just another Perl hacker, 


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

Date: 23 Apr 2004 11:41:24 -0700
From: listen@fomalhaut.de (Tobias Weihmann)
Subject: Regex: How to ignore pairs of quotes?  (beginner level question)
Message-Id: <c59553e1.0404231041.579778cb@posting.google.com>

Hi,

I'm trying to parse VB strings here but I didn't succeed in getting
the regex to ignore pairs of double quotes (which are the equivalent to
\" in Perl)

Example:

print "This is a test ""Test"" yeah" + Str$(4)+ "good" 
--> This is a test ""Test"" yeah
--> good

print """We""are""testing"""+"What they can do" '
--> ""We""are""testing""
--> What they can do

I finished off writing a FSM, but this is quite clumsy compared to a
regex. The best thing I had was like /"(.*?)"[^"]/, but this would get me 
--> This is a test "
for the first example... ( the "T satisfies the end condition, even though
the two quotes should be ignored altogether)

I also considered /"(.*?[^"])"[^"]/, but this will break in the second
example - because it is's of course possible to have two quotes (to be
ignored) right before a quote finishing of the string. I also experi-
mented with non-moving sequences (?!"") but to no avail...

How would you do it?

Cheers!
Toby


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

Date: 23 Apr 2004 14:15:30 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Regex: How to ignore pairs of quotes?  (beginner level question)
Message-Id: <40898772@news.victoria.tc.ca>

Tobias Weihmann (listen@fomalhaut.de) wrote:
: Hi,

: I'm trying to parse VB strings here but I didn't succeed in getting
: the regex to ignore pairs of double quotes (which are the equivalent to
: \" in Perl)

: Example:

: print "This is a test ""Test"" yeah" + Str$(4)+ "good" 
: --> This is a test ""Test"" yeah
: --> good

: print """We""are""testing"""+"What they can do" '
: --> ""We""are""testing""
: --> What they can do

: I finished off writing a FSM, but this is quite clumsy compared to a
: regex. The best thing I had was like /"(.*?)"[^"]/, but this would get me 
: --> This is a test "
: for the first example... ( the "T satisfies the end condition, even though
: the two quotes should be ignored altogether)

: I also considered /"(.*?[^"])"[^"]/, but this will break in the second
: example - because it is's of course possible to have two quotes (to be
: ignored) right before a quote finishing of the string. I also experi-
: mented with non-moving sequences (?!"") but to no avail...

: How would you do it?

Someone else posted something like the following to a similar problem.

my example is tested, but just for the one example


	# $s contains the VB string you wish to parse.

	$s=q{print "This is a test ""Test"" yeah" + Str$(4)+ "good"};

	# extract the quoted portions
	@s= $s=~ m/"((?:[^"]|"")*)"/g;

	# examine what we extracted
	print map {"=>$_<=\n" } @s;



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

Date: Fri, 23 Apr 2004 21:50:52 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: RFC: Text similarity
Message-Id: <ejsi80d1707k2bbi3fccmh2bg79ak4n3mr@4ax.com>

On Fri, 23 Apr 2004 14:16:53 +0200, Tore Aursand <tore@aursand.no>
wrote:

>I have a large (more than 3,000 at the moment) set of documents in various
>formats (mostly PDF and Word).  I need to create a sort of (...) index of
>these documents based on their similarity.  I thought it would be nice to
>gather some suggestions from the people in this group before I proceeded.

I know that this may seem naive, but in a popular science magazine I
read that a paper has been published about a technique that indeed
identifies the (natural) language some documents are written in by
compressing (e.g. LZW) them along with some more text from samples
taken from a bunch of different languages and comparing the different
compressed sizes. You may try some variation on this scheme...

I for one would be interested in the results, BTW!


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: 23 Apr 2004 14:06:07 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: RFC: Text similarity
Message-Id: <4089853f@news.victoria.tc.ca>

Tore Aursand (tore@aursand.no) wrote:
: Hi!

: I have a large (more than 3,000 at the moment) set of documents in various
: formats (mostly PDF and Word).  I need to create a sort of (...) index of
: these documents based on their similarity.  I thought it would be nice to
: gather some suggestions from the people in this group before I proceeded.

: First of all:  Converting the documents to a more sensible format (text in
: my case) is not the problem.  The problem is the indexing and how to store
: the data which represents the similarity between the documents.

: I've done a search on CPAN and found a few modules which is of interest,
: primarily AI::Categorize and WordNet.  I haven't used any of these before,
: but it seems like WordNet is the most appropriate one; AI::Categorize
: seems to require you to categorize some of the documents first (which I
: don't have the opportunity to do).

: Are there any other modules I should take a look at?  Any suggestions on
: how I should deal with this task?  Something you think I might forget?
: Some traps I should look out for?

: Any comments are appreciated!  Thanks.

There is a bayesian filter, not for spam, I think it's called ifile.

It helps file email into folders based on categories.

I could imagine starting the process by creating a few categories by hand,
each with one document or two or three similar documents, and then adding
documents using ifile.  Each time a document doesn't have a good match in
the existing categories then create a new category.

Or do it in reverse, start with 2,999 categories (one for each document,
except the last), and take the last document (number 3,000) and try to
file it into one of the 2,999 categories.  Do that for each document to
get a feel for the process, and then start merging the categories.

$0.02


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

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


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