[22318] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4539 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 10 18:55:19 2003

Date: Mon, 10 Feb 2003 15:51:39 -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           Mon, 10 Feb 2003     Volume: 10 Number: 4539

Today's topics:
    Re: Perl scripts utilizing Openview Omniback commands <abigail@abigail.nl>
        problem with ternary operator  <spamtrap@nowhere.com>
    Re: problem with ternary operator <goldbb2@earthlink.net>
    Re: problem with ternary operator <w_ichmann@uni-wuppertal.de>
    Re: problem with ternary operator <w_ichmann@uni-wuppertal.de>
    Re: problem with ternary operator <spamtrap@nowhere.com>
        proxyreq.al? (Jonas Nordstrom)
    Re: pushing elements into multidimensional array (Nataku)
    Re: pushing elements into multidimensional array <uri@stemsystems.com>
    Re: pushing elements into multidimensional array <nobull@mail.com>
        question <shlomit@stam.com>
    Re: question <barryk2@SPAM-KILLER.mts.net>
    Re: question <mpapec@yahoo.com>
    Re: question <graham@letsgouk.com>
    Re: question <goldbb2@earthlink.net>
    Re: Quick regexp question <abigail@abigail.nl>
    Re: Quick regexp question <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Quick regexp question <bart.lateur@pandora.be>
    Re: Quick regexp question (Tony L. Svanstrom)
    Re: Quick regexp question <bart.lateur@pandora.be>
    Re: Quick regexp question (Tony L. Svanstrom)
    Re: Quick regexp question <abigail@abigail.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 08 Feb 2003 23:33:02 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl scripts utilizing Openview Omniback commands
Message-Id: <slrnb4b4te.sb.abigail@alexandra.abigail.nl>

Kevin (kevin_mudd@adp.com) wrote on MMMCDXLVI September MCMXCIII in
<URL:news:bf26a3a6.0302061251.40643fd2@posting.google.com>:
:}  tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb451hg.ed3.tadmc@magna.augustmail.com>...
:} > Kevin <kevin_mudd@adp.com> wrote:
:} > > 
:} > > I've been assigned the task of incorporating Omniback commands into
:} > > perl scripts.  
:} >  
:} > > Was wondering if anyone here has done the same and
:} > > could help me get started.
:} > 
:} > 
:} > Searching for "Omniback" in the "comp.lang.perl.*" newsgroups at:
:} > 
:} >    http://groups.google.com/advanced_group_search
:} > 
:} > finds 2 threads about it.
:}  
:}  Unfortunately, one of them is mine and the other doesn't have a response.


And what would the conclusion about that?



Abigail
-- 
use   lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";


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

Date: Fri, 07 Feb 2003 20:49:55 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: problem with ternary operator 
Message-Id: <iv684v84d591ej92eedpr9igd0iubi3a52@4ax.com>

Hello,

I am not sure why this does not give me the results I expected :

my $timedue = "18";
defined($timedue) ? $timedue .= ":00" : $timedue = "blah";
print $timedue, "\n";

I thought I'd get 18:00 ...

$timedue ? $timedue .= ":00" : $timedue = "blah";
Does the same.

Naturally it works if I do :

if (defined($timedue)) {
	$timedue .= ":00";
}

but isn't that the same as the first part of the ternary operation???

Thanks for any insight.


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

Date: Fri, 07 Feb 2003 16:09:08 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: problem with ternary operator
Message-Id: <3E442074.1A2A15D0@earthlink.net>

Andrew Lee wrote:
> 
> Hello,
> 
> I am not sure why this does not give me the results I expected :
> 
> my $timedue = "18";
> defined($timedue) ? $timedue .= ":00" : $timedue = "blah";

This parses as:

(defined($timedue) ? $timedue .= ":00" : $timedue) = "blah";

Change it to:

defined($timedue) ? $timedue .= ":00" : ($timedue = "blah");

And it will work as desired.

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: Fri, 07 Feb 2003 21:55:52 +0100
From: Ingo Wichmann <w_ichmann@uni-wuppertal.de>
Subject: Re: problem with ternary operator
Message-Id: <b216p9$1a6$07$1@news.t-online.com>

Andrew Lee schrieb:
> I am not sure why this does not give me the results I expected :
> 
> my $timedue = "18";
> defined($timedue) ? $timedue .= ":00" : $timedue = "blah";
> print $timedue, "\n";
> 
> I thought I'd get 18:00 ...
> 
> $timedue ? $timedue .= ":00" : $timedue = "blah";
> Does the same.
> 
> Naturally it works if I do :
> 
> if (defined($timedue)) {
> 	$timedue .= ":00";
> }
> 
> but isn't that the same as the first part of the ternary operation???

my $timedue = "18";
print defined($timedue) ? $timedue .= ":00" : $timedue = "blah";

Ingo

-- 
Meine Mail-Adresse enthält keinen Unterstrich



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

Date: Fri, 07 Feb 2003 21:58:01 +0100
From: Ingo Wichmann <w_ichmann@uni-wuppertal.de>
Subject: Re: problem with ternary operator
Message-Id: <b216t1$1a6$07$2@news.t-online.com>

Ingo Wichmann schrieb:
> my $timedue = "18";
> print defined($timedue) ? $timedue .= ":00" : $timedue = "blah";

this one is wrong.
forget it.

Ingo
-- 
Meine Mail-Adresse enthält keinen Unterstrich



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

Date: Fri, 07 Feb 2003 21:05:20 GMT
From: Andrew Lee <spamtrap@nowhere.com>
Subject: Re: problem with ternary operator
Message-Id: <2r784v8jmjcg9bi978tagl7oqla3s1cobt@4ax.com>

On Fri, 07 Feb 2003 16:09:08 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:

>Andrew Lee wrote:
>> 
>> Hello,
>> 
>> I am not sure why this does not give me the results I expected :
>> 
>> my $timedue = "18";
>> defined($timedue) ? $timedue .= ":00" : $timedue = "blah";
>
>This parses as:
>
>(defined($timedue) ? $timedue .= ":00" : $timedue) = "blah";

Ahhhh!!

Thanks for upgrading the wattage on my lightbulb  :-)



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

Date: 10 Feb 2003 07:10:58 -0800
From: jonas.nordstrom@frispar.se (Jonas Nordstrom)
Subject: proxyreq.al?
Message-Id: <f634664c.0302100710.6a764567@posting.google.com>

This test code (which is originally a part of a larger program) fails
after upgrading perl to 5.8.0.
the error message puzzles me, where does the reference to proxyreq.al
come from, and what does it mean?


package Apache::TestRewriter;

use strict;
use vars qw(@ISA $VERSION %LINK_ELEMENT);
use Apache::Constants qw(:common);
use LWP::UserAgent ();
use Apache::URI ();
use URI::URL;
use HTML::Filter;

@ISA = qw(HTML::Parser);

sub new {
   my $pack = shift;
   my $self = $pack->SUPER::new();
   print("test");
   $self;
}

sub handler() {
   my $r = shift;
return DECLINED if $r->proxyreq;
 my $pp = Apache::TestRewriter->new;

   return $r->status;
}

1;
__END__


//////////////////////////////////
[Mon Feb 10 15:59:59 2003] [error] Can't locate
auto/Apache/TestRewriter/proxyreq.al in @INC (@INC contains:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .
/usr/local/apache/ /usr/local/apache/lib/perl) at
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Apache/TestRewriter.p
m line 28

Jonas Nordstrom


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

Date: 10 Feb 2003 07:40:34 -0800
From: Crapnut566@yahoo.com (Nataku)
Subject: Re: pushing elements into multidimensional array
Message-Id: <7e48fc99.0302100740.31c2b641@posting.google.com>

Compared to a fully featured multidimensional array such as one found
in C++, where it can grow/shrink etc, without manual intervention.  An
array of array references in perl pretty much has to be watched over
by the programmer, and is specific to one task.

Im sure you could wrap a perl class around an array of array
references though ... hm ... kind of suprised no one has done that yet
- at least to my knowledge.

"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in message news:<b1ufrt$fd$1@nets3.rz.RWTH-Aachen.DE>...
> [ please do not top-post ]
> 
> Also sprach Nataku:
> 
> > Perl doesnt come with native support for multidimensional arrays, at
> > least not to my knowledge.  You can create a pseudo ( and limited in
> > functionality ) multidimensional array by filling an array with array
> > references that you have defined.
> 
> Define 'limited in functionality'. Limited compared to what?
> 
> Tassilo


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

Date: Mon, 10 Feb 2003 16:44:42 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: pushing elements into multidimensional array
Message-Id: <x7ptq0ccg7.fsf@mail.sysarch.com>

>>>>> "N" == Nataku  <Crapnut566@yahoo.com> writes:

  N> Compared to a fully featured multidimensional array such as one found
  N> in C++, where it can grow/shrink etc, without manual intervention.  An
  N> array of array references in perl pretty much has to be watched over
  N> by the programmer, and is specific to one task.

that makes no sense. nada, zilch, bubkis, zero.

what manual intervention do you mean? how is an array (of any dimension)
specific to one task? how does c++ add elements to the highest level of
an array without major munging? perl can do that without any work. you
seem to have very poor understanding of perl in general and arrays as well.

  N> Im sure you could wrap a perl class around an array of array
  N> references though ... hm ... kind of suprised no one has done that yet
  N> - at least to my knowledge.

there is no need for that. and look into pdl if you want fast classic arrays.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


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

Date: 10 Feb 2003 18:24:32 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: pushing elements into multidimensional array
Message-Id: <u9d6m06ljz.fsf@wcl-l.bham.ac.uk>

The aptly named Crapnut566@yahoo.com (Nataku) rudely top-posts
desipite being asked not to:

> "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in message news:<b1ufrt$fd$1@nets3.rz.RWTH-Aachen.DE>...
> > [ please do not top-post ]
> > 
> > Also sprach Nataku:
> > 
> > > Perl doesnt come with native support for multidimensional arrays, at
> > > least not to my knowledge.  You can create a pseudo ( and limited in
> > > functionality ) multidimensional array by filling an array with array
> > > references that you have defined.
> > 
> > Define 'limited in functionality'. Limited compared to what?
>
> Compared to a fully featured multidimensional array such as one found
> in C++,

Core C++ doesn't have multidimensional arrays but I suppose it may be
in one of the standard classes - I haven't used C++ for a while.

Perhaps you could give us a URL that describes the fuctionality of the
class you are talking about since this is a Perl group and people
round here don't necessarily know C++.

> where it can grow/shrink etc, without manual intervention.

Is that a good thing?

>  An array of array references in perl pretty much has to be watched
> over by the programmer,

What do you mean by this statement.

> and is specific to one task.

What do you mean by this statement.

> Im sure you could wrap a perl class around an array of array
> references though ... hm ... kind of suprised no one has done that yet
> - at least to my knowledge.

Just what additional functionality are you looking for?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Sun, 9 Feb 2003 16:08:45 +0200
From: "Shlomit" <shlomit@stam.com>
Subject: question
Message-Id: <3e4660ed$1@news.012.net.il>

Hi,

I saw the following code in PERL script:

$data =~ /(\w{1})\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)/;



Can anyone explain me what does it mean???

Shlomit




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

Date: Sun, 9 Feb 2003 08:33:41 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: question
Message-Id: <MPG.18b022bdf2e9374e9896f2@news.mts.net>


In article <3e4660ed$1@news.012.net.il>, Shlomit (shlomit@stam.com) 
says...
> Hi,
> 
> I saw the following code in PERL script:
> 
> $data =~ /(\w{1})\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)/;
> 
> 
> 
> Can anyone explain me what does it mean???
> 
> Shlomit
> 
> 
> 

In Perl regexp, "\w" matches a word character (i.e. a letter,
underscore or digit)

an expression followed by an integer values in {} specifies the number of 
times the expression must occur to be a successful match; therefor {1}
indicates there must be one of the indicated expression.

a "\" followed by a special character, means to treat that special 
character litterally instead of using its special meaning.

an expression surrounded by () means to save the value of the expression
so it can be accessed after the pattern match in a "numbered variable"
(i.e. $1 , $2 , etc...)

-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Sun, 09 Feb 2003 16:27:34 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: question
Message-Id: <34rc4v44a4is3l0hp1atpci9dlfn9qso00@4ax.com>

X-Ftn-To: Shlomit 

"Shlomit" <shlomit@stam.com> wrote:
>Hi,
>
>I saw the following code in PERL script:
>
>$data =~ /(\w{1})\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)/;
>
>Can anyone explain me what does it mean???

It means, match the contest of $data with pattern between //

(\w{1})\|
----------
\w    - match one char from word class(A..Z,a..z,0..9,_)
\w{1} - the same thing as above, so {1} isn't actually needed 
        (usually it's used to match something n-times {n})

(\w{1}) - braces tells to capture contents of our match and store it to 
          special variables(1st brace to $1, 2nd to $2, etc.)
\|      - previous match should be followed by pipe, |
          since | is metachar, it should be escaped with \ like all
          metachars


(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)
----------
\w*  - match \w zero or more times(as many times as possible),
       equivalent to \w{0,} but more readable


If you want more, head to
http://japhy.perlmonk.org/book/


-- 
Matija


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

Date: Sun, 9 Feb 2003 21:02:52 -0000
From: "Graham" <graham@letsgouk.com>
Subject: Re: question
Message-Id: <3e46c1aa.0@entanet>

Someone is probably testing to see if the variable $data matches a specific
format. Firstly, understand the following:-
w  = a word character (letter, number, or underscore)
w{1} = a single occurence of a word character
w* = zero or more occurrences of a word character
\| = the vertical bar character

From the above you should be able to figure that the writer is testing to
see if $data matches 'single word character|zero or multiple word
characters|etc ett

So the following value of $data would match:
'6|chemical_weapons|mosul|north_iraq|launch_code||7492'

and so would this
'2|inter|150000|fatalities|defcon_red|4|'

but the following would not match:
'what|on_earth|is this%bl**dy|war_about?'

Graham



"Shlomit" <shlomit@stam.com> wrote in message
news:3e4660ed$1@news.012.net.il...
> Hi,
>
> I saw the following code in PERL script:
>
> $data =~ /(\w{1})\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)\|(\w*)/;
>
>
>
> Can anyone explain me what does it mean???
>
> Shlomit
>
>




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

Date: Sun, 09 Feb 2003 23:10:22 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: question
Message-Id: <3E47262E.5A528891@earthlink.net>

Graham wrote:
> 
> Someone is probably testing to see if the variable $data matches a
> specific format. Firstly, understand the following:-
> w  = a word character (letter, number, or underscore)

No.  w matches the letter w.  \w matches a word character.

[snip]

-- 
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
 landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"


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

Date: 09 Feb 2003 01:32:31 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Quick regexp question
Message-Id: <slrnb4bbtf.sb.abigail@alexandra.abigail.nl>

Bernard El-Hagin (bernard.el-hagin@DODGE_THISlido-tech.net) wrote on
MMMCDXLVII September MCMXCIII in <URL:news:Xns931B7C6D5A13Belhber1lidotechnet@62.89.127.66>:
[]  Sandman wrote:
[]  
[] > I have four string:
[] >    
[] >     Managing director: John Jensen
[] >     Supreme VP: Tim Adams
[] >     Sales key person: Math Edwards
[] >     Junk: Junk
[] > 
[] > And I am in a while that has one of the above in $_. Now, I would like
[] > to remove everything up to the :-character, if it contains two or
[] > three words (i.e. not 'Junk: Junk'). First I did a:
[] > 
[] >     s/^(.*?)://;
[] >     $title=$1;
[]  
[]  
[]  If I understand correctly, all you have to do is make the match greedy.
[]  
[]  s/^(.*)://;
[]  $title = $1;

Did you try?

[]  You should also make sure that you got a match before you use $1. Maybe:
[]  
[]  $title = $1 if s/^(.*)://;


Ah, yeah, of course. If .* is used in a regexp in a statement modifier,
it will match strings consisting of 2 or 3 words.




Abigail
-- 
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
           ${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'


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

Date: Mon, 10 Feb 2003 06:16:22 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Quick regexp question
Message-Id: <Xns931E494502E4Delhber1lidotechnet@62.89.127.66>

Abigail wrote:

> Bernard El-Hagin (bernard.el-hagin@DODGE_THISlido-tech.net) wrote on
> MMMCDXLVII September MCMXCIII in
> <URL:news:Xns931B7C6D5A13Belhber1lidotechnet@62.89.127.66>: [] 
> Sandman wrote: []  
> [] > I have four string:
> [] >    
> [] >     Managing director: John Jensen
> [] >     Supreme VP: Tim Adams
> [] >     Sales key person: Math Edwards
> [] >     Junk: Junk
> [] > 
> [] > And I am in a while that has one of the above in $_. Now, I would
> like [] > to remove everything up to the :-character, if it contains
> two or [] > three words (i.e. not 'Junk: Junk'). First I did a:
> [] > 
> [] >     s/^(.*?)://;
> [] >     $title=$1;
> []  
> []  
> []  If I understand correctly, all you have to do is make the match
> greedy. []  
> []  s/^(.*)://;
> []  $title = $1;
> 
> Did you try?


Yes I did. It worked for me _as I understood the problem_. I made it 
clear that I may not have understood the problem with the words "If I 
understand correctly". If there's any part of that you  didn't understand  
let me know and I'll walk you through it.

 
> []  You should also make sure that you got a match before you use $1.
> Maybe: []  
> []  $title = $1 if s/^(.*)://;
> 
> 
> Ah, yeah, of course. If .* is used in a regexp in a statement
> modifier, it will match strings consisting of 2 or 3 words.


Sarcasm is so last Tuesday.


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Mon, 10 Feb 2003 09:25:02 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Quick regexp question
Message-Id: <psre4v4n0h88q8dsgob9ia3rbqkvalj5v5@4ax.com>

Sandman wrote:

>I have four string:
>   
>    Managing director: John Jensen
>    Supreme VP: Tim Adams
>    Sales key person: Math Edwards
>    Junk: Junk
>
>And I am in a while that has one of the above in $_. Now, I would like to 
>remove everything up to the :-character, if it contains two or three words 
>(i.e. not 'Junk: Junk'). First I did a:
>
>    s/^(.*?)://;
>    $title=$1;
>
>(since I want to save the snipped string)

Why donb't you turn that around? Leave the original string as it is, and
extract the part you want to keep.

	($name) = /:\s*(.*)/;

(I assume you're not interested in any spaces immediately after the
colon.)

-- 
	Bart.


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

Date: Mon, 10 Feb 2003 10:23:28 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Quick regexp question
Message-Id: <1fq5wyr.1pv5ky91khe822N%tony@svanstrom.com>

Bart Lateur <bart.lateur@pandora.be> wrote:

> Sandman wrote:
> 
> >I have four string:
> >   
> >    Managing director: John Jensen
> >    Supreme VP: Tim Adams
> >    Sales key person: Math Edwards
> >    Junk: Junk
> >
> >And I am in a while that has one of the above in $_. Now, I would like to
> >remove everything up to the :-character, if it contains two or three words
> >(i.e. not 'Junk: Junk'). First I did a:
> >
> >    s/^(.*?)://;
> >    $title=$1;
> >
> >(since I want to save the snipped string)
> 
> Why donb't you turn that around? Leave the original string as it is, and
> extract the part you want to keep.
> 
>       ($name) = /:\s*(.*)/;
> 
> (I assume you're not interested in any spaces immediately after the
> colon.)

 You also assumed that he'd changed that "two or three words"
requirement...


-- 
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #

    perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'


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

Date: Mon, 10 Feb 2003 15:05:27 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Quick regexp question
Message-Id: <moff4v0rktbi42v98oe1e4kth6f0l8dm4q@4ax.com>

Tony L. Svanstrom wrote:

>>       ($name) = /:\s*(.*)/;
>> 
>> (I assume you're not interested in any spaces immediately after the
>> colon.)
>
> You also assumed that he'd changed that "two or three words"
>requirement...

Ah I see now. He want's to keep the "junk". Some people are strange...

The pattern then can be: if there's a space before the colon.

	($name) = /\S\s+\S+:\s*(.*)/
	  or $name = $_;  # keep the junk

Note that it's not a good idea to declare the variable on the same line,
for this particular case.

-- 
	Bart.


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

Date: Mon, 10 Feb 2003 18:09:23 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Quick regexp question
Message-Id: <1fq6ifr.j83amdih1ts2N%tony@svanstrom.com>

Bart Lateur <bart.lateur@pandora.be> wrote:

> Tony L. Svanstrom wrote:
> 
> >>       ($name) = /:\s*(.*)/;
> >> 
> >> (I assume you're not interested in any spaces immediately after the
> >> colon.)
> >
> > You also assumed that he'd changed that "two or three words"
> >requirement...
> 
> Ah I see now. He want's to keep the "junk". Some people are strange...
> 
> The pattern then can be: if there's a space before the colon.
> 
>       ($name) = /\S\s+\S+:\s*(.*)/
>         or $name = $_;  # keep the junk
> 
> Note that it's not a good idea to declare the variable on the same line,
> for this particular case.

 Weeeell... now you assumed that he'd extended his requirements to be 2
or more words, without an upper limit... =/


-- 
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #

    perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'


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

Date: 10 Feb 2003 19:45:47 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Quick regexp question
Message-Id: <slrnb4g0bb.s72.abigail@alexandra.abigail.nl>

Bernard El-Hagin (bernard.el-hagin@DODGE_THISlido-tech.net) wrote on
MMMCDL September MCMXCIII in <URL:news:Xns931E494502E4Delhber1lidotechnet@62.89.127.66>:
__  Abigail wrote:
__  
__ > Bernard El-Hagin (bernard.el-hagin@DODGE_THISlido-tech.net) wrote on
__ > MMMCDXLVII September MCMXCIII in
__ > <URL:news:Xns931B7C6D5A13Belhber1lidotechnet@62.89.127.66>: [] 
__ > Sandman wrote: []  
__ > [] > I have four string:
__ > [] >    
__ > [] >     Managing director: John Jensen
__ > [] >     Supreme VP: Tim Adams
__ > [] >     Sales key person: Math Edwards
__ > [] >     Junk: Junk
__ > [] > 
__ > [] > And I am in a while that has one of the above in $_. Now, I would
__ > like [] > to remove everything up to the :-character, if it contains
__ > two or [] > three words (i.e. not 'Junk: Junk'). First I did a:
__ > [] > 
__ > [] >     s/^(.*?)://;
__ > [] >     $title=$1;
__ > []  
__ > []  
__ > []  If I understand correctly, all you have to do is make the match
__ > greedy. []  
__ > []  s/^(.*)://;
__ > []  $title = $1;
__ > 
__ > Did you try?
__  
__  
__  Yes I did. It worked for me _as I understood the problem_.

Really? Did you try the example the OP gave? Did your suggestion leave
'Junk: Junk' alone, as specified?

__                                                             I made it 
__  clear that I may not have understood the problem with the words "If I 
__  understand correctly". If there's any part of that you  didn't understand  
__  let me know and I'll walk you through it.

Right. I don't understand how 's/^(.*)://;' leaves 'Junk: Junk' alone.
I can't reproduce that in any version of Perl I have. Please walk me
through your solution.



Abigail
-- 
               split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_)  {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

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


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