[22148] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4369 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 8 21:06:06 2003

Date: Wed, 8 Jan 2003 18:05:07 -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           Wed, 8 Jan 2003     Volume: 10 Number: 4369

Today's topics:
        [ANNOUNCE] Data::Type 0.01.01 enters CPAN <murat.uenalan@gmx.de>
    Re: A Good Perl Book <sjcole@hotmail.com>
    Re: A Good Perl Book (Tad McClellan)
        ANNOUNCE : Data::Validator::Item 0.75 released (anthony staines)
        ANNOUNCE: PostScript::Font 1.08 -- Access to font data (Johan Vromans)
        ANNOUNCE: SPOPS 0.73 released <chris@cwinters.com>
    Re: Existence of an executable of unknown location (Tad McClellan)
        Finding required .pl's home ? <craznar01@hotmail.com>
        Problems reading a message and getting the attachment ( (Ryan)
        Q: Shopping Cart Software <johnsmith2001usa@yahoo.com>
    Re: Q: Shopping Cart Software <mgjv@tradingpost.com.au>
    Re: Recreating directory hierarchy <goldbb2@earthlink.net>
    Re: reload not terminating process (David Efflandt)
    Re: Simple Filter (Jay Tilton)
    Re: Simple Filter <tambaa.Xspam@yahoo.com>
    Re: Simple Filter <goldbb2@earthlink.net>
    Re: Simple Filter <tambaa.Xspam@yahoo.com>
    Re: Simple Filter <bart.lateur@pandora.be>
    Re: Simple Filter (Tad McClellan)
    Re: the length of empty? <spam@thecouch.homeip.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 8 Jan 2003 00:30:54 +0100
From: "Murat Ünalan" <murat.uenalan@gmx.de>
Subject: [ANNOUNCE] Data::Type 0.01.01 enters CPAN
Message-Id: <3e1caf6a$1_3@news.teranews.com>

LAST CHANGES 0.01.01

  Migrated from 'Data::Verify' to 'Data::Type' namespace
  Removed the pre-alpha disclaimer from README
  This now is alpha software

  added IType::W3C Interface where types from
http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/ are implemented
  changed 'Function' namespace to 'Facet' conforming w3c

  added HEX, BINARY types

Enjoy,
Murat Ünalan

NAME

Data::Type - versatile data/type verification, validation and testing

VERSION

0.01.01 (Tue Jan  7 23:27:21 2003)

KEYWORDS

data types, data manipulation, data patterns, form data, user input, tie

DESCRIPTION

This module supports types. Out of the ordinary it supports parameterised
types (like
databases have i.e. VARCHAR(80) ). When you try to feed a typed variable
against some
odd data, this module explains what he would have expected. It doesnt
support casting (yet).

Backend was realized with Regexp::Common, Email::Valid and
Business::CreditCard.


Data::Type 0.01.01 supports 27 types:

  BINARY             - binary code
  BOOL               - a true or false value
  CREDITCARD         - is one of a set of creditcard type (DINERS, BANKCARD,
VISA, ..
  DATE               - a date
  DATETIME           - a date and time combination
  EMAIL              - an email address
  ENUM               - a member of an enumeration
  GENDER             - a gender (male|female)
  HEX                - hexadecimal code
  INT                - an integer
  IP                 - an IP (V4, MAC) network address
  LONGTEXT           - text with a max length of 4294967295 (2^32 - 1)
characters (..
  MEDIUMTEXT         - text with a max length of 16777215 (2^24 - 1)
characters (al..
  NUM                - a number
  QUOTED             - a quoted string
  REAL               - a real
  REF                - a reference to a variable
  SET                - a set (can have a maximum of 64 members (mysql))
  TEXT               - blob with a max length of 65535 (2^16 - 1) characters
(alias..
  TIME               - a time
  TIMESTAMP          - a timestamp
  TINYTEXT           - text with a max length of 255 (2^8 - 1) characters
(alias my..
  URI                - an http uri
  VARCHAR            - a string with limited length of choice (default 60)
  WORD               - a word (without spaces)
  YEAR               - a year in 2- or 4-digit format
  YESNO              - a simple answer (yes|no)

And 4 filters:

  chomp              - chomps
  lc                 - lower cases
  strip              - strip
  uc                 - upper cases


Supported creditcards are: 'Diners Club', 'Australian BankCard', 'VISA',
'Discover/Novus', 'JCB', 'MasterCard', 'Carte B
lache', 'American Express'.

AUTHOR

Murat Ünalan, <murat.uenalan@cpan.org>

COPYRIGHT/LICENSE

(c) 2002 by Murat ?nalan. All rights reserved. Note: This program is
free software; you can redistribute it and/or modify it under the same
terms as perl itself





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

Date: Wed, 8 Jan 2003 23:15:29 -0000
From: "Steve C" <sjcole@hotmail.com>
Subject: Re: A Good Perl Book
Message-Id: <1042067481.536974@ananke.eclipse.net.uk>

I know, I know !!
I'm temporarily using Outlook Express - which I hate at the best of times.
And it said "cannot connect to news server.."
So I left it for a few minutes and clicked Send/Receive - which I assumed
would retry the sending of the message - which it appeared to do.  The
message seemed to post.
When I looked on the newsgroup I found the original posting plus a follow up
to my own posting containing the same text...
Dunno what happened, don't care - I put it down to SHITware....Micro$haft
Outlook !
Apologies to the group aswell.

 ..And thanks Sara for your posting - I shall go for the handbook once I've
bought the "Learning Perl" book - as I think the reference guide may be a
little bit beyond me until I've grasped the basics.
Thanks again

Steve.

"Sara" <genericax@hotmail.com> wrote in message
news:776e0325.0301080620.2fd55b92@posting.google.com...
> "Steve C" <sjcole@hotmail.com> wrote in message
news:<1041892895.356594@ananke.eclipse.net.uk>...
> > Hiya Folks,
> >
> > I'm just about to order the O'Reilly book: Programming Perl (Authors
Larry
> > Wall, Tom Christiansen, Jon Orwant)
> > I know there's plenty of online material - but you know, I like to be
able
> > to read something in the local pub / bar ! (sad !!)
> >
> > Is this book to be recommended by the many perl gurus on this NG, or
should
> > I be considering something different ?
> > For information: I have only ever programmed in PASCAL, BASIC, COBOL,
Visual
> > Basic (Arrgghh!) and more recntly dabbled with PHP4
> >
> > Many Thanks
> >
> > Steve C.
>
> This is like deja-vu all over again!? Are you practicing loops?
>
> -Gx




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

Date: Wed, 8 Jan 2003 19:28:04 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: A Good Perl Book
Message-Id: <slrnb1pk14.mf5.tadmc@magna.augustmail.com>

Steve C <sjcole@hotmail.com> wrote:

> I know, I know !!


You know, you know what?


> Apologies to the group aswell.


OK.

Now if we could just get you to quote followups properly as well...


    http://www.geocities.com/nnqweb/nquote.html



[snip TOFU]

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


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

Date: 6 Jan 2003 16:19:37 -0800
From: anthony.staines@ucd.ie (anthony staines)
Subject: ANNOUNCE : Data::Validator::Item 0.75 released
Message-Id: <3e1caf7a$1_7@news.teranews.com>

Data/Validator/Item version 0.75
================================

VERSION 0.7 First (alpha) release

This is an attempt to create an object which will permit
semi-automatic verification of a data value.

Many people work with data organised as records, each containing
(potentially many) variables. It is often necessary to process files
of such records, and to test every variable within every record to
ensure that each one is valid. I do this before putting data from very
large flat files into my databases.

For each variable I had a need to define specific, sometimes complex
rules for validity, then implement them, and check them. This is what
Data::Validator::Item is for.

COPYRIGHT AND LICENCE

Copyright (C) 2002 Anthony Staines.
GPL/Artistic




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

Date: 05 Jan 2003 12:44:12 +0100
From: jvromans@squirrel.nl (Johan Vromans)
Subject: ANNOUNCE: PostScript::Font 1.08 -- Access to font data
Message-Id: <3e1cafac$1_1@news.teranews.com>

This package contains a couple of modules to get information for and
from PostScript fonts and associated metrics files. Also included is a
module to facilitate basic typesetting, a program to make font
samples, and programs to handle the conversion of font data to
PostScript binary (.pfb) and ASCII (.pfa) formats. Example program
shows how basic typesetting can be obtained.

New in this version: support for TrueType fonts does no longer require
external programs, and ISO-8859-15 (Latin9) font encoding.

Modules:

   PostScript::Resources - fetch info from Unix PostScript Resource files

			Unix PostScript Resource (.upr) files are the
			Adobe specified way of defining PostScript
			resources on Unix systems. Using .upr files,
			font names and families are associated with
			their metrics and outline data.

   PostScript::Font   - get information from a PostScript font file

			Information includes the font name, font
			family name, but also encoding vector and list
			of glyphs.
			Font types 1 and 42 are supported; types 2, 3
			and 5 are usually handled as well.
			TrueType fonts are internally converted to
			Type42 fonts, using an external conversion
			tool (not included).

   PostScript::FontMetrics - get information from Adobe Font Metrics file

			Information includes the font name, font
			family name, encoding vector, width and
			kerning tables.

			A example program is provided that shows how
			to use the metrics for basic typesetting of
			PostScript texts.

   PostScript::PrinterFontMetrics - get information from Printer Font Metrics file

			Like PostScript::FontMetrics, but gets the
			information from a .PFM file instead.

   PostScript::FontInfo - get information from Windows .INF files

			Information includes the font name, font
			family name and PC filename prefix.

   PostScript::BasicTypesetter
   PostScript::PseudoISO - tools for basic typesetting

			These modules contains functions to do basic
			typesetting, like setting paragraphs of text
			using different fonts, colors, styles, and
			alignments (left, right, center and
			justified). All with kerning applied.
			Note that these modules are currently
			experimental.

Programs:

   fontsampler        - makes detailed or concise sample pages of fonts

			In detailed mode, one or more pages are
			produced to show all the glyphs of the font.
			Otherwise, just a sample of the font is
			printed, allowing for 40 or more font samples
			per page.
			The output is compliant with Adobe's Document
			Structuring Conventions version 3.0.

   font2pfa	      - decodes a font file to ASCII (.pfa) format

			The input format may be any type that
			PostScript::Font can deal with.

   font2pfb	      - encodes a font file to binary (.pfb) format

			The input format may be any type that
			PostScript::Font can deal with.

To install, unpack the archive, change to the unpacked directory, and
type:

    perl Makefile.PL
    make all test
    make install

REQUIREMENTS

For TrueType font handling, the CPAN package Font::TTF must be
installed. 

AVAILABILITY

(web-page) http://www.squirrel.nl/people/jvromans/software.html
(search)   http://search.cpan.org/search?module=PostScript%3A%3AFont
(download) http://www.perl.com/CPAN/authors/id/JV/
           Archive name: PostScript-Font-x.xx.tar.gz


----------------------------------------------------------------------------
Johan Vromans                                           jvromans@squirrel.nl
Squirrel Consultancy                                Haarlem, the Netherlands
http://www.squirrel.nl                http://www.squirrel.nl/people/jvromans
PGP Key 2048/4783B14D     http://www.squirrel.nl/people/jvromans/pgpkey.html
----------------------- "Arms are made for hugging" ------------------------




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

Date: Thu, 02 Jan 2003 08:54:02 -0500
From: Chris Winters <chris@cwinters.com>
Subject: ANNOUNCE: SPOPS 0.73 released
Message-Id: <3e1cafba$1_4@news.teranews.com>

A new version (0.73) of SPOPS (Simple Perl Object Persistence with
Security) has been released to CPAN. SPOPS is a robust and powerful
module that allows you to serialize objects to DBI, LDAP and GDBM
datasources. You can create most objects without any code, just
configuration.

This release has a few small bugfixes along with a new option to
maintain linked lists of objects stored in DBI. A few deprecated
modules were removed. And the automated documentation build is now
functional, which means all docs are online and fully linked at the
website (http://spops.sourceforge.net/).

URLs:

Download (or use CPAN):
  http://prdownloads.sourceforge.net/spops/SPOPS-0.73.tar.gz?download

Detailed changes:
  http://sourceforge.net/project/shownotes.php?release_id=131009

Thanks!

Chris

-- 
Chris Winters (chris@cwinters.com)
Building enterprise-capable snack solutions since 1988.




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

Date: Wed, 8 Jan 2003 19:15:13 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Existence of an executable of unknown location
Message-Id: <slrnb1pj91.mf5.tadmc@magna.augustmail.com>

Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
> Liz wrote in comp.lang.perl.misc :
>> 

>> Does anyone
>> know of a tool in Perl to do this that doesn't rely on any system
>> calls?
> 
> I just can't imagine how you can possibly know whether a file exists and
> is executable without a system call.
> 
> Or did you mean a call to system() ? Sorry.

> (and don't forget to check the
> return values of system calls)
                ^^^^^^^^^^^^^^^

and of calls to system().   :-)


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


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

Date: Wed, 08 Jan 2003 23:42:08 GMT
From: "127.0.0.1" <craznar01@hotmail.com>
Subject: Finding required .pl's home ?
Message-Id: <Xns92FE62AD2B946127001craznarcom@61.9.128.12>

How do I find (from within) the directory a required .pl file resides in?

I have the following problem:

main.pl - requires "lib/Shared.pl" .... this works fine...

however I need the following:

Shared.pl - requires "xxxx/Defs.pl"

Such that Defs.pl is loaded from the same directory that Shared.pl is in.

I cannot use fixed paths nor modules, and if I change main.pl to

main.pl - requires "lib2/Shared.pl"

then the Defs.pl must also come out of the lib2 directory.

Thanks.

-- 
HOTMAIL T&C: "Thanks for writing to MSN Hotmail. This is XXXX and I am 
writing in response to your inquiry regarding the status of your account. I 
apologize for the inconvenience this has caused you, however, we cannot 
provide you  with the information you needed. Hotmail, in its sole 
discretion, may terminate your account for violation of the letter or spirit 
of the TOS. Upon termination of the Service, your right to use the Service 
immediately ceases. Hotmail shall have no obligation to maintain any content 
in your account or to forward any unread or unsent messages to you or any 
third party. I appreciate your understanding." 
				: Questions to service_x@hotmail.com

 


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

Date: 8 Jan 2003 15:15:08 -0800
From: zirconx9@yahoo.com (Ryan)
Subject: Problems reading a message and getting the attachment (Mail::Internet)
Message-Id: <e7d49913.0301081515.12aeb1ea@posting.google.com>

Short version:
I have a perl script that will receive an email via STDIN.  What's the
best way to split off the attachment into a file on disk, then
retrieve the important headers and maybe anything that was in the body
of the message:

Long version:
I'm trying to write a perl script that will be invoked when an email
is sent to it.  The mail message will be passed to it via STDIN. 
There will be an attachment, and maybe some info in the body and
subject that I need.

I am able to decode the attachment using

use MIME::Parser;
my $parser = new MIME::Parser;
$parser->output_dir("/tmp");
$entity = $parser->parse(\*STDIN);
$entity->dump_skeleton;

This creates three files in /tmp: the attachment, one txt file with
the body in it, and one empty file.  I've found that if I only pass
the section of the body containing the encoded data to $parser->parse
(I would probably use $parser->parse_data() ), that then I only get
the attachment in the /tmp directory.  This is what I want.

So I'm trying to use Mail::Internet to parse the message and give me
pieces of it.  This is what I've done:

use Mail::Internet;
$message = new Mail::Internet \*STDIN ;
@body = $message->body();
print "body is\n";
foreach (@body) { print; }

But the only output I ever get is:
body is
ARRAY(0x81822dc)

I've read through the docs, it says it returns a reference to an
array.  So I've tried all kinds of things like "foreach (\@body)"  and
"\@body = $message..."  but I can't get it to work.

I could just load the message into a variable, then split it based on
the first occurance of \n\n, but that's not as elegant...

Also no matter what route I go I'd have to parse out the attachment
and the body text manually, is there some module that will just do
what I'm trying to do here a little more simply?  I just want the
attachment from an incoming message, along with anything important in
the headers and the text from the body.

Thanks a lot,
-Ryan


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

Date: Wed, 8 Jan 2003 16:30:25 -0800 (PST)
From: John Smith <johnsmith2001usa@yahoo.com>
Subject: Q: Shopping Cart Software
Message-Id: <20030109003025.80739.qmail@web20903.mail.yahoo.com>

Hi,

I am looking for a freeware/GPL shopping cart software
that would hopefully interface with MySQL database.
After doing much search, I have not been able to
locate any such software. Any helpful pointers or
suggestions on where to look would be really
appreciated. Thanks a lot.

John Smith


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


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

Date: Thu, 09 Jan 2003 00:40:15 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Q: Shopping Cart Software
Message-Id: <slrnb1ph7f.f5l.mgjv@verbruggen.comdyn.com.au>

On Wed, 8 Jan 2003 16:30:25 -0800 (PST),
	John Smith <johnsmith2001usa@yahoo.com> wrote:
> Hi,
> 
> I am looking for a freeware/GPL shopping cart software
> that would hopefully interface with MySQL database.
> After doing much search, I have not been able to
> locate any such software. Any helpful pointers or

When I went to Google, and typed in the keywords

shopping cart perl mysql

I got back lots of links. The fourth one on the list looked really
promising.

> suggestions on where to look would be really
> appreciated. Thanks a lot.

Didn't you know about Google? Generally it is frowned upon to ask for
software in technical groups, especially if a machine could have
answered your question easily.

Martien
-- 
                        | 
Martien Verbruggen      | 
Trading Post Australia  | The gene pool could use a little chlorine.
                        | 


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

Date: Wed, 08 Jan 2003 18:39:20 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Recreating directory hierarchy
Message-Id: <3E1CB6A8.6B980E@earthlink.net>

Michele Dondi wrote:
> 
> On Mon, 06 Jan 2003 23:23:28 -0500, Benjamin Goldberg
> <goldbb2@earthlink.net> wrote:
> 
> >      return if -e $dest;
>        ^^^^^^
> 
> Just a minor point, not strictly Perl-related: wouldn't it be better
> to warn() the user too?

I suppose... you want to provide some modified code?

> Notice that I'm aware yours is only a quick example, but since it's
> rather elaborate the OP might think to use it more or less as is and
> possibly get an unexpected behaviour...


-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Thu, 9 Jan 2003 01:47:04 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: reload not terminating process
Message-Id: <slrnb1pl4n.77f.efflandt@typhoon.xnet.com>

On Wed, 08 Jan 2003 14:46:55 -0500, Marshall Dudley <mdudley@execonn.com> wrote:
> I have a perl program that takes about 2 seconds to complete.  I have
> noticed occassionally all the available servers will become busy and top
> reports that this program is running 30 or so intances. When I do a
> server-status, I find that they are all being requested by the same ip.
> Thus it appears that the user has hit reload 30 or more times in a short
> period, causing the program to execute each time.
> 
> I was under the impression that if you hit the reload or stop on a
> browser, it is suppose to send a kill to the process so this doesn't
> happen. I am not sure quite where to look to resolve this issue, in the
> program, unix, apache, or is there anything that can be done at all?

Actually I think it is just that a perl script will die if it tries to 
write to a pipe and that pipe is closed (which it would be if that browser 
is no longer receiving data from that request).

It could be some cracker is either trying a DoS attack or trying to 
influence what your script does.  I have seen that happen with a script 
that creates a page with 50 or so of the most recently submitted links and 
submissions come in constantly so people can keep their link from 
dropping off the list.  That would be easy to do with a looping Perl 
script.

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Wed, 08 Jan 2003 23:09:05 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Simple Filter
Message-Id: <3e1cac48.282060645@news.erols.com>

"TH" <tambaa.Xspam@yahoo.com> wrote:

: Below is a snippet of some code that I am having trouble with. The if
: statement always evaluates to true whether the word [spam] (could be [SPAM])
: is part of the content or not.  I have tried different variations like
: escaping [ and ] but none works.

What, exactly, did you try?

: What am I doing wrong?
: 
: $content="This is junk mail";
: $text="[spam]";
: 
: if ($content =~ /$text/i) {print "Content contains $text\n"; exit;}

You could look at what is being matched.

    if ($content =~ /($text)/i) {
        print "the regex /$text/ matched '$1'\n";
    }

Your hunch about the square brackets being the problem is correct,
though.  They define a character class, so the match will be
successful if the string contains any of the characters s, p, a, or m.

The quotemeta function, or its double-quotish equivalent \Q , may be
useful.

    if( $content =~ /\Q$text\E/ ) {
        print "Content contains '$text'\n";
    }

But index() is a better choice for simply finding a substring.

    if( index( $content, $text ) > -1 ) {
        print "Content contains the substring '$text'\n";
    }



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

Date: Wed, 8 Jan 2003 17:24:18 -0600
From: "TH" <tambaa.Xspam@yahoo.com>
Subject: Re: Simple Filter
Message-Id: <avibuq$2mo$1@tilde.itg.ti.com>

I tried $text="\[spam\]" and it evaluated to true.
With the above, I also tried if ($content =~ /"$text"/i) and this evaluates
to false whether [Spam] is in $content or not. If I replace the double
quotes with opening and closing brackets, it evaluates to true always.


"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3e1cac48.282060645@news.erols.com...
> "TH" <tambaa.Xspam@yahoo.com> wrote:
>
> : Below is a snippet of some code that I am having trouble with. The if
> : statement always evaluates to true whether the word [spam] (could be
[SPAM])
> : is part of the content or not.  I have tried different variations like
> : escaping [ and ] but none works.
>
> What, exactly, did you try?
>
> : What am I doing wrong?
> :
> : $content="This is junk mail";
> : $text="[spam]";
> :
> : if ($content =~ /$text/i) {print "Content contains $text\n"; exit;}
>
> You could look at what is being matched.
>
>     if ($content =~ /($text)/i) {
>         print "the regex /$text/ matched '$1'\n";
>     }
>
> Your hunch about the square brackets being the problem is correct,
> though.  They define a character class, so the match will be
> successful if the string contains any of the characters s, p, a, or m.
>
> The quotemeta function, or its double-quotish equivalent \Q , may be
> useful.
>
>     if( $content =~ /\Q$text\E/ ) {
>         print "Content contains '$text'\n";
>     }
>
> But index() is a better choice for simply finding a substring.
>
>     if( index( $content, $text ) > -1 ) {
>         print "Content contains the substring '$text'\n";
>     }
>




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

Date: Wed, 08 Jan 2003 18:48:13 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Simple Filter
Message-Id: <3E1CB8BD.CE35D2EF@earthlink.net>

TH wrote:
> 
> I tried $text="\[spam\]" and it evaluated to true.
[snip stuff, where you did $content =~ /$text/]

When you assigned $text = "\[spam\]", all you did was prevent the square
brackets from being treated funny in "" interpolation.

You did not actually produce a string containing backslashes.

If you had done any of:

   $text = qr"\[spam\]";
   $text = qr/\[spam\]/; # preferred
   $text = "\Q[spam]\E"; # preferred
   $text = "\\[spam\\]"; # preferred
   $text = '\\[spam\\]'; # preferred
   $text = q"\[spam\]";
   $text = '\[spam\]'; # preferred

Then you would have a string containing the appropriate escapes.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


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

Date: Wed, 8 Jan 2003 17:46:00 -0600
From: "TH" <tambaa.Xspam@yahoo.com>
Subject: Re: Simple Filter
Message-Id: <avid7q$d08$1@tilde.itg.ti.com>

Great!! It worked with one of your suggestions (\\[spam\\]). Thanks a bunch!


"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3E1CB8BD.CE35D2EF@earthlink.net...
> TH wrote:
> >
> > I tried $text="\[spam\]" and it evaluated to true.
> [snip stuff, where you did $content =~ /$text/]
>
> When you assigned $text = "\[spam\]", all you did was prevent the square
> brackets from being treated funny in "" interpolation.
>
> You did not actually produce a string containing backslashes.
>
> If you had done any of:
>
>    $text = qr"\[spam\]";
>    $text = qr/\[spam\]/; # preferred
>    $text = "\Q[spam]\E"; # preferred
>    $text = "\\[spam\\]"; # preferred
>    $text = '\\[spam\\]'; # preferred
>    $text = q"\[spam\]";
>    $text = '\[spam\]'; # preferred
>
> Then you would have a string containing the appropriate escapes.
>
> --
> $..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
> $..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
> $.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
> |=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);




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

Date: Thu, 09 Jan 2003 01:31:43 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Simple Filter
Message-Id: <16kp1v8k6gb5dr3tigc03rv5t6qc79qnhk@4ax.com>

Benjamin Goldberg wrote:

>If you had done any of:
>
>   $text = qr"\[spam\]";
>   $text = qr/\[spam\]/; # preferred
>   $text = "\Q[spam]\E"; # preferred
>   $text = "\\[spam\\]"; # preferred
>   $text = '\\[spam\\]'; # preferred
>   $text = q"\[spam\]";
>   $text = '\[spam\]'; # preferred
>
>Then you would have a string containing the appropriate escapes.

How about quotemeta -- the function underneath the "\Q..." magic?

	$text = quotemeta "[spam]";

-- 
	Bart.


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

Date: Wed, 8 Jan 2003 19:22:29 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Simple Filter
Message-Id: <slrnb1pjml.mf5.tadmc@magna.augustmail.com>

TH <tambaa.Xspam@yahoo.com> wrote:
> "Jay Tilton" <tiltonj@erols.com> wrote in message
> news:3e1cac48.282060645@news.erols.com...
>> "TH" <tambaa.Xspam@yahoo.com> wrote:
>>

>> : I have tried different variations like
>> : escaping [ and ] but none works.
>>
>> What, exactly, did you try?


>> You could look at what is being matched.
>>
>>     if ($content =~ /($text)/i) {
>>         print "the regex /$text/ matched '$1'\n";
>>     }

> I tried $text="\[spam\]" and it evaluated to true.


You could look at what is being matched.

   $test = "[spam]";
and
   $test = "\[spam\]";

result in the same value in $test.


> With the above, I also tried if ($content =~ /"$text"/i) and this evaluates
> to false whether [Spam] is in $content or not. 


Because it must match a double quote character before, and
another after the stuff you are really trying to match.


> If I replace the double
> quotes with opening and closing brackets, it evaluates to true always.


You should look at what is being matched.


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


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

Date: Wed, 08 Jan 2003 18:37:16 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: the length of empty?
Message-Id: <3E1CB62C.7060705@thecouch.homeip.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1



qjzhu wrote:
| Hi folks,
|
|    @test = undef;
|    print scalar @test; #print 1
|
|    @test = ();
|    print scalar @test; #print 0
|
|    what's the difference?

Perhaps this little program will help show you the difference:

use Data::Dumper;

@test = undef;
print Dumper (\@test);

@test = ();
print Dumper (\@test);


Best of luck.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+HLYreS99pGMif6wRAoeLAJ43niOHkZfztgG4+IgLhW+z4ZBXVQCfbsJE
NUhO+1AJ9dwUO8tzL4l8gJM=
=WrCx
-----END PGP SIGNATURE-----



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

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.  

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


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