[31366] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2618 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 2 03:09:46 2009

Date: Fri, 2 Oct 2009 00:09:09 -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           Fri, 2 Oct 2009     Volume: 11 Number: 2618

Today's topics:
    Re: diff <(echo find / -mount |find2perl) <(echo find / (Name withheld by request)
        diff <(find / -mount |find2perl) <(find / |find2perl) # (Name withheld by request)
    Re: diff <(find / -mount |find2perl) <(find / |find2per (Alan Curry)
        FAQ 8.38 How do I timeout a slow event? <brian@theperlreview.com>
    Re: machine dependent left shift results <ben@morrow.me.uk>
        perl print ASCII <mud_saisem@hotmail.com>
    Re: perl print ASCII <jurgenex@hotmail.com>
    Re: perl print ASCII <mud_saisem@hotmail.com>
    Re: perl print ASCII <ben@morrow.me.uk>
    Re: perl print ASCII sln@netherlands.com
    Re: perl print ASCII <jurgenex@hotmail.com>
    Re: scope subroutine argument with "our" <derykus@gmail.com>
    Re: scope subroutine argument with "our" <uri@StemSystems.com>
        simple hash <rodbass63@gmail.com>
    Re: simple hash <uri@StemSystems.com>
    Re: Web-based two-column diff with color sln@netherlands.com
        ~ substitute ' with ` <BJ@Isabe.com>
    Re: ~ substitute ' with ` <tadmc@seesig.invalid>
    Re: ~ substitute ' with ` <uri@StemSystems.com>
    Re: ~ substitute ' with ` <BJ@Isabe.com>
    Re: ~ substitute ' with ` <BJ@Isabe.com>
    Re: ~ substitute ' with ` <uri@StemSystems.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 02 Oct 2009 04:35:35 GMT
From: anonb6e9@nyx.net (Name withheld by request)
Subject: Re: diff <(echo find / -mount |find2perl) <(echo find / |find2perl) # no diffs?
Message-Id: <1254458135.460898@irys.nyx.net>

Sorry! In trimming the subject I must have deleted the 'echo's.
Subject is now correct.

In article <ha3qqj$fot$1@aioe.org>, Alan Curry <pacman@kosh.dhis.org> wrote:
>In article <1254451259.408086@irys.nyx.net>,
>Name withheld by request <anonb6e9@nyx3.nyx.net> wrote:
>>How do I do this in perl?:
>>
>>  find / -mount
>>    # want to stay in one-file-system
>
>I've never seen that -mount option before, but my local man page says:
>
>       -mount Don't  descend  directories  on other filesystems.  An alternate
>              name for -xdev, for compatibility with some  other  versions  of
>              find.
>
>So don't use -mount, use standard -xdev instead.

mount is more mnemonic

>Secondly...
>
>>
>>No help here:
>>
>>  ~ $ perl -v|grep 'is perl'
>>  This is perl, v5.10.0 built for i386-linux-thread-multi
>>  ~ $ diff <(find / -mount |find2perl) <(find / |find2perl); --snip

oops! How did I leave out the echos, I meant:

  ~ $ diff <(echo find / -mount |find2perl) <(echo find / |find2perl); echo $?
  0
  ~ $ diff <(echo find / -xdev  |find2perl) <(echo find / |find2perl); echo $?
  0

>That's not how you use find2perl at all. You write your find command

Again, sorry for the confusion..

The above diffs compare the output of 'find2perl' for two
different inputs one has the '-mount' the other does not

This is off topic a bit:

   ~ $ man bash|col -b| sed -ne '/^ *Process Substitution/,/^$/p'
   Process Substitution
       Process substitution is supported on systems that support  named  pipes
       (FIFOs)  or the /dev/fd method of naming open files.  It takes the form
       of <(list) or >(list).  The process list is run with its input or  out-
       put connected to a FIFO or some file in /dev/fd.  The name of this file
       is passed as an argument to the current command as the  result  of  the
       expansion.   If the >(list) form is used, writing to the file will pro-
       vide input for list.  If the <(list) form is used, the file  passed  as
       an argument should be read to obtain the output of list.

>  find / -xdev


>and then substitute find2perl for find
>
>  find2perl / -xdev
>
>and that prints a perl script which does the equivalent of the find command.
>It makes no sense to have find2perl at the end of a pipeline, since it
>doesn't do anything with stdin.

man find2perl supports what you say

so..:

  ~ $ diff <(find2perl / -xdev) <(find2perl /); echo $?
  27,30c27
  <     my ($dev,$ino,$mode,$nlink,$uid,$gid);
  <
  <     (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
  <     !($File::Find::prune |= ($dev != $File::Find::topdev));
  ---
  > ;
  1

I'll try the 'find2perl / -xdev' script on Friday.

--
thanks,
T.

>
>-- 
>Alan Curry




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

Date: 02 Oct 2009 02:40:59 GMT
From: anonb6e9@nyx3.nyx.net (Name withheld by request)
Subject: diff <(find / -mount |find2perl) <(find / |find2perl) # no diffs?
Message-Id: <1254451259.408086@irys.nyx.net>

Hi:

How do I do this in perl?:

  find / -mount
    # want to stay in one-file-system

No help here:

  ~ $ perl -v|grep 'is perl'
  This is perl, v5.10.0 built for i386-linux-thread-multi
  ~ $ diff <(find / -mount |find2perl) <(find / |find2perl); echo diff retval: $?
  diff retval: 0
  ~ $

--
thanks/regards,
T.


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

Date: Fri, 2 Oct 2009 03:08:03 +0000 (UTC)
From: pacman@kosh.dhis.org (Alan Curry)
Subject: Re: diff <(find / -mount |find2perl) <(find / |find2perl) # no diffs?
Message-Id: <ha3qqj$fot$1@aioe.org>

In article <1254451259.408086@irys.nyx.net>,
Name withheld by request <anonb6e9@nyx3.nyx.net> wrote:
>Hi:
>
>How do I do this in perl?:
>
>  find / -mount
>    # want to stay in one-file-system

I've never seen that -mount option before, but my local man page says:

       -mount Don't  descend  directories  on other filesystems.  An alternate
              name for -xdev, for compatibility with some  other  versions  of
              find.

So don't use -mount, use standard -xdev instead.

Secondly...

>
>No help here:
>
>  ~ $ perl -v|grep 'is perl'
>  This is perl, v5.10.0 built for i386-linux-thread-multi
>  ~ $ diff <(find / -mount |find2perl) <(find / |find2perl); echo diff

That's not how you use find2perl at all. You write your find command

  find / -xdev

and then substitute find2perl for find

  find2perl / -xdev

and that prints a perl script which does the equivalent of the find command.
It makes no sense to have find2perl at the end of a pipeline, since it
doesn't do anything with stdin.

-- 
Alan Curry


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

Date: Fri, 02 Oct 2009 04:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 8.38 How do I timeout a slow event?
Message-Id: <7Vexm.18819$Bl2.12545@newsfe14.iad>

This is an excerpt from the latest version perlfaq8.pod, which
comes with the standard Perl distribution. These postings aim to 
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

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

8.38: How do I timeout a slow event?

    Use the alarm() function, probably in conjunction with a signal handler,
    as documented in "Signals" in perlipc and the section on "Signals" in
    the Camel. You may instead use the more flexible Sys::AlarmCall module
    available from CPAN.

    The alarm() function is not implemented on all versions of Windows.
    Check the documentation for your specific version of Perl.



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

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in 
perlfaq.pod.


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

Date: Thu, 1 Oct 2009 23:26:59 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: machine dependent left shift results
Message-Id: <jumfp6-bed1.ln1@osiris.mauzo.dyndns.org>


Quoth "easily_confused" <sorry@nospam.com>:
> On a 32 bit machine, ~0<<32 gives 11111111111111111111111111111111  (I was
> expecting 0)

According to perlop, shifting by 32 on a 32-bit build of perl gives
undefined results. In practice, the 32 is wrapped to 0 so it has no
effect. (Similarly, shifting by 33 (on a perl with 32-bit integers) is
equivalent to shifting by 1.)

Ben



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

Date: Thu, 1 Oct 2009 16:01:20 -0700 (PDT)
From: mud_saisem <mud_saisem@hotmail.com>
Subject: perl print ASCII
Message-Id: <a896fce6-5fbb-43e3-a832-fb9e8593144d@m7g2000prd.googlegroups.com>

Hi All,

Can anybody tell me how to print ASCII characters in perl ?

eg: I would like to print the following ASCII character in perl using
the following Alt 63214, which gives you =AF

So at the end of the day i would like perl to print the following



This is my perl line, with a underline !
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF


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

Date: Thu, 01 Oct 2009 16:40:51 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: perl print ASCII
Message-Id: <h4fac512jisa6er8nulud2d1c0uilskdhn@4ax.com>

mud_saisem <mud_saisem@hotmail.com> wrote:
>Can anybody tell me how to print ASCII characters in perl ?

For printable ASCII characters you just print them like in 

	print "This is an unsorted list of some ASCII characters";

>eg: I would like to print the following ASCII character in perl using
>the following Alt 63214, which gives you ¯

That is not one of the 95 printable ASCII character (and neither one of
control characters), see
http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters

jue


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

Date: Thu, 1 Oct 2009 17:25:45 -0700 (PDT)
From: mud_saisem <mud_saisem@hotmail.com>
Subject: Re: perl print ASCII
Message-Id: <f8a06df1-59e3-495c-98f5-e7e3f8a0285a@v23g2000pro.googlegroups.com>

On Oct 2, 9:40=A0am, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> mud_saisem <mud_sai...@hotmail.com> wrote:
> >Can anybody tell me how to print ASCII characters in perl ?
>
> For printable ASCII characters you just print them like in
>
> =A0 =A0 =A0 =A0 print "This is an unsorted list of some ASCII characters"=
;
>
> >eg: I would like to print the following ASCII character in perl using
> >the following Alt 63214, which gives you =AF
>
> That is not one of the 95 printable ASCII character (and neither one of
> control characters), seehttp://en.wikipedia.org/wiki/ASCII#ASCII_printabl=
e_characters
>
> jue

Thanks for the response Jue, I understand that my use of the words
"ASCII characters" was not entirely correct, but I was not sure how
else to describe what I was after.

What I am after is a way to print =AF character in perl and i am not
sure how to do it.


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

Date: Fri, 2 Oct 2009 02:14:19 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl print ASCII
Message-Id: <bo0gp6-78e1.ln1@osiris.mauzo.dyndns.org>


Quoth mud_saisem <mud_saisem@hotmail.com>:
> 
> Can anybody tell me how to print ASCII characters in perl ?
> 
> eg: I would like to print the following ASCII character in perl using
> the following Alt 63214, which gives you ¯

I presume this is a Win32 keyboard shortcut. I can't remember how they
work: is this one simply the number of a Unicode codepoint? If so, you
can use

    print chr(63214);

If not you will need to find out the Unicode code for the character you
want, and then apply chr to it in the same way.

Ben



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

Date: Thu, 01 Oct 2009 18:18:43 -0700
From: sln@netherlands.com
Subject: Re: perl print ASCII
Message-Id: <svkac5tcf8rip2r5tehpng1bbsgva3224d@4ax.com>

On Thu, 1 Oct 2009 16:01:20 -0700 (PDT), mud_saisem <mud_saisem@hotmail.com> wrote:

>Hi All,
>
>Can anybody tell me how to print ASCII characters in perl ?
>
>eg: I would like to print the following ASCII character in perl using
>the following Alt 63214, which gives you ¯
>
>So at the end of the day i would like perl to print the following
>
>
>
>This is my perl line, with a underline !

(now the underline is under some different line)
>¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

Unicode combining diacritics.
http://www.answers.com/topic/combining-character

In digital typography, combining characters are characters that are intended
to modify other characters. The most common combining characters in the
Latin script are the combining diacritical marks (including combining accents).

Unicode also contains many precomposed characters, so that in many cases
it is possible to use both combining diacritics and precomposed characters,
at the user's or application's choice. This leads to a requirement to perform
Unicode normalization before comparing two Unicode strings and to carefully
design encoding converters to correctly map all of the valid ways to represent
a character in Unicode to a legacy encoding to avoid data loss.[1]

In Unicode, the main block of combining diacritics for European languages and the
International Phonetic Alphabet is U+0300–U+036F.
Combining diacritical marks are also present in many other blocks of
Unicode characters. In Unicode, diacritics are always added after the
main character. It is thus possible to add several diacritics to the same
character, although as of 2006, few applications support correct rendering of
such combinations ....

________________________________
For your reading enjoyment.
-sln



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

Date: Thu, 01 Oct 2009 18:21:30 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: perl print ASCII
Message-Id: <bvkac551qnh6o8gb0bg7h1icopgn0h6od6@4ax.com>

mud_saisem <mud_saisem@hotmail.com> wrote:
>What I am after is a way to print  character in perl and i am not
>sure how to do it.

I still don't understand where you got a problem. A simple 
	print '¯';
will print the overscore character just fine.

Maybe you got a cross-code page problem? Your Perl program written in
one code page but your program run in a different code page? Like your
program written in Notepad (e.g Windows-1252 or UTF-8) but run in a DOS
command prompt (e.g. DOS CP437 or CP850)?

jue


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

Date: Thu, 1 Oct 2009 16:57:41 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: scope subroutine argument with "our"
Message-Id: <6204889a-cb41-4dc5-8139-c6d287db501a@f18g2000prf.googlegroups.com>

On Oct 1, 12:36=A0pm, pacmac <pmaca...@gmail.com> wrote:
> Hello All,
>
> I'm trying to understand someone else's code. It's a mod_perl
> PerlAccessHandler.
>
> I'm not sure what's accomplished by "our" scoping an already-our-
> scoped variable when passed as an argument to a subroutine. See the
> way check_pwd() is called below. Does doing this make a copy? I don't
> get it.

The second "our" will draw a warning too if 'use warnings' is
in effect:

     "our" variable $PWD_SECRET redeclared at ....

--
Charles DeRykkus


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

Date: Thu, 01 Oct 2009 23:27:58 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: scope subroutine argument with "our"
Message-Id: <873a62cw5d.fsf@quad.sysarch.com>

>>>>> "CD" == C DeRykus <derykus@gmail.com> writes:

  CD> On Oct 1, 12:36 pm, pacmac <pmaca...@gmail.com> wrote:
  >> Hello All,
  >> 
  >> I'm trying to understand someone else's code. It's a mod_perl
  >> PerlAccessHandler.
  >> 
  >> I'm not sure what's accomplished by "our" scoping an already-our-
  >> scoped variable when passed as an argument to a subroutine. See the
  >> way check_pwd() is called below. Does doing this make a copy? I don't
  >> get it.

  CD> The second "our" will draw a warning too if 'use warnings' is
  CD> in effect:

you caught something there i missed but i wouldn't redeclare anyhow. if
both declarations were in the same namespace they would refer to the
same variable so the code still works. i bet since it is under mod_perl
the warnings (if ever seen) are tucked away in some log and only happen
at startup anyway. still a bad coding thing.

uri

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


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

Date: Thu, 1 Oct 2009 20:30:09 -0700 (PDT)
From: Nene <rodbass63@gmail.com>
Subject: simple hash
Message-Id: <b1aac120-126f-4aeb-a5f9-dbaf72b15ff0@j4g2000yqa.googlegroups.com>

Why is this code not working?

#!/usr/bin/perl -w
use strict;
use warnings;

my %years;
while (<DATA>) {
chomp;
my $year = (split /\t/)[3];
$years{$year}++;
}
foreach (sort keys %years) {
print "In $_, $years{$_} CDs were released.\n";
}

__DATA__
Bragg, Billy  Workers' Playtime  Cooking Vinyl  1987
Bragg, Billy  Mermaid Avenue     EMI            1998
Black, Mary   The Holy Ground    Grapevine      1993
Black, Mary   Circus             Grapevine      1996
Bowie, David  Hunky Dory         RCA            1971
Bowie, David  Earthling          EMI            1987
~


###

I keep getting:

rsimionis-macbook-pro:c2 Rod$ ./hash.pl
Use of uninitialized value in hash element at ./hash.pl line 9, <DATA>
line 1.
Use of uninitialized value in hash element at ./hash.pl line 9, <DATA>
line 2.
Use of uninitialized value in hash element at ./hash.pl line 9, <DATA>
line 3.
Use of uninitialized value in hash element at ./hash.pl line 9, <DATA>
line 4.
Use of uninitialized value in hash element at ./hash.pl line 9, <DATA>
line 5.
Use of uninitialized value in hash element at ./hash.pl line 9, <DATA>
line 6.
Use of uninitialized value in hash element at ./hash.pl line 9, <DATA>
line 7.
In , 7 CDs were released.




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

Date: Thu, 01 Oct 2009 23:41:16 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: simple hash
Message-Id: <87ocoqbgyr.fsf@quad.sysarch.com>

>>>>> "N" == Nene  <rodbass63@gmail.com> writes:

  N> Why is this code not working?

a probable cause is below as well as some code review

  N> #!/usr/bin/perl -w
  N> use strict;
  N> use warnings;

don't put -w and use warnings in. they basically do the same thing and
use warnings is better.

  N> my %years;
  N> while (<DATA>) {

don't use $_ as much as you do. use a named variable as it helps make
the code easier to understan.

  N> chomp;

ever heard of indenting or formatting your code? if you need help, look
for perltidy which can do it for you.


  N> my $year = (split /\t/)[3];

you are splitting on tabs. do you really know the data has tabs in it?
the data you pasted here seems to have spaces. now that could have
happened in pasting your data into your newsreader but it could be from
before. assuming spaces will force the split to return only 1 element as
it finds no tabs. indexing for the 4th element will get undef which is
what you are seeing.

also don't name a scalar and hash with such similar names. the hash
would be better named %year_cnt or something like that.

  N> $years{$year}++;
  N> }
  N> foreach (sort keys %years) {

again, use a named variable here instead of $_

  N> print "In $_, $years{$_} CDs were released.\n";
  N> }

  N> __DATA__
  N> Bragg, Billy**Workers' Playtime**Cooking Vinyl**1987

those *'s are where you think tabs would be but they are spaces
here. check the actual data source or how you put it into DATA.

uri

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


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

Date: Thu, 01 Oct 2009 17:46:18 -0700
From: sln@netherlands.com
Subject: Re: Web-based two-column diff with color
Message-Id: <6uiac51adl69c4uh223lh1nr7jcial1v82@4ax.com>

On Thu, 1 Oct 2009 12:25:33 -0700 (PDT), Stefan <s1037989@gmail.com> wrote:

>I wrote a Perl script that is too simple to create a project for, but
>I do want to share it in case anyone might have use.  For me, I use it
>to upload two Cisco config scripts and quickly see the difference
>between the two.  Use and modify as you will.  It's public domain.
                            ^^^^
I would modify this part. Its less ambigous and more precise.

>	foreach ( qx{diff -iwBay -W $W --left-column "/tmp/diff.old.$$" "/tmp/
>diff.new.$$"} ) {
>		my ($old, $sym, $new);
>		if ( /^(.*?)\s+([\|\>])\t(.*?)$/ ) {
>			($old, $sym, $new) = (/^(.*?)\s+([\|\>])\t(.*?)$/);
>		} elsif ( /^(.*?)\s+([\<\(])$/ ) {
>			($old, $sym) = (/^(.*?)\s+([\<\(])$/);
>		}
>		print "<tr>";
>		if ( $sym eq '<' ) {
>			if ( $old && !$new ) {
>				print "<td class=\"delete\">$old</td><td class=\"delete\">$sym</
>td><td>&nbsp;</td>";
>			} else {
>				print "ERROR";
>			}
>		} elsif ( $sym eq '>' ) {
>			if ( !$old && $new ) {
>				print "<td>&nbsp;</td><td class=\"add\">$sym</td><td class=\"add\">
>$new</td>";
>			} else {
>				print "ERROR";
>			}
>		} elsif ( $sym eq '|' ) {
>			if ( $old && $new ) {
>				print "<td class=\"change\">$old</td><td class=\"change\">$sym</
>td><td class=\"change\">$new</td>";
>			} else {
>				print "ERROR";
>			}
>		} elsif ( $sym eq '(' ) {
>			if ( $old && !$new ) {
>				print "<td class=\"common\">$old</td><td class=\"common\">=</
>td><td class=\"common\">$old</td>";
>			} else {
>				print "ERROR";
>			}
>		}
>		print "</tr>\n";
>	}

use strict;
use warnings;

my ($old, $sym, $new);

my @ary_o_strings = (
   "*old1* <",
   "       >\t*new2*",
   "*old3* |\t*new3*",
   "*old4* ("
);

for (@ary_o_strings)
{
	print "<tr>";

	if (($old, $sym) = /^ (.*?) \s+ ([<(]$ | [|>]) /xgc )
	{
		(($new) =  /\G \t (.+?) $/x) or $new = '';
 
		if ( $sym eq '<' ) {
			if ( length $old ) {
				print "<td class=\"delete\">$old</td><td class=\"delete\">$sym</td><td>&nbsp;</td>";
			} else {
				print "ERROR";
			}
		} elsif ( $sym eq '>' ) {
			if ( !length $old && length $new) {
				print "<td>&nbsp;</td><td class=\"add\">$sym</td><td class=\"add\">$new</td>";
			} else {
				print "ERROR";
			}
		} elsif ( $sym eq '|' ) {
			if ( length $old && length $new) {
				print "<td class=\"change\">$old</td><td class=\"change\">$sym</td><td class=\"change\">$new</td>";
			} else {
				print "ERROR";
			}
		} elsif ( $sym eq '(' ) {
			if ( length $old ) {
				print "<td class=\"common\">$old</td><td class=\"common\">=</td><td class=\"common\">$old</td>";
			} else {
				print "ERROR";
			}
		}
	} else {
		print "ERROR";
	}
	print "</tr>\n";
}

__END__


-sln



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

Date: Thu, 1 Oct 2009 23:56:32 -0400
From: "BJ" <BJ@Isabe.com>
Subject: ~ substitute ' with `
Message-Id: <a9450$4ac579f2$d88adca4$20197@PRIMUS.CA>

We are trying to get a text area from screen and edit it to
replace ' with ` (to preent mysql record mark conflict) $title is could be 
blank initially

$title = ~s/'/`/g ;
or even
$title =~s\/'/\`/g ;

Results "4294967295" for the value of $title !

Can anyone suggest a work arround.

Thanks for any comments.

Regards
BJ





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

Date: Thu, 01 Oct 2009 23:59:32 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: ~ substitute ' with `
Message-Id: <slrnhcb1ap.50r.tadmc@tadmc30.sbcglobal.net>

BJ <BJ@Isabe.com> wrote:

> We are trying to get a text area from screen and edit it to
> replace ' with ` 


    $title =~ tr/'/`/;


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Fri, 02 Oct 2009 01:30:53 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: ~ substitute ' with `
Message-Id: <871vlmbbw2.fsf@quad.sysarch.com>

>>>>> "B" == BJ  <BJ@Isabe.com> writes:

  B> We are trying to get a text area from screen and edit it to
  B> replace ' with ` (to preent mysql record mark conflict) $title is could be 
  B> blank initially

  B> $title = ~s/'/`/g ;

that is very wrong as the op is =~ with no space. you assigned $title
the negation of the s/// op result which was likely 0 and it inverted it
to all 1's which is the number you got.
  B> or even
  B> $title =~s\/'/\`/g ;

here you have the op correct but the s\/ is insane. i am not even sure
if that parses.

  B> Can anyone suggest a work arround.

fix your op and learn to not put spaces inside perl's ops.

uri

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


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

Date: Fri, 2 Oct 2009 02:30:40 -0400
From: "BJ" <BJ@Isabe.com>
Subject: Re: ~ substitute ' with `
Message-Id: <c5ff8$4ac59e14$d88adca4$8046@PRIMUS.CA>

Sorry, no good the same result.
Problem was extras space in between between   "= ~" should be "=~"
Thanks
 .
"Tad J McClellan" <tadmc@seesig.invalid> wrote in message 
news:slrnhcb1ap.50r.tadmc@tadmc30.sbcglobal.net...
> BJ <BJ@Isabe.com> wrote:
>
>> We are trying to get a text area from screen and edit it to
>> replace ' with `
>
>
>    $title =~ tr/'/`/;
>
>
> -- 
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/" 




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

Date: Fri, 2 Oct 2009 02:31:54 -0400
From: "BJ" <BJ@Isabe.com>
Subject: Re: ~ substitute ' with `
Message-Id: <5cdb1$4ac59e5e$d88adca4$31901@PRIMUS.CA>

Thanks for the clue.

Problem was extras space in between between   "= ~" should be "=~"

Works fine Now.

"Uri Guttman" <uri@StemSystems.com> wrote in message 
news:871vlmbbw2.fsf@quad.sysarch.com...
>>>>>> "B" == BJ  <BJ@Isabe.com> writes:
>
>  B> We are trying to get a text area from screen and edit it to
>  B> replace ' with ` (to preent mysql record mark conflict) $title is 
> could be
>  B> blank initially
>
>  B> $title = ~s/'/`/g ;
>
> that is very wrong as the op is =~ with no space. you assigned $title
> the negation of the s/// op result which was likely 0 and it inverted it
> to all 1's which is the number you got.
>  B> or even
>  B> $title =~s\/'/\`/g ;
>
> here you have the op correct but the s\/ is insane. i am not even sure
> if that parses.
>
>  B> Can anyone suggest a work arround.
>
> fix your op and learn to not put spaces inside perl's ops.
>
> uri
>
> -- 
> Uri Guttman  ------  uri@stemsystems.com  --------  
>  http://www.sysarch.com --
> -----  Perl Code Review , Architecture, Development, Training, 
> Support ------
> ---------  Gourmet Hot Cocoa Mix  ----  
>  http://bestfriendscocoa.com --------- 




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

Date: Fri, 02 Oct 2009 02:38:49 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: ~ substitute ' with `
Message-Id: <87ocoq9u6e.fsf@quad.sysarch.com>

>>>>> "B" == BJ  <BJ@Isabe.com> writes:

  B> Sorry, no good the same result.

learn to bottom post which is the proper style here. you acknowledged one clue
from me so do it again.

  >> $title =~ tr/'/`/;

that is actually a better and faster solution to your original
problem. and it does work. tr/// is meant for character processing vs s///
which is for strings and regexes. your problem was replacing ' with `
which is exactly what tr/// is for.

uri

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


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2618
***************************************


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