[25870] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8102 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 22 14:05:23 2005

Date: Sun, 22 May 2005 11:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 22 May 2005     Volume: 10 Number: 8102

Today's topics:
        a simple =~ // question <geoff.cox@notquitecorrectfreeuk.com>
    Re: a simple =~ // question <mark.clementsREMOVETHIS@wanadoo.fr>
    Re: a simple =~ // question <tadmc@augustmail.com>
    Re: Hash String to String/Int <nospam@alexite.com>
        How do I pattern match variables in Perl? <graham@letsgouk.com>
    Re: How do I pattern match variables in Perl? <john@castleamber.com>
    Re: How do I pattern match variables in Perl? <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 22 May 2005 09:33:39 GMT
From: Geoff Cox <geoff.cox@notquitecorrectfreeuk.com>
Subject: a simple =~ // question
Message-Id: <h9k091196sjgg5f0s4lu545rl1kn1pbpic@4ax.com>

Hello,

If I have

<title>
fred - jane
</title>

how can I find the fred - jane part?

I have tried

if ($line =~ /<title>(.*?)</title>/s) {

print $1;

}

but it is not working ...

Thanks

Geoff


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

Date: 22 May 2005 10:50:16 GMT
From: "Mark Clements" <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: a simple =~ // question
Message-Id: <429063e7$0$25021$8fcfb975@news.wanadoo.fr>

Geoff Cox wrote:

> Hello,
> 
> If I have
> 
> <title>
> fred - jane
> </title>
> 
> how can I find the fred - jane part?
> 
> I have tried
> 
> if ($line =~ /<title>(.*?)</title>/s) {
> 
> print $1;
> 
> }
> 
> but it is not working ...

I'm not surprised:

Bareword found where operator expected at 1 line 1, near
"/<title>(.*?)</title"
        (Missing operator before title?)
syntax error at 1 line 1, near "/<title>(.*?)</title"
Search pattern not terminated at 1 line 1.

Did you actually try to compile this?

You need to escape the slash in your pattern.

perldoc perlre

Also, if you are trying to parse XML or HTML there are better methods
than hand-rolling your own regex.

search.cpan.org

Mark


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

Date: Sun, 22 May 2005 08:14:33 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: a simple =~ // question
Message-Id: <slrnd911dp.804.tadmc@magna.augustmail.com>

Geoff Cox <geoff.cox@notquitecorrectfreeuk.com> wrote:

> If I have
> 
><title>
> fred - jane
></title>
> 
> how can I find the fred - jane part?


   my $position = index $_, 'fred - jane';
   print "the 'fred - jane' part is at char number $position\n";


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


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

Date: Sun, 22 May 2005 17:30:33 +0100
From: Alex Banks <nospam@alexite.com>
Subject: Re: Hash String to String/Int
Message-Id: <P6ednVGS1Mo2Lg3fRVnytA@pipex.net>

Jay Tilton wrote:
> Alex Banks <nospam@alexite.com> wrote:
> 
> : Can someone point me to a good cpan module employing a one way hashing 
> : algorithm?
> 
> Look at the various Digest:: modules.
> 

Exactly what I need - thanks Jay.

-- 

Alex Banks
----------------------
Alexite Limited
http://www.alexite.com


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

Date: Sun, 22 May 2005 15:33:31 +0100
From: "Graham" <graham@letsgouk.com>
Subject: How do I pattern match variables in Perl?
Message-Id: <429097ee.0@entanet>

I want to match $variable in an array. My script is as follows:-

foreach ($line(@lines)
{
if ($line =~ /\$variable/i)
{
$counter++;
last;
}
}

The array definitely contains $variable, but I get no match. I've tried 
countless variations of the line:
if ($line =~ /\$variable/i)
all to noavail
Can someone put me out of my misery, please?





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

Date: 22 May 2005 15:40:25 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How do I pattern match variables in Perl?
Message-Id: <Xns965E6C9248E0Dcastleamber@130.133.1.4>

Graham wrote:

> I want to match $variable in an array. My script is as follows:-
> 
> foreach ($line(@lines)

Copy paste code, don't type it

> {
> if ($line =~ /\$variable/i)
                ^
                why?

Use spaces to make it more readable

> {
> $counter++;
> last;
> }
> }

Did you use strict; and use warnings; ?


-- 
John                   Small Perl scripts: http://johnbokma.com/perl/
               Perl programmer available:     http://castleamber.com/
            Happy Customers: http://castleamber.com/testimonials.html
                        


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

Date: Sun, 22 May 2005 12:35:13 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How do I pattern match variables in Perl?
Message-Id: <slrnd91gmh.8iq.tadmc@magna.augustmail.com>

Graham <graham@letsgouk.com> wrote:

> Can someone put me out of my misery, please?


If you post a short and complete program that we can run,
then we surely could...


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


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

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


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