At the moment I can't think of why this makes a difference (somebody
help me here), but you aren't specifying a mode for the open() function.
Also, you're not checking whether your match succeeded before using $1
(which is what I think you meant on that last line).
I personally would write it a li
Ryan Dillinger wrote:
> Hello,
> I had two scripts that were identical, well almost. I ran the two
> together, but
> straghtened them out. Anyway I have one here, that when ran say's: Use
> of uninitialized
> value in pattern match (m//) at headline.pl line 7 and 10. I have
> changed differernt thi
Ryan Dillinger wrote:
> Hello,
> I had two scripts that were identical, well almost. I ran the two
> together, but
> straghtened them out. Anyway I have one here, that when ran say's: Use
> of uninitialized
> value in pattern match (m//) at headline.pl line 7 and 10. I have
> changed differernt thi
Ryan Dillinger wrote:
> [...]
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> open LYNX, "lynx -source http://www.perl.com/ |" or die "Can't open lynx:
> $!";
> $_ = "";
> $_ = until /standard\.def/;
>
If 'standard.def' is not found, this line loops forever.
> my $head = ;
> $head =~ m|^]
Ryan Dillinger wrote:
>
> Hello,
Hi Ryan
> I had two scripts that were identical, well almost. I ran the two together,
> but straghtened them out. Anyway I have one here, that when ran say's: Use of
> uninitialized value in pattern match (m//) at headline.pl line 7 and 10. I
> have changed dif
On Tue, 2006-07-11 at 18:48 -0700, Timothy Johnson wrote:
> open(LYNX,"<","lynx -source http://www.perl.com/ |") or die("Can't open
> lynx: $!");
I am not sure that this is right.
open(LYNX,"|-","lynx -source http://www.perl.com/";) or die("Can't open
lynx: $!");
I think this is.
Ta
Ken
--
Ken Foskey schreef:
> open(LYNX,"|-","lynx -source http://www.perl.com/";) or die("Can't open
> lynx: $!");
#!/usr/bin/perl
use warnings ;
use strict ;
my $cmd = 'lynx -source http://www.perl.com/' ;
open my $ph, '-|', $cmd
or die "\nError opening '$cmd', stopped $!" ;
while ( <
Eric Sand wrote:
>
> I am very new to Perl, but I sense a great adventure ahead after just
> programming with Cobol, Pascal, and C over the last umpteen years. I have
> written a perl script where I am trying to detect a non-printing
> character(Ctrl@ - Ctrl_) and then substitute a printing AS
[mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 09, 2003 11:58 AM
To: [EMAIL PROTECTED]
Subject: Re: Pattern Match
Eric Sand wrote:
>
> I am very new to Perl, but I sense a great adventure ahead after just
> programming with Cobol, Pascal, and C over the last umpteen years. I have
>
On Dec 9, 2003, at 2:37 PM, Tom Kinzer wrote:
Rob, can you explain the details of that replace? That's pretty
slick. I
see you're adding the hex value to get to the appropriate ASCII value,
but
didn't know you could do some of that gyration inside a regex.
The big secret there is the /e modifi
Tom Kinzer wrote:
>
> Rob Dixon wrote:
> >
> > Eric Sand wrote:
> > >
> > > I am very new to Perl, but I sense a great adventure ahead after just
> > > programming with Cobol, Pascal, and C over the last umpteen years. I have
> > > written a perl script where I am trying to detect a non-printin
Rob Dixon writes:
> Tom Kinzer wrote:
> I didn't think it was slick at all. In fact I was disappointed that
> it looked such a mess, but I don't see a better way.
Yes, it is indeed a mess, not only syntacticly, but also semantically.
While it might make a good teaching example to show what y
Robert Brown wrote:
>
> Rob Dixon writes:
>
> > Tom Kinzer wrote:
>
> > I didn't think it was slick at all. In fact I was disappointed that
> > it looked such a mess, but I don't see a better way.
>
> Yes, it is indeed a mess, not only syntacticly, but also semantically.
> While it might make a
Rob Dixon writes:
> Robert Brown wrote:
> >
> > Rob Dixon writes:
> >
> > > Tom Kinzer wrote:
> >
> > > I didn't think it was slick at all. In fact I was disappointed that
> > > it looked such a mess, but I don't see a better way.
> >
> > Yes, it is indeed a mess, not only syntacticly,
Robert Brown wrote:
>
> Rob Dixon writes:
> > Robert Brown wrote:
> > >
> > > Rob Dixon writes:
> > >
> > > > Tom Kinzer wrote:
> > >
> > > > I didn't think it was slick at all. In fact I was disappointed that
> > > > it looked such a mess, but I don't see a better way.
> > >
> > > Yes
Eric Sand wrote:
>
> Hi All,
Hello,
> I am very new to Perl,
Welcome. :-)
> but I sense a great adventure ahead after just
> programming with Cobol, Pascal, and C over the last umpteen years.
"Thinking in Perl" may take a while but it is not your grandfather's
programming language (sorry
Rob Dixon wrote:
>
> I didn't think it was slick at all. In fact I was disappointed that it looked
> such a mess, but I don't see a better way. Anyway, the statement is
>
> s/([\x00-\1F])/'^'.chr(ord($1) + 0x40)/eg
>
> where the regex is
>
> ([\x00-\1F])
Oops. That matches the characters
Rob Dixon writes:
> I'm sure you have something useful to say. This seems such a waste of
> your effort.
>
> Rob
I think we are failing to communicate. What I am asking is:
"Does the regular expression mechanism in perl optimize regular
expressions such as the one you used earlier in this t
It was Tuesday, December 09, 2003 when Robert Brown took the soap box, saying:
: Rob Dixon writes:
: > I'm sure you have something useful to say. This seems such a waste of
: > your effort.
: >
: > Rob
:
: I think we are failing to communicate. What I am asking is:
Thanks for the clarificat
Casey West writes:
> : "Does the regular expression mechanism in perl optimize regular
> : expressions such as the one you used earlier in this thread so that
> : the execution overhead is nearly as good as the C approach I outlined
> : earlier in this thread? In other words, for the problem s
Since we're now talking about performance issues, somebody should say something about
precompiling the regular expression, when you can, with either /o or qr(). I had a
process's running time go from 2min 45sec to just under 24sec simply by using qr on
the relevant regular expressions.
Robert
Before I finally burst my cyanide capsule, may I.. ?
Rj wrote:
>
> Rob Dixon writes:
> >
> > I didn't think it was slick at all. In fact I was
> > disappointed that it looked such a mess, but I don't see
> > a better way.
>
> Yes, it is indeed a mess, not only syntacticly, but also
> semantically.
From: Robert Brown <[EMAIL PROTECTED]>
> Casey West writes:
> > : "Does the regular expression mechanism in perl optimize regular >
> : expressions such as the one you used earlier in this thread so that
> > : the execution overhead is nearly as good as the C approach I
> outlined > : earlier i
On Wed, 10 Dec 2003 20:11:26 +0100,
"Jenda Krynicky" <[EMAIL PROTECTED]> wrote:
>
> 1. Perl builtins and especialy the regular expression engine is
> heavily optimized. So it might very well be quicker to use a regexp
> from Perl than to implement the same stuff in C. Unless you spend a
>
Robert Brown wrote:
> Casey West writes:
> Sorry again for my confusing way of expressing myself. Although I
> wrote my example in C, that was because I am a novice perl programmer,
> but an experienced C programmer, so I expressed my algorithm in C.
>
> The idea was to compare the execution effe
R. Joseph Newton writes:
> When used consciously, with at least a general awareness of the processing
> load being invoked, regexes can do some really incredible things.
Thanks! I especially appreciate the example you gave showing how to
trim both ends of a string: that it is more efficient to
Robert Brown wrote:
>
> R. Joseph Newton writes:
> > When used consciously, with at least a general awareness of the processing
> > load being invoked, regexes can do some really incredible things.
>
> Thanks! I especially appreciate the example you gave showing how to
> trim both ends of a stri
If word1 and word2 are on the same line, you could do something like this:
open(INFILE,"myfile.txt");
open(OUTFILE,">results.txt");
while(){
while($_ =~ /word1(.*)word2/g){ #get all characters between word1 and
word2, one match at a time
print OUTFILE $1."\n";
}
}
Someone else might
On Friday, April 12, 2002, at 12:38 , Raghupathy, Ramesh . wrote:
> I am sorry I was not clear in my question.
>
>The word1 and word2 may occur on different lines of the file and may
> occur in different combinations.
>
> for e.g :
>
> (not showing the new lines..)
>
>
> word1.word1.
> for e.g :
>
> (not showing the new lines..)
>
>
> word1.word1.word1word2word1...word2wor
> d2word2
> .
You're gonna want to check out (in the perldoc perlre manpage) (??{ code
}), which is an example of a recursive regular expression. They have an
exampl
On Friday, April 12, 2002, at 12:58 PM, David Gray wrote:
>> for e.g :
>>
>> (not showing the new lines..)
>>
>>
>> word1.word1.word1word2word1...word2wor
>> d2word2
>> .
>
> You're gonna want to check out (in the perldoc perlre manpage) (??{ code
> }), which
ll tell me you don't want to read the whole file in at once :)
that's when you have to do like what i offered the first time.
>> Thanks,
>> Ramesh
>>
>> -Original Message-
>> From: bob ackerman [mailto:[EMAIL PROTECTED]]
>> Sent: Friday, April
Naser Ali wrote:
I have an array which was created by slurrping a whole text file.
There are certain element in the array after reading the files
which contain only one word. I want to only match those array
elements which contain a single word and print it.
You need to anchor the word to both the
It's difficult to answer if you do not post the code with some input to
test it, but lets suppose you have this:
my @array;
@array = ; # slurp whole file
Then is easy to get what you want:
my @lines_with_single_word = grep /^\s*\S+\s*$/,array; # ^\s*\S+\s*$
means beginning of line, 0 or more wh
- Original Message -
From: "Naser Ali" <[EMAIL PROTECTED]>
Newsgroups: perl.beginners
To: <[EMAIL PROTECTED]>
Sent: Monday, June 21, 2004 3:52 PM
Subject: Pattern match
> Hello,
>
> I have an array which was created by slurrping a whole text file. There
are
> certain element in the arra
-
From: Roberto Etcheverry [mailto:[EMAIL PROTECTED]
Sent: Monday, June 21, 2004 5:44 PM
To: Naser Ali
Cc: [EMAIL PROTECTED]
Subject: Re: Pattern match
It's difficult to answer if you do not post the code with some input to
test it, but lets suppose you have this:
my @array;
@array = ;
Naser Ali wrote:
It works,
What is it that works?
The data pattern looks like this;
Aword
Yep, that's one word.
Aword Anotherword
That's two words. None of the posted suggestions matches that line.
You said in your original post:
"I want to only match those array elements which contain a single wo
Naser Ali wrote:
>
> Naser Ali wrote:
> >
> >I have an array which was created by slurrping a whole text file. There
> >are certain element in the array after reading the files which contain
> >only one word. I want to only match those array elements which contain
> >a single word and print it. Tr
> -Original Message-
> From: Vladimir Lemberg [mailto:[EMAIL PROTECTED]
> Sent: Monday, February 12, 2007 12:33
> To: beginners@perl.org
> Subject: pattern match
>
> Hi,
>
> I have a script, which suppose to find all *.xml files under
> the specified directory then process them.
> I'm
David,
Thanks you very much! It works -)
- Original Message -
From: "Wagner, David --- Senior Programmer Analyst --- WGO"
<[EMAIL PROTECTED]>
To: "Vladimir Lemberg" <[EMAIL PROTECTED]>;
Sent: Monday, February 12, 2007 12:46 PM
Subject: RE: pattern
Vladimir Lemberg am Montag, 12. Februar 2007 21:33:
> Hi,
Hi Vladimir
(in addition to Davids post)
> I have a script, which suppose to find all *.xml files under the specified
> directory then process them. I'm facing the pattern match problem:
>
> use strict;
> use warnings;
> use Win32;
> use
Vladimir Lemberg wrote:
> Hi,
Hello,
> I have a script, which suppose to find all *.xml files under the specified
> directory then process them. I'm facing the pattern match problem:
>
> use strict;
> use warnings;
> use Win32;
> use File::Find;
>
> @ARGV = Win32::GetCwd() unless @ARGV;
Why a
On 02/12/2007 02:33 PM, Vladimir Lemberg wrote:
Hi,
I have a script, which suppose to find all *.xml files under the specified
directory then process them.
I'm facing the pattern match problem:
use strict;
use warnings;
use Win32;
use File::Find;
@ARGV = Win32::GetCwd() unless @ARGV;
my @di
Mumia W. am Montag, 12. Februar 2007 21:53:
> On 02/12/2007 02:33 PM, Vladimir Lemberg wrote:
> > Hi,
> >
> > I have a script, which suppose to find all *.xml files under the
> > specified directory then process them. I'm facing the pattern match
> > problem:
> >
> > use strict;
> > use warnings;
>
It will match the same text, but it will not grab the same data into $1, $2,
and $3. The first one will assign each of these vars while the second will
only assign $1 with the last (\s+\d+).
Rob
-Original Message-
From: Srinivas Reddy [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 2
You wrote on 05/27/2009 10:50 AM:
> I want to match one ... pair.
>
> my code :
>
> my $pattern = "()";
...
> but I got the whole matches instead of one ... pair each loop.
Do need to de-greedify it.
my $pattern = "()";
This should do the trick.
hth
Alex
--
To unsubscribe, e-mail: beginner
Date sent: Wed, 27 May 2009 16:50:41 +0800
Subject:Pattern match question
From: Á÷Ë(R)`Oô
To: beginners@perl.org
> Hi, All:
>
> I want to parse data from a HTML page, data like:
>
>
>
>
>
On 04/05/2013 14:26, Florian Huber wrote:
I'm parsing a logfile and don't quite understand the behaviour of m//.
From a previous regex match I have already captured $+{'GFP'}:
use strict;
use warnings;
(...)
$text =~ m/ (?FILTERS .*? WRT)/x;# I simply have my whole
logfile in $text - I
On 05/04/2013 04:37 PM, Rob Dixon wrote:
On 04/05/2013 14:26, Florian Huber wrote:
I'm parsing a logfile and don't quite understand the behaviour of m//.
From a previous regex match I have already captured $+{'GFP'}:
use strict;
use warnings;
(...)
$text =~ m/ (?FILTERS .*? WRT)/x;# I
On May 4, 2013, at 11:53 AM, Florian Huber wrote:
> On 05/04/2013 04:37 PM, Rob Dixon wrote:
>> On 04/05/2013 14:26, Florian Huber wrote:
>>>
>>>
>>
>> Hello Florian
>>
>> First a couple of points
>>
>> - Don't use named captures for simple regexes like this. They make the
>> code harder
It was Wednesday, December 10, 2003 when Rob Dixon took the soap box, saying:
: Before I finally burst my cyanide capsule, may I.. ?
No, you may not.
I find walking around the block a good way to cool off. Counting to ten
has never done it for me, but you may try. *Both* of you.
Thanks for killi
tao wang wrote:
> hi,
>
> I'm trying to write a script to match a pattern like
> this: 1.10
>
> I wrote [\d.]+, but this also match with pattern ...
> , which has no number in it. Could somebody help me
> with it? I'm new to perl and scripts. thanks a lot.
/^\d+\.\d+/ which says ancho
How about something like this?
/\d{0,3}\.\d{0,3}/
which should match 0-3 digits followed by a period followed by 0-3 digits.
You should be able to see how you can change it if you want to expand how
many digits to capture. You could also try:
/\d+\.\d+/
Which matches one or more digits follo
tao wang wrote:
hi,
I'm trying to write a script to match a pattern like
this: 1.10
I wrote [\d.]+, but this also match with pattern ...
, which has no number in it. Could somebody help me
with it? I'm new to perl and scripts. thanks a lot.
\d.\d+
\d+.\d+
\d*.\d*
\d+\.+\d+
\d+\.*\d+
\
On Thu, Feb 13, 2003 at 04:39:17PM -0800, tao wang wrote:
> hi,
>
> I'm trying to write a script to match a pattern like
> this: 1.10
>
> I wrote [\d.]+, but this also match with pattern ...
> , which has no number in it. Could somebody help me
> with it? I'm new to perl and scripts. thank
I would do
/(?<=Retrieval command for )http:.*?:/
The "Retrieval" part now is contained in a "Look behind section", which
is to mean it's not going to be stored as part of the match.
I'm not sure what other cases you can get in that log file, but this
solves the problem for that particular line
ROTECTED]>
To: Graeme McLaren <[EMAIL PROTECTED]>
CC: [EMAIL PROTECTED]
Subject: Re: pattern match question
Date: 05 May 2004 11:09:19 +0100
MIME-Version: 1.0
Received: from onion.perl.org ([63.251.223.166]) by mc5-f36.hotmail.com
with Microsoft SMTPSVC(5.0.2195.6824); Wed, 5 May 2004 03:13:0
/(?<=Retrieval command for )http:.*?:/){
>
> It prints off the "Retrieval command for" part as it did before :(
>
>
> any ideas?
>
>
> Cheers,
>
> Graeme :)
>
>
>
> >From: Jose Alves de Castro <[EMAIL PROTECTED]>
> >To: Gr
D. Bolliger am Montag, 12. Februar 2007 23:03:
> Mumia W. am Montag, 12. Februar 2007 21:53:
> > On 02/12/2007 02:33 PM, Vladimir Lemberg wrote:
[snipped]
Mumia,
please excuse me for my inappropriate correction!
> > You probably want to push the filename onto the array if you get a
> > successfu
Hello,
I'm currently working with using regexp to extract XML:
Try this:
open(F,"$i");
while (defined( $p = )) {
chomp($p);
# Change statement
if ($p=~ /^(.+?)/){
$code=$1;
print $code;
}
-Original Message-
From: Dermot Paikkos [mailt
Hello Dermot,
Wednesday, December 05, 2001, Dermot Paikkos <[EMAIL PROTECTED]> wrote:
DP> Hi there,
DP> This is both frustrating and embarrassing. I can't capture the
DP> following data into a variable. The line I want is:
DP> GIAZUC00
DP> I have tried a multitude of Regex, none seems to be w
- Original Message -
From: "Dermot Paikkos" <[EMAIL PROTECTED]>
> Hi there,
> This is both frustrating and embarrassing. I can't capture the
> following data into a variable. The line I want is:
> GIAZUC00
>
> I have tried a multitude of Regex, none seems to be working. Here's
> my last at
Casey West wrote:
>
> : Before I finally burst my cyanide capsule, may I.. ?
>
> No, you may not.
>
> I find walking around the block a good way to cool off. Counting to ten
> has never done it for me, but you may try. *Both* of you.
>
> Thanks for killing the personal tension between you two, on t
It was Wednesday, December 10, 2003 when Rob Dixon took the soap box, saying:
: Casey West wrote:
: >
: > : Before I finally burst my cyanide capsule, may I.. ?
: >
: > No, you may not.
: >
: > I find walking around the block a good way to cool off. Counting to ten
: > has never done it for me, but
On 02/12/2007 04:17 PM, D. Bolliger wrote:
D. Bolliger am Montag, 12. Februar 2007 23:03:
Mumia W. am Montag, 12. Februar 2007 21:53:
On 02/12/2007 02:33 PM, Vladimir Lemberg wrote:
[snipped]
Mumia,
please excuse me for my inappropriate correction!
[...]
No problem. I'm glad I tested it be
65 matches
Mail list logo