[28980] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 224 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 15 09:09:42 2007

Date: Thu, 15 Mar 2007 06:09:06 -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           Thu, 15 Mar 2007     Volume: 11 Number: 224

Today's topics:
    Re: FAQ 5.36 Why does Perl let me delete read-only file <dickey@saltmine.radix.net>
    Re: gluing client and server (Jamie)
        new CPAN modules on Thu Mar 15 2007 (Randal Schwartz)
    Re: passing passords to pgsql/pg_create/pg_dump program <filippo2991@virgilio.it>
    Re: Perl DBI/XML processing versus PHP ? (Jamie)
    Re: Perl DBI/XML processing versus PHP ? <jstucklex@attglobal.net>
    Re: Stupid question but its driving me nuts... <tadmc@augustmail.com>
    Re: Stupid question but its driving me nuts... <nitte.sudhir@gmail.com>
        tr/ last char x$ <aisling.cronin@gmail.com>
    Re: tr/ last char x$ anno4000@radom.zrz.tu-berlin.de
        Trouble with a file upload script <sukesh@zoom.co.uk>
    Re: Trouble with a file upload script <paduille.4060.mumia.w+nospam@earthlink.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 15 Mar 2007 12:56:41 -0000
From: Thomas Dickey <dickey@saltmine.radix.net>
Subject: Re: FAQ 5.36 Why does Perl let me delete read-only files?  Why does "-i" clobber protected files?  Isn't this a bug in Perl?
Message-Id: <12vigk9ss0ug8bf@corp.supernews.com>

PerlFAQ Server <brian@stonehenge.com> wrote:

> 5.36: Why does Perl let me delete read-only files?  Why does "-i" clobber protected files?  Isn't this a bug in Perl?

>     The executive summary: learn how your filesystem works. The permissions
>     on a file say what can happen to the data in that file. The permissions
>     on a directory say what can happen to the list of files in that
>     directory. If you delete a file, you're removing its name from the
>     directory (so the operation depends on the permissions of the directory,
>     not of the file). If you try to write to the file, the permissions of
>     the file govern whether you're allowed to.

That's a Unix-specific behavior (does not behave that way with VMS - not
even taking into account access lists, as well as some other widely-used
platforms that implement access lists).

-- 
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net


------------------------------

Date: Thu, 15 Mar 2007 10:24:24 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: gluing client and server
Message-Id: <Lc117393419733170x8939140@pong.podro.com>

In <et8dl9$6ps$1@ss408.t-com.hr>,
Matija Papec <blank@yahoo.com> mentions:
>Sherm Pendley wrote:
>>> I would like to use older mysql client but unfortunately it doesn't
>>> understand newer authentication
>> 
>> Configure the database to use old-style passwords. Problem solved.
>> 
>>     <http://dev.mysql.com/doc/refman/5.0/en/old-client.html>
>
>Tnx, but I don't have the rights to configure the database.

More of a mysql problem, but:

I don't know how secure this is:

	UPDATE mysql.user 
	SET password=old_password('secret') 
	WHERE user='username' AND host='localhost';
	FLUSH PRIVILEGES;

But, I imagine if mysql is using strictly local sockets and the 
web server needs read access to wherever you've placed the password
(hopefully your conf is !OUTSIDE! of web space)...

Naturally, one probably wouldn't want to allow cross-network connections
to mysql this way, without SSL or something.

It should be OK.

Jamie
-- 
http://www.geniegate.com                    Custom web programming
Perl * Java * UNIX                        User Management Solutions


------------------------------

Date: Thu, 15 Mar 2007 05:42:13 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Mar 15 2007
Message-Id: <JExJuD.1y5u@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.

Apache2-Translation-0.12
http://search.cpan.org/~opi/Apache2-Translation-0.12/
Configuring Apache dynamically 
----
Biblio-EndnoteStyle-0.04
http://search.cpan.org/~mirk/Biblio-EndnoteStyle-0.04/
reference formatting using Endnote-like templates 
----
Bio-DOOP-DOOP-0.11
http://search.cpan.org/~tibi/Bio-DOOP-DOOP-0.11/
DOOP API main module 
----
Business-ISBN-2.00_01
http://search.cpan.org/~bdfoy/Business-ISBN-2.00_01/
work with International Standard Book Numbers 
----
Catalyst-Plugin-Session-Store-DBI-0.09
http://search.cpan.org/~agrundma/Catalyst-Plugin-Session-Store-DBI-0.09/
Store your sessions in a database 
----
Catalyst-Runtime-5.7007
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7007/
Catalyst Runtime version 
----
Class-DBI-FormTools-v0.0.5
http://search.cpan.org/~djo/Class-DBI-FormTools-v0.0.5/
Build forms with multiple interconnected objects. 
----
DateTime-Format-Natural-0.26
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.26/
Create machine readable date/time with natural parsing logic 
----
Devel-GDB-2.0
http://search.cpan.org/~jezra/Devel-GDB-2.0/
Open and communicate a gdb session 
----
Devel-Spy-0.05
http://search.cpan.org/~jjore/Devel-Spy-0.05/
Spy on your objects and data 
----
File-Iterator-0.14
http://search.cpan.org/~swhitaker/File-Iterator-0.14/
an object-oriented Perl module for iterating across files in a directory tree. 
----
GD-Graph-Polar-0.15
http://search.cpan.org/~mrdvt/GD-Graph-Polar-0.15/
Make polar graph using GD package 
----
Geo-Coordinates-UTM-XS-0.02
http://search.cpan.org/~salva/Geo-Coordinates-UTM-XS-0.02/
C/XS reimplementation of Geo::Coordinates::UTM 
----
LaTeX-Pod-0.11
http://search.cpan.org/~schubiger/LaTeX-Pod-0.11/
Transform LaTeX source files to POD (Plain old documentation) 
----
MARC-Charset-0.96
http://search.cpan.org/~mikery/MARC-Charset-0.96/
convert MARC-8 encoded strings to UTF-8 
----
Makefile-Parser-0.15
http://search.cpan.org/~agent/Makefile-Parser-0.15/
A simple parser for Makefiles 
----
Math-Matlab-0.08
http://search.cpan.org/~zman/Math-Matlab-0.08/
An abstract base class for a simple Matlab API. 
----
Net-CUPS-0.51
http://search.cpan.org/~dhageman/Net-CUPS-0.51/
Common Unix Printing System Interface 
----
Net-DAAP-Server-MythTV-0.01
http://search.cpan.org/~jablko/Net-DAAP-Server-MythTV-0.01/
Publish MythTV videos to DAAP clients like Apple's Front Row 
----
Net-MirapointAdmin-3.02
http://search.cpan.org/~ahall/Net-MirapointAdmin-3.02/
Perl interface to the Mirapoint administration protocol 
----
Net-Rsh-0.03
http://search.cpan.org/~aslett/Net-Rsh-0.03/
perl client for Rsh protocol 
----
Number-Phone-1.57
http://search.cpan.org/~dcantrell/Number-Phone-1.57/
base class for Number::Phone::* modules 
----
Number-Phone-UK-DetailedLocations-1.3
http://search.cpan.org/~dcantrell/Number-Phone-UK-DetailedLocations-1.3/
more detailed location information for Number::Phone::UK 
----
PGPLOT-Simple-0.04
http://search.cpan.org/~fmerges/PGPLOT-Simple-0.04/
Simple Interface to PGPLOT 
----
Parallel-ForkControl-0.04
http://search.cpan.org/~blhotsky/Parallel-ForkControl-0.04/
Finer grained control of processes on a Unix System 
----
SVN-Notify-Mirror-0.03602
http://search.cpan.org/~jpeacock/SVN-Notify-Mirror-0.03602/
Keep a mirrored working copy of a repository path 
----
Shell-Perl-0.0010
http://search.cpan.org/~ferreira/Shell-Perl-0.0010/
A read-eval-print loop in Perl 
----
Sledge-Plugin-Captcha-0.02
http://search.cpan.org/~tokuhirom/Sledge-Plugin-Captcha-0.02/
create and validate Captcha for Sledge. 
----
Statistics-Cluto-0.01
http://search.cpan.org/~ihara/Statistics-Cluto-0.01/
Perl binding for CLUTO 
----
Taint-Util-0.01
http://search.cpan.org/~avar/Taint-Util-0.01/
Test and flip the taint flag on scalars without regex matches or eval 
----
Taint-Util-0.02
http://search.cpan.org/~avar/Taint-Util-0.02/
Test for and flip the taint flag without regex matches or eval 
----
Test-MonitorSites-0.04
http://search.cpan.org/~hesco/Test-MonitorSites-0.04/
Monitor availability and function of a list of websites 
----
Test-Simple-0.69
http://search.cpan.org/~mschwern/Test-Simple-0.69/
Basic utilities for writing tests. 
----
Text-FixedLengthMultiline-0.04
http://search.cpan.org/~dolmen/Text-FixedLengthMultiline-0.04/
Parse text data formatted in space separated columns optionnaly on multiple lines. 
----
Tie-Array-Packed-0.07
http://search.cpan.org/~salva/Tie-Array-Packed-0.07/
store arrays in memory efficiently as packed strings 
----
UNIVERSAL-ref-0.08
http://search.cpan.org/~jjore/UNIVERSAL-ref-0.08/
Turns ref() into a multimethod 
----
UNIVERSAL-ref-0.09
http://search.cpan.org/~jjore/UNIVERSAL-ref-0.09/
Turns ref() into a multimethod 
----
Video-Subtitle-SRT-0.01
http://search.cpan.org/~miyagawa/Video-Subtitle-SRT-0.01/
Handle Subtitle (.SRT) file with a callback 
----
WWW-UsePerl-Journal-0.16
http://search.cpan.org/~barbie/WWW-UsePerl-Journal-0.16/
A use.perl.org journal tool 
----
XML-RSS-Liberal-0.03_01
http://search.cpan.org/~dmaki/XML-RSS-Liberal-0.03_01/
XML::RSS With A Liberal Parser 
----
caCOREperl_v32
http://search.cpan.org/~ncicb/caCOREperl_v32/


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/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: 15 Mar 2007 01:25:06 -0700
From: "Filippo" <filippo2991@virgilio.it>
Subject: Re: passing passords to pgsql/pg_create/pg_dump programmatically
Message-Id: <1173947106.753391.124820@y80g2000hsf.googlegroups.com>

On 13 Mar, 23:38, Ben Morrow <b...@morrow.me.uk> wrote:
> [pgsql.general trimmed: it doesn't exist]
>
> Quoth "filippo" <filippo2...@virgilio.it>:
>
>
>
> > Hello,
>
> > I have written a program perl/Tkprogram, based on postgres. For
> > maintenance reasons in my program I use these commands:
>
> >       `dropdb -U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
> >       `createdb -U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
> >       `pg_dump -U postgres -h $DATABASE_SERVER $DATABASE_NAME | psql -
> > U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;
>
> > my @psqlOutput = `psql -l -U postgres -h $_`;
>
> > my program has a graphic interface but whenever I use these command,
> > postgres ask for passord in the command line. How can I give these
> > commands the right passowrd programmatically or how can I   interact
> > with these to give the passwords by a graphic box?
>
> Read the manpages for those commands to find the appropriate equivalent
> SQL (which exists, in every case: the commands just connect to the DB
> and send SQL); then send that using DBI.

thanks Ben,
the problem for me with this strategy is to re-create this

pg_dump -U postgres -h $DATABASE_SERVER $DATABASE_NAME | psql -
U postgres -h $BACKUP_SERVER $BACKUP_DATABASE_NAME`;

it is a dump (sql command) plus a pipe into another SQL command. I
don't figure out how to implement into simple SQL. By the way, thanks
for the hint.

BR,

Filippo





------------------------------

Date: Thu, 15 Mar 2007 11:00:06 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: Perl DBI/XML processing versus PHP ?
Message-Id: <Lc117393480733170x8b378c8@pong.podro.com>

In <1173914816.457971.224720@d57g2000hsg.googlegroups.com>,
"surfivor" <surfver@yahoo.com> mentions:
>I may be involved in a data migration project involving databases and
>creating XML feeds. Our site is PHP based, so I imagine the team might
>suggest PHP, but I had a look at the PHP documentation for one of the
>Pear modules for creating XML and it didn't look like much. I've used
>Perl XML:Twig and I have the impression that there is more Perl stuff
>available as well as the Perl stuff being well documented as I have a
>Perl DBI book, a Perl XML, a Perl data munging book and so on. Alot of
>the PHP books seem to be mainly on building sites and connecting to
>databases, but I haven't checked them all and I have most of the Perl
>books. One problem is that some of the Perl stuff is hard to get on
>Activestate Perl for windows, so I may have to try to explain to them
>why I think it should be done in Perl and why I need a linux login to
>do it, etc. I'm not that familiar with PHP, but am looking for
>comments on this.

Seems to me, perl DBI is a bit more intuitive. Last time I looked, 
php didn't really have placeholders (well, it did, depending on which
version of php was available where) 

This was awhile ago, but.. in mysql, placeholders didn't help much. Other DBM's
though, like DB2 or postgresql will use place holders to cache a compiled SQL
statement, (this happens server side) this can really boost performance if you
have a lot of identical INSERT or SELECT statements that vary only in their
input parameters. The DBM only has to inspect and parse the SQL once if it uses
placeholders. This is rather a big deal if you want performance out of other
DBM's.

Trouble with PHP is that one version is incompatible with the next, 
even along the same branches, 5.2 might not work with 5.1. It's sort
of hit -n- miss. On top of that the php you use may have been compiled
with flags the server didn't use or have ini settings that vary. Each
"php platform" is "unique" with it's own settings. Each version of
PHP is "unique" in that it may or may not work with your application.

All of this really makes a mess if you want to use other PHP scripts 
from other packages. PHP is like having the rug ripped out from under
you at every turn.

PHP really isn't very good for larger projects. (but then, the same
has and can be said for perl)

Sometimes you can "throw an exception" in PHP sometimes, you can't, again..
depending on the version and quirks of whoever installed PHP. Perl on the other
hand, it's a pretty safe bet eval { ... die "BOO"; } will work, this is
important if you'll be doing any transactions or need to do things
like break out of an XML parse operation from a callback, but catch
it in the caller space.

If you need to /consume/ XML, then you definately do not want PHP, as
there really isn't the same flexibility with getting at the input
as it arrives. It wants to put everything into $_POST before your
script can have any say in the matter. This makes it quite difficult
to parse an input document "as it arrives" (there are other ways
around this in PHP, but none of them allow you direct access to the
wire the way perl does)

Perl on the other hand, allows you to get at the raw input data if
you need it.

I've been told that you can purchase extra tools to run PHP in a sort
of peristent environment, but, in the free cost version it's impossible
to create say, an XSLT tranformer object and share it with new requests.

In PHP that data needs to be loaded each and every time, tree needs to
be built for each request. With perl (and FastCGI or mod_perl), you can 
create a heavy object once and share it among requests. (pros and cons to 
this, of course. You can also accidently store other information and create
memory leaks if your not careful)

The "heavy object sharing" lends itself really well to XSLT processors
or DOM objects that don't change, load once and re-use over and over.
This can really be crucial with XML processing, as XSLT transformers
tend to be kind of expensive to create.

PHP has the advantage that it's "template" is fairly standardized (well,
most people have settled on "<?php ?>" so you don't have a dozen different
overkill template engines.

Hopefully I've given you enough "perl firepower" but, in my experience, no
matter how you phrase the above points, people always assume perl is older
technology and therefore inferior. PHP is modern, popular and therefore
better:

	 "Don't try to confuse me with the facts!" - LOL


Jamie
-- 
http://www.geniegate.com                    Custom web programming
Perl * Java * UNIX                        User Management Solutions


------------------------------

Date: Thu, 15 Mar 2007 08:24:51 -0500
From: Jerry Stuckle <jstucklex@attglobal.net>
Subject: Re: Perl DBI/XML processing versus PHP ?
Message-Id: <z5KdnSo5vd-qpmTYnZ2dnUVZ_ternZ2d@comcast.com>

Jamie wrote:
> In <1173914816.457971.224720@d57g2000hsg.googlegroups.com>,
> "surfivor" <surfver@yahoo.com> mentions:
>> I may be involved in a data migration project involving databases and
>> creating XML feeds. Our site is PHP based, so I imagine the team might
>> suggest PHP, but I had a look at the PHP documentation for one of the
>> Pear modules for creating XML and it didn't look like much. I've used
>> Perl XML:Twig and I have the impression that there is more Perl stuff
>> available as well as the Perl stuff being well documented as I have a
>> Perl DBI book, a Perl XML, a Perl data munging book and so on. Alot of
>> the PHP books seem to be mainly on building sites and connecting to
>> databases, but I haven't checked them all and I have most of the Perl
>> books. One problem is that some of the Perl stuff is hard to get on
>> Activestate Perl for windows, so I may have to try to explain to them
>> why I think it should be done in Perl and why I need a linux login to
>> do it, etc. I'm not that familiar with PHP, but am looking for
>> comments on this.
> 
> Seems to me, perl DBI is a bit more intuitive. Last time I looked, 
> php didn't really have placeholders (well, it did, depending on which
> version of php was available where) 
>

True, I also find perl DBI more intuitive.  But both work well.

> This was awhile ago, but.. in mysql, placeholders didn't help much. Other DBM's
> though, like DB2 or postgresql will use place holders to cache a compiled SQL
> statement, (this happens server side) this can really boost performance if you
> have a lot of identical INSERT or SELECT statements that vary only in their
> input parameters. The DBM only has to inspect and parse the SQL once if it uses
> placeholders. This is rather a big deal if you want performance out of other
> DBM's.
> 

True, if you're running 1K inserts per second it can make a difference. 
  For most perl and PHP isn't doing nearly that much.  And if you need 
the performance boost, a compiled language would provide a greater boost 
than just using placeholders.

> Trouble with PHP is that one version is incompatible with the next, 
> even along the same branches, 5.2 might not work with 5.1. It's sort
> of hit -n- miss. On top of that the php you use may have been compiled
> with flags the server didn't use or have ini settings that vary. Each
> "php platform" is "unique" with it's own settings. Each version of
> PHP is "unique" in that it may or may not work with your application.
>

Obviously you don't understand PHP very well.  I've been programming 
since the early 4.0.x and currently am at 5.2.1.  I can't remember when 
I've had to chance any code for a new release.  Use good programming 
practices and upgrades are painless.

Now that doesn't mean I haven't rewritten code.  But it's been to take 
advantage of new features rather than because a new version required a 
change.

This is not to say that sometimes changes may not be needed.  The PHP 
developers are doing their best to clean up what has been a mess of a 
language - poorly planned and executed.  It's changing, but sometimes 
change is painful.

Fortunately perl was better planned and implemented.

> All of this really makes a mess if you want to use other PHP scripts 
> from other packages. PHP is like having the rug ripped out from under
> you at every turn.
>

Not at all.  I use a lot of different packages.  No problem.

> PHP really isn't very good for larger projects. (but then, the same
> has and can be said for perl)
> 

Wrong on both count.  I've seen both used in some quite large projects. 
- one perl project I know about was over 250K LOC, for instance.  And 
that's perl code - not html.

> Sometimes you can "throw an exception" in PHP sometimes, you can't, again..
> depending on the version and quirks of whoever installed PHP. Perl on the other
> hand, it's a pretty safe bet eval { ... die "BOO"; } will work, this is
> important if you'll be doing any transactions or need to do things
> like break out of an XML parse operation from a callback, but catch
> it in the caller space.
> 

Yep, exception handling was added to PHP, so like with any new addition, 
you can use it in later versions but not in earlier ones.  Gee - you 
know, the same thing is true in any product. It's hard to use something 
before it was added.

Perl doesn't have this problem as much because it has been around longer 
and is more stable.  But I suspect the same was true with the early 
versions of perl.

> If you need to /consume/ XML, then you definately do not want PHP, as
> there really isn't the same flexibility with getting at the input
> as it arrives. It wants to put everything into $_POST before your
> script can have any say in the matter. This makes it quite difficult
> to parse an input document "as it arrives" (there are other ways
> around this in PHP, but none of them allow you direct access to the
> wire the way perl does)
>

No, that's different implementations.  But I've never seen this as a 
problem in either PHP or perl.  The input document should be arriving 
pretty much all at once, anyway.

> Perl on the other hand, allows you to get at the raw input data if
> you need it.
> 

Yep, it can be nice at times.  But that's one reason there is no "best" 
language.

> I've been told that you can purchase extra tools to run PHP in a sort
> of peristent environment, but, in the free cost version it's impossible
> to create say, an XSLT tranformer object and share it with new requests.
>
> In PHP that data needs to be loaded each and every time, tree needs to
> be built for each request. With perl (and FastCGI or mod_perl), you can 
> create a heavy object once and share it among requests. (pros and cons to 
> this, of course. You can also accidently store other information and create
> memory leaks if your not careful)
> 

Yes, this is easier in perl.  But as you also note - there are both pros 
and cons.

> The "heavy object sharing" lends itself really well to XSLT processors
> or DOM objects that don't change, load once and re-use over and over.
> This can really be crucial with XML processing, as XSLT transformers
> tend to be kind of expensive to create.
>

True, but if you really have to, there are ways around it in PHP.  But 
if you really want speed in processing, I suggest you implement it in 
C/C++.  That is much faster.

> PHP has the advantage that it's "template" is fairly standardized (well,
> most people have settled on "<?php ?>" so you don't have a dozen different
> overkill template engines.
> 
> Hopefully I've given you enough "perl firepower" but, in my experience, no
> matter how you phrase the above points, people always assume perl is older
> technology and therefore inferior. PHP is modern, popular and therefore
> better:
> 
> 	 "Don't try to confuse me with the facts!" - LOL
> 
> 
> Jamie

OTOH, perl is older and therefore more stable and mature.  Newer is not 
always better.  Each language needs to be evaluated in the context it 
will be used.  A language which fits well into one project may not fit 
well into another.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================


------------------------------

Date: Wed, 14 Mar 2007 20:04:17 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Stupid question but its driving me nuts...
Message-Id: <slrnevh6sh.56u.tadmc@tadmc30.august.net>

sumitbee@gmail.com <sumitbee@gmail.com> wrote:
> On Mar 14, 12:16 pm, sumit...@gmail.com wrote:
>> I am trying to do a simple substitution, but there is something wrong
>> and I cant ut my finger on it...
>>
>> $cl_IP = "10.0.4.*";
>> print $cl_IP."\n";
>> $cl_IP = s/\*/\\\\\*/;
>> print $cl_IP."\n";
>>
>> I am perplexed why this is not giving 10.0.4.\\*
>
> Sorry all, I need glasses....


No, you simply need warnings and strictures!

(Like all of us do.)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 15 Mar 2007 00:26:03 -0700
From: "kath" <nitte.sudhir@gmail.com>
Subject: Re: Stupid question but its driving me nuts...
Message-Id: <1173943563.621225.257700@l77g2000hsb.googlegroups.com>

On Mar 14, 11:22 pm, sumit...@gmail.com wrote:
> On Mar 14, 12:16 pm, sumit...@gmail.com wrote:
>
> > I am trying to do a simple substitution, but there is something wrong
> > and I cant ut my finger on it...
>
> > $cl_IP = "10.0.4.*";
> > print $cl_IP."\n";
> > $cl_IP = s/\*/\\\\\*/;
> > print $cl_IP."\n";
>
> > I am perplexed why this is not giving 10.0.4.\\*
>
> Sorry all, I need glasses....


hi, when you write program make sure it should be in more readable
form, so that you when are executing it, you come to know the errors
quickly, if any. This helps when you really frustrated or you cannot
find the simple error. I used Joel's code and modified a bit.

use strict;
use warnings;
my $cl_IP = "10.0.4.*";
print $cl_IP."\n";
#$cl_IP =~ s/\*/\\\\\*/;
$cl_IP =~ s{\*}{\\\\*};	#	or	s|\*|\\\\*|;
print $cl_IP."\n";


kath.



------------------------------

Date: 15 Mar 2007 04:57:18 -0700
From: "ash" <aisling.cronin@gmail.com>
Subject: tr/ last char x$
Message-Id: <1173959838.529190.251850@y80g2000hsf.googlegroups.com>

I am trying to substitute the last char in each array of strings,
could some please explain why the tr/ function is not replacing just
the last char (see below)

The following works but is very bulky
$ts_roundup[$x] = $ts_number[$x];
if ($ts_number[$x]=~ /0$/)
			{
	  			$ts_roundup[$x]=~ s/0$/1/;
	  		}elsif ($ts_number[$x]=~ /1$/)
  			{
	  			$ts_roundup[$x]=~ s/1$/2/;
	  		} elsif ($ts_number[$x]=~ /2$/)
  			{
	  			$ts_roundup[$x]=~ s/2$/3/;
	  		} etc etc


Correct Result:
ts number  = 0109  ts round up =010a
ts number  = 7402  ts round up =7403
ts number  = 5586  ts round up =5587

I tried the following to reduce it to a one liner, This translates all
the characters in the string, not just the last character

$ts_roundup[$x]=~ tr/0$1$2$3$4$5$6$7$8$9$a$b$c$d$e$/1$2$3$4$5$6$7$8$9$a
$b$c$d$e$f$/;

Result:
ts number  = 0109  ts round up =121a
ts number  = 7402  ts round up =8513
ts number  = 5586  ts round up =6697

The following line of code does not produce the correct answer either
$ts_roundup[$x]=~ tr/0$1$2$3$4$5$6$7$8$9$a$b$c$d$e$/123456789abcdef/;

Result:
ts number  = 0109  ts round up =131f
ts number  = 73ee  ts round up =f7ff
ts number  = 9642  ts round up =fd95



------------------------------

Date: 15 Mar 2007 12:28:00 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: tr/ last char x$
Message-Id: <55ssegF26dvbjU1@mid.dfncis.de>

ash <aisling.cronin@gmail.com> wrote in comp.lang.perl.misc:
> I am trying to substitute the last char in each array of strings,
> could some please explain why the tr/ function is not replacing just
> the last char (see below)
> 
> The following works but is very bulky
> $ts_roundup[$x] = $ts_number[$x];
> if ($ts_number[$x]=~ /0$/)
> 			{
> 	  			$ts_roundup[$x]=~ s/0$/1/;
> 	  		}elsif ($ts_number[$x]=~ /1$/)
>   			{
> 	  			$ts_roundup[$x]=~ s/1$/2/;
> 	  		} elsif ($ts_number[$x]=~ /2$/)
>   			{
> 	  			$ts_roundup[$x]=~ s/2$/3/;
> 	  		} etc etc
> 
> 
> Correct Result:
> ts number  = 0109  ts round up =010a
> ts number  = 7402  ts round up =7403
> ts number  = 5586  ts round up =5587
> 
> I tried the following to reduce it to a one liner, This translates all
> the characters in the string, not just the last character
> 
> $ts_roundup[$x]=~ tr/0$1$2$3$4$5$6$7$8$9$a$b$c$d$e$/1$2$3$4$5$6$7$8$9$a
> $b$c$d$e$f$/;

Right, that's how tr/// works.  It always changes the whole string.
Read the documentation.  Use substr() to restrict it to the last
character.

    my @ts_number = qw( 0109 7402 5586);
    my @ts_roundup;
    substr( $_, -1, 1) =~ tr/0123456789abcde/123456789abcdef/ for
        @ts_roundup = @ts_number;
    print "$ts_number[ $_] -> $ts_roundup[ $_]\n" for 0 .. $#ts_roundup;

Anno


------------------------------

Date: 15 Mar 2007 04:22:49 -0700
From: "Suk" <sukesh@zoom.co.uk>
Subject: Trouble with a file upload script
Message-Id: <1173957769.407834.170240@y80g2000hsf.googlegroups.com>

Hi

I am experimenting with a very simple file upload script.

I cannot understand why the script below doesnt work:
My web server log shows:

Modification of a read-only value attempted at /var/apache/cgi-bin/
uploader.cgi line 94.

Line 94 is:      while ( <$upload_filehandle> )
Here is the script.....

#/usr/local/bin/perl
#
use strict;
use CGI qw(:standard);

our $upload_dir = "/tmp";
our ($upload_file,$success,$successfully_uploaded,$count);

foreach ("new","outstanding","weekly","year") {

       if (param("$_") ne "") {

               &upload_and_install("$_");
       }
}

print header();
print <<END_HTML;

<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>

<BODY>

<P>Thanks for uploading your file</P>

</BODY>
</HTML>

END_HTML

sub upload_and_install {

        my ($filename,$upload_filehandle);

        $filename = param($_[0]);
        $filename =~ s/.*[\/\\](.*)/$1/;
        $upload_filehandle = upload($_[0]);

        open UPLOADFILE, ">$upload_dir/$filename";

        binmode UPLOADFILE;

        while ( <$upload_filehandle> )
        {
          print UPLOADFILE;
        }

        close UPLOADFILE;
}


However I try the same script but test each parameter invidually
instead of using the foreach loop,  and the script does work:  So
replacing  the foreach loop with this:

if (param("new") ne "" ) {
        &upload_and_install("new");
}

if (param("outstanding") ne "" ) {
        &upload_and_install("outstanding");
}

if (param("weekly") ne "" ) {
        &upload_and_install("weekly");
}

if (param("year") ne "" ) {
        &upload_and_install("year");
}

And then I get no errors... Any ideas anyone?



------------------------------

Date: Thu, 15 Mar 2007 12:05:00 GMT
From: "Mumia W." <paduille.4060.mumia.w+nospam@earthlink.net>
Subject: Re: Trouble with a file upload script
Message-Id: <MDaKh.127680$_73.44683@newsread2.news.pas.earthlink.net>

On 03/15/2007 06:22 AM, Suk wrote:
> Hi
> 
> I am experimenting with a very simple file upload script.
> 
> I cannot understand why the script below doesnt work:
> My web server log shows:
> 
> Modification of a read-only value attempted at /var/apache/cgi-bin/
> uploader.cgi line 94.
> 
> Line 94 is:      while ( <$upload_filehandle> )
> Here is the script.....
> 
> #/usr/local/bin/perl
> #
> use strict;
> use CGI qw(:standard);
> 
> our $upload_dir = "/tmp";
> our ($upload_file,$success,$successfully_uploaded,$count);
> 
> foreach ("new","outstanding","weekly","year") {
> 
>        if (param("$_") ne "") {
> 

At this point, $_ is an alias for "new" which is a constant (read-only) 
string.

>                &upload_and_install("$_");
>        }
> }
> 
> print header();
> print <<END_HTML;
> 
> <HTML>
> <HEAD>
> <TITLE>Thanks!</TITLE>
> </HEAD>
> 
> <BODY>
> 
> <P>Thanks for uploading your file</P>
> 
> </BODY>
> </HTML>
> 
> END_HTML
> 
> sub upload_and_install {
> 
>         my ($filename,$upload_filehandle);
> 
>         $filename = param($_[0]);
>         $filename =~ s/.*[\/\\](.*)/$1/;
>         $upload_filehandle = upload($_[0]);
> 
>         open UPLOADFILE, ">$upload_dir/$filename";
> 
>         binmode UPLOADFILE;
> 
>         while ( <$upload_filehandle> )

This attepts to put the data read from the file-handle into $_ which is 
aliased to the "new" string above, and since that string is read-only, 
the operation fails.

To solve this problem, at the top of upload_and_install, put this line:

     local $_;

That creates a block-local $_ for you to play with without interfering 
with the for loop's $_.

Do this to get more information about "local":
Start->Run->"perldoc -f local"

This is also an opportunity for you to decide to use named variables 
rather than the default $_, e.g:

	while (my $part = <$upload_filehandle>) {
	...
	}

Note, I haven't run your program. My assumption of the error comes from 
a quick perusal of the program.


>         {
>           print UPLOADFILE;
>         }
> [...]


------------------------------

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 224
**************************************


home help back first fref pref prev next nref lref last post