[28877] in Perl-Users-Digest
Perl-Users Digest, Issue: 121 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 9 23:31:27 2007
Date: Fri, 9 Feb 2007 20:30:50 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 9 Feb 2007 Volume: 11 Number: 121
Today's topics:
read from STDIN <stoupa@practisoft.cz>
Re: read from STDIN <lambik@kieffer.nl>
Re: read from STDIN <mritty@gmail.com>
Re: read from STDIN <stoupa@practisoft.cz>
Re: read from STDIN <joe@inwap.com>
Re: Read on closed filehandle <joe@inwap.com>
Re: Read on closed filehandle <hjp-usenet2@hjp.at>
Re: Read on closed filehandle <joe@inwap.com>
Re: Read on closed filehandle jgraber@ti.com
Regex - Unexpected match for /\r/ <fred4414@nethere.com>
Re: regex multiline help <bik.mido@tiscalinet.it>
rename *-ch03.htm to ch03-*.htm? <robertchen117@gmail.com>
Re: rename *-ch03.htm to ch03-*.htm? <john@castleamber.com>
Re: rename *-ch03.htm to ch03-*.htm? <bart.lateur@pandora.be>
Re: rename *-ch03.htm to ch03-*.htm? <bik.mido@tiscalinet.it>
Re: rename *-ch03.htm to ch03-*.htm? <tadmc@augustmail.com>
Re: rename *-ch03.htm to ch03-*.htm? krakle@visto.com
Re: rename *-ch03.htm to ch03-*.htm? <mritty@gmail.com>
Re: rename *-ch03.htm to ch03-*.htm? <bik.mido@tiscalinet.it>
Re: rename *-ch03.htm to ch03-*.htm? <rvtol+news@isolution.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 7 Feb 2007 01:27:25 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: read from STDIN
Message-Id: <eqbcgb$2duh$1@ns.felk.cvut.cz>
On some servers (IIS6, Apache on Win/Lin) i have sometime problem to read
from STDIN and don't know why.
A simple example
my $total = $ENV{CONTENT_LENGTH};
my $readed = 0;
while(($readed < $total) {
$readed += read(STDIN, $buffer, 1024)
}
If I send 1024 bytes file to this script it work fine. Ofcource I'm sending
file from html form in <input type="file"> tag and use POST method.
But if I send any larger file I never got "end of file" from STDIN and
script will be killed by server for timeout.
Strange is that on some servers this code work and on some not.
Any idea?
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: Wed, 7 Feb 2007 11:10:32 +0100
From: "Lambik" <lambik@kieffer.nl>
Subject: Re: read from STDIN
Message-Id: <45c9a4ec$0$715$5fc3050@dreader2.news.tiscali.nl>
"Petr Vileta" <stoupa@practisoft.cz> wrote in message
news:eqbcgb$2duh$1@ns.felk.cvut.cz...
> On some servers (IIS6, Apache on Win/Lin) i have sometime problem to read
> from STDIN and don't know why.
> A simple example
>
> my $total = $ENV{CONTENT_LENGTH};
> my $readed = 0;
> while(($readed < $total) {
> $readed += read(STDIN, $buffer, 1024)
> }
read(STDIN, $buffer, $ENV{CONTENT_LENGTH}) ??
------------------------------
Date: 7 Feb 2007 03:40:03 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: read from STDIN
Message-Id: <1170848403.164977.217680@m58g2000cwm.googlegroups.com>
On Feb 6, 7:27 pm, "Petr Vileta" <sto...@practisoft.cz> wrote:
> On some servers (IIS6, Apache on Win/Lin) i have sometime problem to read
> from STDIN and don't know why.
> A simple example
>
> my $total = $ENV{CONTENT_LENGTH};
> my $readed = 0;
> while(($readed < $total) {
> $readed += read(STDIN, $buffer, 1024)
>
> }
Get rid of this code and use the correct module for the job.
use CGI qw/:standard/;
And then simply use the param() function to get access to all the
parameters.
Please read:
perldoc CGI
Paul Lalli
------------------------------
Date: Wed, 7 Feb 2007 16:08:17 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: read from STDIN
Message-Id: <eqcr6k$2c1$1@ns.felk.cvut.cz>
"Lambik" <lambik@kieffer.nl> píše v diskusním příspěvku
news:45c9a4ec$0$715$5fc3050@dreader2.news.tiscali.nl...
> "Petr Vileta" <stoupa@practisoft.cz> wrote in message
> news:eqbcgb$2duh$1@ns.felk.cvut.cz...
>> On some servers (IIS6, Apache on Win/Lin) i have sometime problem to read
>> from STDIN and don't know why.
>> A simple example
>>
>> my $total = $ENV{CONTENT_LENGTH};
>> my $readed = 0;
>> while(($readed < $total) {
>> $readed += read(STDIN, $buffer, 1024)
>> }
> read(STDIN, $buffer, $ENV{CONTENT_LENGTH}) ??
>
I forgot to mention purpose of my code :-)
I try to write script for uploading files with upload progressbar.
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: Thu, 08 Feb 2007 12:27:44 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: read from STDIN
Message-Id: <hcCdnf70oIJcGlbYnZ2dnUVZ_hadnZ2d@comcast.com>
Petr Vileta wrote:
> I forgot to mention purpose of my code :-)
> I try to write script for uploading files with upload progressbar.
First make sure you have the ability to code a progressbar that will
display properly in a browser. You'll find it awkward in plain HTML.
print $HTML_HEADERS;
for (1 .. 10) { print "$_ "; sleep 1};
print "\n<hr>\n";
for (1 .. 10) { print "$_<br>\n"; sleep 1};
print $HTML_TRAILERS;
-Joe
------------------------------
Date: Sat, 03 Feb 2007 01:46:15 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Read on closed filehandle
Message-Id: <EOadnXJ8V9VsxFnYnZ2dnUVZ_tGsnZ2d@comcast.com>
jgraber@ti.com wrote:
> "Russ" <Russ.Dilley@gmail.com> writes:
>> I have a very simple script to read an input file, skip everything
>> between the strings "BEGIN" and "END", and store the results in an
>> output file.
>
>> When I run this on a small file, about 28 kb, it works fine. When I
>> try it on a large file, about 3 gigs , I get the error:
>
> Size of input file is not the problem.
No, the size of the input file _is_ the problem.
On a version of perl compiled on a 32-bit machine without "uselargefiles=define",
things like segfault or "read on closed filehandle" will occur after reading
2,147,483,647 bytes from the input file.
-Joe
------------------------------
Date: Sun, 4 Feb 2007 12:52:40 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Read on closed filehandle
Message-Id: <slrnesbi88.vrb.hjp-usenet2@yoyo.hjp.at>
On 2007-02-03 09:46, Joe Smith <joe@inwap.com> wrote:
> jgraber@ti.com wrote:
>> "Russ" <Russ.Dilley@gmail.com> writes:
>>> When I run this on a small file, about 28 kb, it works fine. When I
>>> try it on a large file, about 3 gigs , I get the error:
>>
>> Size of input file is not the problem.
>
> No, the size of the input file _is_ the problem.
Yes.
> On a version of perl compiled on a 32-bit machine without "uselargefiles=define",
> things like segfault or "read on closed filehandle" will occur after reading
> 2,147,483,647 bytes from the input file.
Not on the systems I know. You can't even open the file, and the "read
on closed filehandle" message occurs on the first read (not after 2GB)
and happens because the open failed and the OP failed to check for that.
hp
--
_ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
|_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
| | | hjp@hjp.at | andere ersetzt.
__/ | http://www.hjp.at/ | -- Nils Ketelsen in danr
------------------------------
Date: Sun, 04 Feb 2007 21:24:25 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Read on closed filehandle
Message-Id: <jpudnUouz7QTIlvYnZ2dnUVZ_vupnZ2d@comcast.com>
Peter J. Holzer wrote:
>> On a version of perl compiled on a 32-bit machine without "uselargefiles=define",
>> things like segfault or "read on closed filehandle" will occur after reading
>> 2,147,483,647 bytes from the input file.
>
> Not on the systems I know. You can't even open the file, and the "read
> on closed filehandle" message occurs on the first read (not after 2GB)
> and happens because the open failed and the OP failed to check for that.
Other ways of getting to 2GB is reading from a pipe or socket or reading from
redirected STDIN. I've run into a case where the shell was able to
open a 5GB file and set up redirection, but the program barfed after 2GB.
-Joe
------------------------------
Date: 05 Feb 2007 13:25:56 -0600
From: jgraber@ti.com
Subject: Re: Read on closed filehandle
Message-Id: <yvnps8o9zjv.fsf@famous02.dal.design.ti.com>
Jim Gibson <jgibson@mail.arc.nasa.gov> writes:
> In article <1170376295.591550.133920@a75g2000cwd.googlegroups.com>,
> Russ <Russ.Dilley@gmail.com> wrote:
>
> > On Feb 1, 6:10 pm, "attn.steven....@gmail.com"
> > <attn.steven....@gmail.com> wrote:
> > > while (<IN>) {
> > > next if /BEGIN/ .. /END/;
> > > print OUT $_;
> > > }
>
> > Thanks for in suggestions. It works fine but I'm not familiar with the
> > use of '..' in the next statement.
> > I have used the 'next if' construct with single regular expressions,
> > is the above code just representing
> > the entire group of characters between the "BEGIN" and "END" strings?
> >
> > If that's the case, and I don't have an "END", will the code print
> > everything between "BEGIN" and the end of the file?
>
> It is the range operator in scalar context, which acts like a
> flip-flop. See 'perldoc perlop' and search for 'Range Operators'. The
> operator will be false until /BEGIN/ is true, true until /END/ is true,
> then false again until the next /BEGIN/, etc.
OK so far.
> If you do not have an 'END',
> the program will print from the final BEGIN to the end of the file.
Not true, since $_ is read one line at a time, and is lost if not printed.
This case is demonstrated below.
% cat omit_begin_end.pl
#!/usr/local/bin/perl
use strict; use warnings;
while(<DATA>){
next if (/^BEGIN/ .. /^END/);
print;
} # wend
__DATA__
line1
BEGIN
line2
#END
line3
% perl omit_begin_end.pl
line1
If #END is changed to END,
then output also includes line3.
If it were important to retain lines between BEGIN and eof with no END,
then the pending lines need to be stored until it is known if they are needed
or not, as shown in this tested example.
#!/usr/local/bin/perl
use strict; use warnings;
my @buffer;
while(<DATA>){
if (/^BEGIN/ .. /^END/) {
push @buffer,$_;
next;
}
@buffer = (); # clear buffer
print;
} # wend
print @buffer;
__DATA__
line1
BEGIN
line2
#END
line3
Or if you dont mind slurping the whole file,
this tested partial example code
prints from the final BEGIN to the end of the file if no matching END.
This does not use the range operator though.
{ local $/=undef; # undef the line-break
$_ = <DATA>; # slurp the whole thing
s/^BEGIN.*^END\n//gms; # s/// on whole thing
print; # print the whole thing
}
--
Joel
------------------------------
Date: Tue, 06 Feb 2007 17:28:12 -0800
From: Fred Hare <fred4414@nethere.com>
Subject: Regex - Unexpected match for /\r/
Message-Id: <QKednT9YMMKttlTYnZ2dnUVZ8tyqnZ2d@giganews.com>
Working with Perl 5.6 on Windows XP.
Below are 3 code samples. The first code sample 'Find.pl' behaves as
expected, no problem.
The second code sample 'Find_0A.pl' is for finding files with \r (= hex
'0A' not behind '0D'). Also works, but only after I changed 'if ...' to
'unless ...'.
And I just do not understand why this change is necessary.
Since files with just '0A' are not common on Windows, I added
'MakeFileWith_0A.pl' for generating a sample-file.
# Find.pl
use strict ;
use warnings ;
my $path = 'D:\aa' ;
opendir(DIR, $path) or die $!;
my @files = grep { /.+?\.txt$/i } readdir(DIR) ;
closedir(DIR);
chdir $path or die "Can't chdir: $!";
foreach my $file ( @files ) {
open my $IN, '<', $file or die "Could not open $file: $!\n";
my $string = do {local $/;<$IN>};
if ($string =~ s/Swiss/German/g ) {
print "Found in $file\n" ;
}
close $IN or die "could not close $IN: $!";
}
__END__
# Find_0A.pl
use strict ;
use warnings ;
my $path = 'D:\aa' ;
opendir(DIR, $path) or die $!;
my @files = grep { /.+?\.txt$/i } readdir(DIR) ;
closedir(DIR);
chdir $path or die "Can't chdir: $!";
foreach my $file ( @files ) {
open my $IN, '<', $file or die "Could not open $file: $!\n";
binmode $IN ;
my $string = do {local $/;<$IN>};
# unless ($string =~ s/\x0A/\n/g ) {
unless ($string =~ s/\r/\n/g ) {
print "Found in $file\n" ;
}
close $IN or die "could not close $IN: $!";
}
__END__
# MakeFileWith_0A.pl
use strict ;
use warnings ;
my $outfile = 'D:\aa\File_with_0A.txt' ;
open my $OUT, '>', $outfile or die "Could not open $outfile: $!\n";
my $string = "abc\r (1)def bgrio\r(2)sdt kuy\r(3)ktru" ;
print $OUT "$string\n" ;
__END__
--
Fred
When using my email address, add the word "Trustme" anywhere on the
subject-line. Otherwise the message will be deleted on the server.
------------------------------
Date: Sat, 03 Feb 2007 11:41:10 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: regex multiline help
Message-Id: <bfn8s2lnsb9gm4qccsiq31n9aognkc22lj@4ax.com>
On Sat, 03 Feb 2007 00:02:55 GMT, Lance Hoffmeyer
<lance@augustmail.com> wrote:
>Traditionally, I have found numbers in a particular column using the following regex (see table at bottom of page):
>
>$fileT1 =~ /TABLE\s+1.*?$BRAND2.*?(?:(\d{1,3}\.\d|\-)[A-T\s]+){2}/s;my $val = $1;if($1 eq "- "){$val=0} ###($1 = 0.6)
Ouch! I understand this may be a oneliner for you, but for maximum
clarity you'd better put statements on separate lines, and possibly
use the /x regex modifier to also be more generous with whitespace
there...
>but, the following is matching BRAND5, col 13 = 3.3, instead of BRAND4, col 13 = "-"
>$fileT1 =~ /TABLE\s+1.*?$BRAND4.*?(?:(\d{1,3}\.\d|\-)[A-T\s]+){13}/s;my $val = $1;if($1 eq "- "){$val=0}
...however all in all I undestand what you're trying to do: match
TABLE1, then the BRAND4 line, then anything up to the beginning of a
line and then you have a regex describing the rest of the line, i.e.
the 13 column entries. Incidentally you do not need to escape "-", as
it is not special in regexen, except in charachter classes.
>dot matches ^ and $, then after BRAND4, dot does not match ^ or $, rather I match it manually, allowing me to reach the newline
>of percentages.
You use the /s modifier, which makes . match newlines, which it
normally wouldn't. You probably want /m as well, which makes ^ and $
match the beginning and the end of a line: otherwise they will match
only those of the whole string.
>Basically, I want to find the line BRAND4, then ignore everything up until the next line, then I want to start the multimatch
[snip]
>Any suggestions on how to modify my regex such that
>1) Find TABLE 1 then,
>2) Go past everything until BRAND 4 is found then
>3) match until the end of the line is reached (or there is a newline, or ^)
>4) then, start the multi-match
Sorry for not given an answer *exactly* to your question, but despite
the relative appeal of doing everything with one regex, and maybe also
the possibility of doing so reliably, whatever the modifications to
the above, it seems a rather convoluted way to do what you want. Why
don't you read line by line until you're at the BRAND 4 line under
TABLE 1, skip to the following line and -since it seems rather
regular- just process it with split() which is more natural, instead?
You may even adopt a mixed approach, something along the lines of:
my ($line)=/TABLE\s+1.*?
BRAND4.*?\n
(.*?)$/gxms;
my $thirteen=(split ' ', $line)[12];
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 3 Feb 2007 19:36:48 -0800
From: "robertchen117@gmail.com" <robertchen117@gmail.com>
Subject: rename *-ch03.htm to ch03-*.htm?
Message-Id: <1170560208.840660.207080@a75g2000cwd.googlegroups.com>
I am trying to write a perl to replace all files under c:/perlbook/
like this:
Perl 5 by Example Variables-ch03.htm rename to
ch03-Perl 5 by Example Variables.htm
But I really did not figure out, any one please help me? For some perl
expert, it maybe only 5 minutes work. Thanks!
------------------------------
Date: 4 Feb 2007 06:05:42 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: rename *-ch03.htm to ch03-*.htm?
Message-Id: <Xns98CDF711FE2castleamber@130.133.1.4>
"robertchen117@gmail.com" <robertchen117@gmail.com> wrote:
> I am trying to write a perl to replace all files under c:/perlbook/
> like this:
>
> Perl 5 by Example Variables-ch03.htm rename to
> ch03-Perl 5 by Example Variables.htm
>
> But I really did not figure out, any one please help me?
read all items in the dir (readdir) and grep the ones that
are files ending in htm
for each file:
rename it
Show code you have written so far.
> For some perl expert, it maybe only 5 minutes work.
A sentence like this might piss of a lot of people. When people are
willing to pay me for it, it already does piss me off. They lack the
expertise to code it themselves, yet they know how much time it will take
me.
Renaming it manually will take you less then 5 minutes.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Sun, 04 Feb 2007 08:13:31 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: rename *-ch03.htm to ch03-*.htm?
Message-Id: <n05bs29dg9kqkj86gsbqlvouoiglv74tj8@4ax.com>
robertchen117@gmail.com wrote:
>I am trying to write a perl to replace all files under c:/perlbook/
>like this:
>
>Perl 5 by Example Variables-ch03.htm rename to
>ch03-Perl 5 by Example Variables.htm
OK...
chdir 'c:/perlbook' or die "Can't chdir: $!";
@files = glob '*.htm';
foreach my $old (@files) {
(my $new = $old) =~ s/(.*)-(ch\d+)(?=\.htm$)/$2-$1/ or next;
unless(-e $new) {
rename $old, $new
or warn "Can't rename file $old to $new: $!";
} else {
warn "Can't rename file $old to $new: file name in
use";
}
}
--
Bart.
------------------------------
Date: Sun, 04 Feb 2007 12:28:01 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: rename *-ch03.htm to ch03-*.htm?
Message-Id: <5vfbs2160cnl3oimqpvlcgqpt6okudlsgc@4ax.com>
On 3 Feb 2007 19:36:48 -0800, "robertchen117@gmail.com"
<robertchen117@gmail.com> wrote:
>I am trying to write a perl to replace all files under c:/perlbook/
>like this:
>
>Perl 5 by Example Variables-ch03.htm rename to
>ch03-Perl 5 by Example Variables.htm
$ perl -le 'rename $_,do {(my
$n=$_)=~s/^(.*)-(ch\d\d)(?=\.htm$)/$2-$1/;$n
} for <*.htm>'
>But I really did not figure out, any one please help me? For some perl
>expert, it maybe only 5 minutes work. Thanks!
Should it take me 5 minutes I'd certainly do it by hand! ;-)
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sun, 4 Feb 2007 10:40:32 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: rename *-ch03.htm to ch03-*.htm?
Message-Id: <slrnesc340.65b.tadmc@tadmc30.august.net>
robertchen117@gmail.com <robertchen117@gmail.com> wrote:
> Subject: rename *-ch03.htm to ch03-*.htm?
You should put your question in the body of your message too.
> I am trying to write a perl to replace all files under c:/perlbook/
> like this:
>
> Perl 5 by Example Variables-ch03.htm rename to
> ch03-Perl 5 by Example Variables.htm
>
> But I really did not figure out,
Show us what you have so far, and we will help you fix it.
> any one please help me?
Have a fish:
----------------------------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
use File::Find;
my $dir = '.'; # my $dir = 'c:/perlbook';
find \&do_rename, $dir;
sub do_rename {
return unless (my $new = $_) =~ s/(.*)-(ch03)/$2-$1/;
die "file $new already exists\n" if -e $new;
rename $_, $new;
}
----------------------------------------------------------
> For some perl
> expert, it maybe only 5 minutes work.
It would take more than 5 minutes to work out what you really want,
so I gave only what you asked for instead.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 4 Feb 2007 13:52:14 -0800
From: krakle@visto.com
Subject: Re: rename *-ch03.htm to ch03-*.htm?
Message-Id: <1170625934.609650.19760@p10g2000cwp.googlegroups.com>
On Feb 4, 2:13 am, Bart Lateur <bart.lat...@pandora.be> wrote:
>
> (my $new = $old) =~ s/(.*)-(ch\d+)(?=\.htm$)/$2-$1/ or next;
>
Shouldnt you backslash a dash since a dash has a special meaning in a
regex?
(my $new = $old) =~ s/(.*)\-(ch\d+)(?=\.htm$)/$2\-$1/ or next;
------------------------------
Date: 4 Feb 2007 14:15:39 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: rename *-ch03.htm to ch03-*.htm?
Message-Id: <1170627339.711530.68620@v33g2000cwv.googlegroups.com>
On Feb 4, 4:52 pm, kra...@visto.com wrote:
> On Feb 4, 2:13 am, Bart Lateur <bart.lat...@pandora.be> wrote:
> > (my $new = $old) =~ s/(.*)-(ch\d+)(?=\.htm$)/$2-$1/ or next;
>
> Shouldnt you backslash a dash since a dash has a special meaning in a
> regex?
Says who?
A dash has a special meaning within a character class, but not within
a regex itself.
perldoc perlretut
perldoc perlre
perldoc perlreref
Paul Lalli
------------------------------
Date: Mon, 05 Feb 2007 00:42:22 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: rename *-ch03.htm to ch03-*.htm?
Message-Id: <norcs21janrbtuibrbvgog8fnu8cluijc3@4ax.com>
On 4 Feb 2007 13:52:14 -0800, krakle@visto.com wrote:
>> (my $new = $old) =~ s/(.*)-(ch\d+)(?=\.htm$)/$2-$1/ or next;
>
>Shouldnt you backslash a dash since a dash has a special meaning in a
>regex?
No, because it hasn't. Except in charachter classes, that is. And it's
not in a charachter class above.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Tue, 6 Feb 2007 09:59:52 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: rename *-ch03.htm to ch03-*.htm?
Message-Id: <eq9jkg.pk.1@news.isolution.nl>
Michele Dondi schreef:
> krakle:
>> Shouldnt you backslash a dash since a dash has a special meaning in a
>> regex?
>
> No, because it hasn't. Except in charachter classes, that is.
And not even there if you put it first (after any modifier like ^) or
last.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
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:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#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 121
**************************************