[27878] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9242 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 25 18:05:48 2006

Date: Thu, 25 May 2006 15:05:02 -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, 25 May 2006     Volume: 10 Number: 9242

Today's topics:
    Re: Array aliases wih hashes, some questions <wahab@chemie.uni-halle.de>
    Re: Getting rid of inverted commas around a string. delfin_soft@homoludens.elte.hu
    Re: Help in installing XML::PARSER <rvtol+news@isolution.nl>
        new CPAN modules on Thu May 25 2006 (Randal Schwartz)
    Re: Peculiar rounding behaviour <rvtol+news@isolution.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 25 May 2006 13:22:06 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: Array aliases wih hashes, some questions
Message-Id: <e5448c$rmv$1@mlucom4.urz.uni-halle.de>

Hi Ferry

> docs say, that when passing an array to a sub, the elements of @_ in the sub
> are aliases for th elements of the actual array. So, as long no other array
> or new list is assigned to @_, assigning a value to $_[0], $_[1], ... will
> change the elements in the array passed as argument.
 ...
As I have come to understand this, it 'means' that:
  "anything that can be expressed by SV's is going
  to be 'hard' aliased by $_[...]",

all others are localized (HV-keys, CV and the like)"
and trown away in 'leavesub'.

> %hash = (a => 1, b=> 2);
> test(%hash);
> print %hash;
> 
> sub test {
>  $_[0] = 3;
>  $_[1] = 4;
>  $_[2] = 5;
>  $_[3] = 6;
> }
> 
> This will print out "a4b6". In other words, the array elements which
> correspond to the keys of the hash cannot be changed 
> in this way. Not very surprising.

The same will iirc happen with passed subroutines,
they are localized and then restored.

> While asking my friend Devel::Peek, it tolds me that the SVs of $_[0] and
> $_[2] are marked as "FAKE" and "READONLY". So my questions are:
> 1) While marked as "READONLY",  I would expect to get the
> "Modification of a read-only value attempted..."
> warning (similar when passing a list of constants to the sub and trying to
> change it with the alias mechanism), but there is no warning message,
> although "use warnings" is in effect. Why not?
> 2) What does the "FAKE" flag in a SV mean?

IIRC FAKE means, that all @_ games in this 'stack'-AV[0]
will be subject to non-deterministic optimizations in
order to give perl the edge above anything else - by
keeping a good share of compatibility to Perl4-idioms
(you didn't have references as soubroutine arguments,
how'd you alter an array in place if you would't have
the @_/stack-AV thingy built in).

But I could be wrong in this, maybe some guardian
of the hidden perl source  documentation will speak
eventually (in case Larrys Dogs didn't find them first ..)

> 3) Are there plans to implement a %_ as an addition to @_? So, as in my
> example, when passing a hash to a sub, %_ can be used therein in addition
> to @_?

Because HV-Keys are obviously not simple SV's but
some complex machinery in themselves (must be
hv_fetched first of all).

My € 0.05

Mirco


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

Date: 25 May 2006 12:44:30 +0200
From: delfin_soft@homoludens.elte.hu
Subject: Re: Getting rid of inverted commas around a string.
Message-Id: <nIrW9zgr7m8j@ludens>

In article <1148552440.707502.153890@38g2000cwa.googlegroups.com>, Fearban@gmail.com writes:
> Hi
> 
> How can one get rid of double inverted commas aound a string
> 
> " hello world "
> 
> I know that chop will remove the tailing double inverted comma
> but what about the head.
> 

#which one do you like? what do you really want?


foreach $a ('" hello world "','hello world','hello world"','"hello world','"hello"world"') {
$a3=$a2=$a1=$a0=$a;

chop($a0); # remove last char

$a1=~ s/\"//g; # remove _all_ inverted_commas

$a2=~ s/^\"//; # remove only the first (if exists)
$a2=~ s/\"$//; # remove only the last (if exists)

$a3= (split(/\"/,$a))[1]        ||'undef'; #extract string between the first and second invertedcomas

print "a:-$a-\na0:-$a0-\na1:-$a1-\na2:-$a2-\na3:-$a3-\n\n";

};


# Bye delfin




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

Date: Thu, 25 May 2006 13:12:02 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Help in installing XML::PARSER
Message-Id: <e54as0.11g.1@news.isolution.nl>

vincente13@gmail.com schreef:
> sorry..
>
> rather new to perl and unix machines..therefore been working on this
> for the whole day..and started to realize what is missing and what
> should be done..
> so any alternatives to XML:XPath ? been searching the net, seems like
> i can't find any..

What have you done with the suggestions to start using XML::SAX?


#!/usr/bin/perl
# vincente13.pl

  use strict ;
  use warnings ;

  do {local $/; $_ = <DATA> } ;

# Replace soft newlines by space.
  s/(?<!\n)\n(?!\n)/ /g ;

# Remove spaces before hard newlines.
  s/ +$/\n/mg ;

# Shrink dot sequences before hard newlines.
  s/(\.)\.+$/$1/mg ;

# Remove spaces before [?!].
  s/ +([?!])/$1/g ;

# Uppercase the first letter of a paragraph.
  s/(?:\A|(?<=\n\n))([a-z])/\u$1/g ;

# Shrink dot sequences before a word,
# and insert a space,
# and uppercase the first letter of that word.
  s/(\.)\.+([a-z])/$1 \u$2/g ;

# Change word "i" to "I".
  s/\b(i)\b/\u$1/g ;

# Change ". And " to " ... "
  s/\.( And )/\L$1/g ;

# Change ". Therefore " to ", ... "
  s/\.( Therefore )/,\L$1/g ;

# Change phrase "been" to "I have been"
  s/(?<!(?:have:has) )(been)\b/I have $1/g ;

# Change phrase "Rather" to "I am rather"
  s/\b(Rather)/I am \l$1/g ;

# Change phrase "so any" to "so are there any"
  s/\b([Ss]o) (any)\b/$1 are there $2/g ;

# Change phrase ", seems like I can't" to "and didn't"
  s/, seems like I ca(n't)/ and did$1/g ;

  print;

__DATA__
sorry..

rather new to perl and unix machines..therefore been working on this
for the whole day..and started to realize what is missing and what
should be done..

so any alternatives to XML:XPath ? been searching the net, seems like i
can't find any..

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

Date: Thu, 25 May 2006 04:42:13 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu May 25 2006
Message-Id: <Izt12D.1CKF@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.

Bundle-Modules-2006.0524
http://search.cpan.org/~ermeyers/Bundle-Modules-2006.0524/
All current *stable* bundles of modules in CPAN
----
sepia-0.63
http://search.cpan.org/~seano/sepia-0.63/
----
Class-Adapter-1.02
http://search.cpan.org/~adamk/Class-Adapter-1.02/
Perl implementation of the "Adapter" Design Pattern
----
Template-Plugin-Heritable-0.02
http://search.cpan.org/~samv/Template-Plugin-Heritable-0.02/
OO dispatching and inheritance for templates
----
encoding-split-0.01
http://search.cpan.org/~juerd/encoding-split-0.01/
Like encoding, but affecting only STDIO, or only source.
----
Test-Depends-0.03
http://search.cpan.org/~samv/Test-Depends-0.03/
Gracefully skip tests if missing modules
----
Test-Depends-0.02
http://search.cpan.org/~samv/Test-Depends-0.02/
Gracefully skip tests if missing modules
----
Tk-GraphItems-0.05
http://search.cpan.org/~lamprecht/Tk-GraphItems-0.05/
Display relation-graphs on a Tk::Canvas
----
Snort-Rule-1.03
http://search.cpan.org/~saxjazman/Snort-Rule-1.03/
Perl extension for dynamically building snort rules
----
Rose-DB-Object-0.727
http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.727/
Extensible, high performance RDBMS-OO mapper.
----
Test-Harness-2.60
http://search.cpan.org/~petdance/Test-Harness-2.60/
Run Perl standard test scripts with statistics
----
Net-Connection-Simple-1.02
http://search.cpan.org/~saxjazman/Net-Connection-Simple-1.02/
Perl extension handling simple connection info within an application
----
Pod-XML-0.95
http://search.cpan.org/~mwilson/Pod-XML-0.95/
Module to convert POD to XML
----
Net-eBay-0.33
http://search.cpan.org/~ichudov/Net-eBay-0.33/
Perl Interface to XML based eBay API.
----
WWW-WebStore-TinyURL-0.01
http://search.cpan.org/~nicolaw/WWW-WebStore-TinyURL-0.01/
Store data and files in TinyURLs
----
DBIx-Jello-0.0001
http://search.cpan.org/~tomi/DBIx-Jello-0.0001/
stupidly flexible object storage
----
Net-eBay-0.32
http://search.cpan.org/~ichudov/Net-eBay-0.32/
Perl Interface to XML based eBay API.
----
Net-IP-1.25
http://search.cpan.org/~manu/Net-IP-1.25/
Perl extension for manipulating IPv4/IPv6 addresses
----
HTTP-Cookies-w3m-0.01
http://search.cpan.org/~yappo/HTTP-Cookies-w3m-0.01/
Cookie storage and management for w3m
----
Catalyst-Plugin-Cache-Memcached-0.6
http://search.cpan.org/~sri/Catalyst-Plugin-Cache-Memcached-0.6/
Distributed cache
----
Bio-MCPrimers-2.0
http://search.cpan.org/~slenk/Bio-MCPrimers-2.0/
(and mcprimers.pl)
----
Archive-StringToZip-1.01
http://search.cpan.org/~robbiebow/Archive-StringToZip-1.01/
Transforms a string to a zip
----
Pugs-Compiler-Rule-0.04
http://search.cpan.org/~fglock/Pugs-Compiler-Rule-0.04/
Compiler for Perl 6 Rules
----
Algorithm-RabinKarp-0.36
http://search.cpan.org/~nnunley/Algorithm-RabinKarp-0.36/
Rabin-Karp streaming hash
----
Bio-MCPrimers-1.5.1
http://search.cpan.org/~slenk/Bio-MCPrimers-1.5.1/
(and mcprimers.pl)
----
Plagger-0.7.1
http://search.cpan.org/~miyagawa/Plagger-0.7.1/
Pluggable RSS/Atom Aggregator
----
File-Stat-ModeString-1.00
http://search.cpan.org/~fedorov/File-Stat-ModeString-1.00/
conversion file stat(2) mode to/from string representation.
----
File-Stat-Bits-1.00
http://search.cpan.org/~fedorov/File-Stat-Bits-1.00/
stat(2) bit mask constants
----
Game-Planeshift-Info-0.5
http://search.cpan.org/~dupuisarn/Game-Planeshift-Info-0.5/
A module to retrieve players' data on the main Planeshift server.
----
FEAR-API-0.486
http://search.cpan.org/~xern/FEAR-API-0.486/
There's no fear with this elegant site scraper


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.

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: Thu, 25 May 2006 12:33:37 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Peculiar rounding behaviour
Message-Id: <e548gu.1as.1@news.isolution.nl>

Ilya Zakharevich schreef:
> Dr.Ruud:
>> Ilya:

>>>   perl -e 'printf qq(%.${_}f\n), q(37.) . 1 x $_ . 5 for 1..14'
>>>
>>>   perl -e 'printf qq{%.*f\n}, $_, q{37.} . q{1} x $_ . q{5} for
>>> (1..10)'
>>
>> Is there a specific reason why you used ${_} and not '*' inside the
>> format string?
>
> * should be quickier (no interpolation needed); however, IMO, the only
> "actual" reason for existence of '*' is that interpolation is not
> available in C.

Yes, it's an old habit showing through. But we also built format strings
(with sprintf) in those days.

-- 
Affijn, Ruud

"Gewoon is een tijger."




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

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


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

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


------------------------------
End of Perl-Users Digest V10 Issue 9242
***************************************


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