[30639] in Perl-Users-Digest
Perl-Users Digest, Issue: 1884 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 28 09:09:48 2008
Date: Sun, 28 Sep 2008 06:09:07 -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 Sun, 28 Sep 2008 Volume: 11 Number: 1884
Today's topics:
Re: $current_path=`echo $cwd` does not work <joe@inwap.com>
Download files script. <internetpowerfultools@gmail.com>
new CPAN modules on Sun Sep 28 2008 (Randal Schwartz)
Re: Newlines on Windows <hjp-usenet2@hjp.at>
Re: Newlines on Windows <jurgenex@hotmail.com>
Re: sprintf doesn't round correctly? <tim@burlyhost.com>
Re: sprintf doesn't round correctly? <mgjv@tradingpost.com.au>
Re: use Class::Std :ATTR <Peter@PSDT.com>
Re: What does m@ stand for in the following regular exp <nospam-abuse@ilyaz.org>
Re: What does m@ stand for in the following regular exp <tim@burlyhost.com>
Re: What does m@ stand for in the following regular exp <cdalten@gmail.com>
Re: What does m@ stand for in the following regular exp <tim@burlyhost.com>
Re: What does m@ stand for in the following regular exp <mgjv@tradingpost.com.au>
Re: What does m@ stand for in the following regular exp <tim@burlyhost.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 27 Sep 2008 21:55:29 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: $current_path=`echo $cwd` does not work
Message-Id: <tOadnRTTHbTdk0LVnZ2dnUVZ_gKdnZ2d@comcast.com>
Kuhl wrote:
> $current_path=`pwd`; This works.
> $current_path=`echo $cwd`; This does not work.
You've got two conceptual problems.
1. Without a \ in front of the $, you are passing a perl variable.
$cwd = "This changes a variable inside of perl";
chdir "/tmp";
$echoed_value = `echo $cwd`;
die "Oops, wrong variable" if $echoed_value = $cwd;
2. The value a shell's internal $cwd variable may or may not be set
to the same thing that `pwd` returns. In particular, older versions
of /bin/sh did not have $cwd, and even if $PWD was inherited, it would
not get updated.
Take the case where /home is a symlink to /space/users and I do
"cd /home/jms/bin" before running the script.
Q: Will `echo $cwd` return "/home/jms/bin" or "/space/users/jms/bin"?
A: Yes.
-Joe
------------------------------
Date: Sun, 28 Sep 2008 03:29:26 -0700 (PDT)
From: mathaios <internetpowerfultools@gmail.com>
Subject: Download files script.
Message-Id: <34d7bda7-5940-49be-bf5d-1bfa99168f5a@k30g2000hse.googlegroups.com>
Hi.
I want to install a script in my website for the visitors to be able
to download files.
Is there anyone who can replace the values needed to be changed in the
script below for base downloads folder, downloads log file name,
allowed file types
with highlighted example text?
------------------------------------------------------------------------------------------------------------------------------------------
// Allow direct file download (hotlinking)?
// Empty - allow hotlinking
// If set to nonempty value (Example: example.com) will only allow
downloads when referrer contains this text
define('ALLOWED_REFERRER', '');
// Download folder, i.e. folder where you keep all files for download.
// MUST end with slash (i.e. "/" )
define('BASE_DIR','/home/user/downloads/');
// log downloads? true/false
define('LOG_DOWNLOADS',true);
// log file name
define('LOG_FILE','downloads.log');
// Allowed extensions list in format 'extension' => 'mime type'
// If myme type is set to empty string then script will try to detect
mime type
// itself, which would only work if you have Mimetype or Fileinfo
extensions
// installed on server.
$allowed_ext = array (
// archives
'zip' => 'application/zip',
// documents
'pdf' => 'application/pdf',
'doc' => 'application/msword',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// executables
'exe' => 'application/octet-stream',
// images
'gif' => 'image/gif',
'png' => 'image/png',
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
// audio
'mp3' => 'audio/mpeg',
'wav' => 'audio/x-wav',
// video
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'mov' => 'video/quicktime',
'avi' => 'video/x-msvideo'
);
------------------------------------------------------------------------------------------------------------------------------------------
I would be greatful.
------------------------------
Date: Sun, 28 Sep 2008 04:42:21 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Sep 28 2008
Message-Id: <K7w2EL.1JEn@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
BDB-1.8
http://search.cpan.org/~mlehmann/BDB-1.8/
Asynchronous Berkeley DB access
----
CGI-Application-4.19_1
http://search.cpan.org/~markstos/CGI-Application-4.19_1/
Framework for building reusable web-applications
----
CGI-Lazy-0.10
http://search.cpan.org/~vayde/CGI-Lazy-0.10/
----
Catalyst-Model-MultiAdaptor-0.01
http://search.cpan.org/~kitano/Catalyst-Model-MultiAdaptor-0.01/
use plain classes as a Catalyst Model
----
Catalyst-Model-MultiAdaptor-0.02
http://search.cpan.org/~kitano/Catalyst-Model-MultiAdaptor-0.02/
use plain classes as a Catalyst Model
----
Coro-4.748
http://search.cpan.org/~mlehmann/Coro-4.748/
coroutine process abstraction
----
Crypt-NSS-0.01_03
http://search.cpan.org/~claesjac/Crypt-NSS-0.01_03/
Perl bindings to NSS (Netscape Security Services)
----
ExtUtils-MakeMaker-6.46
http://search.cpan.org/~mschwern/ExtUtils-MakeMaker-6.46/
Create a module Makefile
----
File-Find-Closures-1.08
http://search.cpan.org/~bdfoy/File-Find-Closures-1.08/
functions you can use with File::Find
----
Games-Risk-1.1.0
http://search.cpan.org/~jquelin/Games-Risk-1.1.0/
classical 'risk' board game
----
Geometry-AffineTransform-1.2
http://search.cpan.org/~liyanage/Geometry-AffineTransform-1.2/
Affine Transformation to map 2D coordinates to other 2D coordinates
----
IO-Async-Loop-Glib-0.13
http://search.cpan.org/~pevans/IO-Async-Loop-Glib-0.13/
a Loop using the Glib::MainLoop object
----
Imager-SkinDetector-0.01
http://search.cpan.org/~cosimo/Imager-SkinDetector-0.01/
The great new Imager::SkinDetector!
----
Math-MPC-0.50
http://search.cpan.org/~sisyphus/Math-MPC-0.50/
perl interface to the MPC (multi precision complex) library.
----
Method-Signatures-0.11
http://search.cpan.org/~mschwern/Method-Signatures-0.11/
method declarations with signatures and no source filter
----
Net-Interface-0.10
http://search.cpan.org/~miker/Net-Interface-0.10/
Perl extension to access network interfaces
----
NetAddr-IP-4.010
http://search.cpan.org/~miker/NetAddr-IP-4.010/
Manages IPv4 and IPv6 addresses and subnets
----
OpenGL-0.57
http://search.cpan.org/~bfree/OpenGL-0.57/
v0.57 Perl OpenGL (POGL) module to display 3D data using OpenGL, FreeGLUT/GLUT, and GLX
----
OpenGL-Image-1.03
http://search.cpan.org/~bfree/OpenGL-Image-1.03/
v1.03 copyright 2007 Graphcomp - ALL RIGHTS RESERVED Author: Bob "grafman" Free - grafman@graphcomp.com Contributor: Geoff Broadwell
----
OpenResty-0.4.2
http://search.cpan.org/~agent/OpenResty-0.4.2/
General-purpose web service platform for web applications
----
OpenResty-0.5.0
http://search.cpan.org/~agent/OpenResty-0.5.0/
General-purpose web service platform for web applications
----
Pod-From-GoogleWiki-0.06
http://search.cpan.org/~fayland/Pod-From-GoogleWiki-0.06/
convert from Google Code wiki markup to POD
----
Rose-DBx-Object-Renderer-0.34
http://search.cpan.org/~danny/Rose-DBx-Object-Renderer-0.34/
Web UI Rendering for Rose::DB::Object
----
SVN-Hooks-0.09.364
http://search.cpan.org/~gnustavo/SVN-Hooks-0.09.364/
A framework for implementing Subversion hooks.
----
SVN-Look-0.09.366
http://search.cpan.org/~gnustavo/SVN-Look-0.09.366/
A caching wrapper aroung the svnlook command.
----
Shell-Amazon-S3-0.01
http://search.cpan.org/~kitano/Shell-Amazon-S3-0.01/
Shell for Amazon S3
----
Text-Darts-0.04
http://search.cpan.org/~dankogai/Text-Darts-0.04/
Perl interface to DARTS by Taku Kudoh
----
Variable-Magic-0.21_02
http://search.cpan.org/~vpit/Variable-Magic-0.21_02/
Associate user-defined magic to variables from Perl.
----
WebService-KuronekoYamato-0.0.2
http://search.cpan.org/~clcl/WebService-KuronekoYamato-0.0.2/
Check Track Shipments (Yamato Transport Co., Ltd. /Japan)
----
WebService-NFSN-0.07
http://search.cpan.org/~cjm/WebService-NFSN-0.07/
Client for the NearlyFreeSpeech.NET API
----
scriptname-0.5
http://search.cpan.org/~massa/scriptname-0.5/
Locate original perl script
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Sun, 28 Sep 2008 09:34:31 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Newlines on Windows
Message-Id: <slrngducsf.dsb.hjp-usenet2@hrunkner.hjp.at>
On 2008-09-27 19:47, void.no.spam.com@gmail.com <void.no.spam.com@gmail.com> wrote:
> On Sep 27, 3:34 pm, Jürgen Exner <jurge...@hotmail.com> wrote:
>> "void.no.spam....@gmail.com" <void.no.spam....@gmail.com> wrote:
>> >I thought that on Windows, if you want to output a carriage return,
>> >you have to use \r\n instead of just \n.
>>
>> Neither nor. You are confusing two different layers.
>>
>> To output a carriage return you have to print the ASCII controll
>> character 13 (DEZ) or 0x0D (HEX) or short "\r". That is by definition
>> the CR character for ASCII which in turn is a subset of Windows-1252,
>> ISO-Latin-1, and many other encodings.
>>
>> "\n" on the other hand in Perl is a logical line end, which will be
>> translated automatically into the correct line end sequence for the
>> current OS, be it 0x0A for unixoide OSes, 0x0A 0x0D for Windows, or 0x0D
>> for Mac.
>>
>> So your combination \r\n on Windows will result in 0x0D 0X0A 0x0D.
>> Probably not what you want.
[...]
>
> Thanks for the explanation.
It is worth noting that the translation Jürgen talks about happens only
during file I/O. Inside of a perl script, "\n" is always a single
character ("\015" on old MacOS, "\012" on Unix, Windows, and (I think)
also on MacOS X). When writing to a file with the :crlf I/O layer enabled
(which is the default on Windows, but you can turn it off with binmode
or an argument to open), the single "\n" is converted to "\015\012". The
reverse conversion is done when reading a file with the :crlf layer.
(Perl can do other conversions on I/O, too, e.g., character set
conversions, compression, etc.)
hp
------------------------------
Date: Sun, 28 Sep 2008 02:38:03 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Newlines on Windows
Message-Id: <7rjud4pcu2ueauplh0eimkpp19k2dq4alo@4ax.com>
"Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
>It is worth noting that the translation Jürgen talks about happens only
>during file I/O. Inside of a perl script, "\n" is always a single
>character ("\015" on old MacOS, "\012" on Unix, Windows, and (I think)
>also on MacOS X). When writing to a file with the :crlf I/O layer enabled
>(which is the default on Windows, but you can turn it off with binmode
>or an argument to open), the single "\n" is converted to "\015\012". The
>reverse conversion is done when reading a file with the :crlf layer.
To be crystal clear on that: did you mean "writing to a file" or
"writing to a file handle"?
Like in writing to STDOUT, but having the shell redirect into a file?
jue
------------------------------
Date: Sat, 27 Sep 2008 13:12:02 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: sprintf doesn't round correctly?
Message-Id: <mswDk.6055$M_7.2073@newsfe03.iad>
void.no.spam.com@gmail.com wrote:
> Hi, I have the following code, where the multiplication results in a
> dollar amount which needs to be rounded to the nearest cent.
>
> $a = sprintf("%.2f", 1900*18.12895);
> print $a;
>
> The multiplication yields the value 34445.005, which should be rounded
> up to 34445.01, but perl says that $a has the value 34445.00. Why is
> it exhibiting this behavior?
See:
perldoc -q decimals
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Sun, 28 Sep 2008 08:01:33 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: sprintf doesn't round correctly?
Message-Id: <tfambg.g68.ln@news.heliotrope.home>
On Sat, 27 Sep 2008 21:38:26 +0200,
Chris Haffenstedt <chaff@t-online.de> wrote:
> void.no.spam.com@gmail.com schrieb:
>> Hi, I have the following code, where the multiplication results in a
>> dollar amount which needs to be rounded to the nearest cent.
>>
>> $a = sprintf("%.2f", 1900*18.12895);
>> print $a;
>
> sprintf doesn't round at all.
sprintf and printf do rounding.
See
# perldoc -q round
and
# perldoc -f sprintf
(search for 'rounded')
Martien
--
|
Martien Verbruggen | "In a world without fences,
| who needs Gates?"
|
------------------------------
Date: Sun, 28 Sep 2008 05:09:27 -0700
From: Peter Scott <Peter@PSDT.com>
Subject: Re: use Class::Std :ATTR
Message-Id: <pan.2008.09.28.12.09.27.853202@PSDT.com>
On Thu, 25 Sep 2008 00:53:29 -0500, * Tong * wrote:
> I thought using "my %name_of :ATTR(get<name>, set<name>)" would define
> Cow->set_name for me automatically, wouldn't it?
Colons missing:
my %name_of :ATTR(:get<name>, :set<name>)
--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
------------------------------
Date: Sat, 27 Sep 2008 20:16:23 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: What does m@ stand for in the following regular expression.
Message-Id: <gbm4an$eb0$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Tim Greer
<tim@burlyhost.com>], who wrote in article <JfvDk.29$Ra2.27@newsfe06.iad>:
> > my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
> > What does m@ do in this case?
>
> m(anything) is making (anything) the delimiter. m// is just most common
> to see, but m,, or m!! and so on, are perfectly acceptable.
It would be correct, except for
m(anything) is using `(' and `)' as delimiters.
;-) :-(
Ilya
------------------------------
Date: Sat, 27 Sep 2008 13:19:50 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: What does m@ stand for in the following regular expression.
Message-Id: <GzwDk.23042$Kf6.1233@newsfe02.iad>
Ilya Zakharevich wrote:
> [A complimentary Cc of this posting was sent to
> Tim Greer
> <tim@burlyhost.com>], who wrote in article
> <JfvDk.29$Ra2.27@newsfe06.iad>:
>> > my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
>> > What does m@ do in this case?
>>
>> m(anything) is making (anything) the delimiter. m// is just most
>> common to see, but m,, or m!! and so on, are perfectly acceptable.
>
> It would be correct, except for
>
> m(anything) is using `(' and `)' as delimiters.
>
> ;-) :-(
>
> Ilya
Haha. Okay, I really probably should have been more clear about the
example place holder. To the OP; Don't actually expect that to
work! :-)
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Sat, 27 Sep 2008 13:37:40 -0700 (PDT)
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: What does m@ stand for in the following regular expression.
Message-Id: <f0d2382b-7109-4519-8168-fd74ccf81ca9@d70g2000hsc.googlegroups.com>
On Sep 27, 1:16 pm, Ilya Zakharevich <nospam-ab...@ilyaz.org> wrote:
> [A complimentary Cc of this posting was sent to
> Tim Greer
> <t...@burlyhost.com>], who wrote in article <JfvDk.29$Ra2...@newsfe06.iad>:
>
> > > my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
> > > What does m@ do in this case?
>
> > m(anything) is making (anything) the delimiter. m// is just most common
> > to see, but m,, or m!! and so on, are perfectly acceptable.
>
> It would be correct, except for
>
> m(anything) is using `(' and `)' as delimiters.
>
And what would be the reason for using ( and ) as delimiters in this
case?
------------------------------
Date: Sat, 27 Sep 2008 13:41:20 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: What does m@ stand for in the following regular expression.
Message-Id: <RTwDk.23098$Kf6.587@newsfe02.iad>
grocery_stocker wrote:
> On Sep 27, 1:16 pm, Ilya Zakharevich <nospam-ab...@ilyaz.org> wrote:
>> [A complimentary Cc of this posting was sent to
>> Tim Greer
>> <t...@burlyhost.com>], who wrote in article
>> <JfvDk.29$Ra2...@newsfe06.iad>:
>>
>> > > my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
>> > > What does m@ do in this case?
>>
>> > m(anything) is making (anything) the delimiter. m// is just most
>> > common to see, but m,, or m!! and so on, are perfectly acceptable.
>>
>> It would be correct, except for
>>
>> m(anything) is using `(' and `)' as delimiters.
>>
>
> And what would be the reason for using ( and ) as delimiters in this
> case?
None, I had made a poor example of saying that the "delimiter character"
would be anything, by using the example of "(anything)" as the place
holder (for the example). That could cause confusion, so Ilya called
me on it. You _could_ use parenthesis if you wanted to m() instead of
m// or m@@ or m!! or m,, and so on. There's no reason for using any
one over another, other than personal preference, or in the case where
you can save typing and have it look cleaner, especially by not having
to backwack the same characters in the regex that you use as the
delimiter. I hope that's more clear (and I think Ilya called me on
this just for the above reason and the confusion it has already
caused).
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Sun, 28 Sep 2008 08:17:42 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: What does m@ stand for in the following regular expression.
Message-Id: <6ebmbg.g68.ln@news.heliotrope.home>
On Sat, 27 Sep 2008 13:41:20 -0700,
Tim Greer <tim@burlyhost.com> wrote:
> grocery_stocker wrote:
>
>> On Sep 27, 1:16 pm, Ilya Zakharevich <nospam-ab...@ilyaz.org> wrote:
>>> [A complimentary Cc of this posting was sent to
>>> Tim Greer
>>> <t...@burlyhost.com>], who wrote in article
>>> <JfvDk.29$Ra2...@newsfe06.iad>:
>>>
>>> > > my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
>>> > > What does m@ do in this case?
>>>
>>> > m(anything) is making (anything) the delimiter. m// is just most
>>> > common to see, but m,, or m!! and so on, are perfectly acceptable.
>>>
>>> It would be correct, except for
>>>
>>> m(anything) is using `(' and `)' as delimiters.
>>>
>>
>> And what would be the reason for using ( and ) as delimiters in this
>> case?
>
> None, I had made a poor example of saying that the "delimiter character"
> would be anything, by using the example of "(anything)" as the place
> holder (for the example). That could cause confusion, so Ilya called
> me on it. You _could_ use parenthesis if you wanted to m() instead of
> m// or m@@ or m!! or m,, and so on.
One more footnote to this (and I'm sure you already know this, but
others might not):
If you use ? as the delimiter, then the pattern will only match once,
until you call reset().
Even if you don't ever need this, and even if you take into account that
that usage is deprecated, it's useful to know, as it can create some
weird and obscure bugs if you choose ?? as your delimiters, without
being aware of this behaviour.
> There's no reason for using any
> one over another, other than personal preference, or in the case where
> you can save typing and have it look cleaner, especially by not having
> to backwack the same characters in the regex that you use as the
> delimiter.
Using brackets, either (), {}, <> or [] can be advantageous in that they
properly nest. What I mean by that is that you only ever have to escape
a closing bracket in the pattern if it hasn't been preceded by a opening
one. If you choose non-bracket delimiters, you need to escape your
delimiter in the pattern more often.
Also, most code editors have a 'find matching bracket' functionality
somewhere, which, for checking and debugging large regexen can be handy.
Check the section 'Quote and Quote-like Operators' in the perlop
documentation for more information.
Martien
--
|
Martien Verbruggen | "In a world without fences,
| who needs Gates?"
|
------------------------------
Date: Sat, 27 Sep 2008 15:51:05 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: What does m@ stand for in the following regular expression.
Message-Id: <tNyDk.23358$Kf6.9676@newsfe02.iad>
Martien Verbruggen wrote:
> On Sat, 27 Sep 2008 13:41:20 -0700,
> Tim Greer <tim@burlyhost.com> wrote:
>> grocery_stocker wrote:
>>
>>> On Sep 27, 1:16 pm, Ilya Zakharevich <nospam-ab...@ilyaz.org> wrote:
>>>> [A complimentary Cc of this posting was sent to
>>>> Tim Greer
>>>> <t...@burlyhost.com>], who wrote in article
>>>> <JfvDk.29$Ra2...@newsfe06.iad>:
>>>>
>>>> > > my ($title) = ($body =~ m@<title>\s*(.*?)\s*</title>@si);
>>>> > > What does m@ do in this case?
>>>>
>>>> > m(anything) is making (anything) the delimiter. m// is just most
>>>> > common to see, but m,, or m!! and so on, are perfectly
>>>> > acceptable.
>>>>
>>>> It would be correct, except for
>>>>
>>>> m(anything) is using `(' and `)' as delimiters.
>>>>
>>>
>>> And what would be the reason for using ( and ) as delimiters in this
>>> case?
>>
>> None, I had made a poor example of saying that the "delimiter
>> character" would be anything, by using the example of "(anything)" as
>> the place
>> holder (for the example). That could cause confusion, so Ilya called
>> me on it. You _could_ use parenthesis if you wanted to m() instead
>> of m// or m@@ or m!! or m,, and so on.
>
> One more footnote to this (and I'm sure you already know this, but
> others might not):
>
> If you use ? as the delimiter, then the pattern will only match once,
> until you call reset().
>
> Even if you don't ever need this, and even if you take into account
> that that usage is deprecated, it's useful to know, as it can create
> some weird and obscure bugs if you choose ?? as your delimiters,
> without being aware of this behaviour.
>
>> There's no reason for using any
>> one over another, other than personal preference, or in the case
>> where you can save typing and have it look cleaner, especially by not
>> having to backwack the same characters in the regex that you use as
>> the delimiter.
>
> Using brackets, either (), {}, <> or [] can be advantageous in that
> they properly nest. What I mean by that is that you only ever have to
> escape a closing bracket in the pattern if it hasn't been preceded by
> a opening one. If you choose non-bracket delimiters, you need to
> escape your delimiter in the pattern more often.
>
> Also, most code editors have a 'find matching bracket' functionality
> somewhere, which, for checking and debugging large regexen can be
> handy.
>
> Check the section 'Quote and Quote-like Operators' in the perlop
> documentation for more information.
>
> Martien
Excellent points.
--
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
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 1884
***************************************