Re: regular expression, this but not that

2011-09-18 Thread Glenn Linderman

On 9/18/2011 9:38 PM, Jer A wrote:

All,

lets say i want to test if a string contains pig but not dog 
and/or not cat


i tried something like this:

 =~ m/[^dog]|[^cat]|pig/ig

what is the best way of going about this, using one regex?

your help is very much appreciated,


perhaps the following:
if ($s =~ m/((dog|cat)?.*pig.*(dog|cat)?)/ig   $1 == pig)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression, this but not that

2011-09-18 Thread Gabor Szabo
On Mon, Sep 19, 2011 at 7:38 AM, Jer A jeremy...@hotmail.com wrote:
 All,

 lets say i want to test if a string contains pig but not dog and/or not
 cat

 i tried something like this:

  =~ m/[^dog]|[^cat]|pig/ig

 what is the best way of going about this, using one regex?

 your help is very much appreciated,
 thanks.


Hi Jeremy,

I am not sure why would you want to use only one regex
and IMHO it would be very complex to write that.
It would make your code both unreadable and slow.


I'd use two regexes for that:

if ($str =~ m/pig/ and $str !~ /dog|cat/) {
}

Add the railing /i if you want this to be case insensitive.
The /g is not needed as the first pig will be ok
and the first dog or cat would also be indication that the match should fail.

regards
   Gabor

-- 
Gabor Szabo                     http://szabgab.com/
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression with variable

2006-11-11 Thread Jerry Kassebaum
I have a regular expression problem

how do i use scalar variables in substitution and complex matching?

eg I want the following to work.

$string =~ s/^$variable//;

$string =~ m/^([^$variable]*)/;


thanks in advance for your help.

-Jeremy A.

$x = Cowboy;
$y = ow;
$x =~ s/$y/-/;
print $x;
;
# Output is C-boy

_
Get FREE company branded e-mail accounts and business Web site from 
Microsoft Office Live 
http://clk.atdmt.com/MRT/go/mcrssaub0050001411mrt/direct/01/

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression question

2006-08-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Title: Regular expression question



From: 
[EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Cai, Lucy (L.)Sent: Monday, July 31, 2006 17:21To: 
Cai, Lucy (L.); perl-win32-users@listserv.ActiveState.com; 
perl-unix-users@listserv.ActiveState.com; 
[EMAIL PROTECTED]; 
[EMAIL PROTECTED]Subject: Regular 
_expression_ question

I have a file such as: 
My $file = "c:\temp\zips\ok.txt"; 
How can I split the $file to get the only 
path: 
My $dir = "c:\temp\zips"; My $file = "ok.txt"; 
Thanks in advance! 
Lucy
Better to use File::Basename which will break it out foryou. Comes 
as part of std Perl.
Wags ;)
**
This message contains information that is confidential and proprietary to FedEx Freight or its affiliates.  It is intended only for the recipient named and for the express  purpose(s) described therein.  Any other use is prohibited.
**

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression question

2006-08-01 Thread Joe Discenza
Title: Regular expression question



Cai, Lucy (L.) wrote, on Monday, July 31, 2006 8:21 
PM
: My 
$file = "c:\temp\zips\ok.txt"; 

: How can 
I split the $file to get the only path: 
: My $dir 
= "c:\temp\zips";: My $file = "ok.txt"; 
May I 
suggest you use File:Basename instead of a regex?
Joe
Joseph Discenza, Senior Programmer/Analystmailto:[EMAIL PROTECTED]Carleton 
Inc. http://www.carletoninc.com574.243.6040 
ext. 300Fax: 574.243.6060 


  
  
  From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED] On Behalf Of 
  : Cai, Lucy (L.); perl-win32-users@listserv.ActiveState.com; 
  perl-unix-users@listserv.ActiveState.com; 
  [EMAIL PROTECTED]; 
  [EMAIL PROTECTED]Subject: Regular 
  _expression_ question
  
  I have a file such as: 
  Thanks in advance! 
  Lucy 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression question

2006-04-27 Thread Chris Wagner
At 09:45 PM 4/26/2006 -0400, Cai, Lucy \(L.\) wrote:
return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);
$Output =/vobs/na_mscs_pvob
/ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public (ucmvob,replicated)
 
What I want to do is if this tring include word ucmvob, then return 1,
else return 0.

If u just want the word ucmvob then u don't need any of the rest of the
regex u put in there.  And I think the outer parenthesis on the return could
be messing u up too.  Not sure without testing but that could be trying to
return an array.  This will work:

$Output =~ m/ucmvob/ ? return 1 : return 0;

If u want to retain ur previous return format then do this:

return scalar $Output =~ m/ucmvob/; # returns no. of matches i.e. 1 or 0







--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede malis

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression question

2006-04-26 Thread Timothy Johnson

Well, there are a couple of issues here.  First off, I don't think this
would even compile, because you used /s instead of \s.  Secondly, your
regex is looking for:



.*  zero or more of any character
(unnecessary, since you didn't anchor the start of the
string)

\(ucmvob\)  the string '(ucmvob)'

\s* zero or more whitespace characters

$   the end of the string

--

I think what you might be looking for is something similar to this:

/\(ucmvob\)/

or possibly this:

/\(ucmvob,.*?\)/

which would match 'ucmvob', a comma, and any other text (non-greedy
match) between parentheses.


Of course, I can't test this where I am, but that should get you
started.



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Cai, Lucy (L.)
Sent: Wednesday, April 26, 2006 6:46 PM
To: perl-win32-users@listserv.ActiveState.com
Cc: perl-win32-users@listserv.ActiveState.com
Subject: Regular expression question

Hi, all,
 
I have a question about regular expression:
 
my code is like this:
**
sub IsPVob
{
my ($Vob) = @_;
 
my $Output = `cleartool lsvob $Vob`;
die IsPVob can't list vob $Vob  if $?;
 
return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);

}
**
 
$Output =/vobs/na_mscs_pvob
/ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public (ucmvob,replicated)
 
What I want to do is if this tring include word ucmvob, then return 1,
else return 0.
 
My code does not work, it return 0. Could you please see why it is like
this? or do you have a better idea?
 
Thanks a lot inadvance!
 
Lucy
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression question

2006-04-26 Thread Ted Schuerzinger
Cai, Lucy (L.) [EMAIL PROTECTED] graced perl with these words of wisdom:

 return (($Output =~ /.*\(ucmvob\)/s*$/) ? 1 : 0);
 
 }
 **
  
 $Output =/vobs/na_mscs_pvob
 /ccstore/ecc/vobs_fcis321/na_mscs_pvob.vbs public (ucmvob,replicated)
  
 What I want to do is if this tring include word ucmvob, then return 1,
 else return 0.

If I understand your code correctly, you're looking for the string 
(ucmvob) -- note that you don't have anything in your regex between the 
b and the escaped close partentheses.

In $Output, that string doesn't exist, as the b in ucmvob is followed by a 
comma.

-- 
Ted fedya at bestweb dot net
Oh Marge, anyone can miss Canada, all tucked away down there
--Homer Simpson

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression

2005-11-29 Thread Foo Ji-Haw



$String = 'Integration Test Lead: \ul\b0  \tab\tab\tab Kimberly
Kim\tab\tab\tab\tab\tab\tab  \par';

How would I extract Kimberly Kim from the string using regular
expression. Is there a way using expression to skip \[characters] (
like \tab ) and search for only real words, maybe between spaces.

Have you thought of using the \t\t\t as a marker for the start of the 
string you want to capture, like:

$string =~ /\t\t\t([^\t]+)/


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression

2005-11-28 Thread Chris Wagner
At 05:40 PM 11/28/2005 -0800, Wong, Danny H. wrote:
$String = 'Integration Test Lead: \ul\b0  \tab\tab\tab Kimberly
Kim\tab\tab\tab\tab\tab\tab  \par';

How would I extract Kimberly Kim from the string using regular
expression. Is there a way using expression to skip \[characters] (
like \tab ) and search for only real words, maybe between spaces.


So u want to be able to search for multi word strings, that may or may not
be interrupted by whitespace or other junk characters?

$match = $string =~ m/(Kimberly\W*\s\W*Kim)/s;
@match = $string =~ m/(Kimberly)\W*\s\W*(Kim)/s;
@match = $string =~ m/($firstname)\W*\s\W*($lastname)/s;
($firstname, $lastname) = $string =~ m/($firstname)\W*\s\W*($lastname)/s;

\s is whitespace and \W is any non alphanumeric garbage.  If any high ASCII
characters are valid name letters it's a little more complicated but
basically the same format.





--
REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =--
...ne cede malis

0100

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression

2005-09-15 Thread Foo Ji-Haw
Don't know if this works, but have you tried:

$string = 1\\.2\\.3;

- Original Message - 
From: Wong, Danny H. [EMAIL PROTECTED]
To: Sisyphus [EMAIL PROTECTED]; Jan Dubois
[EMAIL PROTECTED]; perl-win32-users
perl-win32-users@listserv.ActiveState.com
Sent: Thursday, September 15, 2005 2:28 PM
Subject: Regular expression


 Hi Perl Gurus,
 I have a regular expression question.
 I have a variable
 $Number = 1.2.3.4

 When I use the variable $Number as part of my regular expression, the
 . character gets interpret as any character. How do I make it a
 literal . that I'm searching for?
 Example:
 $String = This is a numeric string 1.2.3.411 embedded within another
 string 3.4.5.6
 $String =~ m/$Number/I; This returns 1.2.3.411 true, when it
 shouldn't.

 Thanks for your help!

 Thanks
 Danny Wong
 SCM Engineer
 PowerTV Inc.,


 - - - - - - - Appended by PowerTV, A division of Scientific
Atlanta. - - - - - - -
 This e-mail and any attachments may contain information that is
confidential, proprietary, privileged or otherwise protected by law. The
information is solely intended for the named addressee (or a person
responsible for delivering it to the addressee). If you are not the intended
recipient of this message, you are not authorized to read, print, retain,
copy or disseminate this message or any part of it. If you have received
this e-mail in error, please notify the sender immediately by return e-mail
and delete it from your computer.

 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression

2005-09-15 Thread Сергей Черниенко
Hello Danny,

Thursday, September 15, 2005, 9:28:44 AM, You wrote:

WDH $Number = 1.2.3.4

WDH When I use the variable $Number as part of my regular expression, the
WDH . character gets interpret as any character. How do I make it a
WDH literal . that I'm searching for?  
WDH Example:
WDH $String = This is a numeric string 1.2.3.411 embedded within another
WDH string 3.4.5.6
WDH $String =~ m/$Number/I; This returns 1.2.3.411 true, when it
WDH shouldn't.

 If You mean that '1.2.3.4' is a word i.e. has whitespaces before and
 after it, than your pattern have to be

 $String =~ /$Number\b/;

 That match ' 1.2.3.4 ' and do not match '1.2.3.411'. Dots in $Number
 do not affect matching because variable substituted as string. And
 note: 'i' modifier MUST be lowercase.
-- 
Best regards,
 Сергейmailto:[EMAIL PROTECTED]


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression

2005-09-15 Thread $Bill Luebkert
Wong, Danny H. wrote:

 Hi Perl Gurus,
   I have a regular expression question.
 I have a variable
 $Number = 1.2.3.4
 
 When I use the variable $Number as part of my regular expression, the
 . character gets interpret as any character. How do I make it a
 literal . that I'm searching for?  
 Example:
 $String = This is a numeric string 1.2.3.411 embedded within another
 string 3.4.5.6
 $String =~ m/$Number/I; This returns 1.2.3.411 true, when it
 shouldn't.

Easiest way is
$String =~ m/\Q$Number\E/i;

You can also use quotemeta (look it up) or escape your .'s in $number (ie: 
1\.2\.3\.4).

PS:  It's not good etiquette to CC people who already read the list.
-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular expression

2005-09-15 Thread $Bill Luebkert
$Bill Luebkert wrote:

 You can also use quotemeta (look it up) or escape your .'s in $number (ie: 
 1\.2\.3\.4).

That should have been '1\.2\.3\.4' or 1\\.2\\.3\\.4.

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression Help Please

2005-02-08 Thread Gerber, Christopher J
-Original Message-
 One of the columns I'm calling out of my database is the email one. I'ts
in MAPI format,
 so I need to extract the very last part. So the bottom example I would
need to grab
 
 JDoe
 
 MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe

Steve,

An easy way might be:

$_ = 'MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe';
/([^=]+)$/;
print $1;

Chris


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be 
privileged. It is intended for the addressee(s) only. Access to this E-mail by 
anyone else is unauthorized. If you are not an addressee, any disclosure or 
copying of the contents of this E-mail or any action taken (or not taken) in 
reliance on it is unauthorized and may be unlawful. If you are not an 
addressee, please inform the sender immediately.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression Help Please

2005-02-08 Thread Charles K. Clarkson
From: [EMAIL PROTECTED]  wrote:

: One of the columns I'm calling out of my database is the email
: one. I'ts in MAPI format, so I need to extract the very last
: part. So the bottom example I would need to grab
: 
: JDoe
: 
: MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe
: 
: 
: Then I can append the rest as
: 
: [EMAIL PROTECTED]
: 
: Every one is the same format,
: 
: MAPI:{Smith, Jane}EX:/o=Company/ou=Site/cn=Recipients/cn=LJSmith
: 
: Any help greatly appreciated.


my $field = 'MAPI:{Smith,
Jane}EX:/o=Company/ou=Site/cn=Recipients/cn=LJSmith';
my $email;
if ( $field =~ /=([^=]+)$/ ) {
$email = [EMAIL PROTECTED];

} else {
# Uh Oh!
}


The '$' is a zero length placeholder for the end of
the string. [^=] is a character class of all characters
which are not the equal sign. Anything inside parenthesis
'()' will be captured to $1.

HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression Help Please

2005-02-08 Thread Chris Wagner
You can get that plus some other info with this regex:

$string = 'MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe';
($lastname, $firstname, $mailid) = $string =~ m/^.+?\{(\w+),
(\w+)\}.+?cn\=(\w+)$/;


At 09:46 PM 2/8/05 +, steve silvers wrote:
One of the columns I'm calling out of my database is the email one. I'ts in 
MAPI format, so I need to extract the very last part. So the bottom example 
I would need to grab

JDoe





___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression Help Please

2005-02-08 Thread Chris


-Original Message-

One of the columns I'm calling out of my database is the email one. I'ts in 
MAPI format, so I need to extract the very last part. So the bottom example 
I would need to grab

JDoe

MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe


Then I can append the rest as

[EMAIL PROTECTED]

Every one is the same format,

MAPI:{Smith, Jane}EX:/o=Company/ou=Site/cn=Recipients/cn=LJSmith

Any help greatly appreciated.
Thanks in advance
Steve

---

I know there's probably a better way to do this, but...

my $field='MAPI:{Doe, John}EX:/o=Company/ou=Site/cn=Recipients/cn=JDoe';
my @bla = split(/=/, $field);
print pop(@bla);


- Chris




___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-02 Thread Beckett Richard-qswi266
 So I get:
 
 /^-?(?:\d+\.?\d*|\.\d+)$/

I'm being thrown by the ?:

What's that all about?

R.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2004-04-01 Thread Cai_Lixin
Thanks for the replying.

I have another question, if I have a string like 
$a = this is a (test);

How can I change it to 
$a = this_is_a_test;

How can I remove ()?

Thanks

Lixin


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
$Bill Luebkert
Sent: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, March 31, 2004 16:49
 To: [EMAIL PROTECTED]
 Subject: regular expression question
 
 I have a $a which
 
  
 
 $a = this is a test;
 
  
 
 How can I change $a like:
 
  
 
 $a = this_is_a_test;
 
  
 
 No problem using $a, but if I were you, I would not.  In the Perl
 sort $a, $b are the default variables to use and I would stay away if I
 were you.
 
  
 
 That said,
 
 $a =~ s/ /_/g;

You could also use tr (slightly faster) :

$a =~ tr/ /_/;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic
http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2004-04-01 Thread Stacy Doss
$a = this is a (test);
$a =~ s/\W+/_/g;

HTH

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 11:28 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular expression question


Thanks for the replying.

I have another question, if I have a string like 
$a = this is a (test);

How can I change it to 
$a = this_is_a_test;

How can I remove ()?

Thanks

Lixin


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
$Bill Luebkert
Sent: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, March 31, 2004 16:49
 To: [EMAIL PROTECTED]
 Subject: regular expression question
 
 I have a $a which
 
  
 
 $a = this is a test;
 
  
 
 How can I change $a like:
 
  
 
 $a = this_is_a_test;
 
  
 
 No problem using $a, but if I were you, I would not.  In the Perl
 sort $a, $b are the default variables to use and I would stay away if I
 were you.
 
  
 
 That said,
 
 $a =~ s/ /_/g;

You could also use tr (slightly faster) :

$a =~ tr/ /_/;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic
http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2004-04-01 Thread Peter Guzis
$a =~ s/ /_/g;
$a =~ s/[()]//g;

or

$a =~ tr/ ()/_/d;


Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 9:28 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular expression question


Thanks for the replying.

I have another question, if I have a string like 
$a = this is a (test);

How can I change it to 
$a = this_is_a_test;

How can I remove ()?

Thanks

Lixin


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
$Bill Luebkert
Sent: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, March 31, 2004 16:49
 To: [EMAIL PROTECTED]
 Subject: regular expression question
 
 I have a $a which
 
  
 
 $a = this is a test;
 
  
 
 How can I change $a like:
 
  
 
 $a = this_is_a_test;
 
  
 
 No problem using $a, but if I were you, I would not.  In the Perl
 sort $a, $b are the default variables to use and I would stay away if I
 were you.
 
  
 
 That said,
 
 $a =~ s/ /_/g;

You could also use tr (slightly faster) :

$a =~ tr/ /_/;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic
http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2004-04-01 Thread Michael 'topdog' Thompson





Stacy Doss wrote:

  $a = "this is a (test)";
$a =~ s/\W+/_/g;

HTH

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 11:28 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: regular _expression_ question


Thanks for the replying.

I have another question, if I have a string like 
$a = "this is a (test)";

How can I change it to 
$a = "this_is_a_test";

How can I remove ()?

Thanks

Lixin


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of
$Bill Luebkert
Sent: Wednesday, March 31, 2004 8:27 PM
To: [EMAIL PROTECTED]
Subject: Re: regular _expression_ question

Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

  
  
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
[EMAIL PROTECTED]
Sent: Wednesday, March 31, 2004 16:49
To: [EMAIL PROTECTED]
Subject: regular _expression_ question

I have a $a which

 

$a = "this is a test";

 

How can I change $a like:

 

$a = "this_is_a_test";

 

No problem using $a, but if I were you, I would not.  In the Perl
sort $a, $b are the default variables to use and I would stay away if I
were you.

 

That said,

$a =~ s/ /_/g;

  
  
You could also use tr (slightly faster) :

	$a =~ tr/ /_/;

  


-- 
hi,

you might want to add the following statement after words:

$a =~ s/__/_/g;  # for viewing reasons...

regards,
topdog

"i have slipped the surly bonds of earth, and danced the skies on laughter-silvered wings;" --john gillespie magee jr.
 


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Peter Guzis
$txtype = 0 unless $txtype =~ /^-{0,1}\d+(?:\.\d+){0,1}$/;

Peter Guzis
Web Administrator, Sr.
ENCAD, Inc.
- A Kodak Company
email: [EMAIL PROTECTED]
www.encad.com 

-Original Message-
From: Motter, Jeffrey D [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 01, 2004 10:40 AM
To: Perl-Win32-Users
Subject: Regular expression to test for numeric values


I've read the FAQ's on this, but they don't seem to answer the question.

I have a variable that could contain any value( alpha, alpha-numeric, or
numeric). If the value is NOT numeric, I need to change the variables' value
to 0( as in zero ).

Examples:
$txtype=2.314;   # is numeric, so keep the value
$txtype=-2.314;  # is numeric, so keep the value
$txtype=7;   # is numeric, so keep the value
$txtype=-7;  # is numeric, so keep the value
$txtype=2.31.4;  # is not numeric, so change the value to 0
$txtype=7-7; # is not numeric, so change the value to 0
$txtype=UNKNOWN; # is not numeric, so change the value to 0
$txtype=7+E09;   # is not numeric( even though it really is ), so change
the value to 0


My guess is that I need a regex that will match on any character that is:
not 0-9 
or 
more than one . 
or 
more than one - 
or if - is not the first character of the string

Any ideas? Is it possible to do without using additional modules?

Thanks!

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Gerber, Christopher J
-Original Message-
My guess is that I need a regex that will match on any character that is:
not 0-9 
or 
more than one . 
or 
more than one - 
or if - is not the first character of the string

Any ideas? Is it possible to do without using additional modules?
--
I haven't written a regex in a few months, but how about something like
this:

  for (2.314,-2.314,7,-7,2.31.4,7-7,UNKNOWN,7+E09) {
$txtype=$_;
$txtype=0 unless /^-?((\d+)|(\d*\.\d+)|(\d+\.\d*))$/;
print $_ = $txtype\n;
  }

^   match beginning of string
-?  string MIGHT begin with a -
(\d+)   string of numbers with no .
(\d*\.\d+)  string of numbers with a . (digits only required AFTER .)
(\d+\.\d*)  string of numbers with a . (digits only required BEFORE .)
(..|..|..)  pick one of the three options for a match
$   match end of the string

Chris


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. 
It is intended for the addressee(s) only. Access to this E-mail by anyone else is 
unauthorized. If you are not an addressee, any disclosure or copying of the contents 
of this E-mail or any action taken (or not taken) in reliance on it is unauthorized 
and may be unlawful. If you are not an addressee, please inform the sender immediately.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Joseph Discenza
Gerber, Christopher J wrote, on Thursday, April 01, 2004 2:12 PM
:  -Original Message-
:  My guess is that I need a regex that will match on any character that is:
:   not 0-9 
:   or 
:   more than one . 
:   or 
:   more than one - 
:   or if - is not the first character of the string
:  
:  Any ideas? Is it possible to do without using additional modules?
:  --
:  I haven't written a regex in a few months, but how about something like
:  this:
:  
:for (2.314,-2.314,7,-7,2.31.4,7-7,UNKNOWN,7+E09) {
:  $txtype=$_;
:  $txtype=0 unless /^-?((\d+)|(\d*\.\d+)|(\d+\.\d*))$/;
:  print $_ = $txtype\n;
:}
:  
:  ^match beginning of string
:  -?   string MIGHT begin with a -
:  (\d+)string of numbers with no .
:  (\d*\.\d+)   string of numbers with a . (digits only required AFTER .)
:  (\d+\.\d*)   string of numbers with a . (digits only required BEFORE .)
:  (..|..|..)   pick one of the three options for a match
:  $match end of the string

I'd make just a few suggestions. First, since there's no need for capture,
dispense with the internal capturing parentheses, and make the outer ones
non-capturing. This will speed up the regex engine a little, and if there's
a lot of stuff to go through...

Secondly, if you make your decimal optional in the third alternation,
it's no different from the first, so you can eliminate one of the alternatives.
Then you've also matched those with *any* digits before the decimal, so you
can remove the leading \d* from the other alternative.

So I get:

/^-?(?:\d+\.?\d*|\.\d+)$/

for the regex. Just a slight improvement (and a shorter regex is almost
always more readable, too). You could embed the comments in the regex
(use the /x flag) to make it crystal clear.

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]
 
  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! *  




___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Peter Eisengrein
Title: RE: Regular expression to test for numeric values





use Scalar::Util;


if (Scalar::Util::looks_like_number $num)
{
 print Yes, $num is a number\n;
}
else
{
 print no.\n;
}



... found it with perldoc -q number, which also showed a number of regex's that do the same kinda thing




 -Original Message-
 From: Motter, Jeffrey D [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, April 01, 2004 1:40 PM
 To: Perl-Win32-Users
 Subject: Regular _expression_ to test for numeric values
 
 
 I've read the FAQ's on this, but they don't seem to answer 
 the question.
 
 I have a variable that could contain any value( alpha, 
 alpha-numeric, or
 numeric). If the value is NOT numeric, I need to change the 
 variables' value
 to 0( as in zero ).
 
 Examples:
 $txtype=2.314; # is numeric, so keep the value
 $txtype=-2.314; # is numeric, so keep the value
 $txtype=7; # is numeric, so keep the value
 $txtype=-7; # is numeric, so keep the value
 $txtype=2.31.4; # is not numeric, so change the value to 0
 $txtype=7-7; # is not numeric, so change the value to 0
 $txtype=UNKNOWN; # is not numeric, so change the value to 0
 $txtype=7+E09; # is not numeric( even though it really is 
 ), so change
 the value to 0
 
 
 My guess is that I need a regex that will match on any 
 character that is:
  not 0-9 
  or 
  more than one . 
  or 
  more than one - 
  or if - is not the first character of the string
 
 Any ideas? Is it possible to do without using additional modules?
 
 Thanks!
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular expression to test for numeric values

2004-04-01 Thread Dial Joe

How about this (direct from The Perl Cookbook[1])  ??


warn has nondigitsif /\D/;
warn not a natural number unless /^\d+$/; # rejects -3
warn not an integer   unless /^-?\d+$/;   # rejects +3
warn not an integer   unless /^[+-]?\d+$/;
warn not a decimal number unless /^-?\d+\.?\d*$/; # rejects .2
warn not a decimal number unless /^-?(?:\d+(?:\.\d*)?|\.\d+)$/;
warn not a C float
   unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;

The cookbook is the first place I look for this kind of stuff.
HTH,
Joe Dial

[1] 
Perl Cookbook 
Tips and Tricks for Perl Programmers
By Tom Christiansen, Nathan Torkington
1st Edition August 1998 
www.oreilly.com 
ISBN: 1-56592-243-3

Current Version is:
Perl Cookbook, 2nd Edition
By Tom Christiansen, Nathan Torkington
2nd Edition August 2003 
ISBN: 0-596-00313-7
964 pages, $49.95 US, $77.95 CA, £35.50 UK 

-Original Message-
From: Motter, Jeffrey D [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 01, 2004 1:40 PM
To: Perl-Win32-Users
Subject: Regular expression to test for numeric values


I've read the FAQ's on this, but they don't seem to answer the question.

I have a variable that could contain any value( alpha, alpha-numeric, or
numeric). If the value is NOT numeric, I need to change the variables' value
to 0( as in zero ).

Examples:
$txtype=2.314;   # is numeric, so keep the value
$txtype=-2.314;  # is numeric, so keep the value
$txtype=7;   # is numeric, so keep the value
$txtype=-7;  # is numeric, so keep the value
$txtype=2.31.4;  # is not numeric, so change the value to 0
$txtype=7-7; # is not numeric, so change the value to 0
$txtype=UNKNOWN; # is not numeric, so change the value to 0
$txtype=7+E09;   # is not numeric( even though it really is ), so change
the value to 0


My guess is that I need a regex that will match on any character that is:
not 0-9 
or 
more than one . 
or 
more than one - 
or if - is not the first character of the string

Any ideas? Is it possible to do without using additional modules?

Thanks!

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2004-03-31 Thread $Bill Luebkert
Wagner, David --- Senior Programmer Analyst --- WGO wrote:

Hey guys - what's with the HTML ?

 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] Behalf Of
 [EMAIL PROTECTED]
 Sent: Wednesday, March 31, 2004 16:49
 To: [EMAIL PROTECTED]
 Subject: regular expression question
 
 I have a $a which
 
  
 
 $a = this is a test;
 
  
 
 How can I change $a like:
 
  
 
 $a = this_is_a_test;
 
  
 
 No problem using $a, but if I were you, I would not.  In the Perl
 sort $a, $b are the default variables to use and I would stay away if I
 were you.
 
  
 
 That said,
 
 $a =~ s/ /_/g;

You could also use tr (slightly faster) :

$a =~ tr/ /_/;

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--  o // //  Castle of Medieval Myth  Magic http://www.todbe.com/
-/-' /___/__/_/_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression replacement

2003-11-28 Thread Beckett Richard-qswi266
Hi,
 
I would like to know how can I replace the value c:\qqq\www\ to
c:/qqq/www/.
I tried several ways, but didn't manage to.
 
Thanks,
Eran


s!\\!/!g
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression replacement

2003-11-28 Thread shonorio



$Value = 'c:\qqq\www\';
$Value =~ s/\\/\//g;
print $Value ;




De:   [EMAIL PROTECTED] em 28/11/2003 09:15
  GMT

Para:   'Kaufman Eran (StarHome)' [EMAIL PROTECTED]
  [EMAIL PROTECTED]
cc:
Assunto: RE: regular expression replacement

Hi,

I would like to know how can I replace the value c:\qqq\www\ to
c:/qqq/www/.
I tried several ways, but didn't manage to.

Thanks,
Eran


s!\\!/!g
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Tamanho do  Documento: 3,78 KbytesLimite = 1200 Kbytes







___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression problem?

2003-09-26 Thread Carl Jolley
On Fri, 26 Sep 2003, Xu, Qiang (XSSC SGP) wrote:

 Ted S. wrote:
  Beckett Richard-qswi266 graced perl with these words of wisdom:
  That should have been s/.*\///
 
  Don't you have to escape the period, too?
 
  s/\.*\///

 No, we shouldn't, because here . stands for any single character except a
 new line.


Well you are correct that a . regex character will match a period
but consider if the matched string was 'aaabcd.txt' the unescaped
period followed by * would match the string 'aaa'. Technically you are
correct, you don't have to escape the . character unless of course you
want the match to work correctly.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression problem?

2003-09-25 Thread Xu, Qiang (XSSC SGP)
Ted S. wrote:
 Beckett Richard-qswi266 graced perl with these words of wisdom:
 That should have been s/.*\///
 
 Don't you have to escape the period, too?
 
 s/\.*\///

No, we shouldn't, because here . stands for any single character except a
new line. 

thx,

Regards,
Xu Qiang
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression problem?

2003-09-25 Thread Glenn Linderman
On approximately 9/25/2003 6:45 AM, came the following characters from
the keyboard of Xu, Qiang (XSSC SGP):
Hi, all: 

I have a regular expression that I can't understand. 

Suppose $filename is a file name that includes the full path. Say, it is
/u/scan/abc.jpg, 
The regular expression is: $filename =~ s|.*/||;

I only know regular expressions such as s/.../.../, but this has the form of
s|...|...| which I am confuse with. 

Anyone can explain the above regular expression as detailed as possible? 
Any delimiter can be used (other posters were correct about that).  The 
delimiter used affects which delimiter character would need to be 
escaped in the regular expression.  Generally, if something other than / 
is used as the delimiter character, it is chosen because it doesn't 
appear in the regular expression, so that there is no need to escape the 
delimiter character.  Some exceptions to that rule include delimiter 
characters that add additional semantics, such as '.

The expression in this case is stripping off leading directory names, 
probably hoping to leave an unqualified file name in the $filename 
variable.  (Other posters claimed it was stripping the extension, but 
that is incorrect.)

--
Glenn -- http://nevcal.com/
===
Like almost everyone, I receive a lot of spam every day, much of it
offering to help me get out of debt or get rich quick.  It's ridiculous.
-- Bill Gates
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression problem?

2003-09-25 Thread Xu, Qiang (XSSC SGP)
Strohmeier Ruediger wrote:
 Hi Xu Qiang,
 
 unlike e.g. awk, vi or the shell, perl support different delimiter
 for regexes. When a slash is part of the regex or the substitution
 pattern, they can either be escaped (i.e. \/) or other characters can
 be used as delimiters.  
 
 Thus the regex is equivalent to s/.*\/// and cuts away everything
 including the last slash changing /u/scan/abc.jpg into abc.jpg

Yes, this is the correct result, thank you.

Regards,
Xu Qiang
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Regular Expression problem?

2003-09-25 Thread Xu, Qiang (XSSC SGP)
Glenn Linderman wrote:
 Any delimiter can be used (other posters were correct about that). 
 The delimiter used affects which delimiter character would need to be
 escaped in the regular expression.  Generally, if something other
 than / is used as the delimiter character, it is chosen because it
 doesn't appear in the regular expression, so that there is no need to
 escape the delimiter character.  Some exceptions to that rule include
 delimiter characters that add additional semantics, such as '.
 
 The expression in this case is stripping off leading directory names,
 probably hoping to leave an unqualified file name in the $filename
 variable.  (Other posters claimed it was stripping the extension, but
 that is incorrect.)

Thank you, Glenn, you are right. The book said the purpose is to remove the
path and keep the base name. 
I just couldn't understand the grammar in the expression, Now I can. 

Thanks for everyone who helped me. :)

Regards,
Xu Qiang
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Perldoc problem was Re: regular expression on military time

2003-07-27 Thread John
On Saturday, July 26, 2003 12:05 AM AEST, Ted S.  wrote:

 On 25 Jul 2003, John McMahon wrote in perl:

 Ted

 When you produced the output of 'set' below how did you get to the
 CLI console (command line interpreter aka DOS prompt)? This console
 was opened in the 'Windows' directory.

 What was different in *HOW* you got to this console *TO HOW* you got
 to the console where you invoked 'perldoc.bat' in your earlier
 message (other than the directory they were opened in)? This console
 was opened in the 'Perl' directory.

 I'm not certain I understand your question?  In all cases, I'm
 opening the console via the same shortcut that I've got in the
 Start menu.  I then use the cd command to change directories if
 need be.  And the console is always opened in the Windows directory.

I'm just trying to get a picture of what you are doing and how you are
doing it to see if I can suggest alternatives that might work. I have
changed the subject as it was getting off topic.

I assume you have installed Perl in the default location 'c:\perl' and
your perl executable directory will be 'c:\perl\bin'. Since you use the
same shortcut all the time and your path variable (as shown previously
by your 'set' output 'PATH=C:\WINDOWS;C:\WINDOWS\COMMAND') does not
include your Perl directory, to run scripts from the CLI console you
would have to run them from the 'c:\perl\bin' directory.

Ahh! I think I see the problem. Your previous postings:

 snip
 C:\Perlperldoc
 Usage: perldoc.bat [-h] [-r] [-i] [-v] [-t] [-u] [-m] [-n program]
[-l] [-
 F] [-X
 ] PageName|ModuleName|ProgramName
perldoc.bat -f PerlFunc
perldoc.bat -q FAQKeywords

 The -h option prints more help.  Also try perldoc perldoc to get
 acquainted with the system.
 /snip

and

snip

C:\Perlperldoc perltoc
Can't spawn command.com: No such file or directory at
C:\PERL\BIN/perldoc.bat
line 383.
Can't spawn command.com: No such file or directory at
C:\PERL\BIN/perldoc.bat
line 383.
Can't spawn command.com: No such file or directory at
C:\PERL\BIN/perldoc.bat
line 383.

/snip

shows you invoking perldoc in the 'c:\Perl' directory. Information
provided so far suggests that this should not work at all, however it
did, just not properly. I think this is probably because you don't have
the perl executable directory (c:\perl\bin) in your path. If you were to
repeat the exercise above in the 'c:\perl\bin' directory, I think it
should work.

If it does work, invoke 'path c:\perl\bin;%path%' at the prompt to
change the path variable for the current console session then 'cd' to
another directory and test again. It should work.

If this is the answer, then you need to put 'c:\perl\bin' in your path,
you probably should anyway.

HTH
John

-- 
Regards
   John McMahon  (mailto:[EMAIL PROTECTED])

Tired of Outlook Express/Outlook's messy quoting?
Check out OE-Quotefix/Outlook-Quotefix via http://flash.to/oblivion



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perldoc problem was Re: regular expression on military time

2003-07-27 Thread Gerry Green
Just a quick note:

- Original Message - 
From: John [EMAIL PROTECTED]
To: Ted S. [EMAIL PROTECTED]
Cc: Perl-Win32-Users [EMAIL PROTECTED]
Sent: Sunday, July 27, 2003 3:07 AM
Subject: Perldoc problem was Re: regular expression on military time

clip
 If it does work, invoke 'path c:\perl\bin;%path%' at the prompt to
 change the path variable for the current console session then 'cd' to
 another directory and test again. It should work.

If I remember right, this %path% syntax from the command prompt doesn't work
under command.com.   To change the path like that you'll need to repeat the
current value and include the new entry on the end:

path c:\windows;c:\windows\command;c:\perl\bin



 If this is the answer, then you need to put 'c:\perl\bin' in your path,
 you probably should anyway.

 HTH
 John

 -- 
 Regards
John McMahon  (mailto:[EMAIL PROTECTED])

 Tired of Outlook Express/Outlook's messy quoting?
 Check out OE-Quotefix/Outlook-Quotefix via http://flash.to/oblivion



 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perldoc problem was Re: regular expression on military time

2003-07-27 Thread Ted S.
On 27 Jul 2003, Gerry Green wrote in perl:

 Just a quick note:
 
 - Original Message - 
 From: John [EMAIL PROTECTED]
 To: Ted S. [EMAIL PROTECTED]
 Cc: Perl-Win32-Users [EMAIL PROTECTED]
 Sent: Sunday, July 27, 2003 3:07 AM
 Subject: Perldoc problem was Re: regular expression on military time
 
clip
 If it does work, invoke 'path c:\perl\bin;%path%' at the prompt to
 change the path variable for the current console session then 'cd' to
 another directory and test again. It should work. 
 
 If I remember right, this %path% syntax from the command prompt
 doesn't work under command.com.   To change the path like that you'll
 need to repeat the current value and include the new entry on the end:
 
 path c:\windows;c:\windows\command;c:\perl\bin

This doesn't stick when I exit the DOS console.

No, I don't know how to change environment variables or other such fun 
stuff.  And heaven knows the help files/documentation are even more 
meager than what comes with most Perl modules!

-- 
Ted Schuerzinger
Homer Simpson: I'm sorry Marge, but sometimes I think we're the worst 
family in town.
Marge: Maybe we should move to a larger community.
http://www.snpp.com/episodes/7G04.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Perldoc problem was Re: regular expression on military time

2003-07-27 Thread John
On Monday, July 28, 2003 1:32 AM AEST, Gerry Green  wrote:

 Just a quick note:

 - Original Message -
 From: John [EMAIL PROTECTED]
 To: Ted S. [EMAIL PROTECTED]
 Cc: Perl-Win32-Users [EMAIL PROTECTED]
 Sent: Sunday, July 27, 2003 3:07 AM
 Subject: Perldoc problem was Re: regular expression on military time

 clip
 If it does work, invoke 'path c:\perl\bin;%path%' at the prompt to
 change the path variable for the current console session then 'cd' to
 another directory and test again. It should work.

 If I remember right, this %path% syntax from the command prompt
 doesn't work under command.com.   To change the path like that you'll
 need to repeat the current value and include the new entry on the end:

 path c:\windows;c:\windows\command;c:\perl\bin

I am pretty sure it does, I have done that sort of thing for years (back
to DOS 2.1), it certainly works in batch files, but I am not going to
reboot into W98 just to test it.




 If this is the answer, then you need to put 'c:\perl\bin' in your
 path, you probably should anyway.

 HTH
 John


-- 
Regards
   John McMahon  (mailto:[EMAIL PROTECTED])

Tired of Outlook Express/Outlook's messy quoting?
Check out OE-Quotefix/Outlook-Quotefix via http://flash.to/oblivion



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression on military time

2003-07-25 Thread Ted S.
On 25 Jul 2003, John McMahon wrote in perl:

 Ted
 
 When you produced the output of 'set' below how did you get to the CLI
 console (command line interpreter aka DOS prompt)? This console was
 opened in the 'Windows' directory.
 
 What was different in *HOW* you got to this console *TO HOW* you got to
 the console where you invoked 'perldoc.bat' in your earlier message
 (other than the directory they were opened in)? This console was opened
 in the 'Perl' directory.

I'm not certain I understand your question?  In all cases, I'm opening the 
console via the same shortcut that I've got in the Start menu.  I then 
use the cd command to change directories if need be.  And the console is 
always opened in the Windows directory.

-- 
Ted Schuerzinger
Homer Simpson: I'm sorry Marge, but sometimes I think we're the worst 
family in town.
Marge: Maybe we should move to a larger community.
http://www.snpp.com/episodes/7G04.html
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression on military time

2003-07-21 Thread Carl Jolley
On Fri, 18 Jul 2003, Ted S. wrote:

 On 18 Jul 2003, Carl Jolley wrote in perl:

  On Thu, 17 Jul 2003, Ted S. wrote:
 
  On 17 Jul 2003, Tobias Hoellrich wrote in perl:
 
   my @t=(08:00, 23:59, 00:00, aa:00, 24:00,  00:01,
   8:00, 08.00, 36:12, 08:61 ); foreach(@t) {
 unless(/^(\d{2}):(\d{2})$/  $124  $260) {
 
  Forgive my ignorance, since I only use perl for basic things and
  haven't yet gotten to text-munging:
 
  I don't see what in your regex is capturing a $1 and a $2.  (Yes, I
  know what $1 and $2 are for.  You can all stop laughing now.  ;-)
 
 
  The first set of parens maps to $1, the second to $2, etc.

 Thanks, Carl and Bill.  Wouldn't you know that this information about
 parentheses mapping to $1 etc. actually *is* in the mess of documents that
 is the Perl manpages.  :-)  (Specifically, perlre, but who can remember
 what all the different page names actually stand for?)


You don't have to remember each of the perl pod file names. Just
remenber one command: perldoc perltoc.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2003-03-28 Thread thomas . baetzler
[EMAIL PROTECTED] schrieb:
 I have a txt file like the bottom (I use cleardiff to
 compare 2 files and
 get this file):

I would recommend that you look at Parse::RecDescent.

Go grab the distribution from CPAN and have a look
at the tutorial - the first example shows you how to
parse a diff.

http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?site=ftp.funet.fi;join=and;stem=no;arrange=file;case=clike;download=auto;age=;distinfo=3453

HTH,
Thomas
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2003-03-28 Thread Gerber, Christopher J
The easiest way to reference all but the first character of a string is
probably:

$rest=substr $var,1;

You could also use a regex.  Maybe search for a line that starts with  and
then return 0 or more characters matching anything after that:

$var=~/^(.*)/;
$rest=$1;

You could also use rindex and select all the characters but one.  Basically,
there are a lot of possibilities... a weekend with the Camel book or perldoc
would probably be rather informative.

Chris

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 11:58 AM
 To: [EMAIL PROTECTED]
 Subject: RE: regular expression question
 
 
 I have another question,
 
 I have string like  GENERATION 116, How can I get rid of 
 , of the
 string?
 
 Thanks
 
 Lixin
 
 
 
 -Original Message-
 From: Todd Hayward [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 11:30 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: regular expression question
 
 
 load the file into a file handle, and iterate through it line 
 by line. Pipe
 each line to the file handle (the | is not a typo in the example)...
 
 So,
 
 open(fHandle, myfile.txt|);
 while (defined ($line = fHandle)){
 if ($line ~= /generic/ig){
 do something}
 };
 
 Hope this helps,
 
 NuTs
 
 
 - Original Message -
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 9:40 AM
 Subject: regular expression question
 
 
  Dear all
 
  I have a txt file like the bottom (I use cleardiff to 
 compare 2 files and
  get this file):
 
  I will check whether the line includes 
 ___GENERIC_MULTILINE___ or not,
 if
  it includes, I will get the following information
 
   GENERATION 116
   # Impossible dependency
   # Needed to prevent FC4700 to CX-series upgrades
   DEPEND Navisphere 2.0.0.0.0
   DEPEND Navisphere 1.0.0.0.0
   GENDEPEND Navisphere 116
  
 
  without  sign,
 
  How can I do it?
 
  Thanks a lot in advance!
 
  Lixin
 
  
 #
  3,4c3,4
   REVISION ___INTERNAL_REV___
   DISPLAYREV ___EXTERNAL_REV___
  ---
   REVISION 02041405.002
   DISPLAYREV 02.04.1.40.5.002
  24c24,30
   ___GENERIC_MULTILINE___
  ---
   GENERATION 116
   # Impossible dependency
   # Needed to prevent FC4700 to CX-series upgrades
   DEPEND Navisphere 2.0.0.0.0
   DEPEND Navisphere 1.0.0.0.0
   GENDEPEND Navisphere 116
  
  3,4c3,4
   REVISION ___INTERNAL_REV___
   DISPLAYREV ___EXTERNAL_REV___
  ---
   REVISION 02041405.002
   DISPLAYREV 02.04.1.40.5.002
  
 ##
 
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. 
It is intended for the addressee(s) only. Access to this E-mail by anyone else is 
unauthorized. If you are not an addressee, any disclosure or copying of the contents 
of this E-mail or any action taken (or not taken) in reliance on it is unauthorized 
and may be unlawful. If you are not an addressee, please inform the sender immediately.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2003-03-28 Thread Adam Frielink

 
 I have another question,
 
 I have string like  GENERATION 116, How can I get rid of , of the
 string?

If you want to remove the 1st character if it is a , then use this...

$var =~ s///;
$var =~ s/^//;  #This removes it only if it is the first character
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2003-03-28 Thread viktoras
This  works:

open (INPUT ,your_input.txt) || die $!;
open (OUTPUT,  your_output.txt) || die $!;
while (INPUT) {
if (m/GENERIC_MULTILINE/) {
$_=GENERATION 116
# Impossible dependency
# Needed to prevent FC4700 to CX-series upgrades
DEPEND Navisphere 2.0.0.0.0
DEPEND Navisphere 1.0.0.0.0
GENDEPEND Navisphere 116\n;}
print OUTPUT $_;}
close (OUTPUT);
close (INPUT);
viktoras

[EMAIL PROTECTED] wrote:

Dear all

I have a txt file like the bottom (I use cleardiff to compare 2 files and
get this file):
I will check whether the line includes ___GENERIC_MULTILINE___ or not, if
it includes, I will get the following information
 

GENERATION 116 
# Impossible dependency 
# Needed to prevent FC4700 to CX-series upgrades 
DEPEND Navisphere 2.0.0.0.0 
DEPEND Navisphere 1.0.0.0.0 
GENDEPEND Navisphere 116 

   

without  sign,

How can I do it?

Thanks a lot in advance!

Lixin  

#
3,4c3,4
 REVISION ___INTERNAL_REV___ 
 DISPLAYREV ___EXTERNAL_REV___ 
---
 

REVISION 02041405.002 
DISPLAYREV 02.04.1.40.5.002 
   

24c24,30
 ___GENERIC_MULTILINE___
---
 

GENERATION 116 
# Impossible dependency 
# Needed to prevent FC4700 to CX-series upgrades 
DEPEND Navisphere 2.0.0.0.0 
DEPEND Navisphere 1.0.0.0.0 
GENDEPEND Navisphere 116 

   

3,4c3,4
 REVISION ___INTERNAL_REV___ 
 DISPLAYREV ___EXTERNAL_REV___ 
---
 

REVISION 02041405.002 
DISPLAYREV 02.04.1.40.5.002
   

##

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

--
Your favorite stores, helpful shopping tools and great gift ideas. 
Experience the convenience of buying online with [EMAIL PROTECTED] 
http://shopnow.netscape.com/

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2003-03-28 Thread Cai_Lixin
Thanks a lot for your great help, another question,

if I want to switch all \n to \\n in a string how can I do it?
Like 

$var = This is a book\nThat is a desk\nwho is that man?\n;
I did like 
$var =~ s/\n/\\n/g;

but it does nt work. What is wrong with it?

Thanks

Lixin

-Original Message-
From: Todd Hayward [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 12:26 PM
To: [EMAIL PROTECTED]
Subject: Re: regular expression question



Borrowing from the previous example of:

 open(fHandle, myfile.txt|);
 while (defined ($line = fHandle)){
 if ($line ~= /generic/ig){
 do something}
 };

Add this line: $line =~ s/\//g;

This is what your code block should look like:

open(fHandle, myfile.txt|);
while (defined ($line = fHandle)){
$line =~ s/\//g;
if ($line =~ /generic/ig){
 do something}
   };


The 3rd line will effectively delete any instance of  that it finds. If
you want it to only remove the first instance of  from each line, remove
the g from the end. This makes it global to the string, thus
substituting no character for each  it finds.

HTH,

NuTs


- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 28, 2003 10:58 AM
Subject: RE: regular expression question


 I have another question,

 I have string like  GENERATION 116, How can I get rid of , of the
 string?

 Thanks

 Lixin



 -Original Message-
 From: Todd Hayward [mailto:[EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 11:30 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: regular expression question


 load the file into a file handle, and iterate through it line by line.
Pipe
 each line to the file handle (the | is not a typo in the example)...

 So,

 open(fHandle, myfile.txt|);
 while (defined ($line = fHandle)){
 if ($line ~= /generic/ig){
 do something}
 };

 Hope this helps,

 NuTs


 - Original Message -
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, March 28, 2003 9:40 AM
 Subject: regular expression question


  Dear all
 
  I have a txt file like the bottom (I use cleardiff to compare 2 files
and
  get this file):
 
  I will check whether the line includes ___GENERIC_MULTILINE___ or not,
 if
  it includes, I will get the following information
 
   GENERATION 116
   # Impossible dependency
   # Needed to prevent FC4700 to CX-series upgrades
   DEPEND Navisphere 2.0.0.0.0
   DEPEND Navisphere 1.0.0.0.0
   GENDEPEND Navisphere 116
  
 
  without  sign,
 
  How can I do it?
 
  Thanks a lot in advance!
 
  Lixin
 
  #
  3,4c3,4
   REVISION ___INTERNAL_REV___
   DISPLAYREV ___EXTERNAL_REV___
  ---
   REVISION 02041405.002
   DISPLAYREV 02.04.1.40.5.002
  24c24,30
   ___GENERIC_MULTILINE___
  ---
   GENERATION 116
   # Impossible dependency
   # Needed to prevent FC4700 to CX-series upgrades
   DEPEND Navisphere 2.0.0.0.0
   DEPEND Navisphere 1.0.0.0.0
   GENDEPEND Navisphere 116
  
  3,4c3,4
   REVISION ___INTERNAL_REV___
   DISPLAYREV ___EXTERNAL_REV___
  ---
   REVISION 02041405.002
   DISPLAYREV 02.04.1.40.5.002
  ##
 
  ___
  Perl-Win32-Users mailing list
  [EMAIL PROTECTED]
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
 
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: regular expression question

2003-03-28 Thread Cai_Lixin
I have another question,

I have string like  GENERATION 116, How can I get rid of , of the
string?

Thanks

Lixin



-Original Message-
From: Todd Hayward [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 11:30 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: regular expression question


load the file into a file handle, and iterate through it line by line. Pipe
each line to the file handle (the | is not a typo in the example)...

So,

open(fHandle, myfile.txt|);
while (defined ($line = fHandle)){
if ($line ~= /generic/ig){
do something}
};

Hope this helps,

NuTs


- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, March 28, 2003 9:40 AM
Subject: regular expression question


 Dear all

 I have a txt file like the bottom (I use cleardiff to compare 2 files and
 get this file):

 I will check whether the line includes ___GENERIC_MULTILINE___ or not,
if
 it includes, I will get the following information

  GENERATION 116
  # Impossible dependency
  # Needed to prevent FC4700 to CX-series upgrades
  DEPEND Navisphere 2.0.0.0.0
  DEPEND Navisphere 1.0.0.0.0
  GENDEPEND Navisphere 116
 

 without  sign,

 How can I do it?

 Thanks a lot in advance!

 Lixin

 #
 3,4c3,4
  REVISION ___INTERNAL_REV___
  DISPLAYREV ___EXTERNAL_REV___
 ---
  REVISION 02041405.002
  DISPLAYREV 02.04.1.40.5.002
 24c24,30
  ___GENERIC_MULTILINE___
 ---
  GENERATION 116
  # Impossible dependency
  # Needed to prevent FC4700 to CX-series upgrades
  DEPEND Navisphere 2.0.0.0.0
  DEPEND Navisphere 1.0.0.0.0
  GENDEPEND Navisphere 116
 
 3,4c3,4
  REVISION ___INTERNAL_REV___
  DISPLAYREV ___EXTERNAL_REV___
 ---
  REVISION 02041405.002
  DISPLAYREV 02.04.1.40.5.002
 ##

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression matching problem

2003-03-14 Thread Carl Jolley
On Sun, 9 Mar 2003, Electron One wrote:

 Hello Everyone,

   If I have a file that contains this,

 test3.txt##
 wilma

 wimagren was here

 twilma was type wilma

 wilma

 wilma

 wilma

 twowilmase
 ##

 and i have a perl script that contains this,

 ###perlname.pl
 #!/usr/bin/perl


 while(){
 chomp;
 if(/wilma\s+/){
print wilma was mentioned\n;
}
 }

 #

 and I type, perl -w perlname.pl test3.txt
 shouldnt the output be, wilma was mentioned \n, 7 times? My output file
 only mentions it once. What am I doing wrong?


Two things:

One since your are chomping the input line, your regex which requires
trailing white space after 'wilma' wont't match those lines which end with
the characters wilma. I suggest you change your regex to: /wilma\b/.
Alternatively you could just take out the chomp.

Two you are only checking for one instance of your regex per input line.
I suggest you change your code from an 'if' to:

while(/wilma\b/g) {

You should get 6 matches on your input file not seven.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression matching problem

2003-03-10 Thread Phil Ritchie

Not if the fourth to sixth lines don't have a space before the end of line.
Try if(/wilma\s*/). Actually, you'll need to use if(/wilma/g) to catch them
all.

Phil.



|-+---
| |   Electron One|
| |   [EMAIL PROTECTED]|
| |   Sent by:|
| |   [EMAIL PROTECTED]|
| |   veState.com |
| |   |
| |   |
| |   10/03/03 02:29  |
| |   |
|-+---
  
--|
  |
  |
  |   To:   [EMAIL PROTECTED]  
  |
  |   cc:   electron One [EMAIL PROTECTED]   
 |
  |   Subject:  Regular Expression matching problem
  |
  
--|




Hello Everyone,

  If I have a file that contains this,

test3.txt##

wilma

wimagren was here

twilma was type wilma

wilma

wilma

wilma

twowilmase
##


and i have a perl script that contains this,

###perlname.pl

#!/usr/bin/perl


while(){
chomp;
if(/wilma\s+/){
   print wilma was mentioned\n;
   }
}

#


and I type, perl -w perlname.pl test3.txt
shouldnt the output be, wilma was mentioned \n, 7 times? My output file
only mentions it once. What am I doing wrong?

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs







**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
www.vistatec.ie
**

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: Regular Expression matching problem

2003-03-09 Thread Keith C. Ivey
Electron One [EMAIL PROTECTED] wrote:

 while(){
 chomp;
 if(/wilma\s+/){
print wilma was mentioned\n;
}
 }
 
 #
 
 and I type, perl -w perlname.pl test3.txt
 shouldnt the output be, wilma was mentioned \n, 7 times? My
 output file only mentions it once. What am I doing wrong?

What do you think the '\s+' means in that regular expression?  
After you've chomped them, only one line has whitespace after 
'wilma', so only one matches.

-- 
Keith C. Ivey [EMAIL PROTECTED]
Washington, DC
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: regular expression question

2002-11-23 Thread Carl Jolley
On Fri, 22 Nov 2002 [EMAIL PROTECTED] wrote:

 all,

 I want to check the first line of the file if it is machine or not, like

 The first line of the file is:

 Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.

 my code is like:

 if (!-z $file)
 {
 open(LOG_FILE, $file) or warn  can not open $file:$!\n;
 my @read_lines = LOG_FILE;
 close (LOG_FILE);
 next unless chomp($read_lines[0]) =~ m#\\nest and \toolbox VOBs\#;
 }

 it did not work for regular expression, can you help me to figure what is
 wrong with it?


You are performing your regex match on the result of the function call:
chomp($read_lines[0]). The value of chomp will be 1 if it removed a
new-line character from the end of $read_lines[0] and it will be zero if
it didn't remove a new-line character, i.e. if the last character was not
the new-line character (actually the $/ string which has a default value
of \n).  Somehow I don't believe that your regex will match either a 1
or a 0.

However, even if you anchor the regex on the variable $read_lines[0],
I don't believe that the regex match string is correct considering
that fact that it contains the representation of a new-line character (the
\n) and a tab (the \t). Also note that it is not necessary to escape the
double quote characters inside the regex match string unless the quote is
used to delimit the match string (you used # to delimit the regex match
string, my code below uses the default regex delimter, /) I believe the
the following will fix your problem as far as the regex is concerned:

next unless $read_lines[0] =~ /\\nest and \\toolbox VOBs/;

Take out the chomp, it serves no purpose based on the code fragment
you showed. Also reconsider your logic. Exactly what do you expect to
happen if the regex doesn't match, i.e. if the 'next' is done what
code will then execute next?

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-23 Thread Carl Jolley
On Fri, 22 Nov 2002, Stovall, Adrian M. wrote:

  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
  Sent: Friday, November 22, 2002 4:38 PM
  To: Stovall, Adrian M.; [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Subject: RE: regular expression question
 
 
  I tried that, it does not work for me!
 
  Lixin
 

 This code should print yes, if it does, then the code works for you...

 $line = 'Job \nest and \toolbox VOBs began execution on 9/6/02 at
 2:00:11 AM.';
 print $line\n;
 if ($line =~ m#\\\nest and \\toolbox VOBs\#) { print yes; }
 else { print no; }


Your code may work fine but as long as his code is archoring
the regex to the result of the function call: chomp($read_lines[0])
it won't. Unless of course he changes the regex match string to:

m#^[01]$#;

Note that the result of doing chomp on a scalar will be one of
two values, 0 or 1.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-22 Thread Cai_Lixin
Sorry, I did not state quite clear, if it is machine or not, I want to say
if I it is the right file or not...

Lixin

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 5:07 PM
Cc: [EMAIL PROTECTED]
Subject: regular expression question


all,

I want to check the first line of the file if it is machine or not, like

The first line of the file is:

Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.

my code is like:

if (!-z $file)
{
open(LOG_FILE, $file) or warn  can not open $file:$!\n;
my @read_lines = LOG_FILE;
close (LOG_FILE);
next unless chomp($read_lines[0]) =~ m#\\nest and \toolbox VOBs\#;
}

it did not work for regular expression, can you help me to figure what is
wrong with it?

Thanks a lot!

Lixin
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-22 Thread Stovall, Adrian M.
Cai Lixin said:
 
 
 all,
 
 I want to check the first line of the file if it is machine 
 or not, like
 
 The first line of the file is:
 
 Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.
 
 my code is like:
 
 if (!-z $file)
 {
 open(LOG_FILE, $file) or warn  can not open $file:$!\n;
 my @read_lines = LOG_FILE;
 close (LOG_FILE);
 next unless chomp($read_lines[0]) =~ m#\\nest and 
 \toolbox VOBs\#;
 }
 
 it did not work for regular expression, can you help me to 
 figure what is wrong with it?
 

You forgot to escape the backslashes...change your code to read:

next unless chomp($read_lines[0]) =~ m#\\\nest and \\toolbox VOBs\#) 



perl -e sub Sub{return reverse(@_);}$_='.$yyye k ca i Xl $yyye jX $yyye
hto ZfX tq $uQ';s+[ \$]++g;s-j-P-;s^yyy^r^g;s:i:H:;s!X!
!g;s|Z|n|;s*Q*J*;s{q}{s}g;s(f)(A);$print=join('',Sub(split('')));system(
'echo',$print);

To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be. 

Adrian Okay, I won't top-post unless it's an emergency Stovall
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-22 Thread Cai_Lixin
I tried that, it does not work for me!

Lixin

-Original Message-
From: Stovall, Adrian M. [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 5:28 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: regular expression question


Cai Lixin said:
 
 
 all,
 
 I want to check the first line of the file if it is machine 
 or not, like
 
 The first line of the file is:
 
 Job \nest and \toolbox VOBs began execution on 9/6/02 at 2:00:11 AM.
 
 my code is like:
 
 if (!-z $file)
 {
 open(LOG_FILE, $file) or warn  can not open $file:$!\n;
 my @read_lines = LOG_FILE;
 close (LOG_FILE);
 next unless chomp($read_lines[0]) =~ m#\\nest and 
 \toolbox VOBs\#;
 }
 
 it did not work for regular expression, can you help me to 
 figure what is wrong with it?
 

You forgot to escape the backslashes...change your code to read:

next unless chomp($read_lines[0]) =~ m#\\\nest and \\toolbox VOBs\#) 



perl -e sub Sub{return reverse(@_);}$_='.$yyye k ca i Xl $yyye jX $yyye
hto ZfX tq $uQ';s+[ \$]++g;s-j-P-;s^yyy^r^g;s:i:H:;s!X!
!g;s|Z|n|;s*Q*J*;s{q}{s}g;s(f)(A);$print=join('',Sub(split('')));system(
'echo',$print);

To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be. 

Adrian Okay, I won't top-post unless it's an emergency Stovall
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-22 Thread Stovall, Adrian M.
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, November 22, 2002 4:38 PM
 To: Stovall, Adrian M.; [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: regular expression question
 
 
 I tried that, it does not work for me!
 
 Lixin
 

This code should print yes, if it does, then the code works for you...

$line = 'Job \nest and \toolbox VOBs began execution on 9/6/02 at
2:00:11 AM.';
print $line\n;
if ($line =~ m#\\\nest and \\toolbox VOBs\#) { print yes; }
else { print no; }



perl -e sub Sub{return reverse(@_);}$i='ohce';$_='.$yyye k ca i Xl
$yyye jX $yyyehto ZfX tq $uQ';s+[ \$]++g;s-j-P-;s^yyy^r^g;s:i:H:;s!X!
!g;s|Z|n|;s*Q*J*;s{q}{s}g;s(f)(A);system(join('',Sub(split('',$i))),(joi
n('',Sub(split('');

To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be. 

Adrian Okay, I won't top-post unless it's an emergency Stovall
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression question

2002-11-22 Thread Cai_Lixin
Yes, it works fine for me!

Thanks a lot!

Have a nice day.

Lixin

-Original Message-
From: Stovall, Adrian M. [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 5:42 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: regular expression question


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, November 22, 2002 4:38 PM
 To: Stovall, Adrian M.; [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: regular expression question
 
 
 I tried that, it does not work for me!
 
 Lixin
 

This code should print yes, if it does, then the code works for you...

$line = 'Job \nest and \toolbox VOBs began execution on 9/6/02 at
2:00:11 AM.';
print $line\n;
if ($line =~ m#\\\nest and \\toolbox VOBs\#) { print yes; }
else { print no; }



perl -e sub Sub{return reverse(@_);}$i='ohce';$_='.$yyye k ca i Xl
$yyye jX $yyyehto ZfX tq $uQ';s+[ \$]++g;s-j-P-;s^yyy^r^g;s:i:H:;s!X!
!g;s|Z|n|;s*Q*J*;s{q}{s}g;s(f)(A);system(join('',Sub(split('',$i))),(joi
n('',Sub(split('');

To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be. 

Adrian Okay, I won't top-post unless it's an emergency Stovall
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Problem

2002-11-20 Thread Joseph P. Discenza
Lee Cullip wrote, on Wednesday, November 20, 2002 06:50
: Can anybody tell me what is wrong with the following line ? 
:
:   $prmpt = /(^.*[:]\/home\/oracle[:=]{1,2})/;
:
: I'm trying to use the value of $prmpt in a call to Net::Telnet but before I can
: use the variable $prmpt, perl is complaining about the format of the pattern.

Please try to post in plain text. Thanks.

Do you really want $prmpt to be true if $_ matched your pattern,
and false if it didn't? Perhaps you meant =~ instead of =.

What exactly is Perl's complaint about your pattern? I have a
few suggestions:

o Use a different pattern delimiter if you want to match
forward slashes, to avoid the leaning toothpick
phenomenon.
o You don't need to turn a single character into a 
character class: remove the brackets from the [:].
o Unless you need $1 later, you don't need parentheses
around the whole pattern. My guess is that Perl
didn't like having the start anchor inside parens.

Rewriting your pattern, then, I get this:

   $prmpt =~ !^(.*:/home/oracle[:=]{1,2})!;
   $prmpt = $1;

Is that what you really meant?

Good luck,

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]
 
  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! * 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Regular Expression Problem

2002-11-20 Thread Lee Cullip
Thanks for replying joe,
maybe if you see a bit more code you can get an idea for what I'm trying to
do :

use Net::Telnet;
use IO::File;

  $prmpt =~  /^(.*:\/home\/oracle[:=]{1,2})/;
  $telnet = new Net::Telnet(-prompt = $prmpt, -Errmode = 'die');
  $telnet-open($HOST);
  $telnet-login($USER,$PASSWORD);
  $telnet-cmd(-string =,-Timeout = 20,-prompt = $prmpt);
  @lines = $telnet-cmd(cat .netrc);
  $telnet-cmd(-string =,-Timeout = 20,-prompt = $prmpt);

  $netrctxt = new IO::File;
  $netrctxt-open('c:\temp\netrc.txt') or die Cannot open
C:\temp\netrc.txt for writing;
  $netrctxt-print(@lines);
  $netrctxt-close;
  $telnet-close;

Don't know if you can see what I'm trying to do, but I want the telnet
prompt to match $prmpt. Maybe I'm Tackling it the wrong way, but I'm still
not a perl guru (yet ;-) ).

I still get the following error message though :

bad match operator: opening delimiter missing: ^(.*:/home/oracle[:=]{1,2})
at C:\Documents and Settings\lcullip\My
Documents\programming\perl\oracheck.pl line 41

WTH am I doing wrong ?

TIA
Lee

- Original Message -
From: Joseph P. Discenza [EMAIL PROTECTED]
To: Lee Cullip [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Wednesday, November 20, 2002 12:35 PM
Subject: RE: Regular Expression Problem


Lee Cullip wrote, on Wednesday, November 20, 2002 06:50
: Can anybody tell me what is wrong with the following line ?
:
:   $prmpt = /(^.*[:]\/home\/oracle[:=]{1,2})/;
:
: I'm trying to use the value of $prmpt in a call to Net::Telnet but before
I can
: use the variable $prmpt, perl is complaining about the format of the
pattern.

Please try to post in plain text. Thanks.

Do you really want $prmpt to be true if $_ matched your pattern,
and false if it didn't? Perhaps you meant =~ instead of =.

What exactly is Perl's complaint about your pattern? I have a
few suggestions:

o Use a different pattern delimiter if you want to match
forward slashes, to avoid the leaning toothpick
phenomenon.
o You don't need to turn a single character into a
character class: remove the brackets from the [:].
o Unless you need $1 later, you don't need parentheses
around the whole pattern. My guess is that Perl
didn't like having the start anchor inside parens.

Rewriting your pattern, then, I get this:

   $prmpt =~ !^(.*:/home/oracle[:=]{1,2})!;
   $prmpt = $1;

Is that what you really meant?

Good luck,

Joe

==
  Joseph P. Discenza, Sr. Programmer/Analyst
   mailto:[EMAIL PROTECTED]

  Carleton Inc.   http://www.carletoninc.com
  574.243.6040 ext. 300fax: 574.243.6060

Providing Financial Solutions and Compliance for over 30 Years
* Please note that our Area Code has changed to 574! *

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Regular Expression Problem

2002-11-20 Thread csaba . raduly

On 20/11/2002 13:06:29 Lee Cullip wrote:

Thanks for replying Joe,
maybe if you see a bit more code you can get an idea for what I'm trying
to
do :

use Net::Telnet;
use IO::File;

$prmpt =~  /^(.*:\/home\/oracle[:=]{1,2})/;
[snip]

I still get the following error message though :

bad match operator: opening delimiter missing: ^(.*:/home/oracle[:
=]{1,2})
at C:\Documents and Settings\lcullip\My
Documents\programming\perl\oracheck.pl line 41

WTH am I doing wrong ?


You are not giving us the exact script, perhaps because you are re-typing
instead of copypaste.

I pasted the above regex into

perl -pwe s/^(.*:\/home\/oracle[:=]{1,2})/$1/

and it duly replaced :/home/oracle: with  :/home/oracle:


--
Csaba Ráduly, Software Engineer   Sophos Anti-Virus
email: [EMAIL PROTECTED]http://www.sophos.com
US Support: +1 888 SOPHOS 9 UK Support: +44 1235 559933


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Sorry (was RE: Regular Expression Help)

2002-06-12 Thread Lee Goddard

My fault: I'm sorry. I avoid usenet for the same reasons.
I apologise.

But really, such use of English makes me wonder about
possible use of Perl.

However, I must say that it is not the whole group, just
me.

Lee

At 04:19 12/06/2002, Allegakoen, Justin Devanandan wrote:
Lets not point fingers here, but this group is starting to become like
comp.lang.perl.misc

I subscribed to this list to avoid that type of . . . [insert disparaging
term here] . . .

We have all sort of people inside this list, from many country, some of our
grammer are
worst then others, but lets remember that we is all brothers in alms with
our won common
language - Perl ; )

Flame at will!

-Original Message-
From: Ron Grabowski [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 2:16 AM
To: [EMAIL PROTECTED]
Subject: Re: Regular Expression Help


  phone number. The three digit is
 
  are

digits
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Lee Goddard
perl -e while(1){print rand0.5?chr 47:chr 92}

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Help

2002-06-11 Thread Allegakoen, Justin Devanandan

Lets not point fingers here, but this group is starting to become like
comp.lang.perl.misc

I subscribed to this list to avoid that type of . . . [insert disparaging
term here] . . .

We have all sort of people inside this list, from many country, some of our
grammer are
worst then others, but lets remember that we is all brothers in alms with
our won common
language - Perl ; )

Flame at will!

-Original Message-
From: Ron Grabowski [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 12, 2002 2:16 AM
To: [EMAIL PROTECTED]
Subject: Re: Regular Expression Help


 phone number. The three digit is
 
 are

digits
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Help

2002-06-10 Thread Joseph Youngquist

This worked for me, 

$a = 12345678904539;

@numbers = split(/(\d{2})/, $a);

$NewA = join(' ', @numbers);

print \nNew A: $NewA;


hth,

Joe Y.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
steve silvers
Sent: Monday, June 10, 2002 8:39 AM
To: [EMAIL PROTECTED]
Subject: Regular Expression Help


How can I put a white space between every second number.

I have $a = (12345678904539);
I want 12 34 56 78 90 45 39

I'm trying

$a =~ s/\\d[2*]/ /g; #This obviously dosen't work :-(

Also how can I tell if there are 3,4, or 5 digits.

$3dig = (888);
$4dig = ();
$5dig = (8);

Thanks in advance.
Steve.


_
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Help

2002-06-10 Thread Rubinow, Larry

Joseph Youngquist wrote:

 This worked for me, 
 
 $a = 12345678904539;
 
 @numbers = split(/(\d{2})/, $a);
 
 $NewA = join(' ', @numbers);
 
 print \nNew A: $NewA;

Or, more simply, s/(\d\d)(?=\d\d)/$1  /g;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Help

2002-06-10 Thread Stephen J Martin

On Mon, 10 Jun 2002 09:10:05  
 Joseph Youngquist wrote:
This worked for me, 
$a = 12345678904539;
@numbers = split(/(\d{2})/, $a);
$NewA = join(' ', @numbers);
print \nNew A: $NewA;
 snip
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
steve silvers

How can I put a white space between every second number.
I have $a = (12345678904539);
I want 12 34 56 78 90 45 39

And this worked for me:
s%([\d]{2})%$1 %g;

---
Steve Martin
[EMAIL PROTECTED]


___
WIN a first class trip to Hawaii.  Live like the King of Rock and Roll
on the big Island. Enter Now!
http://r.lycos.com/r/sagel_mail/http://www.elvis.lycos.com/sweepstakes
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Regular Expression Help

2002-06-10 Thread Stephen J Martin

On Mon, 10 Jun 2002 13:38:52  
 steve silvers wrote:
How can I put a white space between every second number.

I have $a = (12345678904539);
I want 12 34 56 78 90 45 39

I'm trying

$a =~ s/\\d[2*]/ /g; #This obviously dosen't work :-(

Also how can I tell if there are 3,4, or 5 digits.

$3dig = (888);
$4dig = ();
$5dig = (8);

Thanks in advance.
Steve.

Oops, forgot to answer the second part. But we really need more info.
Is each number (i.e. a run of digits) in a separate variable as you have shown? If 
so simply find length($5dig), etc.

If it is not as simple as this (e.g. are the numbers in a file which you will read in, 
is there one number per line, is there anything else on the line, do you have to find 
all the numbers or just the first or just the last, etc.) something like
print 3 digits found: $\n if ($string =~ m%[\d]{3}%);
may get you started, but note that 3 digits will be found even when there are 4 or 5, 
so do the tests in the right order.
---
Steve Martin
[EMAIL PROTECTED]

PS I have learned something from this post, I didn't know you could define a string 
using brackets as you have done...




___
WIN a first class trip to Hawaii.  Live like the King of Rock and Roll
on the big Island. Enter Now!
http://r.lycos.com/r/sagel_mail/http://www.elvis.lycos.com/sweepstakes
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Help

2002-06-10 Thread Arms, Mike

PS I have learned something from this post, I didn't know you could 
define a string using brackets as you have done...

Except that what you learned:

  $a = (12345678904539);

is a bad practise. It is a novice mistake. What is being done here is
an anonymous list has been created with one element: 12345678904539 .
The scalar $a is then assigned the last element of the array (which
in this case is also the first element. To see this, try:

  $a = (123, 456);
  print $a;
  # you will get: 456

Also, the value is not a string. It is a number. The following is an
error:

  $a = (abc);
  # this is an error!

--
Mike Arms


-Original Message-
From: Stephen J Martin [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 10, 2002 8:51 AM
To: steve silvers
Cc: [EMAIL PROTECTED]
Subject: Re: Regular Expression Help


On Mon, 10 Jun 2002 13:38:52  
 steve silvers wrote:
How can I put a white space between every second number.

I have $a = (12345678904539);
I want 12 34 56 78 90 45 39

I'm trying

$a =~ s/\\d[2*]/ /g; #This obviously dosen't work :-(

Also how can I tell if there are 3,4, or 5 digits.

$3dig = (888);
$4dig = ();
$5dig = (8);

Thanks in advance.
Steve.

Oops, forgot to answer the second part. But we really need more info.
Is each number (i.e. a run of digits) in a separate variable as you have
shown? If so simply find length($5dig), etc.

If it is not as simple as this (e.g. are the numbers in a file which you
will read in, is there one number per line, is there anything else on the
line, do you have to find all the numbers or just the first or just the
last, etc.) something like
print 3 digits found: $\n if ($string =~ m%[\d]{3}%);
may get you started, but note that 3 digits will be found even when there
are 4 or 5, so do the tests in the right order.
---
Steve Martin
[EMAIL PROTECTED]

PS I have learned something from this post, I didn't know you could define a
string using brackets as you have done...

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Help

2002-06-10 Thread Jim Angstadt


--- Stephen J Martin [EMAIL PROTECTED] wrote:
 On Mon, 10 Jun 2002 09:10:05  
  Joseph Youngquist wrote:
 This worked for me, 
 $a = 12345678904539;
 @numbers = split(/(\d{2})/, $a);
 $NewA = join(' ', @numbers);
 print \nNew A: $NewA;
  snip
 -Original Message-
 From:
 [EMAIL PROTECTED]

[mailto:[EMAIL PROTECTED]]On
 Behalf Of
 steve silvers
 
 How can I put a white space between every second
 number.
 I have $a = (12345678904539);
 I want 12 34 56 78 90 45 39
 
 And this worked for me:
 s%([\d]{2})%$1 %g;
 
 ---
 Steve Martin
 [EMAIL PROTECTED]
 
snip 

When I run this snippet below, using the three
approaches from others, there are three slightly
different results.  See results at end.

Please note spaces at start and end of some results. 
Also, note results with a number of odd length.
 
Perhaps the difference is not significant to the OP.

I wish I could figure out a better way,
Jim

# -
#!perl
use strict;
use warnings;

if (1){
   # try with several numbers of diff lengths.
   my $a = 12345671234;
   my $b = 123456712345;
   my $c = 1234567123456;

   print \n;
   foreach my $n ( $a, $b, $c, ){
  # Joseph
  my @numbers = split(/(\d{2})/, $n);
  print \t*, join(' ', @numbers), *\n;

  # Larry
  my $L = $n;
  $L =~ s/(\d\d)(?=\d\d)/$1 /g;
  print \t*$L* \n;

  # Stephen
  my $s = $n;
  $s =~ s%([\d]{2})%$1 %g;
  print \t*$s* \n\n;
   }
} # end of if 0.
# -

produces:
* 12  34  56  71  23 4*
*12 34 56 71 234* 
*12 34 56 71 23 4* 

* 12  34  56  71  23  45*
*12 34 56 71 23 45* 
*12 34 56 71 23 45 * 

* 12  34  56  71  23  45 6*
*12 34 56 71 23 456* 
*12 34 56 71 23 45 6* 


__
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Help

2002-06-10 Thread Rubinow, Larry

Jim Angstadt wrote:

 When I run this snippet below, using the three
 approaches from others, there are three slightly
 different results.  See results at end.
 
 Please note spaces at start and end of some results. 
 Also, note results with a number of odd length.
  
 Perhaps the difference is not significant to the OP.
 
 I wish I could figure out a better way,
 Jim
 
 # -
 #!perl
 use strict;
 use warnings;
 
 if (1){
# try with several numbers of diff lengths.
my $a = 12345671234;
my $b = 123456712345;
my $c = 1234567123456;
 
print \n;
foreach my $n ( $a, $b, $c, ){
   # Joseph
   my @numbers = split(/(\d{2})/, $n);
   print \t*, join(' ', @numbers), *\n;
 
   # Larry
   my $L = $n;
   $L =~ s/(\d\d)(?=\d\d)/$1 /g;
   print \t*$L* \n;
 
   # Stephen
   my $s = $n;
   $s =~ s%([\d]{2})%$1 %g;
   print \t*$s* \n\n;
}
 } # end of if 0.
 # -
 
 produces:
   * 12  34  56  71  23 4*
   *12 34 56 71 234* 
   *12 34 56 71 23 4* 
 
   * 12  34  56  71  23  45*
   *12 34 56 71 23 45* 
   *12 34 56 71 23 45 * 
 
   * 12  34  56  71  23  45 6*
   *12 34 56 71 23 456* 
   *12 34 56 71 23 45 6* 

Nice job of breaking down the problem.

If you tweak my regular expression ever-so-slightly, it does a much cleaner
job:

#!perl
use strict;
use warnings;

if (1){
   # try with several numbers of diff lengths.
   my $a = 12345671234;
   my $b = 123456712345;
   my $c = 1234567123456;

   print \n;
   foreach my $n ( $a, $b, $c, ){
  # Joseph
  my @numbers = split(/(\d{2})/, $n);
  print \t*, join(' ', @numbers), *\n;

  # Larry
  my $L = $n;
  $L =~ s/(\d\d)(?=\d)/$1 /g; # Note: only one digit in the look-ahead
  print \t*$L* \n;

  # Stephen
  my $s = $n;
  $s =~ s%([\d]{2})%$1 %g;
  print \t*$s* \n\n;
   }
} # end of if 0.
__END__

Output:

* 12  34  56  71  23 4*
*12 34 56 71 23 4*
*12 34 56 71 23 4*

* 12  34  56  71  23  45*
*12 34 56 71 23 45*
*12 34 56 71 23 45 *

* 12  34  56  71  23  45 6*
*12 34 56 71 23 45 6*
*12 34 56 71 23 45 6*
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Help

2002-06-10 Thread Stephen J Martin

On Mon, 10 Jun 2002 10:29:28  
 Arms, Mike wrote:
PS I have learned something from this post, I didn't know you could 
define a string using brackets as you have done...

Except that what you learned:

  $a = (12345678904539);

is a bad practise. It is a novice mistake. What is being done here is
snip

Ah yes, of course, thanks for pointing that out. I had a feeling something was fishy 
there but didn't know what it was. Luckily I was not planning to use my new 
knowledge any time soon ... Also luckily my solution works with real strings too (I 
tested both, honestly).

Steve.



___
WIN a first class trip to Hawaii.  Live like the King of Rock and Roll
on the big Island. Enter Now!
http://r.lycos.com/r/sagel_mail/http://www.elvis.lycos.com/sweepstakes
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Regular Expression Help

2002-06-10 Thread steve silvers

Sorry for not elaborating on the 3 and 4 digit thing. I have a form that the 
end user inters there phone number. The three digit is for the area code and 
first 3 digits of the phone number. I just want to add some server side 
validation besides just javascript. So I have something like:

$query-('areacode') =~ m/\d{3}/g;

I want to make sure that there is only 3 digits, not two, or four.

Steve.


From: Stephen J Martin [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: steve silvers [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Re: Regular Expression Help
Date: Mon, 10 Jun 2002 14:50:53  

On Mon, 10 Jun 2002 13:38:52
  steve silvers wrote:
 How can I put a white space between every second number.
 
 I have $a = (12345678904539);
 I want 12 34 56 78 90 45 39
 
 I'm trying
 
 $a =~ s/\\d[2*]/ /g; #This obviously dosen't work :-(
 
 Also how can I tell if there are 3,4, or 5 digits.
 
 $3dig = (888);
 $4dig = ();
 $5dig = (8);
 
 Thanks in advance.
 Steve.

Oops, forgot to answer the second part. But we really need more info.
Is each number (i.e. a run of digits) in a separate variable as you have 
shown? If so simply find length($5dig), etc.

If it is not as simple as this (e.g. are the numbers in a file which you 
will read in, is there one number per line, is there anything else on the 
line, do you have to find all the numbers or just the first or just the 
last, etc.) something like
print 3 digits found: $\n if ($string =~ m%[\d]{3}%);
may get you started, but note that 3 digits will be found even when there 
are 4 or 5, so do the tests in the right order.
---
Steve Martin
[EMAIL PROTECTED]

PS I have learned something from this post, I didn't know you could define 
a string using brackets as you have done...




___
WIN a first class trip to Hawaii.  Live like the King of Rock and Roll
on the big Island. Enter Now!
http://r.lycos.com/r/sagel_mail/http://www.elvis.lycos.com/sweepstakes
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_
Send and receive Hotmail on your mobile device: http://mobile.msn.com

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression

2002-05-05 Thread Toby Stuart

Hi Steve,

This may not be the most eficient way, but it seems to work.

Someone will undoubtedly offer another (probably better) way to do it.

hth

Toby

snip
my @numbers = qw(01 02 03 03 05 08 09 12 14 13 11 18 17 12 15 16 15 16 12 13
14 16 17 22 23 24 25 25 23 22 21 20);
my %counts;

occur_in_array(\@numbers);

sub occur_in_array
{
my $aRef = shift;

foreach (@$aRef)
{
if (!exists($counts{$_}))
{
$counts{$_} = 1;
}
else
{
$counts{$_}++;
}
}

}

while (($key,$value) = each %counts)
{
print $key = $value\n;
}
/snip

-Original Message-
From: steve silvers [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 10:51 AM
To: [EMAIL PROTECTED]
Subject: Regular Expression


I have seen a couple of good regular expression questions asked and 
answered. Now I have a question. This is probably easy but i'm stuck on it. 
All I want to do is take.


my @numbers = 
(01,02,03,03,05,08,09,12,14,13,11,18,17,12,15,16,15,16,12,13,14,16,17,22,23,
24,25,25,23,22,21,20); 
  so on, could be up to 99. Read them in and get a count of all the numbers.

How many 01 or 17 or 22 there are in the array. I saw an answer for doing 
this with single numbers such as 2897, but how with double numbers. The out 
put i'm looking for is similar.

one - however many times.
two - however many times.
...
...
twenty - however many times.
...
...

You get the picture :-)

Any help would be great.
Thanks in advance. Steve.

_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression

2002-05-05 Thread Mike G

At 05:59 PM 05/05/2002, you wrote:
Hi Steve,

This may not be the most eficient way, but it seems to work.

Someone will undoubtedly offer another (probably better) way to do it.

This is good, but more than necessary...

Toby

snip
my @numbers = qw(01 02 03 03 05 08 09 12 14 13 11 18 17 12 15 16 15 16 12 13
14 16 17 22 23 24 25 25 23 22 21 20);
my %counts;


for my $num ( @numbers ) {
$counts{$num}++;
}

for my $num ( sort keys %counts ) {
print There were $counts{$num} occurences of $num\n;
}

Notably, no need to check for the existence of the hash element before incrementing 
it, even with strict.

occur_in_array(\@numbers);

sub occur_in_array
{
my $aRef = shift;

foreach (@$aRef)
{
if (!exists($counts{$_}))
{
$counts{$_} = 1;
}
else
{
$counts{$_}++;
}
}

}

while (($key,$value) = each %counts)
{
print $key = $value\n;
}
/snip

-Original Message-
From: steve silvers [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 06, 2002 10:51 AM
To: [EMAIL PROTECTED]
Subject: Regular Expression


I have seen a couple of good regular expression questions asked and 
answered. Now I have a question. This is probably easy but i'm stuck on it. 
All I want to do is take.


my @numbers = 
(01,02,03,03,05,08,09,12,14,13,11,18,17,12,15,16,15,16,12,13,14,16,17,22,23,
24,25,25,23,22,21,20); 
  so on, could be up to 99. Read them in and get a count of all the numbers.

How many 01 or 17 or 22 there are in the array. I saw an answer for doing 
this with single numbers such as 2897, but how with double numbers. The out 
put i'm looking for is similar.

one - however many times.
two - however many times.
...
...
twenty - however many times.
...
...

You get the picture :-)

Any help would be great.
Thanks in advance. Steve.

_
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Regular Expression Question

2002-03-04 Thread Tim . Moose

Try this

#
my $text = this is a website: www.hello-world.com and an e-mail: 
[EMAIL PROTECTED];
@found = $text =~ m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g;
print Found something interesting:\n, join \n, @found if @found;
#

which uses the m//g operation in a list context. Explanation from the 
perlop manpage:

The /g modifier specifies global pattern matching--that is, matching as many 
times as possible within the string. How it behaves depends on the 
context. In list context, it returns a list of the substrings matched by 
any capturing parentheses in the regular expression. If there are no 
parentheses, it returns a list of all the matched strings, as if there 
were parentheses around the whole pattern.
In scalar context, each execution of m//g finds the next match, returning true if it 
matches, and false if there is 
no further match. The position after the last match can be read or set 
using the pos() function; see pos in the perlfunc manpage. A failed match normally 
resets the search position to the beginning of 
the string, but you can avoid that by adding the /c modifier (e.g. m//gc). Modifying 
the target string also resets the search position.

Tim
_ 
Tim Moose |  T R I L O G Y
voice (512) 874-5342
fax (512) 874-8500 





Joseph Youngquist [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
03/04/2002 02:23 PM

 
To: [EMAIL PROTECTED]
cc: 
Subject:Regular Expression Question


Hello all, I hope some RegEx guru could answer why this stops once it 
finds
the first occurrence of the expression.

m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g

This is trying to find web addresses and e-mail addresses from any thing
that is sent to it...

So far, I'm able to get somesite.com, www.somesite.somedomain or
john.doe@somedomain, etc...

The thing that's not working, is of you have more than one of these on a
line sent to it.

so:
my $text = this is a website: www.hello-world.com and an e-mail:
[EMAIL PROTECTED]

if($text =~ m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g) {
  print Found something interesting!\n\t$1\n;
}

Thank you for the extra eye-balls,

Joe Y.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Question

2002-03-04 Thread Joseph Youngquist

Only problem with using html::parser is I'm not parsing an html document...
There are no html tags to hook onto ... if there were, I'd be happy.

  What the domain my script must do is this...say we have some text:

Once upon a time, in a galaxy far, far away. Yogi ([EMAIL PROTECTED]) found a
family where the Chi (for more information see: www.yedi-chi.ye) was strong.

Now, I need to wrap the e-mail addresses and web URLs with the html mark-up
to allow people to click on the link instead of copy and paste

Now if html::parser can re-wrap html on text that'd be slick but I'm not
familiar with the package.  Anyone out there know if this is possible with
the package?

Now...if this were a GUI where one was trapping events from a Text control
and adding a style to make the email or URL be blue underlined text, there
wouldn't be a need for html.

Thanks for the idea, I'll poke about with it...if no one sends a yes/no to
the question above.

Joe Y.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Jeffrey
Sent: Monday, March 04, 2002 3:51 PM
To: [EMAIL PROTECTED]
Subject: RE: Regular Expression Question


I've never used the module, but you might want to look
at HTML::Parser, and avoid the reinvention of that
round thingy (aka the Wheel).  ;)

--- Morse, Richard E. [EMAIL PROTECTED] wrote:
 I think that you may need to do this in a while
 loop:

 my @items
 while($text =~ m/your string here/g) {
   push @items, $1;
 }

 print join(\n, @items);

 HTH,
 Ricky

 -Original Message-
 From: Joseph Youngquist
 [mailto:[EMAIL PROTECTED]]
 Sent: Monday 04 March 2002 3:23 PM
 To: [EMAIL PROTECTED]
 Subject: Regular Expression Question


 Hello all, I hope some RegEx guru could answer why
 this stops once it finds
 the first occurrence of the expression.


m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g

 This is trying to find web addresses and e-mail
 addresses from any thing
 that is sent to it...

 So far, I'm able to get somesite.com,
 www.somesite.somedomain or
 john.doe@somedomain, etc...

 The thing that's not working, is of you have more
 than one of these on a
 line sent to it.

 so:
 my $text = this is a website: www.hello-world.com
 and an e-mail:
 [EMAIL PROTECTED]

 if($text =~

m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g)
 {
   print Found something interesting!\n\t$1\n;
 }

 Thank you for the extra eye-balls,

 Joe Y.

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe:
 http://listserv.ActiveState.com/mailman/mysubs
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe:
http://listserv.ActiveState.com/mailman/mysubs


=

Jeffrey Hottle
nkuvu at monkey yahoo dot com
(remove the animal to email me!)

__
Do You Yahoo!?
Yahoo! Sports - sign up for Fantasy Baseball
http://sports.yahoo.com
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: Regular Expression Question

2002-03-04 Thread Joseph Youngquist

Thanks, this did the trick...although when I tried this before I got an
infinit loop...bahh just my programing :)...any how, the

while($text =~ m/blah/g) {
 ...
}
works.

Again, thank you

Joe Y.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Morse, Richard E.
Sent: Monday, March 04, 2002 3:32 PM
To: 'Joseph Youngquist'; [EMAIL PROTECTED]
Subject: RE: Regular Expression Question


I think that you may need to do this in a while loop:

my @items
while($text =~ m/your string here/g) {
push @items, $1;
}

print join(\n, @items);

HTH,
Ricky

-Original Message-
From: Joseph Youngquist [mailto:[EMAIL PROTECTED]]
Sent: Monday 04 March 2002 3:23 PM
To: [EMAIL PROTECTED]
Subject: Regular Expression Question


Hello all, I hope some RegEx guru could answer why this stops once it finds
the first occurrence of the expression.

m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g

This is trying to find web addresses and e-mail addresses from any thing
that is sent to it...

So far, I'm able to get somesite.com, www.somesite.somedomain or
john.doe@somedomain, etc...

The thing that's not working, is of you have more than one of these on a
line sent to it.

so:
my $text = this is a website: www.hello-world.com and an e-mail:
[EMAIL PROTECTED]

if($text =~ m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g) {
  print Found something interesting!\n\t$1\n;
}

Thank you for the extra eye-balls,

Joe Y.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: Regular Expression Question

2002-03-04 Thread Tim . Moose

Resending because I never saw the message post. Sorry if duplicate.



Try this

#
my $text = this is a website: www.hello-world.com and an e-mail: 
[EMAIL PROTECTED];
@found = $text =~ m/\s+((?:[\w\d\-\~]{2,}[@|\.](?:[\w\d\-\~]{2,}\.?)+))/g;
print Found something interesting:\n, join \n, @found if @found;
#

which uses the m//g operation in a list context. Explanation from the 
perlop manpage:

The /g modifier specifies global pattern matching--that is, matching as many 
times as possible within the string. How it behaves depends on the 
context. In list context, it returns a list of the substrings matched by 
any capturing parentheses in the regular expression. If there are no 
parentheses, it returns a list of all the matched strings, as if there 
were parentheses around the whole pattern.
In scalar context, each execution of m//g finds the next match, returning true if it 
matches, and false if there is 
no further match. The position after the last match can be read or set 
using the pos() function; see pos in the perlfunc manpage. A failed match normally 
resets the search position to the beginning of 
the string, but you can avoid that by adding the /c modifier (e.g. m//gc). Modifying 
the target string also resets the search position.

Tim
_ 
Tim Moose |  T R I L O G Y
voice (512) 874-5342
fax (512) 874-8500 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: regular expression

2002-02-01 Thread Wang, Pin-Chieh

Bill, 
You misunderstood me, I need to convert

 $name[0] = tom???.???;
 $name[1] = tom*.???;
 
 into 
 
 $name[0] = tom[a-z|A-Z]{3}.[a-z|A-Z]{2};
 $name[1] = tom*.[0-9]{3};

So I can build a grep command to get all the files in this directory.
the purpose is to look through all files and check it's attributes.

PC




-Original Message-
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 3:23 PM
To: Wang, Pin-Chieh
Cc: [EMAIL PROTECTED]
Subject: Re: regular expression


Wang, Pin-Chieh wrote:

 Hi,
 
 Is there a simple way to convert a variable from wild card represention
into
 regular expression?
 
 i.e.
 
 $name[0] = tom???.???;
 $name[1] = tom*.???;
 
 into 
 
 $name[0] = tom[a-z|A-Z]{3}.[a-z|A-Z]{2};
 $name[1] = tom*.[0-9]{3};


Actually that's not correct.  The '?' can be converted to '.' and

the '*' can be converted to '.*' :

foreach (@name) {
s/\?/\./g;
s/\*/\.\*/g;
}

Depending on OS, certain characters aren't legal for the '.'.  So
you could change the '.' to a character class that represents the legal
characters that a filename can take on (or a negation of the ones it
can't).  But that shouldn't be necessary since the filesystem won't
have any files in it that aren't legal and the '.' should work fine.

-- 
   ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
  (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--  o // //  http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/__/_/_ Castle of Medieval Myth  Magic
http://www.todbe.com/


**
This email and any files transmitted with it from the ElPaso 
Corporation are confidential and intended solely for the 
use of the individual or entity to whom they are addressed. 
If you have received this email in error please notify the 
sender.
**
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: regular expression

2002-02-01 Thread Tillman, James

  $name[0] = tom???.???;
  $name[1] = tom*.???;
  
  into 
  
  $name[0] = tom[a-z|A-Z]{3}.[a-z|A-Z]{2};
  $name[1] = tom*.[0-9]{3};
 
 So I can build a grep command to get all the files in this directory.
 the purpose is to look through all files and check it's attributes.

I believe what you're needing is a regular expression to convert your
wildcard into a regular expression.

Try this for a start:

$name[0] =~ s|\.|\\.|g;
$name[0] =~ s|\?|.|g;
$name[0] =~ s|\*|.*|g;

I realize this doesn't even come close to being complete, but it's a start.

jpt
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular expression for an IPv4 address

2002-01-16 Thread Thiebaud Richard

The following:

use strict;
sub try1;
try1 001.001.001.001;
try1 1.1.101.1;
try1 002.2.102.001;
exit(0);

sub try1{
my $str = shift;
my $str2 = $str;
$str2 =~ s/(^|\.)(0*)(\d*)/$1$3/go;
print in: '$str' out: '$str2'\n;
}

gives:

C:\TEMPc:\temp\t1.pl
in: '001.001.001.001' out: '1.1.1.1'
in: '1.1.101.1' out: '1.1.101.1'
in: '002.2.102.001' out: '2.2.102.1'

 -Original Message-
 From: CARPENTER,STEPHEN (HP-Corvallis,ex1)
 [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, January 16, 2002 7:25 PM
 To: '[EMAIL PROTECTED]'
 Subject: Regular expression for an IPv4 address
 
 
 Hi,
   I'm a beginner with Perl and I'm sure this has been 
 done before: I
 would like to take a string like this '001.202.033.400' and 
 turn it into
 '1.202.33.400'. In other words, strip leading zeros from each 
 octet of an IP
 address. I could just split each piece into a different 
 variable, do it, and
 then recombine, but is seems like a one line regular 
 expression could work
 here instead. Thanks to all who reply!
 
 StephenC.
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
 
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular expression for an IPv4 address

2002-01-16 Thread Bro Ji, Ing.

Try for example
$ip = join '.',map {int} split /\./,$oldip;
or (if you resist on a regular expression)
$oldip =~ s/(?:^0+|(\.)0+([1-9]+)|(\.0)00)/$1.$2 || $3/eg;
JB


-Original Message-
From: CARPENTER,STEPHEN (HP-Corvallis,ex1)
[mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 17, 2002 1:25 AM
To: '[EMAIL PROTECTED]'
Subject: Regular expression for an IPv4 address

Hi,
I'm a beginner with Perl and I'm sure this has been done before:
I
would like to take a string like this '001.202.033.400' and turn it into
'1.202.33.400'. In other words, strip leading zeros from each octet of
an IP
address. I could just split each piece into a different variable, do it,
and
then recombine, but is seems like a one line regular expression could
work
here instead. Thanks to all who reply!

StephenC.
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular expression for an IPv4 address

2002-01-16 Thread Bullock, Howard A.

I am sure one of the experts can make these two regex lines into one, but
here it is..
$z = '001.022.003.040';
print $z\n;
$z =~ s/^0+//;
$z =~ s/\.0+/\./g;
print $z\n;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-12-02 Thread Carl Jolley

On Sat, 1 Dec 2001, linkagent wrote:

 - Original Message -
 From: $Bill Luebkert [EMAIL PROTECTED]
 To: linkagent [EMAIL PROTECTED]
  linkagent wrote:
   I need members help on this;
   Q1)As far as I know, \d* means match either 0 or more digits, since
   /(\d*)/ match 1006326869812 , therefore
   I could not see how /(\d*)(\d{4})(\d{5})/) could seperate 1006326869812
 into
   (1006)(3268)(69812)
 
  The last two parts of the regex pick up 4 and 5 digits resp.  The first
  picks up all the rest since it's 0 or more.  Obviously some back-tracking
  has to occur since the first length is unknown.  It might be faster to
  anchor the back end:
  /(\d*)(\d{4})(\d{5})$/

 Correct me if I am wrong;
 Therefore am I right to say that the matching sequence starts from the back
 first (which is not what I read from the books about matching / /).

 i.e in the following match /(\d*)(\d{4})(\d{5})$/
 the regexes look for $ first;
 then followed by (\d{5}) ;
 then followed by (\d{4})
 then (\d*)

   Q2)Out of curiosity, I tried the undermentioned but I could not
   understand why on the 3rd iteration it print only 3 instead of
   35968322963568389 :-
  
   for $number (1006326869812, 563296853235993 , 35968322963568389){
   print $1\n if ($number =~ /(\d*)/);
   }

  The third number is too large to express as an integer.
  Try putting quotes around it so it's treated as a string.

 I thought if the number is too large, it will display something like this
 3e0whatever-number, nevertheless, I will read on this.


Which may explain why the last number matched only on the leading 3 digit.
To find out for sure, the print statement could be changed to:

  print $1 number=$number\n if $number=~/(\d*)/;

Actually on my PC the third number printed out as: 3.59683229635684e+016

Note that the character in the second-most significant position of the
mantissa is the . character which doesn't match the \d* regex pattern.
Bill's suggestion to surround the numbers with quotes will allow the
entire string of digits to match.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-12-01 Thread linkagent

- Original Message -
From: $Bill Luebkert [EMAIL PROTECTED]
To: linkagent [EMAIL PROTECTED]
 linkagent wrote:
  I need members help on this;
  Q1)As far as I know, \d* means match either 0 or more digits, since
  /(\d*)/ match 1006326869812 , therefore
  I could not see how /(\d*)(\d{4})(\d{5})/) could seperate 1006326869812
into
  (1006)(3268)(69812)

 The last two parts of the regex pick up 4 and 5 digits resp.  The first
 picks up all the rest since it's 0 or more.  Obviously some back-tracking
 has to occur since the first length is unknown.  It might be faster to
 anchor the back end:
 /(\d*)(\d{4})(\d{5})$/

Correct me if I am wrong;
Therefore am I right to say that the matching sequence starts from the back
first (which is not what I read from the books about matching / /).

i.e in the following match /(\d*)(\d{4})(\d{5})$/
the regexes look for $ first;
then followed by (\d{5}) ;
then followed by (\d{4})
then (\d*)

  Q2)Out of curiosity, I tried the undermentioned but I could not
  understand why on the 3rd iteration it print only 3 instead of
  35968322963568389 :-
 
  for $number (1006326869812, 563296853235993 , 35968322963568389){
  print $1\n if ($number =~ /(\d*)/);
  }

 The third number is too large to express as an integer.
 Try putting quotes around it so it's treated as a string.

I thought if the number is too large, it will display something like this
3e0whatever-number, nevertheless, I will read on this.

Thank You.



_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-12-01 Thread Terry Carroll

On Sat, 1 Dec 2001, linkagent wrote:

 - Original Message -
 From: $Bill Luebkert [EMAIL PROTECTED]
 To: linkagent [EMAIL PROTECTED]
  linkagent wrote:
   I need members help on this;
   Q1)As far as I know, \d* means match either 0 or more digits, since
   /(\d*)/ match 1006326869812 , therefore
   I could not see how /(\d*)(\d{4})(\d{5})/) could seperate 1006326869812
 into
   (1006)(3268)(69812)
 
  The last two parts of the regex pick up 4 and 5 digits resp.  The first
  picks up all the rest since it's 0 or more.  Obviously some back-tracking
  has to occur since the first length is unknown.  It might be faster to
  anchor the back end:
  /(\d*)(\d{4})(\d{5})$/
 
 Correct me if I am wrong;
 Therefore am I right to say that the matching sequence starts from the back
 first (which is not what I read from the books about matching / /).

Let me see if I understand it, because this had me scrathing my head 
for a while, too (I'm not so great at regex).  The regex 

  /(\d*)(\d{4})(\d{5})/

Means match any number of digits that is followed by a string of 4
digits, that is followed by a string of 5 digits, (and slop those three
things into $1, $2, and $3).

So, using, for example, 1006326869812, 1006 is the only string of digits
that is followed by a string of 4 digits (3268), that is followed by a
string of 5 digits (69812).

Now, the regex /(\d*)(\d{4})(\d{5})/ means almost the same thing: match
any number of digits that is followed by a string of 4 digits, that is
followed by a string of 5 digits that ends at the end of the string (and
slop into $1, $2 and $3).

Same thing in your context, but by telling perl up front about that
end-of-string, perl should start its processing using that part of the
regex, rather than spend a lot of computation trying all the possible
permutations that might match that initial (\d*).

   Q2)Out of curiosity, I tried the undermentioned but I could not
   understand why on the 3rd iteration it print only 3 instead of
   35968322963568389 :-
 
  The third number is too large to express as an integer.
  Try putting quotes around it so it's treated as a string.
 
 I thought if the number is too large, it will display something like this
 3e0whatever-number, nevertheless, I will read on this.

That would be consistent with matching only the first (\d*), and matching
it only to '3'.


-- 
Terry Carroll|  There ain't no such thing as a free lunch.
Santa Clara, CA  |   - Washington Legal Foundation v. Legal 
[EMAIL PROTECTED]  | Foundation of Washington, no. 98-35154
Modell delendus est  | (9th Cir. Nov. 14, 2001) (Kozinski, dissenting)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-12-01 Thread Keith C. Ivey

linkagent [EMAIL PROTECTED] wrote:

 Correct me if I am wrong;
 Therefore am I right to say that the matching sequence starts
 from the back first (which is not what I read from the books
 about matching / /).

No, the matcher starts from the front, but when it fails it 
backtracks to see if there's a match with earlier * and + being 
less greedy.

 I thought if the number is too large, it will display something
 like this 3e0whatever-number, nevertheless, I will read on this.

It does display something like that.  Try print  
35968322963568389.  You'll get something like 
3.59683229635684e+016, which is what Perl does when 
asked to convert the number 35968322963568389 to a string.  
Regex matching works on strings, so the '\d*' stops 
matching at the '.'.

-- 
Keith C. Ivey [EMAIL PROTECTED]
Washington, DC
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-12-01 Thread $Bill Luebkert

linkagent wrote:

 
 Correct me if I am wrong;
 Therefore am I right to say that the matching sequence starts from the back
 first (which is not what I read from the books about matching / /).
 
 i.e in the following match /(\d*)(\d{4})(\d{5})$/
 the regexes look for $ first;
 then followed by (\d{5}) ;
 then followed by (\d{4})
 then (\d*)


To the best of my knowledge, the engine always starts at the front.

Anchoring at the back makes the back-tracking easier/simpler.

-- 
   ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
  (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--  o // //  http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/__/_/_ Castle of Medieval Myth  Magic http://www.todbe.com/

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-11-30 Thread linkagent

- Original Message -
From: Ron Hartikka [EMAIL PROTECTED]
 for $number (1006326869812, 563296853235993 , 35968322963568389){
 print $1-$2-$3\n if ($number =~ /(\d*)(\d{4})(\d{5})/);

I need members help on this;
Q1)As far as I know, \d* means match either 0 or more digits, since
/(\d*)/ match 1006326869812 , therefore
I could not see how /(\d*)(\d{4})(\d{5})/) could seperate 1006326869812 into
(1006)(3268)(69812)

Q2)Out of curiosity, I tried the undermentioned but I could not
understand why on the 3rd iteration it print only 3 instead of
35968322963568389 :-

for $number (1006326869812, 563296853235993 , 35968322963568389){
print $1\n if ($number =~ /(\d*)/);
}

Results :-
1006326869812
563296853235993
3

Thanks




_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-11-30 Thread $Bill Luebkert

linkagent wrote:

 - Original Message -
 From: Ron Hartikka [EMAIL PROTECTED]
 
for $number (1006326869812, 563296853235993 , 35968322963568389){
print $1-$2-$3\n if ($number =~ /(\d*)(\d{4})(\d{5})/);

 
 I need members help on this;
 Q1)As far as I know, \d* means match either 0 or more digits, since
 /(\d*)/ match 1006326869812 , therefore
 I could not see how /(\d*)(\d{4})(\d{5})/) could seperate 1006326869812 into
 (1006)(3268)(69812)

The last two parts of the regex pick up 4 and 5 digits resp.  The first 
picks up all the rest since it's 0 or more.  Obviously some back-tracking 
has to occur since the first length is unknown.  It might be faster to 
anchor the back end:

/(\d*)(\d{4})(\d{5})$/


 Q2)Out of curiosity, I tried the undermentioned but I could not
 understand why on the 3rd iteration it print only 3 instead of
 35968322963568389 :-
 
 for $number (1006326869812, 563296853235993 , 35968322963568389){
 print $1\n if ($number =~ /(\d*)/);
 }


The third number is too large to express as an integer.

Try putting quotes around it so it's treated as a string.

-- 
   ,-/-  __  _  _ $Bill Luebkert   ICQ=14439852
  (_/   /  )// //   DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--  o // //  http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/__/_/_ Castle of Medieval Myth  Magic http://www.todbe.com/

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular expression help

2001-11-29 Thread Ron Hartikka

for $number (1006326869812, 563296853235993 , 35968322963568389){
print $1-$2-$3\n if ($number =~ /(\d*)(\d{4})(\d{5})/);

}

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]On Behalf Of
 [EMAIL PROTECTED]
 Sent: Thursday, November 29, 2001 3:32 PM
 To: [EMAIL PROTECTED]
 Subject: Regular expression help
 
 
 I need help creating a regular expression to do the following.
 
 I have the following numbers:
 
 1006326869812
 563296853235993
 35968322963568389
 
 and it needs to be broken up like this
 
 1006-3268-69812
 563296-8532-35993
 35968322-9635-68389
 
 Notice the second group of numbers is always 4 places and the 
 last group is
 always 5 places.
 
 I'm stumped and not to good with RE's. Any pointers would be great.
 
 Rob
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
 
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular expression help

2001-11-29 Thread Rubinow, Larry

[EMAIL PROTECTED] wrote:

 I need help creating a regular expression to do the following.
 
 I have the following numbers:
 
 1006326869812
 563296853235993
 35968322963568389
 
 and it needs to be broken up like this
 
 1006-3268-69812
 563296-8532-35993
 35968322-9635-68389
 
 Notice the second group of numbers is always 4 places and the 
 last group is
 always 5 places.
 
 I'm stumped and not to good with RE's. Any pointers would be great.


s/(\d+)(\d{4})(\d{5})/$1-$2-$3/;
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular expression help

2001-11-29 Thread Hanson, Robert


You don't even need a regex although you could use one...

# untested
my $num = 92739874598745;
$num =~ /^(\d*)(d{4})(\d{5})$/;
my ($n1, $n2, $n3) = ($1, $2, $3);

Or you could do this...

# untested
my $num = 92739874598745;
my $n1 = substr($num, 0, length($num) - 9);
my $n2 = substr($num, -9, 4);
my $n3 = substr($num, -5);

Also add some error checking unless you are sure that the number is at least
9 chars long.

Rob


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 29, 2001 3:32 PM
To: [EMAIL PROTECTED]
Subject: Regular expression help


I need help creating a regular expression to do the following.

I have the following numbers:

1006326869812
563296853235993
35968322963568389

and it needs to be broken up like this

1006-3268-69812
563296-8532-35993
35968322-9635-68389

Notice the second group of numbers is always 4 places and the last group is
always 5 places.

I'm stumped and not to good with RE's. Any pointers would be great.

Rob
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-11-29 Thread Jeffrey

How about something like
s/(\d+)(\d{4})(\d{5})/$1-$2-$3/
?

--- [EMAIL PROTECTED] wrote:
 I need help creating a regular expression to do the
 following.
 
 I have the following numbers:
 
 1006326869812
 563296853235993
 35968322963568389
 
 and it needs to be broken up like this
 
 1006-3268-69812
 563296-8532-35993
 35968322-9635-68389
 
 Notice the second group of numbers is always 4
 places and the last group is
 always 5 places.
 
 I'm stumped and not to good with RE's. Any pointers
 would be great.
 
 Rob
 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]

http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users


=

Jeffrey Hottle
nkuvu at yahoo dot com

__
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular expression help

2001-11-29 Thread David Kaufman

[EMAIL PROTECTED] wrote:

 I need help creating a regular expression to do the following.

 I have the following numbers:

 1006326869812
 563296853235993
 35968322963568389

 and it needs to be broken up like this

 1006-3268-69812
 563296-8532-35993
 35968322-9635-68389

 Notice the second group of numbers is always 4 places and the last group
is
 always 5 places.

 I'm stumped and not to good with RE's. Any pointers would be great.

try this:

$number=~s/^(\d+)(\d{4})(\d{5})$/$1-$2-$3/;

hth,

-dave

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: Regular expression help

2001-11-29 Thread rplane

Thanks to all those who responded

Rob

-Original Message-
From: Plane, Robert 
Sent: Thursday, November 29, 2001 3:32 PM
To: '[EMAIL PROTECTED]'
Subject: Regular expression help


I need help creating a regular expression to do the following.

I have the following numbers:

1006326869812
563296853235993
35968322963568389

and it needs to be broken up like this

1006-3268-69812
563296-8532-35993
35968322-9635-68389

Notice the second group of numbers is always 4 places and the last group is
always 5 places.

I'm stumped and not to good with RE's. Any pointers would be great.

Rob
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



[PBML] Re: Regular expression needed

2001-10-10 Thread Jorge Goncalvez






Hi, I have a file with several lines which begins with:
/bootp/linux/

I would like to match theses lines

I tried this  while (INFILE) {
chomp();
/^\/bootp/linux/\/

but it doesn't work how can I do ?

Thanks.











___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: [PBML] Re: Regular expression needed

2001-10-10 Thread Vroom, Tim
Title: RE: [PBML] Re: Regular expression needed





you need to escape all of the /'s in your path with in
the match


/^\/bootp\/linux\//;


should match;


a good technique for building regular expressions is to
match a small portion of what you're looking for. then
after you get that part working continue adding to your
regular expression, if that doesn't match you know something
you just added was faulty.


-Original Message-
From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, October 10, 2001 9:41 AM
To: [EMAIL PROTECTED]
Subject: [PBML] Re: Regular expression needed








Hi, I have a file with several lines which begins with:
/bootp/linux/


I would like to match theses lines


I tried this while (INFILE) {
 chomp();
 /^\/bootp/linux/\/


but it doesn't work how can I do ?


Thanks.












___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users





RE: [PBML] Re: Regular expression needed

2001-10-10 Thread Jeffrey

Another method is to specify different delimiters for
the match.  This avoids LTS (leaning toothpick
syndrome):

m#^/bootp/linux/#;
m%^/bootp/linux/%;
m(^/bootp/linux/);

Each of the lines above are equivalent -- they're also
equivalent to /^\/bootp\/linux\//;


--- Vroom, Tim [EMAIL PROTECTED] wrote:
 you need to escape all of the /'s in your path with
 in
 the match
 
 /^\/bootp\/linux\//;


=

Jeffrey
[EMAIL PROTECTED]

__
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: [PBML] Re: Regular expression needed

2001-10-10 Thread Thomas_M

Jeffrey [mailto:[EMAIL PROTECTED]] wrote:
 
 Another method is to specify different delimiters for
 the match.  This avoids LTS (leaning toothpick
 syndrome):
 
 m#^/bootp/linux/#;
 m%^/bootp/linux/%;
 m(^/bootp/linux/);
 
 Each of the lines above are equivalent -- they're also
 equivalent to /^\/bootp\/linux\//;

No one mentioned this: /^\Q/bootp/linux/\E/; 

also equivalent, but has an advantage when doing things like this:

$skipdir = '/bootp/linux/';
while (INFILE) {
next if /^\Q$skipdir\E/;
...
}

-- 
Mark Thomas[EMAIL PROTECTED]
Sr. Internet Architect User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;
 

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



  1   2   >