/(\w+)/g gets the command as well and only the args are wanted, so it would
need to be
my @args = $s =~ / (\w+)/g;
shift @args;
also,
my VAR if TEST;
is deprecated IIRC and slated to be removed soon (as it's behavior is
surprising). It would probably be better to say
my @args = $s =~
On Wed, Mar 1, 2017 at 2:52 AM, Chas. Owens wrote:
> Sadly, Perl will only capture the last match of capture with a qualifier, so
> that just won't work. The split function really is the simplest and most
> elegant solution for this sort of problem (you have a string with a
mands properly as you can
escape " and use ' to create strings, but those details are left as an
exercise for the reader.
On Wed, Mar 1, 2017 at 4:04 AM Luca Ferrari <fluca1...@infinito.it> wrote:
> Hi all,
> I'm not sure if this is possible, but imagine I've got a line as follo
Hi Luca,
On Wed, 1 Mar 2017 10:01:34 +0100
Luca Ferrari <fluca1...@infinito.it> wrote:
> Hi all,
> I'm not sure if this is possible, but imagine I've got a line as follows:
>
> command arg1 arg2 arg3 arg4 ...
>
> I would like to capture all args with a single regexp,
Hi all,
I'm not sure if this is possible, but imagine I've got a line as follows:
command arg1 arg2 arg3 arg4 ...
I would like to capture all args with a single regexp, possibly with a
named capture, but I don't know exactly how to do:
my $re = qr/command\s+(?\w+)+/;
the above of course
On 8 July 2015 at 19:12, Nagy Tamas (TVI-GmbH) tamas.n...@tvi-gmbh.de wrote:
This is the code:
} elsif (defined($row) ($row =~ m/\(\*[ ]+\\@PATH\[ ]+:=[
]+'(\/)?([\*A-Za-z_ ]*(\/)?)+'[ ]\*\)?/)) {
# PATH first version: \(\*[ ]+@PATH[ ]+:=[ ]+'(\\/)?([\*A-Za-z_
]*(\\/)?)+'[ ]\*\)?
Tamas (TVI-GmbH)
Cc: beginners@perl.org
Betreff: Re: Regexp under PERL
On 8 July 2015 at 04:40, Nagy Tamas (TVI-GmbH) tamas.n...@tvi-gmbh.de wrote:
m/\(\*[ ]+\\@PATH\[ ]+:=[ ]+'(\/)?([\*A-Za-z_ ]*(\/)?)+'[ ]\*\)?/))
This is not the exact code you 're using obviously, because the last 2 )
marks
Hi,
PERL shows this line ok, but for the next lines it tells: String found where
operator expected at line...
m/\(\*[ ]+\\@PATH\[ ]+:=[ ]+'(\/)?([\*A-Za-z_ ]*(\/)?)+'[ ]\*\)?/))
So it seems that it is not ok.
I have the proper regexp that was tested at http://www.regexr.com/
# Tested
On 8 July 2015 at 04:40, Nagy Tamas (TVI-GmbH) tamas.n...@tvi-gmbh.de wrote:
m/\(\*[ ]+\\@PATH\[ ]+:=[ ]+'(\/)?([\*A-Za-z_ ]*(\/)?)+'[ ]\*\)?/))
This is not the exact code you 're using obviously, because the last 2
) marks are actually outside the regex.
Removing those ))'s makes the regex
Hi Bill,
On Thu, Jan 8, 2015 at 1:36 AM, $Bill n...@todbe.com wrote:
Why not just ignore the case ?
Sure it's an option.
Why does the script care what the case is ? Is there a rationale for
checking it ?
Of course there's, and of course my script does different things
depending on what I'm
On Wed, 7 Jan 2015 10:59:07 +0200
Shlomi Fish shlo...@shlomifish.org wrote:
Anyway, one can use the Benchmark.pm module to determine which
alternative is faster, but I suspect their speeds are not going to be
that much different. See:
http://perl-begin.org/topics/optimising-and-profiling/
On Wed, 7 Jan 2015 07:56:18 +
Andrew Solomon and...@geekuni.com wrote:
Hi Luca,
I haven't tested it, but my suspicion is that your first solution will
be faster because regular expressions (which don't contain variables)
are only compiled once, while you have a function call for every
Hi all,
this could be trivial, and I suspect the answer is that the regexp
engine is smart enough, but suppose I want to test the following:
$extention =~ / \.bat | \.BAT /x;
is the following a better solution?
$extension = lc $extension;
$extension =~ / \.bat /x;
In other words, when testing
(which would also match BaT, BAt...)
Andrew
On Wed, Jan 7, 2015 at 7:45 AM, Luca Ferrari fluca1...@infinito.it wrote:
Hi all,
this could be trivial, and I suspect the answer is that the regexp
engine is smart enough, but suppose I want to test the following:
$extention =~ / \.bat | \.BAT /x
Hi all,
how do you get all words starting with letter 'r' in a string.
thanks,rakesh
On Sat, 8 Mar 2014 18:20:48 +0530
rakesh sharma rakeshsharm...@hotmail.com wrote:
Hi all,
how do you get all words starting with letter 'r' in a string.
thanks,rakesh
/\br/
--
Don't stop where the ink does.
Shawn
--
To unsubscribe,
Hello Rakesh,
On Sat, 8 Mar 2014 18:20:48 +0530
rakesh sharma rakeshsharm...@hotmail.com wrote:
Hi all,
how do you get all words starting with letter 'r' in a string.
thanks,rakesh
1. Find all words in the sentence. Your idea of what is a word will
Am 08.03.2014 13:50, schrieb rakesh sharma:
how do you get all words starting with letter 'r' in a string.
What have you tried so far?
Greetings,
Janek
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/
On Mar 8, 2014, at 4:50 AM, rakesh sharma rakeshsharm...@hotmail.com wrote:
Hi all,
how do you get all words starting with letter 'r' in a string.
Try
my @rwords = $string =~ /\br\w*?\b/g;
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail:
On 3/8/2014 12:05 AM, Bill McCormick wrote:
I have the following string I want to extract from:
my $str = foo (3 bar): baz;
and I want to to extract to end up with
$p1 = foo;
$p2 = 3;
$p3 = baz;
the complication is that the \s(\d\s.+) is optional, so in then $p2 may
not be set.
getting
I have the following string I want to extract from:
my $str = foo (3 bar): baz;
and I want to to extract to end up with
$p1 = foo;
$p2 = 3;
$p3 = baz;
the complication is that the \s(\d\s.+) is optional, so in then $p2 may
not be set.
getting close was
my ($p1, $p3) = $str =~
([^]+) \(([0-9]+).*\) ([a-z]+)
On Mar 8, 2014 1:07 AM, Bill McCormick wpmccorm...@gmail.com wrote:
I have the following string I want to extract from:
my $str = foo (3 bar): baz;
and I want to to extract to end up with
$p1 = foo;
$p2 = 3;
$p3 = baz;
the complication is that the
On 3/8/2014 12:41 AM, shawn wilson wrote:
my $str = foo (3 bar): baz;
my $test = foo (3 bar): baz;
my ($p1, $p2, $p3) = $test =~ /([^]+) \(([0-9]+).*\) ([a-z]+)/;
print p1=[$p1] p2=[$p2] p3=[$p3]\n;
Use of uninitialized value $p1 in concatenation (.) or string at
./lock_report.pl line 11.
On Mar 8, 2014 1:41 AM, shawn wilson ag4ve...@gmail.com wrote:
Oh and per optional, just do (?:\([0-9]+).*\)?
You should probably use do
my @match = $str =~ / ([^]+) (?:\([0-9]+).*\)? ([a-z]+)/;
my ($a, $b, $c) = (scalar(@match) == 3 ? @match : $match[0], undef,
$match[1]);
([^]+)
On Mar 7, 2014, at 10:05 PM, Bill McCormick wpmccorm...@gmail.com wrote:
I have the following string I want to extract from:
my $str = foo (3 bar): baz;
and I want to to extract to end up with
$p1 = foo;
$p2 = 3;
$p3 = baz;
the complication is that the \s(\d\s.+) is optional, so
systems than on my 6 year old systems.
Here's some of the relevant details:
+ 6 year old server, 32 bit architecture, CentOS5 perl5.8
perl, and in particular regexp operations, perform reasonably fast.
+ Very new server, 64 bit architecture, CentOS6, perl5.10 (and have tried
perl5.18)
perl
seeing. Basically, I'm seeing perl performance significantly slower on my
new systems than on my 6 year old systems.
Here's some of the relevant details:
+ 6 year old server, 32 bit architecture, CentOS5 perl5.8
perl, and in particular regexp operations, perform reasonably fast.
+ Very new
, and in particular regexp operations, perform reasonably fast.
+ Very new server, 64 bit architecture, CentOS6, perl5.10 (and have tried
perl5.18)
perl, and in particular regexp operations, perform significantly slower
than on the 6 year old server. That struck me as odd right off. I though
details:
+ 6 year old server, 32 bit architecture, CentOS5 perl5.8
perl, and in particular regexp operations, perform reasonably fast.
+ Very new server, 64 bit architecture, CentOS6, perl5.10 (and have
tried perl5.18)
perl, and in particular regexp operations, perform significantly slower
than
new systems than on my 6 year old systems.
Here's some of the relevant details:
+ 6 year old server, 32 bit architecture, CentOS5 perl5.8
perl, and in particular regexp operations, perform reasonably fast.
+ Very new server, 64 bit architecture, CentOS6, perl5.10 (and have
tried perl5.18
Hi,
I'm just wondering if it is possible to place a regexp as a value into
an hash so to use it later as something like:
my $string =~ $hash_ref-{ $key };
Is it possible? Should I take into account something special?
Thanks,
Luca
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
On Sat, Jan 25, 2014 at 03:51:53PM +0100, Luca Ferrari wrote:
Hi,
I'm just wondering if it is possible to place a regexp as a value into
an hash so to use it later as something like:
my $string =~ $hash_ref-{ $key };
Is it possible? Should I take into account something special?
Yes
On Sat, Jan 25, 2014 at 4:12 PM, Paul Johnson p...@pjcj.net wrote:
$ perl -E '$h = { a = qr/y/ }; say $_ =~ $h-{a} for qw(x y z)'
Thanks, but then another doubt: having a look at
http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators I dont
understand how I can use the regexp
On Sat, Jan 25, 2014 at 06:41:00PM +0100, Luca Ferrari wrote:
On Sat, Jan 25, 2014 at 4:12 PM, Paul Johnson p...@pjcj.net wrote:
$ perl -E '$h = { a = qr/y/ }; say $_ =~ $h-{a} for qw(x y z)'
Thanks, but then another doubt: having a look at
http://perldoc.perl.org/perlop.html#Regexp-Quote
On Jun 8, 2013, at 8:06 PM, Noah wrote:
Hi there,
I am attempting to parse the following output and not quite sure how to do
it. The text is in columns and spaced out that way regardless if there are
0 numbers in say col5 or Col 6 or not. If the column has an entry then I
want to
A18 A5 A5 A1',$line);
Exactly what you need to do depends upon the exact nature of your data and how
much it varies from line to line.
Good luck!
Thanks Jim,
Here is the regexp I came up with. Works really well
if ($line =~
/^\*\s(\S+)\s+(\S)\s+(\d+)\s{6}([\s\d]{0,5})\s
Hi there,
I am attempting to parse the following output and not quite sure how to
do it. The text is in columns and spaced out that way regardless if
there are 0 numbers in say col5 or Col 6 or not. If the column has an
entry then I want to save it to a variable if there is no entry then
On Fri, Jan 11, 2013 at 2:01 PM, Christer Palm b...@bredband.net wrote:
Do you have suggestions on this character issue? Is it possible to determine
the character set of a text efficiently? Is it other ways to solve the
problem?
As far as other ways to solve the problem, my suggestion would
On Sat, Jan 12, 2013 at 12:56 PM, Charles DeRykus dery...@gmail.com wrote:
On Fri, Jan 11, 2013 at 2:01 PM, Christer Palm b...@bredband.net wrote:
Hi!
I have a perl script that parses RSS streams from different news sources and
experience problems with national characters in a regexp
On Fri, Jan 11, 2013 at 2:01 PM, Christer Palm b...@bredband.net wrote:
Hi!
I have a perl script that parses RSS streams from different news sources and
experience problems with national characters in a regexp function used for
matching a keyword list with the RSS data.
Everything works
Hi!
I have a perl script that parses RSS streams from different news sources and
experience problems with national characters in a regexp function used for
matching a keyword list with the RSS data.
Everything works fine with a simple regexp for plain english i.e. words
containing
On Jan 11, 2013, at 2:01 PM, Christer Palm wrote:
Hi!
I have a perl script that parses RSS streams from different news sources and
experience problems with national characters in a regexp function used for
matching a keyword list with the RSS data.
Everything works fine with a simple
On Fri, Jan 11, 2013 at 11:01:45PM +0100, Christer Palm wrote:
Hi!
Hello,
I have a perl script that parses RSS streams from different
news sources and experience problems with national characters
in a regexp function used for matching a keyword list with the
RSS data.
Everything works
On 2012-12-15 06:13, timothy adigun wrote:
Using Dr., Ruud's data. This is another way of doing it:
[solution using a hash]
Realize that with keys(), the input order is not preserved.
Another difference is that when a key comes back later,
the hash solution will collide those, which is
Hi!
I work in a library and i need to have several fields in one line
Example
I have this
=995 \\$xPR$wLivre
=995 \\$bECAM$cECAM
=995 \\$n
=995 \\$oDisponible
=995 \\$kG1 42171
and i want in one line
=995 \\$bECAM$cECAM$kG1 42171$n$oDisponible$xPR$wLivre
i complete my email
Hi!
I work in a library and i need to have several fields in one line
Example
I have this
=995 \\$xPR$wLivre
=995 \\$bECAM$cECAM
=995 \\$n
=995 \\$oDisponible
=995 \\$kG1 42171
and i want in one line
=995 \\$bECAM$cECAM$kG1 42171$n$oDisponible$xPR$wLivre
How could
On 2012-12-14 14:54, samuel desseaux wrote:
=995 \\$xPR$wLivre
=995 \\$bECAM$cECAM
=995 \\$n
=995 \\$oDisponible
=995 \\$kG1 42171
and i want in one line
=995 \\$bECAM$cECAM$kG1 42171$n$oDisponible$xPR$wLivre
echo -n '1 a
1 b
1 c
2 x
=995 \\$xPR$wLivre
=995 \\$bECAM$cECAM
=995
Hi,
On Fri, Dec 14, 2012 at 2:53 PM, samuel desseaux sdesse...@gmail.comwrote:
Hi!
I work in a library and i need to have several fields in one line
Example
I have this
=995 \\$xPR$wLivre
=995 \\$bECAM$cECAM
=995 \\$n
=995 \\$oDisponible
=995 \\$kG1 42171
and i want in one
, 15 December 2012 10:43 AM
Subject: Re: question of regexp or (another solution)
Hi,
On Fri, Dec 14, 2012 at 2:53 PM, samuel desseaux sdesse...@gmail.comwrote:
Hi!
I work in a library and i need to have several fields in one line
Example
I have this
=995 \\$xPR$wLivre
=995 \\$bECAM
On Mon, Jan 23, 2012 at 2:12 AM, David Christensen
dpchr...@holgerdanske.com wrote:
beginners@perl.org:
While coding some tests tonight, I discovered that Scalar::Util::blessed()
considers Regexp references to be blessed.
Is this a bug or a feature?
Implementation detail. Internally
beginners@perl.org:
While coding some tests tonight, I discovered that
Scalar::Util::blessed() considers Regexp references to be blessed.
Is this a bug or a feature?
TIA,
David
2012-01-22 21:07:57 dpchrist@p43400e ~/sandbox/perl
$ cat blessed
#! /usr/bin/perl
# $Id: blessed,v 1.1 2012
anything.mp3/ at Untitled1 line 13.
So how do I rewrite the regexp.
Thanks.
## script ###
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
my @datas = (test.mp3 , only one brace here[anything.mp3 , whatever.mp3);
while (@datas){
my $ref = splice @datas,0,1;
foreach
this Unmatched [ in regex; marked by -- HERE in m/only one
brace here[ -- HERE anything.mp3/ at Untitled1 line 13.
So how do I rewrite the regexp.
Thanks.
## script ###
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
my @datas = (test.mp3 , only one brace here[anything.mp3
one brace here[-- HERE anything.mp3/ at Untitled1 line 13.
So how do I rewrite the regexp.
Thanks.
## script ###
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
my @datas = (test.mp3 , only one brace here[anything.mp3 , whatever.mp3);
while (@datas){
my $ref = splice @datas
On 2011-06-13 14:05, eventual wrote:
I have a list of mp3 files in my computer and some of the file names consists of a
bracket like this darling I love [you.mp3
I wish to check them for duplicates using the script below, but theres error msg like this
Unmatched [ in regex; marked by-- HERE
I have a list of mp3 files in my computer and some of the file names consists
of a bracket like this darling I love [you.mp3
I wish to check them for duplicates using the script below, but theres error
msg like this Unmatched [ in regex; marked by -- HERE in m/only one brace
here[ -- HERE
From: Stanislaw Findeisen
Suppose you have a collection of books, and want to provide your users
with the ability to search the book title, author or content using
regular expressions.
But you don't want to let them execute any code.
How would you validate/compile/evaluate the user
On 2011-06-02 14:27, Bob McConnell wrote:
From: Stanislaw Findeisen
Suppose you have a collection of books, and want to provide your users
with the ability to search the book title, author or content using
regular expressions.
But you don't want to let them execute any code.
How would
2011/6/1 Stanisław Findeisen s...@eisenbits.com
Suppose you have a collection of books, and want to provide your users
with the ability to search the book title, author or content using
regular expressions.
But you don't want to let them execute any code.
How would you
Stanisław == Stanisław Findeisen s...@eisenbits.com writes:
Stanisław But you don't want to let them execute any code.
Unless use re 'eval' is in scope, /$a/ is safe even if $a came from an
untrusted source, as long as you limit the run-time to a few seconds or
so with an alarm. (Some regex
On Wed, Jun 01, 2011 at 11:25:39PM +0200, Stanisław Findeisen wrote:
Suppose you have a collection of books, and want to provide your users
with the ability to search the book title, author or content using
regular expressions.
But you don't want to let them execute any code.
How would
Suppose you have a collection of books, and want to provide your users
with the ability to search the book title, author or content using
regular expressions.
But you don't want to let them execute any code.
How would you validate/compile/evaluate the user provided regex so as to
provide maximum
Kammen == Kammen van, Marco, Springer SBM NL
marco.vankam...@springer.com writes:
Kammen What am I doing wrong??
Using a regex when something else would be much better.
Stop trying to pound a nail in with a wrench handle.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1
On Dec 7, 9:38 am, p...@utilika.org (Jonathan Pool) wrote:
Well, I have no idea why it does what it does, but I can tell you how to
make it work:
s¶3(456)7¶¶$1¶x;
s§3(456)7§§$1§x;
Hm, what platform and perl version?
No errors here:
c:\perl -wE say
On Dec 7, 9:38 am, p...@utilika.org (Jonathan Pool) wrote:
Well, I have no idea why it does what it does, but I can tell you how to
make it work:
s¶3(456)7¶¶$1¶x;
s§3(456)7§§$1§x;
Oops. yes there is:
c:\perl -Mutf8 -wE
say $^V,$^O;$_='123456789'; s§3(456)7§$1§;say
Malformed UTF-8
On Dec 7, 9:38 am, p...@utilika.org (Jonathan Pool) wrote:
Well, I have no idea why it does what it does, but I can tell you how to
make it work:
s¶3(456)7¶¶$1¶x;
s§3(456)7§§$1§x;
Oops, sorry, yes there is:
c:\perl -Mutf8 -wE
say $^V,$^O;$_='123456789';s§3(456)7§$1§;say
Malformed
Hm, what platform and perl version?
5.8.8 and 5.12.2 on RHEL, and 5.10.0 on OS X 10.6.
c:\perl -Mutf8 -wE
say $^V,$^O;$_='123456789';s§3(456)7§$1§;say
Malformed UTF-8 character (unexpected continuation byte 0xa7,
with no preceding start byte) at -e line 1.
Not the same error as I
c:\perl -wE say $^V,$^O;$_='123456789';s§3(456)7§$1§;say
v5.12.1MSWin32
1245689
My equivalent that works is:
perl -wE use utf8;my \$_='123456789';s§3(456)7§§\$1§;say;
1245689
If I stop treating this section-sign delimiter as a bracketing delimiter, it
fails:
perl -wE use utf8;my
Well, I have no idea why it does what it does, but I can tell you how to make
it work:
s¶3(456)7¶¶$1¶x;
s§3(456)7§§$1§x;
Amazing. Thanks very much.
This seems to contradict the documentation. The perlop man page clearly says
that there are exactly 4 bracketing delimiters: (), [], {}, and .
The perlop document under s/PATTERN/REPLACEMENT/msixpogce says Any
non-whitespace delimiter may replace the slashes.
I take this to mean that any non-whitespace character may be used instead of a
slash.
However, I am finding that some non-whitespace characters cause errors. For
example, using
Well, I have no idea why it does what it does, but I can tell you how to
make it work:
s¶3(456)7¶¶$1¶x;
s§3(456)7§§$1§x;
For whatever reason, Perl is treating those character as an 'opening'
delimiter[0], so that when you write s¶3(456)7¶$1¶;, you are telling Perl
that the regex part is delimited
On 10-12-05 05:58 PM, Brian Fraser wrote:
Well, I have no idea why it does what it does, but I can tell you how to
make it work:
s¶3(456)7¶¶$1¶x;
s§3(456)7§§$1§x;
For whatever reason, Perl is treating those character as an 'opening'
delimiter[0], so that when you write s¶3(456)7¶$1¶;, you are
You have to tell perl to use UTF-8. Add this line to the top of your
script(s):
use utf8;
See `perldoc utf8` for more details.
Hm, I don't mean to step on your toes or anything, but he is already using
utf8. The problem is with some utf8 characters being interpreted as a paired
delimiter,
On 10-12-05 07:38 PM, Brian Fraser wrote:
You have to tell perl to use UTF-8. Add this line to the top of
your script(s):
use utf8;
See `perldoc utf8` for more details.
Hm, I don't mean to step on your toes or anything, but he is already
using utf8. The problem is with some
That's probably because you are using what I sent, rather than what the OP
did:
C:\perl -E s§3(456)7§$1§;
Unrecognized character \x98 in column 16 at -e line 1.
C:\perl -Mutf8 -E s§3(456)7§$1§;
Substitution replacement not terminated at -e line 1.
C:\perl -E s§3(456)7§§$1§; say
On 30/11/2010 06:39, Uri Guttman wrote:
GK == Guruprasad Kulkarniguruprasa...@gmail.com writes:
GK Here is another way to do it:
GK /^127\.0\.0\.([\d]|[1-9][\d]|[1][\d][\d]|[2]([0-4][\d]|[5][0-4]))$/) {
why are you putting single chars inside a char class? [\d] is the same
as \d and
Dear List,
I've been struggeling with the following:
#!/usr/bin/perl
use strict;
use warnings;
my $ip = (127.0.0.255);
if ($ip =~ /127\.0\.0\.[2..254]/) {
print IP Matched!\n;;
} else {
print No Match!\n;
}
For a reason i don't understand:
127.0.0.1 doesn't match as expected...
On 29/11/2010 14:22, Kammen van, Marco, Springer SBM NL wrote:
Dear List,
I've been struggeling with the following:
#!/usr/bin/perl
use strict;
use warnings;
my $ip = (127.0.0.255);
if ($ip =~ /127\.0\.0\.[2..254]/) {
print IP Matched!\n;;
} else {
print No Match!\n;
}
For a reason i
Kammen van, Marco, Springer SBM NL wrote:
Dear List,
Hello,
I've been struggeling with the following:
#!/usr/bin/perl
use strict;
use warnings;
my $ip = (127.0.0.255);
if ($ip =~ /127\.0\.0\.[2..254]/) {
print IP Matched!\n;;
} else {
print No Match!\n;
}
For a reason i don't
On 29/11/2010 23:46, John W. Krahn wrote:
Kammen van, Marco, Springer SBM NL wrote:
Dear List,
Hello,
I've been struggeling with the following:
#!/usr/bin/perl
use strict;
use warnings;
my $ip = (127.0.0.255);
if ($ip =~ /127\.0\.0\.[2..254]/) {
print IP Matched!\n;;
} else {
print No
Hi Marco,
Here is another way to do it:
#!/usr/bin/perl
use strict;
use warnings;
my $ip = 127.0.0.1;
if ($ip =~
/^127\.0\.0\.([\d]|[1-9][\d]|[1][\d][\d]|[2]([0-4][\d]|[5][0-4]))$/) {
print IP Matched!\n;;
} else {
print No Match!\n;
}
On Tue, Nov 30, 2010 at 11:21 AM, Rob Dixon
-Original Message-
From: John W. Krahn [mailto:jwkr...@shaw.ca]
Sent: Tuesday, November 30, 2010 12:47 AM
To: Perl Beginners
Subject: Re: regexp matching nummeric ranges
As Rob said [2..254] is a character class that matches one character
(so
127.0.0.230 should match also.) You also
GK == Guruprasad Kulkarni guruprasa...@gmail.com writes:
GK Here is another way to do it:
GK /^127\.0\.0\.([\d]|[1-9][\d]|[1][\d][\d]|[2]([0-4][\d]|[5][0-4]))$/) {
why are you putting single chars inside a char class? [\d] is the same
as \d and [1] is just 1.
also please don't quote
Rob Dixon wrote:
On 29/11/2010 23:46, John W. Krahn wrote:
As Rob said [2..254] is a character class that matches one character (so
127.0.0.230 should match also.) You also don't anchor the pattern so
something like '765127.0.0.273646' would match as well. What you need is
something like
(Sorry but I have problem with my ISP, so I repost !)
Uri Guttman wrote:
how do you know when a keyword section begins or ends? how large is this
file? could free text have keywords? i see a ; to end a word list but
that isn't enough to properly parse this if you have 'free text'.
Uri Guttman wrote:
please show your code. there is no way to help otherwise. s/// is not a
pattern matcher but a substitution operator. it uses regexes and can be
used to parse things.
uri
Here it is ...
$ cat test.txt
keyword1 word1, word2
word3;
blabla
blabla
keyword2
olivier.scalb...@algosyn.com wrote:
$ cat test.txt
keyword1 word1, word2
word3;
blabla
blabla
keyword2
word4, word5,
word6, word7, word8,
word9;
bla bla
bla bla
keyword1
word10, word11;
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
# Make
Hello,
I need to extract info from some text files. And I want to do it with
Perl !
The file I need to parse has the following layout:
keywordA word1, word2, word3;
Here we can have some free text
...
...
keywordB word4,
word5, word6, word7, word8,
word9,
osc == olivier scalb...@algosyn com olivier.scalb...@algosyn.com
writes:
osc keywordA word1, word2, word3;
osc Here we can have some free text
osc ...
osc ...
osc keywordB word4,
osc word5, word6, word7, word8,
osc word9, word10;
osc
sftriman wrote:
Dr.Ruud:
sub trim { ...
}#trim
You're missing the tr to squash space down
To trim() is to remove from head and tail only.
Just use it as an example to build a trim_and_normalize().
So I think it can boil down to:
sub fixsp7 {
s#\A\s+##, s#\s+\z##, tr/ \t\n\r\f/ /s
On Dec 23, 2:31 am, rvtol+use...@isolution.nl (Dr.Ruud) wrote:
sftriman wrote:
1ST PLACE - THE WINNER: 5.0s average on 5 runs
# Limitation - pointer
sub fixsp5 {
${$_[0]}=~tr/ \t\n\r\f/ /s;
${$_[0]}=~s/\A //;
${$_[0]}=~s/ \z//;
}
Just decide to change in-place, based on the
sftriman wrote:
So I think it can boil down to:
sub fixsp7 {
s#\A\s+##, s#\s+\z##, tr/ \t\n\r\f/ /s foreach @_;
return;
}
sub fixsp7 {
tr/ \t\n\r\f/ /s, s#\A\s##, s#\s\z## foreach @_;
return;
}
Placing the tr/// first reduces the number of characters scanned for
s#\s\z## which makes
sftriman wrote:
1ST PLACE - THE WINNER: 5.0s average on 5 runs
# Limitation - pointer
sub fixsp5 {
${$_[0]}=~tr/ \t\n\r\f/ /s;
${$_[0]}=~s/\A //;
${$_[0]}=~s/ \z//;
}
Just decide to change in-place, based on the defined-ness of wantarray.
sub trim {
no warnings 'uninitialized';
if
string for testing, and ran each method 1,000,000
times to time
the speed. The winner is: 3 regexp, using tr for intra-string
spaces. I found I could
make this even faster using a pointer to the variable versus passing
in the variable
as a local input parameter, modifying, then returning
sftriman wrote:
I use this series of regexp all over the place to clean up lines of
text:
$x=~s/^\s+//g;
$x=~s/\s+$//g;
$x=~s/\s+/ /g;
in that order, and note the final one replace \s+ with a single space.
The g-modifier on the first 2 is bogus
(unless you would add an m-modifier).
I
Shawn H Corey wrote:
$text =~ tr{\t}{ };
$text =~ tr{\n}{ };
$text =~ tr{\r}{ };
$text =~ tr{\f}{ };
$text =~ tr{ }{ }s;
That can be written as:
tr/\t\n\r\f/ /, tr/ / /s for $text;
But it doesn't remove all leading nor all trailing spaces.
--
Ruud
--
To unsubscribe, e-mail:
2009/12/20 Dr.Ruud rvtol+use...@isolution.nl rvtol%2buse...@isolution.nl
sftriman wrote:
I use this series of regexp all over the place to clean up lines of
text:
$x=~s/^\s+//g;
$x=~s/\s+$//g;
$x=~s/\s+/ /g;
in that order, and note the final one replace \s+ with a single space.
The g
At 6:11 PM +0800 12/21/09, Albert Q wrote:
2009/12/20 Dr.Ruud rvtol+use...@isolution.nl rvtol%2buse...@isolution.nl
For a multi-line buffer you can do it like this:
perl -wle '
my $x = EOT;
123456 \t
abc def
\t\t\t\t\t\t\t\t
*** *** *** \t
EOT
I've been wondering for a long time... is there a slick (and hopefully
fast!) way
to do this?
foreach (keys %fixhash) {
$x=~s/\b$_\b/$fixhash{$_}/gi;
}
So if
$x=this could be so cool
and
$fixhash{could}=would;
$fixhash{COOL}=awesome;
$fixhash{beso}=nope;
$fixhash{his}=impossible;
then it
I use this series of regexp all over the place to clean up lines of
text:
$x=~s/^\s+//g;
$x=~s/\s+$//g;
$x=~s/\s+/ /g;
in that order, and note the final one replace \s+ with a single space.
Basically, it's (1) remove all leading space, (2) remove all trailing
space,
and (3) replace all multi
1 - 100 of 1027 matches
Mail list logo