Bill Harpley wrote:
Hi Gunnar,
I tried your suggestions but had no luck :-(
(1) I tried your idea of using a paragraph separator
local $/ = ''; # paragraph mode
while ( my $entry = ) {
if ( $entry =~ /\[([a-z0-9]{5})]/ ) {
print "$1\n";
Can you explain why this works but my orginal effort did not?
Many thanks,
Bill Harpley
-Original Message-
From: Rob Dixon [mailto:rob.di...@gmx.com]
Sent: Monday, January 26, 2009 7:19 PM
To: Perl Beginners
Cc: Bill Harpley
Subject: Re: Simple regex problem has me baffled
Bill Harple
each record into a single long
line before trying to perform regex match? Is there an easy way to do
this?
Regards,
Bill Harpley
-Original Message-
From: Gunnar Hjalmarsson [mailto:nore...@gunnar.cc]
Sent: Monday, January 26, 2009 5:22 PM
To: beginners@perl.org
Subject: Re: Simple re
it:]] but to no avail
So I remain stuck at square one !!
Regards,
Bill
-Original Message-
From: John W. Krahn [mailto:jwkr...@shaw.ca]
Sent: Monday, January 26, 2009 5:20 PM
To: Perl Beginners
Subject: Re: Simple regex problem has me baffled
Bill Harpley wrote:
> Hello,
He
uch as 'print
"$1\n";' in other scripts.
Regards,
Bill Harpley
-Original Message-
From: Mr. Shawn H. Corey [mailto:shawnhco...@magma.ca]
Sent: Monday, January 26, 2009 4:32 PM
To: Bill Harpley
Cc: beginners@perl.org
Subject: Re: Simple regex problem has
Bill Harpley wrote:
> Hello,
>
> I have simple regex problem that is driving me crazy.
>
> I am writing a script to analyse a log file. It contains Java related
> information about requests and responses.
>
> Each pair of Request (REQ) and Response (RES) calls have a u
Bill Harpley wrote:
[2009-01-23 09:20:48,719]TRACE [server-1] [http-80-5] a...@mydomain.net
:090123-092048567:f5825 (SetCallForwardStatusImpl.java:call:54) -
RequestId [81e80] SetCallForwardStatus.REQ { accountNumber:=W12345,
phoneNumber:=12121212121, onBusyStatus:=true, busyCurrent:=voicemail,
Bill Harpley wrote:
Hello,
Hello,
I have simple regex problem that is driving me crazy.
I am writing a script to analyse a log file. It contains Java related
information about requests and responses.
Each pair of Request (REQ) and Response (RES) calls have a unique
Request ID. This is a 5
On Mon, 2009-01-26 at 16:20 +0100, Bill Harpley wrote:
> foreach $entry(@list)
> {
>
> $entry =~ /\[([a-z0-9]{5})\]/;
>
> print "$1\n"; # print to screen
>
> # print FILE "$1\n";# print to file
> }
If there is no match, you are printing a uninitiali
Hello,
I have simple regex problem that is driving me crazy.
I am writing a script to analyse a log file. It contains Java related
information about requests and responses.
Each pair of Request (REQ) and Response (RES) calls have a unique
Request ID. This is a 5 digit hex number contained in
Rob Dixon wrote:
>> you want to know what's failing, right?
>
> Wrong. John was just pointing out that $1 would remain
> defined from a previous regex match in my previous post.
> This would mean that there was no way of telling in
> retrospect if the match had suceeded. The context of
> the prob
Hi Scott.
Scott R. Godin wrote:
> Rob Dixon wrote:
>
> > Paul Johnson wrote:
> > > Rob Dixon said:
> > >
> > > > $data =~ m/ <([^>]*)> /x;
> > > > my $newdata = $1;
> > >
> > > And if the match fails?
> >
> > Well I think it's likely that you'd want to do:
> >
> > $data =~ m/ <([^>]*)>
Rob Dixon wrote:
> Paul Johnson wrote:
>> Rob Dixon said:
>>
>> > $data =~ m/ <([^>]*)> /x;
>> > my $newdata = $1;
>>
>> And if the match fails?
>
> Well I think it's likely that you'd want to do:
>
> $data =~ m/ <([^>]*)> /x or die "Malformed data";
>
> or at least:
>
> $data
David wrote:
> Gregg R . Allen wrote:
>
>> It was close but what I got is : "JohnDoe.com" Instead of
>> "[EMAIL PROTECTED]".
>>
>> I think it has something to do with escaping the "@" sign. I've been
>> experimenting, but without much luck.
>>
>
> that's because Perl thinks @Someplace is an
Paul Johnson wrote:
> Rob Dixon said:
>
> > $data =~ m/ <([^>]*)> /x;
> > my $newdata = $1;
>
> And if the match fails?
Well I think it's likely that you'd want to do:
$data =~ m/ <([^>]*)> /x or die "Malformed data";
or at least:
$data =~ m/ <([^>]*)> /x or next;
as a mismatch
Rob Dixon said:
> $data =~ m/ <([^>]*)> /x;
> my $newdata = $1;
And if the match fails?
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
David --- Senior Programmer Analyst --- Wgo Wagner wrote:
> I had to change as follows:
> my $data = 'BlahBlahBlahBlah From: BlahsvilleDude
> <[EMAIL PROTECTED]>BlahBBlahBBlah';
>
> printf "bf:%-s\n", $data;
>
> $data =~ s/^.*<([^>]*)>.*$/$1/gs;
>
> printf "af:%-s\n", $data;
>
> but it does work t
Rob Hanson wrote:
> Try this...
>
> my $data = "BlahBlahBlahBlah From: BlahsvilleDude
> <[EMAIL PROTECTED]>BlahBBlahBBlah"
> $data =~ s/^.*<([^>]*)>.*$/$1/;
Hi Rob.
Anchoring the search at the start of the string and then allowing
'any number of anything' is the same as not anchoring it! Likewis
stop trapping text
>> .* = anything, zero or more times
>> $ = end of string
>> /$1/ = replace matched text with the trapped text
>>
>> Rob
>>
>> -Original Message-
>> From: Gregg R. Allen [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, March
Gregg R . Allen wrote:
> It was close but what I got is : "JohnDoe.com" Instead of
> "[EMAIL PROTECTED]".
>
> I think it has something to do with escaping the "@" sign. I've been
> experimenting, but without much luck.
>
that's because Perl thinks @Someplace is an array. if you have warning
Hi -
> -Original Message-
> From: Gregg R. Allen [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 04, 2003 2:16 PM
> To: Hanson, Rob
> Cc: Gregg R. Allen; [EMAIL PROTECTED]
> Subject: Re: Simple Regex Problem.
>
>
> It was close but what I got is : "Jo
ng text
[^>]* = anything but ">", zero or more times
)> = stop trapping text
.* = anything, zero or more times
$ = end of string
/$1/ = replace matched text with the trapped text
Rob
-Original Message-
From: Gregg R. Allen [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04,
PM
To: [EMAIL PROTECTED]
Cc: Gregg R. Allen
Subject: Simple Regex Problem.
So my boss just told me that he doesn't like the fact that the "From:"
field in our email database typically looks like:
"BlahBlahBlahBlah From: BlahsvilleDude
<[EMAIL PROTECTED]>BlahBBla
So my boss just told me that he doesn't like the fact that the "From:"
field in our email database typically looks like:
"BlahBlahBlahBlah From: BlahsvilleDude
<[EMAIL PROTECTED]>BlahBBlahBBlah"
(The "blahs", of course, are not literal, but can be anything.)
He wants the subject field to look
R. Joseph Newton wrote:
Ramprasad wrote:
hello all,
I have a file read into a single string, and I want to write a regex
that will tell me wether the file contains any non hashed line
__DATA__
## FORWARD
## FORWARD
## VACATION
## VACATION
__END__
But my regex fails in case of any blank lines o
Ramprasad wrote:
> hello all,
>
> I have a file read into a single string, and I want to write a regex
> that will tell me wether the file contains any non hashed line
>
> __DATA__
> ## FORWARD
> ## FORWARD
> ## VACATION
> ## VACATION
> __END__
>
> But my regex fails in case of any blank lines or
Ramprasad wrote:
hello all,
I have a file read into a single string, and I want to write a regex
that will tell me wether the file contains any non hashed line
This is my test script
#!/usr/bin/perl
#
{
local($/)=undef;
$str=;
}
print $str;
if($str=~/^\s*[^#]/m){
print "NOT ENTIRELY COMMENT
hello all,
I have a file read into a single string, and I want to write a regex
that will tell me wether the file contains any non hashed line
This is my test script
#!/usr/bin/perl
#
{
local($/)=undef;
$str=;
}
print $str;
if($str=~/^\s*[^#]/m){
print "NOT ENTIRELY COMMENT";
} else {
pri
28 matches
Mail list logo