[30322] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1565 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 22 03:10:13 2008

Date: Thu, 22 May 2008 00:09:08 -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, 22 May 2008     Volume: 11 Number: 1565

Today's topics:
    Re: FAQ 4.63 How do I reset an each() operation part-wa <bill@ts1000.us>
    Re: FAQ 4.63 How do I reset an each() operation part-wa <mjcarman@mchsi.com>
    Re: FAQ 6.19 What good is "\G" in a regular expression? <tadmc@seesig.invalid>
    Re: finding & saving accented (unicode) chars with perl <jimsgibson@gmail.com>
    Re: How would I extract the URL name. <noreply@gunnar.cc>
    Re: How would I extract the URL name. <jimsgibson@gmail.com>
    Re: How would I extract the URL name. <cdalten@gmail.com>
    Re: import CSV files to Excel <jimsgibson@gmail.com>
        new CPAN modules on Thu May 22 2008 (Randal Schwartz)
    Re: Order of operations <mjcarman@mchsi.com>
    Re: Order of operations <mjcarman@mchsi.com>
    Re: Out of memory! Yet ... <alexxx.magni@gmail.com>
    Re: Perl 6 (David Combs)
        printf + escape code aequites@yahoo.com
    Re: printf + escape code <spamtrap@dot-app.org>
    Re: Strawberry <mjcarman@mchsi.com>
    Re: Strawberry <1usa@llenroc.ude.invalid>
    Re: Strawberry <mjcarman@mchsi.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 21 May 2008 18:21:32 -0700 (PDT)
From: Bill H <bill@ts1000.us>
Subject: Re: FAQ 4.63 How do I reset an each() operation part-way through?
Message-Id: <7b25489d-e0e2-4ca4-8e55-a0518d9a1162@b1g2000hsg.googlegroups.com>

On May 21, 9:03=A0pm, PerlFAQ Server <br...@stonehenge.com> wrote:
> This is an excerpt from the latest version perlfaq4.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 athttp://faq.perl.org.
>
> --------------------------------------------------------------------
>
> 4.63: How do I reset an each() operation part-way through?
>
> =A0 =A0 (contributed by brian d foy)
>
> =A0 =A0 You can use the "keys" or "values" functions to reset "each". To s=
imply
> =A0 =A0 reset the iterator used by "each" without doing anything else, use=
 one
> =A0 =A0 of them in void context:
>
> =A0 =A0 =A0 =A0 =A0 =A0 keys %hash; # resets iterator, nothing else.
> =A0 =A0 =A0 =A0 =A0 =A0 values %hash; # resets iterator, nothing else.
>
> =A0 =A0 See the documentation for "each" in perlfunc.
>
> --------------------------------------------------------------------
>
> 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.

I hope this doesnt't sound like a d'oh moment, but am I being lead to
believe that all these years I have been using the following:

foreach $temp (keys(%in))
{
print $in{$temp};
}

I could have been using this instead:

foreach $temp (values(%in))
{
print $temp;
}

Bill H


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

Date: Thu, 22 May 2008 01:49:06 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: FAQ 4.63 How do I reset an each() operation part-way through?
Message-Id: <mi4Zj.120141$TT4.72334@attbi_s22>

Bill H wrote:
> 
> I hope this doesnt't sound like a d'oh moment, but am I being lead to
> believe that all these years I have been using the following:
> 
> foreach $temp (keys(%in))
> {
> print $in{$temp};
> }
> 
> I could have been using this instead:
> 
> foreach $temp (values(%in))
> {
> print $temp;
> }

In this case, yes. The two loops do the same thing. I've found that in 
practice I usually need the key for some reason and end up using the 
first form. It's a guilty pleasure when I can iterate over values() 
instead. ;)

There is also a third option that's occasionally useful:

while (my ($k, $v) = each %hash) {
     print "$k => $v\n";
}

-mjc


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

Date: Wed, 21 May 2008 06:53:45 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: FAQ 6.19 What good is "\G" in a regular expression?
Message-Id: <slrng383a9.sd6.tadmc@tadmc30.sbcglobal.net>

szr <szrRE@szromanMO.comVE> wrote:
> PerlFAQ Server wrote:


>>       m/ \G( \d+\b    )/gcx   && do { print "number: $1\n";  redo; };


> doesn't the  C< \d+ >  already match until it encounters a non-digit, 
> which implicitly include word boundries?


\d+ implicitly includes "digit boundaries".

\w+ implicitly includes "word boundaries".


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


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

Date: Wed, 21 May 2008 18:09:38 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: finding & saving accented (unicode) chars with perl 5.6.1
Message-Id: <210520081809382894%jimsgibson@gmail.com>

In article
<320d2308-cfe5-4bcc-b6a4-8e21666fe2aa@d1g2000hsg.googlegroups.com>,
<"jcmmat@gmail.com"> wrote:

> Google & newsreaders exactly show my code (but indeed changed the
> lookds of the examples of reference text) :
> 
> i am using the Questionmark symbol as placeholder in my QstnLines &
> thus the var $wrd
> iow $wrd = Lu?ija (a qstn-mark as 3rd char)
> 
> the referenceLines & thus the var $match contains the real life &
> correctly written word containing accented chars
> iow $match = Lu&#267;ija (3rd char = c-with-dot-above ; total word
> looks like Lucija but with a different c)
> 
> so rephrased, the PERL problem seems to be that the statement
>   $match =~ /$wrd/
>   Lu&#267;ija =~ /Lu?ija/
> doesn't seem to be TRUE
> 
> what the total progrm wants to achieve, is find the real/correct
> written word in a reference file,
> given a list of 'simplified' keywords that do not contain any accented
> chars, those are all replaced by a Questionmark

The question mark in Perl regular expressions is a quantifier that
means "0 or 1 of the previous character". Thus the RE /Lu?ija? will
match any string containing the substring 'Lija' or 'Liuja'. It will
not match any string having any character between the 'u' and the 'i'.

The Perl meta-character for matching a single character is period (.).

You need an expression that will match a single accented character. You
can use character classes enclosed in brackets ([...]), control
character codes (\cX), numerical character codes (\NNN), POSIX style
character classes ([[:ascii:]), or one of the fancier Unicode
constructs (see pp 167-174 in Programmin Perl, 3rd Ed.). I do not have
experience with those and can't help you. Be aware that the Unicode
constructs probably do not exist in Perl 5.6.

Good luck!

-- 
Jim Gibson


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

Date: Thu, 22 May 2008 02:43:58 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: How would I extract the URL name.
Message-Id: <69ju2kF325unvU1@mid.individual.net>

grocery_stocker wrote:
> Say I have an HTML document that contains the following...
> 
> <a href="/stuff.html">A Link</a>
> 
> How would I parse  it so that if the program so "A Link", it would
> fetch the corresponding URL?

     use HTML::TokeParser;
     my $html = '<a href=/stuff.html>A Link</a>';

     my $p = HTML::TokeParser->new(\$html);

     while ( my $token = $p->get_tag('a') ) {
         if ( $p->get_text eq 'A Link' ) {
             print "$token->[1]{href}\n";
             last;
         }
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Wed, 21 May 2008 17:48:31 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: How would I extract the URL name.
Message-Id: <210520081748316908%jimsgibson@gmail.com>

In article
<69a936eb-8d1d-491b-bff4-dd785646a2c8@h1g2000prh.googlegroups.com>,
grocery_stocker <cdalten@gmail.com> wrote:

> On May 21, 1:00 pm, Jim Gibson <jimsgib...@gmail.com> wrote:
> > In article
> > <8bda0261-258a-4415-ab77-4ca01981c...@p25g2000pri.googlegroups.com>,

> > There are numerous snippets in the documentation for HTML::Parser. I
> > would also look at the HTML::LinkExtor module.
> >
> > perldoc HTML::Parser
> > perldoc HTML::LinkExtor
> >

> 
> Eerr.....It looks like all those examples deal with manipulating the
> tags itself. Ie, the <a></a> and <img>/</img>. I didnt see anything
> that would deal with associating the text "A Link" with the url "/
> stuff.html".
> 
> <a href="/stuff.html">A Link</a>

It looks like HTML::LinkExtor doesn't keep the link text around.
However, HTML::Parser will return the text, the tags, and the tag
attributes, including the "href" attribute, which is what you want.
HTML::Parser is an event parser, so it scans the HTML and calls your
provided callback subroutines. Since you will get the tag name and href
attribute in one call, and the link text in a subsequent call, you will
have to save the link URL in a handy global variable. Something like
this:

#!/usr/local/bin/perl
use strict;
use warnings;
use HTML::Parser;

my $html = <<EOS;
<html>
<head>
<title>Title</title>
</head>
<body>
<p>This is some text</p>
<a href="http://path/to/some/file.html">A Link</a>
<p>More text</p>
</body>
</html>
EOS

my( $tag, $href );

my $p = HTML::Parser->new( 
  start_h => [\&start, "tagname, attr"],
  text_h  => [\&text, "dtext"],
);
$p->parse($html);

sub start {
  my($t, $attref) = @_;
  my %attr = %$attref;
  if( $t eq 'a' && exists $attr{href} ) {
    $tag = $t;
    $href = $attr{href};
  }
};

sub text {
  my($text) = @_;
  if( defined $tag && $tag eq 'a' && defined $href ) {
    print "Link text for <a href=\"$href\"> is \"$text\"\n";
    $tag = $href = undef;
  }
}

HTH

-- 
Jim Gibson


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

Date: Wed, 21 May 2008 18:26:26 -0700 (PDT)
From: grocery_stocker <cdalten@gmail.com>
Subject: Re: How would I extract the URL name.
Message-Id: <ae639620-1ec0-4118-8186-340bbac8f07d@i36g2000prf.googlegroups.com>

On May 21, 5:48 pm, Jim Gibson <jimsgib...@gmail.com> wrote:
> In article
> <69a936eb-8d1d-491b-bff4-dd785646a...@h1g2000prh.googlegroups.com>,
>
>
>
> grocery_stocker <cdal...@gmail.com> wrote:
> > On May 21, 1:00 pm, Jim Gibson <jimsgib...@gmail.com> wrote:
> > > In article
> > > <8bda0261-258a-4415-ab77-4ca01981c...@p25g2000pri.googlegroups.com>,
> > > There are numerous snippets in the documentation for HTML::Parser. I
> > > would also look at the HTML::LinkExtor module.
>
> > > perldoc HTML::Parser
> > > perldoc HTML::LinkExtor
>
> > Eerr.....It looks like all those examples deal with manipulating the
> > tags itself. Ie, the <a></a> and <img>/</img>. I didnt see anything
> > that would deal with associating the text "A Link" with the url "/
> > stuff.html".
>
> > <a href="/stuff.html">A Link</a>
>
> It looks like HTML::LinkExtor doesn't keep the link text around.
> However, HTML::Parser will return the text, the tags, and the tag
> attributes, including the "href" attribute, which is what you want.
> HTML::Parser is an event parser, so it scans the HTML and calls your
> provided callback subroutines. Since you will get the tag name and href
> attribute in one call, and the link text in a subsequent call, you will
> have to save the link URL in a handy global variable. Something like
> this:
>
> #!/usr/local/bin/perl
> use strict;
> use warnings;
> use HTML::Parser;
>
> my $html = <<EOS;
> <html>
> <head>
> <title>Title</title>
> </head>
> <body>
> <p>This is some text</p>
> <a href="http://path/to/some/file.html">A Link</a>
> <p>More text</p>
> </body>
> </html>
> EOS
>
> my( $tag, $href );
>
> my $p = HTML::Parser->new(
>   start_h => [\&start, "tagname, attr"],
>   text_h  => [\&text, "dtext"],
> );
> $p->parse($html);
>
> sub start {
>   my($t, $attref) = @_;
>   my %attr = %$attref;
>   if( $t eq 'a' && exists $attr{href} ) {
>     $tag = $t;
>     $href = $attr{href};
>   }
>
> };
>
> sub text {
>   my($text) = @_;
>   if( defined $tag && $tag eq 'a' && defined $href ) {
>     print "Link text for <a href=\"$href\"> is \"$text\"\n";
>     $tag = $href = undef;
>   }
>
> }
>
> HTH
>
> --
> Jim Gibson


Okay. Thanks. And just for the record, I did make several attempts at
the solution before I asked the follupw questions


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

Date: Wed, 21 May 2008 17:59:20 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: import CSV files to Excel
Message-Id: <210520081759205831%jimsgibson@gmail.com>

In article
<fcecd759-f7f4-4f5b-a741-2cd2a1fe3434@k30g2000hse.googlegroups.com>,
Slickuser <slick.users@gmail.com> wrote:

> With 1868 CSV files and this is how long it took to execute the
> script.
> 
> Wed May 21 10:48:51 2008 START
> Wed May 21 12:30:59 2008 END
> 
> I found this link, http://www.rondebruin.nl/txtcsv.htm.
> Now I have to learn VB and understand what it's doing.
> 
> I also look at Insert>Object>from files, but this is embedded only. I
> can't interact between worksheet with hyperlinks.
> 
> Any help would be great.
> 
> Source Code:
> 
> 
> use strict;
> use warnings;
> use Win32::OLE;
> use Win32::OLE::Const 'Microsoft Excel';
> 
> 
>   print localtime() ." START \n";
> 
>   my $localTime = localtime();
>   $localTime =~ s/\s/_/g;
>   $localTime =~ s/\:/_/g;
> 
>   my $csv_path = "C:/slickuser/Tue_May_20_20_49_44_2008/*.csv";
>   my $fileOutput = "C:/slickuser/out.xls";
>   my $MAX_ROW = 65356;

[loop over all CSV files]

  [open a CSV file as a workbook]

> 
>     $Workbook_CSV->ActiveSheet->Range("A1:Z$MAX_ROW")->Copy;

Perhaps it is taking a long time because you seem to be copying 26 x
65356 cells. Can you read the CSV file and determine exactly how many
rows and columns are needed and only copy those?

  [add CSV worksheet to master workbook]

>   }
>   $Workbook->Close();
>   $Excel->Quit();
>   Win32::OLE->FreeUnusedLibraries();
> 
>   print localtime() ." END \n";

-- 
Jim Gibson


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

Date: Thu, 22 May 2008 04:42:20 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu May 22 2008
Message-Id: <K196EK.p6K@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.

Acme-CPANAuthors-0.02
http://search.cpan.org/~ishigaki/Acme-CPANAuthors-0.02/
We are CPAN authors 
----
Acme-CPANAuthors-CodeRepos-0.080522
http://search.cpan.org/~ishigaki/Acme-CPANAuthors-CodeRepos-0.080522/
We are CPAN authors using CodeRepos 
----
Acme-CPANAuthors-Japanese-0.080522
http://search.cpan.org/~ishigaki/Acme-CPANAuthors-Japanese-0.080522/
We are Japanese CPAN authors 
----
Acme-nicde-0.02
http://search.cpan.org/~schwigon/Acme-nicde-0.02/
----
Autodia-2.07
http://search.cpan.org/~teejay/Autodia-2.07/
The configuration and Utility perl module for AutoDia. 
----
BLOB-1.01
http://search.cpan.org/~juerd/BLOB-1.01/
Perl extension for explicitly marking binary strings 
----
Bluepay-Bluepay20DailyReport-0.15
http://search.cpan.org/~cpkois/Bluepay-Bluepay20DailyReport-0.15/
----
Catalyst-Plugin-AutoRestart-0.91
http://search.cpan.org/~jgoulah/Catalyst-Plugin-AutoRestart-0.91/
Catalyst plugin to restart every 'n' requests 
----
Class-Meta-0.62
http://search.cpan.org/~dwheeler/Class-Meta-0.62/
Class automation, introspection, and data validation 
----
Config-Model-Itself-0.203
http://search.cpan.org/~ddumont/Config-Model-Itself-0.203/
Model editor for Config::Model 
----
DBIx-Class-VirtualColumns-1.00
http://search.cpan.org/~maros/DBIx-Class-VirtualColumns-1.00/
Add virtual columns to DBIx::Class schemata 
----
DBIx-SchemaChecksum-0.02
http://search.cpan.org/~domm/DBIx-SchemaChecksum-0.02/
Generate and compare checksums of database schematas 
----
Data-PostfixDeref-0.01
http://search.cpan.org/~bmorrow/Data-PostfixDeref-0.01/
Allow ->[] ->{} as an alternative to @{ } %{ } 
----
Devel-PerlySense-0.0154
http://search.cpan.org/~johanl/Devel-PerlySense-0.0154/
Perl IDE backend with Emacs frontend 
----
EV-3.41
http://search.cpan.org/~mlehmann/EV-3.41/
perl interface to libev, a high performance full-featured event loop 
----
FSA-Rules-0.28
http://search.cpan.org/~dwheeler/FSA-Rules-0.28/
Build simple rules-based state machines in Perl 
----
GRID-Machine-0.093
http://search.cpan.org/~casiano/GRID-Machine-0.093/
Remote Procedure Calls over a SSH link 
----
Games-RolePlay-MapGen-1.2.17
http://search.cpan.org/~jettero/Games-RolePlay-MapGen-1.2.17/
The base object for generating dungeons and maps 
----
Glib-Ex-ConnectProperties-1
http://search.cpan.org/~kryde/Glib-Ex-ConnectProperties-1/
link properties between objects 
----
Glib-Ex-ObjectBits-1
http://search.cpan.org/~kryde/Glib-Ex-ObjectBits-1/
----
Graph-Maker-0.02
http://search.cpan.org/~batz/Graph-Maker-0.02/
Create many types of graphs 
----
Gtk2-Ex-Dragger-1
http://search.cpan.org/~kryde/Gtk2-Ex-Dragger-1/
drag to move adjustment position 
----
HTML-Tested-0.36
http://search.cpan.org/~bosu/HTML-Tested-0.36/
Provides HTML widgets with the built-in means of testing. 
----
Hardware-Simulator-MIX-0.4
http://search.cpan.org/~litchie/Hardware-Simulator-MIX-0.4/
A simulator of Knuth's famous virtual machine 
----
Language-Lisp-ECLs-0.03
http://search.cpan.org/~vkon/Language-Lisp-ECLs-0.03/
Perl extension for ECL lisp 
----
Log-Handler-0.42
http://search.cpan.org/~bloonix/Log-Handler-0.42/
Log messages to one or more outputs. 
----
Log-Handler-0.43
http://search.cpan.org/~bloonix/Log-Handler-0.43/
Log messages to one or more outputs. 
----
Mail-Convert-Mbox-ToEml-0.05
http://search.cpan.org/~rjbs/Mail-Convert-Mbox-ToEml-0.05/
convert mbox files to Outlook Express .eml files 
----
Math-Random-MT-Perl-1.01
http://search.cpan.org/~jfreeman/Math-Random-MT-Perl-1.01/
Pure Perl Pseudorandom Number Generator 
----
Muldis-D-0.31.0
http://search.cpan.org/~duncand/Muldis-D-0.31.0/
Formal spec of Muldis D relational DBMS lang 
----
POE-Component-Client-NRPE-0.10
http://search.cpan.org/~bingos/POE-Component-Client-NRPE-0.10/
a POE Component that implements check_nrpe functionality 
----
POE-Component-Client-NSCA-0.10
http://search.cpan.org/~bingos/POE-Component-Client-NSCA-0.10/
a POE Component that implements send_nsca functionality 
----
POE-Component-Client-RADIUS-0.04
http://search.cpan.org/~bingos/POE-Component-Client-RADIUS-0.04/
a flexible POE-based RADIUS client 
----
POSIX-Regex-0.90.4
http://search.cpan.org/~jettero/POSIX-Regex-0.90.4/
OO interface for the gnu regex engine 
----
Perl-Critic-1.083_006
http://search.cpan.org/~elliotjs/Perl-Critic-1.083_006/
Critique Perl source code for best-practices. 
----
PerlIO-Util-0.14
http://search.cpan.org/~gfuji/PerlIO-Util-0.14/
A selection of general PerlIO utilities 
----
ProgressMonitor-0.26
http://search.cpan.org/~knth/ProgressMonitor-0.26/
a flexible and configurable framework for providing feedback on how a long-running task is proceeding. 
----
RRDTool-OO-0.22
http://search.cpan.org/~mschilli/RRDTool-OO-0.22/
Object-oriented interface to RRDTool 
----
Rose-DBx-Garden-0.12
http://search.cpan.org/~karman/Rose-DBx-Garden-0.12/
bootstrap Rose::DB::Object and Rose::HTML::Form classes 
----
Socket-GetAddrInfo-0.09
http://search.cpan.org/~pevans/Socket-GetAddrInfo-0.09/
RFC 2553's getaddrinfo and getnameinfo functions. 
----
Test-Reporter-1.4001
http://search.cpan.org/~dagolden/Test-Reporter-1.4001/
sends test results to cpan-testers@perl.org 
----
WWW-Lengthen-0.06
http://search.cpan.org/~ishigaki/WWW-Lengthen-0.06/
lengthen 'shortened' urls 
----
Win32-IE-SlideShow-0.03
http://search.cpan.org/~ishigaki/Win32-IE-SlideShow-0.03/
show and manipulate your slides on IE 
----
Win32-PowerPoint-0.07
http://search.cpan.org/~ishigaki/Win32-PowerPoint-0.07/
helps to convert texts to PP slides 
----
ZConf-0.0.1
http://search.cpan.org/~vvelox/ZConf-0.0.1/
A configuration system allowing for either file or LDAP backed storage. 
----
ZConf-0.0.2
http://search.cpan.org/~vvelox/ZConf-0.0.2/
A configuration system allowing for either file or LDAP backed storage. 
----
pfacter-1.13-1
http://search.cpan.org/~sschneid/pfacter-1.13-1/
Collect and display facts about the system 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Thu, 22 May 2008 03:44:46 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Order of operations
Message-Id: <O_5Zj.120255$TT4.108710@attbi_s22>

szr wrote:
> Peter J. Holzer wrote:
>> is
>>
>>    ($i = 1) + ($i = 2)
>>
>> also undefined? (it is in C)
> 
> This seems quite defined to me; assignments occur first, going left to 
> right, so $i becomes 2 (ok, it becomes 1 and then immediately becomes 
> 2), and then you add (+), resulting in 2 + 2, which of course is 4.

AFAIK nothing defines which assignment happens first so this could just 
as easily result in a value of 2.

-mjc


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

Date: Thu, 22 May 2008 03:52:04 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Order of operations
Message-Id: <E56Zj.174357$yE1.60@attbi_s21>

Ben Morrow wrote:
> Quoth "John W. Krahn" <krahnj@telus.net>:
>> I've had this discussion on c.l.p.misc before and it has been (rightly) 
>> pointed out to me that precedence does not determine order of evaluation.
> 
> Can you give me an example? I can't really see how the yacc parser can
> produce anything else...

Roughly speaking: Precedence defines the order in which operations are 
performed. Order of evaluation defines the order in which the operands 
are evaluated. Even if the parser always returns a particular order an 
optimizing stage could decide to reorder things.

So in "f() + g() * h()" precedence says that the multiplication happens 
before the addition but it does not dictate which order the functions 
are called in. That's determined by the order of evaluation. If the 
three functions are independent it doesn't matter, but if they have side 
effects (like modifying shared global data) it could.

-mjc


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

Date: Wed, 21 May 2008 23:32:52 -0700 (PDT)
From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: Re: Out of memory! Yet ...
Message-Id: <b6e3bf37-79d9-4759-ad40-e1b3544a341f@b64g2000hsa.googlegroups.com>

On 21 Mag, 18:11, "A. Sinan Unur" <1...@llenroc.ude.invalid> wrote:
> "alexxx.ma...@gmail.com" <alexxx.ma...@gmail.com> wrote innews:e84cae72-e396-40a6-beec-4bad5aa3d615@d77g2000hsb.googlegroups.com:
>
> > I am having trouble running my script, which stops with an "Out of
> > memory!" error.
> > But what I find unusual is that it stops as soon as the "Free" memory
> > reported by the <free> utility goes to zero - without even starting to
> > touch the free swap memory (and I have 2GB swap).
>
> How much physical memory do you have and what OS are you on? Does it
> actually support more than 2GB addressable memory space?
>
> > The memory-eating line is this:
> > for $i(1..$n)
> > {
> >   for $y(1..$ny)
> >   {  for $x(1..$nx) { $AAA[$i][$x][$y]=$a[3+$nx*($y-1)+$x] }   }
> >   print("\n$i>\ttotal size: ",total_size($AAA));
> > }
>
> The only information this snippet conveys is that you write code that is
> hard to read. Crucial information such as the values of $n and $nx is
> missing.
>
> > where for $n times I read a grayscale image in @a, then assign its
> > value to $AAA[][][].
>
> How large is the image? You are basically holding two copies of the
> image in memory. Plus, you have the overhead of a multilevel data
> structure.
>
> Even if you did not run out of memory, this smells. Without knowing any
> details, it is hard to say definitely that what you are doing is wrong,
> but I would have constructed the AoAoA in $AAA step by step while
> reading the data.
>
> > BTW, as you can see I try to use Devel::Size to check how big becomes
>
> How can we see that? Because you have total_size? Without the use
> statement being shown total_size could be any function.
>
> > $AAA, but it always answers "12". WTF? I could accept it if it was
> > "42", but "12", come on...
>
> Who knows what is going on. Please read the posting guidelines and try
> to reduce the problem to the smallest script possible.
>
> As for overhead, note the following:
>
> E:\Home> cat t.pl
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> use Devel::Size qw( total_size );
>
> my @AAA = ( 1 .. 6 );
> my $AAA = [ [ [ 1, 2 ], [ 3, 4 ] ], [ [ 5, 6 ] ] ];
>
> print join( "\n", total_size(\@AAA), total_size($AAA) ), "\n";
>
> __END__
>
> E:\Home> t
> 224
> 684
>
> The multilevel data structure takes up 200% more space than the simple
> array.
>
> Sinan
> --
> A. Sinan Unur <1...@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:http://www.rehabitation.com/clpmisc/


sorry if I didnt put all the info in - I didnt want to burden the
newsgroup too much: my script is large (and of course I used
Devel::Size). Plus, my fault was to bring up 2 separate questions
together: I'll try to remedy now

1)
> How much physical memory do you have and what OS are you on? Does it
actually support more than 2GB addressable memory space?

maybe that's a hint: I use Linux, Fedora FC8. I have 4GB RAM, can it
be this the problem?


2) concerning the huge overhead, I cannot avoid it - I need all the
images (indexed by $i) in parallel in $AAA[$i][$x][$y], since I have
to process each pixel ($x,$y) along $i=1..$n ($n can vary, right now I
have ~ 100 images). The alternative would be to continuously open the
~100 images and read each time a different pixel: choosing whether to
stress the disk or the RAM I choose the latter, but maybe it's too
much.


thanks everybody

 Alessandro


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

Date: Thu, 22 May 2008 06:04:44 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: Perl 6
Message-Id: <g132ds$6l$1@reader2.panix.com>

In article <Xns9AA09211F9F98castleamber@130.133.1.4>,
John Bokma  <john@castleamber.com> wrote:
>"Gordon Etly" <get@INVALIDbentsys.com> wrote:
>
>> John Bokma wrote:
>>> Sherman Pendley <spamtrap@dot-app.org> wrote:
>> 
>>> > Uri Guttman <uri@stemsystems.com> writes:
>
>[..]
> 
>>> From what I've read, written by Uri, it's somewhat his writing style.
>> 
>> I don't think it's just his writting style. Many times he just jumps
>> in to defend someone or something and often takes it way too far. He's
>> of the type that doesn't want to see things through any other lens
>> than his own.
>
>Yup, that's online discussing stuff for you. I am a little like that too
>I guess, and I see this behavior a lot. I have little doubt that if you
>meet those people IRL they are really nice people. Also, dealing every
>day with people who are too lazy to even pick a decent subject, and
>expect that "the Usenet people" act as their private help desk (free at
>that), makes someone not always replying in a nice way, even to serious
>questions (it's the main reason why I am giving up on Usenet again (and
>permanently this time), real soon). 


No, no, no, NO!, damnit, NO!

Can't do that -- you're NEEDED here, John.

You guys constitute an *invaluable* resource for, what, maybe thousands
of people.  While you answer one guy's questions, etc, there's a whole
bunch of us looking on, taking advantage of the (needed) extra education
we get here.

Any one of you gurus quit, and we all suffer.

No sweat, you say, there's plenty of others (what -- 10, 20 or so) who
can equally well answer these questions.

Maybe so -- but it cuts down on the among-gurus conversation, which
leads to all kinds of interesting pearisms, etc.

If some guy is bothering you, nagging you, being nasty, warn him
or her once, and if he or she persists in the same mode, do the
usual PLONK! action we've gotten used to seeing here.


Please, you guys stick around.

Heck, we could give a party for your guys at yapc!  (Unfortunately
I can't be there.)

Anyway, you (and the rest of you) *are* appreciated, giving up
all that time to be of service here.

THANKS!


David





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

Date: Wed, 21 May 2008 21:36:49 -0700 (PDT)
From: aequites@yahoo.com
Subject: printf + escape code
Message-Id: <4a7ccdd0-f277-419f-b109-27a1db8f82c3@z72g2000hsb.googlegroups.com>

Could someone help to explain why the second column is not formatted
with the correct width when escape codes are used?

$ perl -e 'printf ":%-20s:%-20s:\n", "string1", "\e[32mstring2\e[m"'
:string1             :string2     :



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

Date: Thu, 22 May 2008 02:42:10 -0400
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: printf + escape code
Message-Id: <m1hccqrgal.fsf@dot-app.org>

aequites@yahoo.com writes:

> Could someone help to explain why the second column is not formatted
> with the correct width when escape codes are used?
>
> $ perl -e 'printf ":%-20s:%-20s:\n", "string1", "\e[32mstring2\e[m"'
> :string1             :string2     :

Perl is counting *all* of the characters in the second variable to find the
amount of padding needed. Not just the "string2" part, but the escape codes
too, because printf() doesn't know about them. The second string is 15 chars
long, counting the escape codes, so printf pads it to 20 chars by adding 5
spaces. It doesn't know that more spaces need to be added to account for the
escape codes being removed.

You could adjust the formatting width for the second string to account for
the escape codes:

$ perl -e 'printf ":%-20s:%-28s:\n", "string1", "\e[32mstring2\e[m"'
:string1             :string2             :

Or, you could put the escape codes in the format string:

$ perl -e 'printf ":%-20s:\e[32m%-20s\e[m:\n", "string1", "string2"'
:string1             :string2             :

Or, include the escape codes separately:

$ perl -e 'printf ":%-20s:%s%-20s%s:\n", "string1", "\e[32m", "string2", "\e[m"'
:string1             :string2             :

I hope this helps!

sherm--

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


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

Date: Thu, 22 May 2008 01:53:24 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Strawberry
Message-Id: <om4Zj.174245$yE1.18806@attbi_s21>

A. Sinan Unur wrote:
> 
> The installer put 
> 
> C:\strawberry\perl\bin;C:\strawberry\c\bin;
> 
> at the end of %PATH%. Well, that is not going to work for me (I have quite 
> a few Perl installations at the moment).

Did you build them yourself or did you relocate (e.g.) ActivePerl 
installations? I'd like to have a few different versions of Perl 
installed on Windows for testing purposes but haven't been willing to go 
through the pain of multiple compilations.

-mjc


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

Date: Thu, 22 May 2008 02:12:56 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Strawberry
Message-Id: <Xns9AA5E1FBA8312asu1cornelledu@127.0.0.1>

Michael Carman <mjcarman@mchsi.com> wrote in
news:om4Zj.174245$yE1.18806@attbi_s21: 

> A. Sinan Unur wrote:
>> 
>> The installer put 
>> 
>> C:\strawberry\perl\bin;C:\strawberry\c\bin;
>> 
>> at the end of %PATH%. Well, that is not going to work for me (I have
>> quite a few Perl installations at the moment).
> 
> Did you build them yourself or did you relocate (e.g.) ActivePerl 
> installations? I'd like to have a few different versions of Perl 
> installed on Windows for testing purposes but 

Both ;-)

I have AS 5.8.8 and 5.10, cygwin Perl 5.8.8, 5.10 built using cygwin and 
5.10 built using VC++ 9 Express (and now Strawberry 5.10)

I use AS 5.10 for daily work (it is in the default path. For the rest, I 
have setup tabs in Console2 (http://sourceforge.net/projects/console/) 
and added context menu entries a la "Command Prompt Here"

> haven't been willing to
> go through the pain of multiple compilations.

There wasn't much pain involved.

Well, with one exception ... I haven't managed to compile all the 
prerequisites for libgd (I can't remember now but I think I had 
difficulty with Freetype) using VC++ 9 Express so no GD for the 5.10 
distro compiled using that compiler.

I built these basically as learning exercises. As I said, 99% of the 
time, I just use the most current AS Perl.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Thu, 22 May 2008 04:03:34 GMT
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: Strawberry
Message-Id: <qg6Zj.120276$TT4.20285@attbi_s22>

A. Sinan Unur wrote:
> Michael Carman <mjcarman@mchsi.com> wrote:
>> A. Sinan Unur wrote:
>>> I have quite a few Perl installations at the moment
>> 
>> Did you build them yourself or did you relocate (e.g.) ActivePerl 
>> installations?
> 
> I have AS 5.8.8 and 5.10, cygwin Perl 5.8.8, 5.10 built using cygwin
> and 5.10 built using VC++ 9 Express (and now Strawberry 5.10)

I'll assume that the versions you built yourself were targeted at 
secondary locations at compile time. Did you have to do anything to 
relocate ActivePerl beyond hacking Config.pm and Config_heavy.pl? Have 
you tried installing modules on any of the secondary versions of Perl?

-mjc


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

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


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