[30890] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2135 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 16 21:09:46 2009

Date: Fri, 16 Jan 2009 18:09:13 -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, 16 Jan 2009     Volume: 11 Number: 2135

Today's topics:
    Re: Circular lists <gamo@telecable.es>
    Re: Cygwin or Windows: file permission functions are br (Tim McDaniel)
    Re: fastest way to allocate memory ? <steve.roscio@hp.com>
    Re: fastest way to allocate memory ? <uri@stemsystems.com>
    Re: fastest way to allocate memory ? <hansmu@xs4all.nl>
    Re: fastest way to allocate memory ? <uri@stemsystems.com>
    Re: Integration Watch: The end for Perl? (SD Times) <tim@burlyhost.com>
    Re: opening a file <cwilbur@chromatico.net>
    Re: opening a file <cartercc@gmail.com>
    Re: String replacement involving special characters. <glex_no-spam@qwest-spam-no.invalid>
    Re: String replacement involving special characters. <someone@example.com>
    Re: String replacement involving special characters. <tim@burlyhost.com>
    Re: String replacement involving special characters. <jurgenex@hotmail.com>
    Re: String replacement involving special characters. <usenet@larseighner.com>
    Re: String replacement involving special characters. <mrlawrencelam@gmail.com>
    Re: String replacement involving special characters. <uri@stemsystems.com>
    Re: What do you need to have to be considered a Master  <spamtrap@dot-app.org>
    Re: What do you need to have to be considered a Master  <cartercc@gmail.com>
    Re: What do you need to have to be considered a Master  <jurgenex@hotmail.com>
    Re: What do you need to have to be considered a Master  <rabbits77@my-deja.com>
    Re: What do you need to have to be considered a Master  <tim@burlyhost.com>
    Re: What do you need to have to be considered a Master  <cwilbur@chromatico.net>
    Re: What do you need to have to be considered a Master  <jurgenex@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 17 Jan 2009 01:00:33 +0100
From: gamo <gamo@telecable.es>
Subject: Re: Circular lists
Message-Id: <alpine.LNX.2.00.0901170043170.6919@jvz.es>

On Thu, 15 Jan 2009, Xho Jingleheimerschmidt wrote:

> gamo wrote:
> 
> > The thing could change radically if there is a method to canonicalize all
> > the rotations of a list in a compact string. Did you say that is possible?
> 
> Of course.  From a previous post:
> 
>     my $s = join '',@set;
>     my $two = $s . $s;
>     next if ($two =~ /gg/);
>     my ($canon) = sort map {substr $two,$_,length $s} 0..length($s) -1;
> 
> That last line canonicalizes by the simple method of computing all rotations
> and taking the alphabetically least of them (you could use List::Util::minstr
> instead of sort).  You could use other canonicalization rules if they made
> other optimizations possible.  For example, it might be a good idea to define
> the canonical representation as the one the alphabetically first *among those
> that start with the rarest element*.  In your example, "a" was both the rarest
> and the alphabetically first, but that wouldn't hold in general.  By doing
> this, you get the double advantage of fixing the first position and so not
> needing to permute it, plus you don't have to compute all rotations but only
> the few ones that would put another instance of the rarest element first.

That's fine, but don't works for handling the circular permutations.
It detects distintinct permutations but not the circular ones, as far as
I tested. Probably the problem comes for taking the first element of the 
sorted list (only).

@canon = sort map ...
$canon = join '', @canon;

> 
> > I don't think so. If we have numbers instead of letters, I can't think in a
> > method that could describe the list of circular numbers 
> 
> If the numbers are single digits, then it works just the same as with letters.
> If they can be integers of any number of digits, you just need a non-digit
> delimiter to join on to make a canonical representation:
> 
>     my @two=(@s,@s);
>     my ($canon) = sort map {join ";", @two[$_..$_+$#s]} 0..$#s;
> 
> 
> > in less space that it has.
> 
> An array packed into a string generally takes less space, in Perl, then the
> array itself.  Plus you are using one such string to represent not just one
> array, but all rotations of it.  Plus, you might find you don't
> actually need to store the canonical representation in memory long-term, just
> use it to test something else on the fly.

In the case of 20 letters it has 20*20 rotations per item. That's a number
highly enough to think in using a msg-digest like sha and have a hash of 
it.
About testing candidates on the fly I still don't imagine how could be 
done without using hashes of the previous ones. 

Best regards,   

> 
> Xho
> 

-- 
http://www.telecable.es/personales/gamo/
"Was it a car or a cat I saw?"
perl -E 'say 111_111_111**2;'


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

Date: Sat, 17 Jan 2009 00:25:26 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: Cygwin or Windows: file permission functions are broken
Message-Id: <gkr8hm$gj$1@reader1.panix.com>

In article <4970331e$0$48226$815e3792@news.qwest.net>,
Andrew DeFaria  <Andrew@DeFaria.com> wrote:
>
>Tim McDaniel wrote:
>> My apologies for asking a Cygwin- or Windows-specific question
>> here, but it's also Perl-specific, and I'm not sure of a better
>> easy-to-access place.
 ...
>> I'm using a pretty recent Cygwin, but I don't know how to find out a 
>> version number or date. "cd"ed into an NTFS partition. Environment 
>> variable CYGWIN is "tty ntsec".
>
>IMHO "tty" is bad...

<http://www.cygwin.com/cygwin-ug-net/using-cygwinenv.html> explains
it.  I don't find the explanation very clear (does "the Windows
console" refer to a cmd window or what?, but I'll look at it some
more.

>> The current directory is owned by group Administrators; my user ID
>> is in group Administrators; group Administrators has full
>> control. So I can do any regular commands that create or delete
>> files (Cygwin touch, CMD.EXE copy, anything).
>>
>> But
>> perl -e 'print(-w "." ? "yes\n" : "no\n")'
>> prints "no", and the same for -r and -x.
>> Possibly related to "ls -ld" outputting this:
>> drwx------+ 30 ???????? none 0 Jan 15 11:44 .
>
>The "+" above indicates that the permissions are "special". Stated
>differently, the Windows permissions mask is way larger of a set than
>the Unix permissions mask. The "+" is saying that there are Windows
>permissions to this directory (or file) that simply cannot be
>represented in POSIX file permissions. This is probably the key to
>your misunderstanding.

You might have been kind enough to *explain* what you thought the
misunderstanding was.  When I searched "man perlfunc" to quote you
the line that I remembered,

    -w  File is writable by effective uid/gid.

I also ran across lines that explained the problem:

    The interpretation of the file permission operators "-r", "-R",
    "-w", "-W", "-x", and "-X" is by default based solely on the mode
    of the file and the uids and gids of the user.  There may be other
    reasons you can't actually read, write, or execute the file: for
    example network filesystem access controls, ACLs (access control
    lists), read-only filesystems, and unrecognized executable
    formats.  Note that the use of these six specific operators to
    verify if some operation is possible is usually a mistake, because
    it may be open to race conditions.

    Also note that, for the superuser on the local filesystems, the
    "-r", "-R", "-w", and "-W" tests always return 1, and "-x" and
    "-X" return 1 if any execute bit is set in the mode.  Scripts run
    by the superuser may thus need to do a stat() to determine the
    actual mode of the file, or temporarily set their effective uid to
    something else.

    If you are using ACLs, there is a pragma called "filetest" that
    may produce more accurate results than the bare stat() mode bits.
    When under the "use filetest 'access'" the above-mentioned
    filetests will test whether the permission can (not) be granted
    using the access() family of system calls.  Also note that the
    "-x" and "-X" may under this pragma return true even if there are
    no execute permission bits set (nor any extra execute permission
    ACLs).  This strangeness is due to the underlying system calls'
    definitions. Note also that, due to the implementation of "use
    filetest 'access'", the "_" special filehandle won't cache the
    results of the file tests when this pragma is in effect.  Read the
    documentation for the "filetest" pragma for more information.

Specifically, _ *will* cache any other test bits, like -e, -d, and
such.

The "use filetest access" pragma does work on Cygwin (in the latest
regular version).  I created a directory and made it read/write only
to Administrators.  In it,

    $ touch frog   # no error, so it works OK
    $ perl -e 'print (-w "." ? "yes\n" : "no\n")'
    no
    $ perl -e 'use filetest access; print (-w "." ? "yes\n" : "no\n")'
    yes

Unfortunately,
- File::Temp or File::Spec uses _ extensively
- "use filetest 'access'" has lexical scope, so it can't reach into
  File::Temp or File::Spec

So I consider it a bug in File::Temp that I can't get around.

>> Question 1: is there any way I can get Perl's -r / -w / -x
>> functions to work?
>
>Change the permissions of the directory such that they fall within
>possibility of the simplistic POSIX standard.

No, thank you.  The permissions work well for my purposes as they are.

>> I guess I'll just adapt the code from perlfaq5 ...
>>
>> Question 3: ... but why is it wrapped in a BEGIN block?
>
>BEGIN?

Yes, BEGIN, as in "the code from perlfaq5":

    How do I make a temporary file name?

    ... If you're committed to creating a temporary file by hand, use
    the process ID and/or the current time-value.  If you need to have
    many temporary files in one process, use a counter:

        BEGIN {
        use Fcntl;
        my $temp_dir = -d '/tmp' ? '/tmp' : $ENV{TMPDIR} || $ENV{TEMP};
        my $base_name = sprintf "%s/%d-%d-0000", $temp_dir, $$, time;

        sub temp_file {
            local *FH;
            my $count = 0;
            until( defined(fileno(FH)) || $count++ > 100 ) {
                $base_name =~ s/-(\d+)$/"-" . (1 + $1)/e;
                # O_EXCL is required for security reasons.
                sysopen FH, $base_name, O_WRONLY|O_EXCL|O_CREAT;
                }

            if( defined fileno(FH) ) {
                return (*FH, $base_name);
                }
            else {
                return ();
                }
            }

        }

When I implemented it, with a cache of filenames, a destroyer, and a
signal handler, it did not need to be in a BEGIN block.

>> ... if you insist: I often run the Perl program outside of a Cygwin 
>> window.
>
>Running within a Cygwin "window" (Whatever that is) or not is not the
>issue.

It is an issue of why I don't use TMP, cygpath, and such.

By a "Cygwin window", I refer to rxvt or some other run of bash.  In
 .bashrc, I set a Cygwin-aware PATH.  The programs I pick up are mostly
Cygwin-aware, in practice.

In a cmd.exe window, it has a Windows-aware Path, and I don't put
Cygwin programs into it.  The programs I run want only Windows file
syntax.

>> Even when TMPDIR is set in Windows syntax as C:\tmp, on startup
>> Perl transmogrifies it to /tmp (or whatever, per cygpath -u).
>
>I think you're confused. There is not C:\tmp in Cygwin terms.  There
>is only /tmp. /tmp *translates* (not transmogrifies) to C:\Cygwin\tmp

My apologies for being imprecise.  /tmp actually translates to
[root of the Cygwin installation]\tmp.  I set the root of the Cygwin
installation to C:\ instead of C:\cygwin, so for me, /tmp DOES
translate to C:\tmp.  That's because I got too tired of having to
insert and delete "cygwin\" when converting paths by hand
(copying-and-pasting commands from one command window or file to
another), and to heck with setup.exe's deprecation warning.

And don't get snippy about informal / slangy terminology.
"transmogrify" is a just a sillier-sounding way of writing
"translate".

>> The Perl program calls non-Cygwin-aware programs, so they have to get 
>> non-Cygwin paths like "e:\foo\bar" instead of "/CM/foo/bar".
>
>However many Windows programs understand the syntax of C:/foo/bar

But apparently not the syntax of just "/tmp", judging by the error
messages from Windows programs, and /tmp is what they were receiving
when I thought it was passing C:\tmp.

>The definition of "writable" differs between the POSIX world and the 
>Windows world.

POSIX defines ACLs quite well.  Say, rather, that Perl's
implementations of -r / -w / -x take a shortcut that works in practice
on most UNIXy systems, since few people there use ACLs, but produces
an unuseful effect on ACL-heavy systems.

-- 
Tim McDaniel, tmcd@panix.com


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

Date: Fri, 16 Jan 2009 12:16:48 -0700
From: Steve Roscio <steve.roscio@hp.com>
Subject: Re: fastest way to allocate memory ?
Message-Id: <gkqmf0$v43$1@usenet01.boi.hp.com>

To preallocate memory, I use vec() to set a byte out at the end of the 
chunk of memory I want.

- Steve


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

Date: Fri, 16 Jan 2009 16:08:46 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: fastest way to allocate memory ?
Message-Id: <x7fxjjx8kh.fsf@mail.sysarch.com>

>>>>> "SR" == Steve Roscio <steve.roscio@hp.com> writes:

  SR> To preallocate memory, I use vec() to set a byte out at the end of the
  SR> chunk of memory I want.

you could just as easily use 4 arg substr (or the slower lvalue substr)
which would be simpler and much easier to read.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Sat, 17 Jan 2009 00:09:16 +0100
From: Hans Mulder <hansmu@xs4all.nl>
Subject: Re: fastest way to allocate memory ?
Message-Id: <497114c8$0$190$e4fe514c@news.xs4all.nl>

Uri Guttman wrote:
>>>>>> "SR" == Steve Roscio <steve.roscio@hp.com> writes:
> 
>   SR> To preallocate memory, I use vec() to set a byte out at the end of the
>   SR> chunk of memory I want.
> 
> you could just as easily use 4 arg substr (or the slower lvalue substr)
> which would be simpler and much easier to read.

I get an error "substr outside of string" when I do that.

I would use $var = 'x' x $size, when I need a large chunk of memory.
(I hope the '=' operator can set $var without copying the string.)

-- HansM



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

Date: Fri, 16 Jan 2009 19:39:06 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: fastest way to allocate memory ?
Message-Id: <x7iqoevk9h.fsf@mail.sysarch.com>

>>>>> "HM" == Hans Mulder <hansmu@xs4all.nl> writes:

  HM> Uri Guttman wrote:
  >>>>>>> "SR" == Steve Roscio <steve.roscio@hp.com> writes:
  SR> To preallocate memory, I use vec() to set a byte out at the
  >> end of the
  SR> chunk of memory I want.
  >> you could just as easily use 4 arg substr (or the slower lvalue
  >> substr)
  >> which would be simpler and much easier to read.

  HM> I get an error "substr outside of string" when I do that.

  HM> I would use $var = 'x' x $size, when I need a large chunk of memory.
  HM> (I hope the '=' operator can set $var without copying the string.)

interesting. i would have though extending with substr would work. it
warns for lvalue substr as well. i may be confusing it with extending
arrays which is warning free.

this still begs the question as to why the OP wants a buffer that
large. it smells to me like a poor design decision.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Fri, 16 Jan 2009 11:23:22 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: Integration Watch: The end for Perl? (SD Times)
Message-Id: <L85cl.19363$qi.2022@newsfe09.iad>

Charlton Wilbur wrote:

>>>>>> "a" == admin  <admin@.......com> writes:
> 
>     a> http://www........com/fw.php?tp=perl
> 
> I recommend reading the comments on the article, which are much closer
> to the truth than the article itself.
> 
> Charlton
> 
> 

I recommend ignoring that spammer altogether and any information they
propagate (correct or incorrect), as they spend their days posting
their site's URL in news groups, acting like it's a news site or
anything more than them simply spamvertizing their own site.
-- 
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: Fri, 16 Jan 2009 15:55:54 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: opening a file
Message-Id: <861vv32co5.fsf@mithril.chromatico.net>

>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:

    >> Then I must not be a programmer, because most of what I do gets
    >> printed with a physical printer on real paper. My point is (and
    >> I'm being redundant here) is that in doing a job you minimize
    >> costs while maximizing benefits.

    JE> Yeah, right. And then you are posting about "Perl
    JE> crisis". Right.

Ah, in doing a job you minimize *overall* costs while maximizing
*overall* benefits.

cartercc's fundamental problem is that he is apparently completely
unaware of long-term costs (or considers them his manager's problem, not
his problem), and is thus minimizing *short-term* costs.

Eventually, this bites you in the ass.  If cartercc's posting history is
to be believed, it has bitten him in the ass several times, but he has
yet to learn from it.  

Charlton




-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Fri, 16 Jan 2009 13:19:08 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: opening a file
Message-Id: <a019b916-1e33-4fd0-a29f-1da054516bfa@u13g2000yqg.googlegroups.com>

On Jan 16, 1:45=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> What did you do about that? Did you talk to those guys? Did you talk to
> your boss about it? What did he do about it? If an agreed upon interface
> is not respected and modified without discussion and even without notice
> then something is seriously, I mean SERIOUSLY, wrong. If it happenens
> more than once this is bad enough to raise hell at least two levels up
> the hierachie.

I can't talk to 'those guys.' I've tried many times but have gotten no
response. I seriously doubt they create any kind of documentation.
Some of the tables are horrendous, something like 500 columns across,
and with no rhyme or reason in the calculated fields. Example: in one
table there are three calculated fields named 'Start Term.' You would
think that all three fields would return the same value, except this
morning (for the new term) one returned about 2500, one returned 2488,
and the third returned less than 100. I honestly think that the
keepers of the database keep it locked up because they are afraid of
exposing it to public scrutiny.

> And afterwards, what happened to prevent further incidentcs like this?
> Did those guys update the spec for the database format? Did they at the
> very least appologize? Did _YOU_ or your boss establish a better line of
> communication with those guys?

Hell, no. Trying to have a conversation with the Lords of the Database
is as futile as trying to fly by flapping your arms.

> So -theoretically speaking- you boss doesn't care how you create
> whatever results you create. As far as he is concerned you could use
> pencil and paper, right? Then you are not a programmer but a data
> analyst or data processor who happens to be using some scripts for his
> own pleasure.

Exactly right. He's a business type, and couldn't tell the difference
between an array and a scalar to save his live. He doesn't care what I
do as long as it's right, and he mostly leaves me alone. I can go
weeks without doing more than just saying hello. In some ways, it's a
very good work environment because I don't have anyone looking over my
shoulder.

> Excellent case in point. In a stable environment you can get away
> without much error checking, because errors are infrequent.

Go back to your previous point. I live in an ad hoc world, writing
mostly ad hoc scripts and rely more on technique than checklists. (It
wasn't always this way, when I started I was building web front ends
for databases and paid attention to exception and error checking --
you have to do this building apps for a web server.)

> It is in an ever changing environment where error checking becomes a
> mandatory survival strategy and where you need to do every error
> checking imaginable, so that your scripts will alert you about those
> changes right away and pinpoint the cause as detailed as possible.

Actually, there's a difference between querying the database and
processing the data. Once I acquire the data, I can do anything I want
with it, and it's all transparent. Yes, I am frequently surprised by
something that does not turn out as expected (like the transposition
of columns), but I can protect myself against personal error (by using
strict, using warnings, etc.). I can't protect myself against garbage
input, usually because I have no way of knowing that the initial data
import is garbage.

> In your first example you were assuming, the grades would be letters.
> Had you verified this assumptions by a test in your program then your
> program would have told you right away and you wouldn't have to start an
> expedition to <quote>discover</quote> the cause.

Yes, you are right. In a perfect world maybe I should have assumed
that grades wouldn't always be characters, but I would still have no
way to know the translation of letter grades to numbers. A is now 6, B
is 7, and Incomplete is 13. Who wouldda thought it?

> Do it right or suffer the consequences. Sorry, but your arguments are
> very short sighted and your problems at your job are very much caused by
> yourself: you keep patching the symptoms instead of addressing the
> cause. Well, keep patching. It will keep you busy, but it will never
> improve the situation.

Hey, it's a job, and I'm somewhat fortunate to have a job. I know
several IT guys who have been laid off recently. The good points are
that I have a lot of free time, a very non-intrusive manager, the
total freedom to use any technology that I want, a steady pay check,
non-existent stress, and a collegial environment (among the IT guys,
all but me are network and sys admins.)

> And if you can't do it, then it's your bosses job to recognize your
> problem and assign someone else to fix the reason or to do it himself.
> If he doesn't then he is incompetent.

Mostly, my boss cares about not getting complaints about the work that
I do -- he certainly has no desire to acquaint himself with what I do
on a technical level. I'm pretty successful keeping my customers
happy, so he almost never gets a complaint.

CC


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

Date: Fri, 16 Jan 2009 13:14:13 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: String replacement involving special characters.
Message-Id: <4970dc85$0$89387$815e3792@news.qwest.net>

J. Gleixner wrote:
> Blue wrote:
>> $string = "aaa ' ccc ";
>> $string =~ s/'/bbb/eg;
>>
>> The above replaces the single-quotation mark with bbb. The result will
>> be:
>> aaa bbb ccc
>>
>> How do I modify it so that the single-quotation mark is replaced with
>> \' (a backslash and a single-quotation mark) resulting in:
>> aaa \' ccc
> 
> Escape it.
> 
> $string = "aaa ' ccc ";
> $string =~ s/'/\\'bb/; #why are you using /eg?
> print $string;
> aaa \'bb ccc

sorry.. should have removed 'bb' there.

$string =~ s/'/\\'/;


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

Date: Fri, 16 Jan 2009 11:21:45 -0800
From: "John W. Krahn" <someone@example.com>
Subject: Re: String replacement involving special characters.
Message-Id: <d75cl.19354$qi.10398@newsfe09.iad>

Blue wrote:
> $string = "aaa ' ccc ";
> $string =~ s/'/bbb/eg;

Because of the /e option you are evaluating the string 'bbb' as though 
it were perl code.  Why are you doing that?


> The above replaces the single-quotation mark with bbb. The result will
> be:
> aaa bbb ccc
> 
> How do I modify it so that the single-quotation mark is replaced with
> \' (a backslash and a single-quotation mark) resulting in:
> aaa \' ccc

$string =~ s/'/\\'/g;



John
-- 
Those people who think they know everything are a great
annoyance to those of us who do.        -- Isaac Asimov


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

Date: Fri, 16 Jan 2009 11:27:08 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: String replacement involving special characters.
Message-Id: <Jc5cl.24753$H12.15315@newsfe12.iad>

Blue wrote:

> $string = "aaa ' ccc ";
> $string =~ s/'/bbb/eg;
> 
> The above replaces the single-quotation mark with bbb. The result will
> be:
> aaa bbb ccc
> 
> How do I modify it so that the single-quotation mark is replaced with
> \' (a backslash and a single-quotation mark) resulting in:
> aaa \' ccc

$string =~ s/'/\\'/g;
-- 
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: Fri, 16 Jan 2009 11:38:43 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: String replacement involving special characters.
Message-Id: <74o1n4hqq2abga73jddd49p4c322j0p9hi@4ax.com>

Blue <mrlawrencelam@gmail.com> wrote:
>$string = "aaa ' ccc ";
>$string =~ s/'/bbb/eg;
>
>The above replaces the single-quotation mark with bbb. The result will
>be:
>aaa bbb ccc

Hmmm, for me the result was 
	Bareword "bbb" not allowed while "strict subs" in use at ...

Which is not surprising because why on earth are you evaluating 'bbb'?
And why are you applying the substitution globally although there is
only one quote sign in the text? 

>How do I modify it so that the single-quotation mark is replaced with
>\' (a backslash and a single-quotation mark) resulting in:
>aaa \' ccc

Just put the new text there. Just remember that the desired backslash is
the escape character. Therefore if you want a literal backslash in the
result, then you have to escape the escape character. Oh, and get rid of
those bogus options, too:

	$string =~ s/'/\\'/;

jue


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

Date: Fri, 16 Jan 2009 19:59:52 +0000 (UTC)
From: Lars Eighner <usenet@larseighner.com>
Subject: Re: String replacement involving special characters.
Message-Id: <slrngn1poa.vbt.usenet@debranded.larseighner.com>

In our last episode,
<67d58bc8-d9fe-45fd-a45b-949fa8f3cf1d@a29g2000pra.googlegroups.com>, the
lovely and talented Blue broadcast on comp.lang.perl.misc:

> $string = "aaa ' ccc ";
> $string =~ s/'/bbb/eg;

> The above replaces the single-quotation mark with bbb. The result will
> be:
> aaa bbb ccc

> How do I modify it so that the single-quotation mark is replaced with
> \' (a backslash and a single-quotation mark) resulting in:
> aaa \' ccc

To enter a literal backslash, use two backslashes.

-- 
        Lars Eighner <http://larseighner.com/> usenet@larseighner.com
    Bush's third term begins Jan. 20th with an invocation by Rick Warren.
                Obama: No hope; No change; More of the Same.


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

Date: Fri, 16 Jan 2009 14:47:11 -0800 (PST)
From: Blue <mrlawrencelam@gmail.com>
Subject: Re: String replacement involving special characters.
Message-Id: <0f23c4d5-2b71-49cd-b355-ab27e7e420a4@k36g2000pri.googlegroups.com>

On Jan 17, 3:59=A0am, Lars Eighner <use...@larseighner.com> wrote:
> In our last episode,
> <67d58bc8-d9fe-45fd-a45b-949fa8f3c...@a29g2000pra.googlegroups.com>, the
> lovely and talented Blue broadcast on comp.lang.perl.misc:
>
> > $string =3D "aaa ' ccc ";
> > $string =3D~ s/'/bbb/eg;
> > The above replaces the single-quotation mark with bbb. The result will
> > be:
> > aaa bbb ccc
> > How do I modify it so that the single-quotation mark is replaced with
> > \' (a backslash and a single-quotation mark) resulting in:
> > aaa \' ccc
>
> To enter a literal backslash, use two backslashes.
>
> --
> =A0 =A0 =A0 =A0 Lars Eighner <http://larseighner.com/> use...@larseighner=
 .com
> =A0 =A0 Bush's third term begins Jan. 20th with an invocation by Rick War=
ren.
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Obama: No hope; No change; More of the Sa=
me.

$string =3D~ s/'/\\'/;

Thanks guys. I thought I did the above and got Internal Server Error.
I did it again and it is working. Thanks.


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

Date: Fri, 16 Jan 2009 18:39:15 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: String replacement involving special characters.
Message-Id: <x7vdsevn18.fsf@mail.sysarch.com>

>>>>> "B" == Blue  <mrlawrencelam@gmail.com> writes:

  B> Thanks guys. I thought I did the above and got Internal Server Error.
  B> I did it again and it is working. Thanks.

you should not debug your programs via a web server. that is making it
much harder for you. run the scripts locally on your dev box and then
upload to your server. and don't say you don't have perl on your box
because you can install it easily. and don't say you can't test web
programs on your box because again, you can set up a web server on your
box with little effort. and the term internal server error should be never
be used in a perl group as it is a web server issue. report the actual
perl bug by running it outside a web server

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Fri, 16 Jan 2009 15:00:26 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: What do you need to have to be considered a Master at Perl?
Message-Id: <m163kfnhr9.fsf@dot-app.org>

sln@netherlands.com writes:

> I'm just going to jumstart the topic with these:
>
> - Technically expert at Regular Expressions
> - Analytically and Creative at Regular Expressions
> - Thoroughly adept at map/split/grep, know limitations
> - Arrays and Hashes, including slices and references
>
> Add some more...

Someone who understands the Chomsky hierarchy, and why not every context-
free language can be described with a regular grammar.

sherm--

-- 
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Fri, 16 Jan 2009 13:32:36 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: What do you need to have to be considered a Master at Perl?
Message-Id: <c8ef484f-e34d-41a9-8db2-b2f9d51f3707@r24g2000vbp.googlegroups.com>

On Jan 15, 6:06=A0pm, s...@netherlands.com wrote:
> I'm just going to jumstart the topic with these:
>
> - Technically expert at Regular Expressions
> - Analytically and Creative at Regular Expressions
> - Thoroughly adept at map/split/grep, know limitations
> - Arrays and Hashes, including slices and references

From time to time I apply for different jobs, not really needing a new
job but looking for better opportunities, and twice I have gotten as
far as taking a Perl programming exam. I'm not a real programmer but
have done a fair amount of web stuff, database stuff, sys admin, and
data processing, and don't consider my skills exceptional.

In both exams, I placed in the top quintile, which surprised me very
much. In both cases, I had made it through two rounds of interviews.
My take is that there must be a lot of people who claim to know Perl
but maybe they don't.

I've been using Perl consistently for about ten years, and I guess if
you do anything for that long you tend to develop some skill at it.

CC


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

Date: Fri, 16 Jan 2009 13:34:36 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: What do you need to have to be considered a Master at Perl?
Message-Id: <eav1n411qdkioa0ji703ocmgmaf9jr6fp6@4ax.com>

Sherm Pendley <spamtrap@dot-app.org> wrote:
>sln@netherlands.com writes:
>
>> I'm just going to jumstart the topic with these:
>>
>> - Technically expert at Regular Expressions
>> - Analytically and Creative at Regular Expressions
>> - Thoroughly adept at map/split/grep, know limitations
>> - Arrays and Hashes, including slices and references
>>
>> Add some more...
>
>Someone who understands the Chomsky hierarchy, and why not every context-
>free language can be described with a regular grammar.

:-))

YMMD

jue


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

Date: Fri, 16 Jan 2009 16:54:45 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: What do you need to have to be considered a Master at Perl?
Message-Id: <af146$49710226$c650990a$20055@news.eurofeeds.com>

Sherm Pendley wrote:
> sln@netherlands.com writes:
> 
>> I'm just going to jumstart the topic with these:
>>
>> - Technically expert at Regular Expressions
>> - Analytically and Creative at Regular Expressions
>> - Thoroughly adept at map/split/grep, know limitations
>> - Arrays and Hashes, including slices and references
>>
>> Add some more...
> 
> Someone who understands the Chomsky hierarchy, and why not every context-
> free language can be described with a regular grammar.
BFD, that describes just about every CS undergraduate who has taken
a theory course.
Unfortunately, I think you might be surprised to learn that CFLs aren't 
that impressive a concept. :-/




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

Date: Fri, 16 Jan 2009 13:59:39 -0800
From: Tim Greer <tim@burlyhost.com>
Subject: Re: What do you need to have to be considered a Master at Perl?
Message-Id: <gr7cl.115210$2w3.61183@newsfe19.iad>

cartercc wrote:

> In both exams, I placed in the top quintile, which surprised me very
> much. In both cases, I had made it through two rounds of interviews.
> My take is that there must be a lot of people who claim to know Perl
> but maybe they don't.

You will pretty much find that's the case with any language.  Due to
this, sometimes a qualified programmer doesn't get a job in those
cases, because the current "programmers" are threatened by you.  Also,
because the current programmers have convinced the equally clueless
boss, that their methods are best.  Those are the jobs that few
qualified programmers want, because you are actually forced to work in
bad code and they won't want to change it (or see a need to).  That's
when you start encountering companies that think AWS is the future,
because no one actually had to program (you just pay a service online
for the data transfer, disk space, the number of requests, and use of
their service).
-- 
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: Fri, 16 Jan 2009 17:44:14 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: What do you need to have to be considered a Master at Perl?
Message-Id: <86wscu27nl.fsf@mithril.chromatico.net>

>>>>> "r" == rabbits77  <rabbits77@my-deja.com> writes:

    r> Sherm Pendley wrote:

    >> Someone who understands the Chomsky hierarchy, and why not every
    >> context- free language can be described with a regular grammar.

    r> BFD, that describes just about every CS undergraduate who has
    r> taken a theory course. 

Then why do they ask so many questions about parsing (X|HT)ML with
regular expressions?

Asnwer: because they don't *really* understand it, having just learned
enough to pass the exam and then forgotten it the next week.

Or because they never had the theory course in the first place.

    r> Unfortunately, I think you might be surprised to learn that CFLs
    r> aren't that impressive a concept. :-/

Impressive, no.  But understanding the difference between regular
languages and context-free languages, even if it isn't in those terms,
is the mark of a professional.

Charlton


-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Fri, 16 Jan 2009 15:35:00 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: What do you need to have to be considered a Master at Perl?
Message-Id: <bc62n4t0k45n1kor372utbo44r3kttb57u@4ax.com>

rabbits77 <rabbits77@my-deja.com> wrote:
>Sherm Pendley wrote:
>> sln@netherlands.com writes:
>> 
>>> I'm just going to jumstart the topic with these:
>>>
>>> - Technically expert at Regular Expressions
>>> - Analytically and Creative at Regular Expressions
>>> - Thoroughly adept at map/split/grep, know limitations
>>> - Arrays and Hashes, including slices and references
>>>
>>> Add some more...
>> 
>> Someone who understands the Chomsky hierarchy, and why not every context-
>> free language can be described with a regular grammar.
>BFD, that describes just about every CS undergraduate who has taken
>a theory course.

Exactly. You _almost_ got the joke.

jue


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

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


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