[31373] in Perl-Users-Digest
Perl-Users Digest, Issue: 2625 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 7 18:09:29 2009
Date: Wed, 7 Oct 2009 15:09:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 7 Oct 2009 Volume: 11 Number: 2625
Today's topics:
Re: [regexp] Changing lines NOT containing a pattern <source@netcom.com>
Re: [regexp] Changing lines NOT containing a pattern <tadmc@seesig.invalid>
Re: [regexp] Changing lines NOT containing a pattern <ben@morrow.me.uk>
All About Tramadol | BUY TRAMADOL at the LOWEST online <terdfopisa@gmail.com>
Re: Changing lines NOT containing a pattern <derykus@gmail.com>
FAQ 4.61 How can I always keep my hash sorted? <brian@theperlreview.com>
FAQ 8.44 How do I tell the difference between errors fr <brian@theperlreview.com>
Re: How to parse section of html code? <spamtrap@shermpendley.com>
Re: Once again: CGI help <cwilbur@chromatico.net>
Perl and packge <cvrčak@banana.com>
Re: Perl and packge <ben@morrow.me.uk>
Perlpod, pod2man: get ascii grave accent in ROFF \(ga. <waterlan@xs4all.nl>
Re: Perlpod, pod2man: get ascii grave accent in ROFF \( <ben@morrow.me.uk>
Re: Perlpod, pod2man: get ascii grave accent in ROFF \( <waterlan@xs4all.nl>
Re: Perlpod, pod2man: get ascii grave accent in ROFF \( <ben@morrow.me.uk>
Re: regex - backwards? <jurgenex@hotmail.com>
Re: regex - backwards? <dannywoodz@yahoo.co.uk>
Re: regex - backwards? <jimsgibson@gmail.com>
Re: regex - backwards? sln@netherlands.com
regex - hex class <john1949@yahoo.com>
Re: regex - hex class sln@netherlands.com
Re: regex - hex class <john1949@yahoo.com>
Re: regex - hex class <someone@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 07 Oct 2009 05:30:10 -0700
From: David Harmon <source@netcom.com>
Subject: Re: [regexp] Changing lines NOT containing a pattern
Message-Id: <pI2dnVfNfdueF1HXnZ2dnUVZ_tadnZ2d@earthlink.com>
On Tue, 06 Oct 2009 17:09:50 -0500 in comp.lang.perl.misc, Tad J
McClellan <tadmc@seesig.invalid> wrote,
>azrazer <azeroiu@poupidoup.com> wrote:
>> How to do the following
>> for all lines at once ?
>> 1/ if <code> contains a fixed word [let say WORD] then do not remove
>> comments
>> 2/ if <code> does nots contain WORD then remove comments
>
>
> $my_text =~ s/(.*)(;.*)/$1 . (index($1, 'WORD') == -1 ? '' : $2)/ge;
I believe the first .* should be .*? otherwise a semicolon in the middle
of the comment will throw it off.
------------------------------
Date: Wed, 07 Oct 2009 09:00:13 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: [regexp] Changing lines NOT containing a pattern
Message-Id: <slrnhcp6rt.5e6.tadmc@tadmc30.sbcglobal.net>
David Harmon <source@netcom.com> wrote:
> On Tue, 06 Oct 2009 17:09:50 -0500 in comp.lang.perl.misc, Tad J
> McClellan <tadmc@seesig.invalid> wrote,
>>azrazer <azeroiu@poupidoup.com> wrote:
>>> How to do the following
>>> for all lines at once ?
>>> 1/ if <code> contains a fixed word [let say WORD] then do not remove
>>> comments
>>> 2/ if <code> does nots contain WORD then remove comments
>>
>>
>> $my_text =~ s/(.*)(;.*)/$1 . (index($1, 'WORD') == -1 ? '' : $2)/ge;
>
> I believe the first .* should be .*? otherwise a semicolon in the middle
> of the comment will throw it off.
Who is to say that the "code" cannot contain semicolons?
We were never told anything about the grammar of the "code"...
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 7 Oct 2009 19:24:40 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: [regexp] Changing lines NOT containing a pattern
Message-Id: <803vp6-n112.ln1@osiris.mauzo.dyndns.org>
Quoth Ben Morrow <ben@morrow.me.uk>:
>
> The obvious answer (besides the one Tad suggested, or simply splitting
> twice on newlines and then on ';') would be
>
> s/(?<! WORD .*) ; .*//gx
>
> but that doesn't work because perl doesn't do variable-length
> look-behind. 5.10 implements a limited form of variable-length
> lookbehind using the \K escape, which will work in this case:
>
> s/WORD .* \K ; .*//gx
>
> The /m flag is irrelevant here, but the pattern relies on the *absence*
> of the /s flag, to make sure /./ won't match across newlines.
>
> You can also perform the obvious translation from a \K-using pattern to
> one with an extra capture, which will work on any version of perl:
>
> s/( WORD .* ) ; .*/$1/gx
This is all complete nonsense. Sorry about that. Except for the first
(?<!) pattern, which doesn't work, it is solving the problem 'remove the
comments if the code *does* contain WORD', which is considerably easier.
Ben
------------------------------
Date: Wed, 7 Oct 2009 14:51:42 -0700 (PDT)
From: Teraposa Lunodas <terdfopisa@gmail.com>
Subject: All About Tramadol | BUY TRAMADOL at the LOWEST online PRICES |
Message-Id: <ab5e2c45-4f17-4fb7-9a15-f78de7faab9c@k26g2000vbp.googlegroups.com>
[CENTER][B][SIZE="6"][COLOR="Red"]Buy Tramadol at
[URL="http://tramadol-drug.oq.pl"]www.TRAMADOL-DRUG.oq.pl[/URL][/COLOR]
[/SIZE][/B]
[COLOR="Green"][SIZE="4"][B]Most sites give you only one set of
prices. Here, up to seven of the top online pharmacies quote their
prices openly for all to see. The number varies depending on where you
live.[/B][/SIZE][/COLOR]
[B][SIZE="5"][COLOR="Red"]So, first check out the price per tablet -
[URL="http://tramadol-drug.oq.pl"]CLICK HERE TO VIEW[/URL]![/COLOR][/
SIZE][/B]
[B][SIZE="4"][COLOR="Red"]Use code: "16304871" to get 25% discount![/
COLOR][/SIZE][/B]
[B]Top searches: [/B]Order Tramadol. Cheap Tramadol. Side Effects
Tramadol. Tramadol medication. Tramadol hcl. Tramadol 50mg. Tramadol
dogs. what is tramadol. ultram tramadol. tramadol mg. tramadol for
dogs. z1wp2z. [/CENTER]
------------------------------
Date: Wed, 7 Oct 2009 03:55:49 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Changing lines NOT containing a pattern
Message-Id: <8d912b87-de60-4ba8-9e19-4eb1c77cb075@2g2000prl.googlegroups.com>
On Oct 6, 3:28=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth azrazer <azer...@poupidoup.com>:
>
>
>
> > Hello,
> > I recently found an interesting issue on fr.comp.lang.perl and thought =
it
> > would be good to share [since not answers were found until now]. So her=
e
> > it goes.
>
> > A file is slurped into a scalar variable (let say $my_text) [NOT AN
> > ARRAY].
> > This $my_text now contains many lines of this form : <code>;<comments>.
>
> > The question is : Using a regexp (with mg flags) How to do the followin=
g
> > for all lines at once ?
> > 1/ if <code> contains a fixed word [let say WORD] then do not remove
> > comments
> > 2/ if <code> does nots contain WORD then remove comments
>
> > I have tried using look-forward and behind regexps but i guess it is no=
t
> > the good way of doing it. Also, i wanted to try using extended regexps
> > like (?(COND)true|false) but i ended up drawing a blank...
>
> The obvious answer (besides the one Tad suggested, or simply splitting
> twice on newlines and then on ';') would be
>
> =A0 =A0 s/(?<! WORD .*) ; .*//gx
>
> but that doesn't work because perl doesn't do variable-length
> look-behind.
> ...
Hm, late night.. but this does appear to work:
s/ ( (?<!WORD) ) ;. * /$1/gx;
(only tried in 5.10)
--
Charles DeRykus
------------------------------
Date: Wed, 07 Oct 2009 16:00:04 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 4.61 How can I always keep my hash sorted?
Message-Id: <8W2zm.31381$lR3.2166@newsfe25.iad>
This is an excerpt from the latest version perlfaq4.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
4.61: How can I always keep my hash sorted?
You can look into using the "DB_File" module and "tie()" using the
$DB_BTREE hash bindings as documented in "In Memory Databases" in
DB_File. The "Tie::IxHash" module from CPAN might also be instructive.
Although this does keep your hash sorted, you might not like the slow
down you suffer from the tie interface. Are you sure you need to do
this? :)
--------------------------------------------------------------------
The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.
If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.
------------------------------
Date: Wed, 07 Oct 2009 22:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
Message-Id: <Db8zm.155532$nL7.129281@newsfe18.iad>
This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
8.44: How do I tell the difference between errors from the shell and perl?
(answer contributed by brian d foy)
When you run a Perl script, something else is running the script for
you, and that something else may output error messages. The script might
emit its own warnings and error messages. Most of the time you cannot
tell who said what.
You probably cannot fix the thing that runs perl, but you can change how
perl outputs its warnings by defining a custom warning and die
functions.
Consider this script, which has an error you may not notice immediately.
#!/usr/locl/bin/perl
print "Hello World\n";
I get an error when I run this from my shell (which happens to be bash).
That may look like perl forgot it has a print() function, but my shebang
line is not the path to perl, so the shell runs the script, and I get
the error.
$ ./test
./test: line 3: print: command not found
A quick and dirty fix involves a little bit of code, but this may be all
you need to figure out the problem.
#!/usr/bin/perl -w
BEGIN {
$SIG{__WARN__} = sub{ print STDERR "Perl: ", @_; };
$SIG{__DIE__} = sub{ print STDERR "Perl: ", @_; exit 1};
}
$a = 1 + undef;
$x / 0;
__END__
The perl message comes out with "Perl" in front. The BEGIN block works
at compile time so all of the compilation errors and warnings get the
"Perl:" prefix too.
Perl: Useless use of division (/) in void context at ./test line 9.
Perl: Name "main::a" used only once: possible typo at ./test line 8.
Perl: Name "main::x" used only once: possible typo at ./test line 9.
Perl: Use of uninitialized value in addition (+) at ./test line 8.
Perl: Use of uninitialized value in division (/) at ./test line 9.
Perl: Illegal division by zero at ./test line 9.
Perl: Illegal division by zero at -e line 3.
If I don't see that "Perl:", it's not from perl.
You could also just know all the perl errors, and although there are
some people who may know all of them, you probably don't. However, they
all should be in the perldiag manpage. If you don't find the error in
there, it probably isn't a perl error.
Looking up every message is not the easiest way, so let perl to do it
for you. Use the diagnostics pragma with turns perl's normal messages
into longer discussions on the topic.
use diagnostics;
If you don't get a paragraph or two of expanded discussion, it might not
be perl's message.
--------------------------------------------------------------------
The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.
If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.
------------------------------
Date: Wed, 07 Oct 2009 12:59:04 -0400
From: Sherm Pendley <spamtrap@shermpendley.com>
Subject: Re: How to parse section of html code?
Message-Id: <m2tyybxhrb.fsf@shermpendley.com>
James Egan <jegan473@comcast.net> writes:
> How can I parse this value from the html code?
Use an HTML parser module, such as HTML::Parser.
sherm--
------------------------------
Date: Wed, 07 Oct 2009 11:18:25 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Once again: CGI help
Message-Id: <867hv7tepq.fsf@mithril.chromatico.net>
>>>>> "M" == Marek <mstep@podiuminternational.org> writes:
M> So why are you answering? I am beginner, and your answers you
M> gave are not really helpful!
1 - The answers he gave answered your questions clearly and concisely.
2 - He is also helping you to realize that *everyone's* patience here is
limited, and that you would do very well to read the Posting Guidelines
that are posted here frequently and follow them.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Wed, 7 Oct 2009 22:13:21 +0200
From: "cvrčak" <cvrčak@banana.com>
Subject: Perl and packge
Message-Id: <haisp0$eg7$1@news.metronet.hr>
Hy,
Can somebody explain me when use *.pm files and when uses *.pl?
must be classes in *.pm files?
------------------------------
Date: Wed, 7 Oct 2009 21:37:10 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perl and packge
Message-Id: <moavp6-tm12.ln1@osiris.mauzo.dyndns.org>
Quoth "cvrčak" <cvrčak@banana.com>:
>
> Can somebody explain me when use *.pm files and when uses *.pl?
You use a .pm file when you want it to be picked up by
require Foo::Bar;
or
use Foo::Bar;
If you are happy to load it with
require "/path/to/foo.pl";
you may call the file whatever you like, but *.pl is conventional.
> must be classes in *.pm files?
No, not at all, though it is *usual* for a class Foo::Bar to be defined
in a file Foo/Bar.pm, so it can be loaded with
use Foo::Bar;
See perldoc -f require, perldoc -f use and perldoc perlmod.
Ben
------------------------------
Date: Wed, 07 Oct 2009 17:23:07 +0200
From: Erwin Waterlander <waterlan@xs4all.nl>
Subject: Perlpod, pod2man: get ascii grave accent in ROFF \(ga.
Message-Id: <4accb25b$0$83238$e4fe514c@news.xs4all.nl>
Hi,
I'm in the process of converting a manual written man page in ROFF
format to POD.
In ROFF I use these commands:
\(ga grave accent
\(aq apostrophe quote
These ROFF commands will produce an ASCII grave accent (ASCII 0x60) and
apostrophe quote (ASCII 0x27) in the man page in any locale environment:
ASCII, Latin1 or UTF-8.
If I use in ROFF plain ` and ' I may get other characters displayed in
man depending on the locale character encoding setting of my
environment. In an UTF-8 environment I will get unicode equivalents.
Suppose I want to do the same in POD, produce ASCII grave accent
regardless of the locale, how do I do that? (don't ask why). Or in other
words: what is a neat way to produce \(ga and \(aq in ROFF from a POD file?
regards,
Erwin
------------------------------
Date: Wed, 7 Oct 2009 18:34:57 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perlpod, pod2man: get ascii grave accent in ROFF \(ga.
Message-Id: <130vp6-ih02.ln1@osiris.mauzo.dyndns.org>
Quoth Erwin Waterlander <waterlan@xs4all.nl>:
>
> I'm in the process of converting a manual written man page in ROFF
> format to POD.
>
> In ROFF I use these commands:
> \(ga grave accent
> \(aq apostrophe quote
>
> These ROFF commands will produce an ASCII grave accent (ASCII 0x60) and
> apostrophe quote (ASCII 0x27) in the man page in any locale environment:
> ASCII, Latin1 or UTF-8.
>
> If I use in ROFF plain ` and ' I may get other characters displayed in
> man depending on the locale character encoding setting of my
> environment. In an UTF-8 environment I will get unicode equivalents.
>
> Suppose I want to do the same in POD, produce ASCII grave accent
> regardless of the locale, how do I do that? (don't ask why). Or in other
> words: what is a neat way to produce \(ga and \(aq in ROFF from a POD file?
You can't, in general, without using a custom POD formatter that does
what you need.
Ben
------------------------------
Date: Wed, 07 Oct 2009 22:08:29 +0200
From: Erwin Waterlander <waterlan@xs4all.nl>
Subject: Re: Perlpod, pod2man: get ascii grave accent in ROFF \(ga.
Message-Id: <4ACCF53D.9060700@xs4all.nl>
Op 7-10-2009 19:34, Ben Morrow schreef:
> Quoth Erwin Waterlander <waterlan@xs4all.nl>:
>> I'm in the process of converting a manual written man page in ROFF
>> format to POD.
>>
>> In ROFF I use these commands:
>> \(ga grave accent
>> \(aq apostrophe quote
>>
>> These ROFF commands will produce an ASCII grave accent (ASCII 0x60) and
>> apostrophe quote (ASCII 0x27) in the man page in any locale environment:
>> ASCII, Latin1 or UTF-8.
>>
>> If I use in ROFF plain ` and ' I may get other characters displayed in
>> man depending on the locale character encoding setting of my
>> environment. In an UTF-8 environment I will get unicode equivalents.
>>
>> Suppose I want to do the same in POD, produce ASCII grave accent
>> regardless of the locale, how do I do that? (don't ask why). Or in other
>> words: what is a neat way to produce \(ga and \(aq in ROFF from a POD file?
>
> You can't, in general, without using a custom POD formatter that does
> what you need.
>
> Ben
>
I was afraid of that. This leaves nothing else then some 'sed' post
processing.
With a plain ` and ' in ROFF I see for instance this happening on RedHat
Enterprise Linux 4: In an ASCII locale both ` and ' are converted to the
apostrophe quote (0x27). `quote' becomes 'quote'. That's wrong. In a
Latin1 locale both quotes are converted to a Latin1 quote (0xB4) (wrong
again). On RHEL3 these problems don't occur (strange?). Anyway, if I use
\(ga and \(aq in ROFF the quotes are always displayed correctly on any
system.
Erwin
------------------------------
Date: Wed, 7 Oct 2009 21:32:56 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Perlpod, pod2man: get ascii grave accent in ROFF \(ga.
Message-Id: <ogavp6-tm12.ln1@osiris.mauzo.dyndns.org>
Quoth Erwin Waterlander <waterlan@xs4all.nl>:
>
> I was afraid of that. This leaves nothing else then some 'sed' post
> processing.
>
> With a plain ` and ' in ROFF I see for instance this happening on RedHat
> Enterprise Linux 4: In an ASCII locale both ` and ' are converted to the
> apostrophe quote (0x27). `quote' becomes 'quote'. That's wrong.
'Wrong' according to whom? Pod is not supposed to be a highly-specific
document creation system, it is supposed to be a quick and easy way of
documenting Perl with lots of DWIM in the formatters.
I know you said 'don't ask', but I have to ask why you think you need
this. It sounds like you may be better served by some other markup
language.
> In a
> Latin1 locale both quotes are converted to a Latin1 quote (0xB4) (wrong
> again). On RHEL3 these problems don't occur (strange?).
You will have a different version of the Pod modules installed. There
was some effort a while ago put into preventing pod from rendering with
Unicode with some versions of groff. It's possible that this has
resulted in normalization of ` and ' that didn't happen before.
In running text those two characters are semantically equivalent, in any
case (or rather, quoting `like this' is incorrect, but accepted since
it's commonly done by Unix people). In C<> and verbatim sections they
should be left unchanged; if they are not, you have a buggy version of
the podlators installed.
> Anyway, if I use
> \(ga and \(aq in ROFF the quotes are always displayed correctly on any
> system.
One more thought: have you tried using E<96> and E<39>?
Ben
------------------------------
Date: Wed, 07 Oct 2009 03:08:52 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: regex - backwards?
Message-Id: <qupoc5hrnsgkj6pc71nfv8696rh2iubrs0@4ax.com>
"John" <john1949@yahoo.com> wrote:
>$x =~s |a|b|;
>
>That will replace the first 'a' by 'b' in $x.
>
>Is there any obvious tweek so that it replaces the last occurrence of 'a'?
The most simple solutions are often the best solutions:
reverse;
s///;
reverse;
As long as you don't do that hundreds of thousands of times or you are
dealing with gigantic strings there shouldn't be much of a problem with
this trivial approach.
jue
------------------------------
Date: Wed, 07 Oct 2009 15:12:52 +0100
From: Danny Woods <dannywoodz@yahoo.co.uk>
Subject: Re: regex - backwards?
Message-Id: <50bpkjgumz.fsf@yahoo.co.uk>
"John" <john1949@yahoo.com> writes:
> Hi
>
> $x =~s |a|b|;
>
> That will replace the first 'a' by 'b' in $x.
>
> Is there any obvious tweek so that it replaces the last occurrence of 'a'?
Yes: regex lookahead:
$x =~ s|a(?=[^a]*$)|b|;
Can be read as "an 'a', followed by zero or more non-'a's up until the
end of line"
Cheers,
Danny.
------------------------------
Date: Wed, 07 Oct 2009 09:44:54 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: regex - backwards?
Message-Id: <071020090944542385%jimsgibson@gmail.com>
In article <hahfd0$lc5$1@news.albasani.net>, John <john1949@yahoo.com>
wrote:
> Hi
>
> $x =~s |a|b|;
>
> That will replace the first 'a' by 'b' in $x.
>
> Is there any obvious tweek so that it replaces the last occurrence of 'a'?
$x =~ s/(.*)a/$1b/;
should do it, taking advantage of the fact that the * modifier is
greedy.
--
Jim Gibson
------------------------------
Date: Wed, 07 Oct 2009 09:48:57 -0700
From: sln@netherlands.com
Subject: Re: regex - backwards?
Message-Id: <rdhpc5dgck4oemb2qof9o04bmesmhs68aj@4ax.com>
On Wed, 7 Oct 2009 08:19:00 +0100, "John" <john1949@yahoo.com> wrote:
>Hi
>
>$x =~s |a|b|;
>
>That will replace the first 'a' by 'b' in $x.
>
>Is there any obvious tweek so that it replaces the last occurrence of 'a'?
>
>Regards
>John
>
>
If you don't want to use lookahead as Danny suggested,
which is probably easiest, a couple of alternatives:
$aaa =~ s/a ([^a]*) $ /b$1/x;
# or
substr ($aaa, pos($aaa)-1, 1) = 'b' if ($aaa =~ / .*a /xg);
Of these, lookahead may be quickest. Have to benchmark them.
-sln
------------------------------
Date: Wed, 7 Oct 2009 14:38:09 +0100
From: "John" <john1949@yahoo.com>
Subject: regex - hex class
Message-Id: <hai5jt$okv$1@news.albasani.net>
Hi
I may have an error elsewhere in my program,
but , for the moment, will the following removed all hex chars 00 to 40?
$x =~ s|[\x00-\x40]||g;
Regards
John
------------------------------
Date: Wed, 07 Oct 2009 09:12:23 -0700
From: sln@netherlands.com
Subject: Re: regex - hex class
Message-Id: <nafpc5p1ftcgpk73sii1bne59ostsj99t0@4ax.com>
On Wed, 7 Oct 2009 14:38:09 +0100, "John" <john1949@yahoo.com> wrote:
>Hi
>
>I may have an error elsewhere in my program,
>but , for the moment, will the following removed all hex chars 00 to 40?
>
>$x =~ s|[\x00-\x40]||g;
>
>Regards
>John
>
>
"but , for the moment, will the following removed chars: hex 00 to 40?
That should work, have you tried it?
$x =~ s/[\x{00}-\x{40}]//g;
-sln
------------------------------
Date: Wed, 7 Oct 2009 18:48:37 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: regex - hex class
Message-Id: <haik9h$hdu$1@news.albasani.net>
<sln@netherlands.com> wrote in message
news:nafpc5p1ftcgpk73sii1bne59ostsj99t0@4ax.com...
> On Wed, 7 Oct 2009 14:38:09 +0100, "John" <john1949@yahoo.com> wrote:
>
>>Hi
>>
>>I may have an error elsewhere in my program,
>>but , for the moment, will the following removed all hex chars 00 to 40?
>>
>>$x =~ s|[\x00-\x40]||g;
>>
>>Regards
>>John
>>
>>
> "but , for the moment, will the following removed chars: hex 00 to 40?
> That should work, have you tried it?
> $x =~ s/[\x{00}-\x{40}]//g;
>
> -sln
Hi
It doesn't work so I now know I have a problem somewhere else.
Regards and thanks
John
------------------------------
Date: Wed, 07 Oct 2009 14:22:20 -0700
From: "John W. Krahn" <someone@example.com>
Subject: Re: regex - hex class
Message-Id: <iE7zm.225471$sC1.64449@newsfe17.iad>
John wrote:
>
> I may have an error elsewhere in my program,
> but , for the moment, will the following removed all hex chars 00 to 40?
>
> $x =~ s|[\x00-\x40]||g;
$ perl -le'
use Data::Dumper;
$Data::Dumper::Useqq = 1;
my $string = join q//, map chr, 0 .. 127;
print Dumper $string;
$string =~ s|[\x00-\x40]||g;
print Dumper $string;
'
$VAR1 =
"\0\1\2\3\4\5\6\a\b\t\n\13\f\r\16\17\20\21\22\23\24\25\26\27\30\31\32\e\34\35\36\37
!\"#\$%&'()*+,-./0123456789:;<=>?\@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177";
$VAR1 =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177";
Yes, that works.
John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity. -- Damian Conway
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 2625
***************************************