[31000] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2245 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 3 03:09:43 2009

Date: Tue, 3 Mar 2009 00:09:06 -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           Tue, 3 Mar 2009     Volume: 11 Number: 2245

Today's topics:
    Re: Develop a PERL WEB SERVICE that utilizes the Yahoo  <1usa@llenroc.ude.invalid>
        new CPAN modules on Tue Mar  3 2009 (Randal Schwartz)
        open for writing without immediately erasing <no_th@nks.org>
    Re: open for writing without immediately erasing <nat.k@gm.ml>
    Re: open for writing without immediately erasing (Darren Dunham)
    Re: open for writing without immediately erasing <syscjm@sumire.gwu.edu>
    Re: open for writing without immediately erasing <uri@stemsystems.com>
    Re: perl dates: a notify alert window <ben@morrow.me.uk>
    Re: perl dates: a notify alert window <ericcire@gmail.com>
    Re: perl dates: a notify alert window <cartercc@gmail.com>
    Re: variables that won't stay shared <1usa@llenroc.ude.invalid>
    Re: Why the same script have different behavior when ex djslls@sina.com
        Why the same script have different behavior when execut djslls@sina.com
    Re: Why the same script have different behavior when ex <bwalton@nospam.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 02 Mar 2009 23:04:25 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Develop a PERL WEB SERVICE that utilizes the Yahoo Web Services API
Message-Id: <Xns9BC2B7D9FE2E9asu1cornelledu@127.0.0.1>

seef gordon <tfgordon@buffalo.edu> wrote in
news:C5CD51EB.32D%tfgordon@buffalo.edu: 

> Okay ben , please understand that am not asking for any one to spoon
> feed me the answer my teacher just send me that project to do , and I
> have no real idea where to start , I don't want the answer , I just
> want some  who knows perl to brake it down to me that all thanks for
> your response 

Reading the documentation for Yahoo web services would be a start.

You might want to brush up on your English before doing that.

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: Tue, 3 Mar 2009 05:42:26 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Tue Mar  3 2009
Message-Id: <KFx16q.24K0@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.

AProf-0.1
http://search.cpan.org/~unera/AProf-0.1/
is a profiler for periodically running processes 
----
AProf-0.2
http://search.cpan.org/~unera/AProf-0.2/
is a profiler for periodically running processes 
----
Authen-DecHpwd-2.003
http://search.cpan.org/~zefram/Authen-DecHpwd-2.003/
DEC VMS password hashing 
----
Bio-Phylo-0.17_RC7
http://search.cpan.org/~rvosa/Bio-Phylo-0.17_RC7/
Phylogenetic analysis using perl. 
----
CHI-0.101
http://search.cpan.org/~jswartz/CHI-0.101/
Unified cache interface 
----
CHI-Driver-Memcached-0.05
http://search.cpan.org/~jswartz/CHI-Driver-Memcached-0.05/
Distributed cache via memcached (memory cache daemon) 
----
CPANPLUS-Dist-Build-0.10
http://search.cpan.org/~bingos/CPANPLUS-Dist-Build-0.10/
CPANPLUS plugin to install packages that use Build.PL 
----
CPANPLUS-Dist-Build-0.12
http://search.cpan.org/~bingos/CPANPLUS-Dist-Build-0.12/
CPANPLUS plugin to install packages that use Build.PL 
----
Catalyst-Plugin-ConfigLoader-MultiState-0.02
http://search.cpan.org/~syber/Catalyst-Plugin-ConfigLoader-MultiState-0.02/
Convenient and flexible config loader for Catalyst. 
----
Catalyst-Plugin-ConfigLoader-MultiState-0.03
http://search.cpan.org/~syber/Catalyst-Plugin-ConfigLoader-MultiState-0.03/
Convenient and flexible config loader for Catalyst. 
----
Catalyst-Plugin-Log-Colorful-0.13
http://search.cpan.org/~taro/Catalyst-Plugin-Log-Colorful-0.13/
Catalyst Plugin for Colorful Log 
----
Catalyst-View-XSLT-0.07
http://search.cpan.org/~janus/Catalyst-View-XSLT-0.07/
XSLT View Class 
----
DBIx-DataAudit-0.11
http://search.cpan.org/~corion/DBIx-DataAudit-0.11/
summarize column data for a table 
----
Data-Hexdumper-2.0
http://search.cpan.org/~dcantrell/Data-Hexdumper-2.0/
Make binary data human-readable 
----
Data-ICal-0.15
http://search.cpan.org/~alexmv/Data-ICal-0.15/
Generates iCalendar (RFC 2445) calendar files 
----
Data-NDS-3.00
http://search.cpan.org/~sbeck/Data-NDS-3.00/
routines to work with a perl nested data structure 
----
Data-NDS-Multiele-3.00
http://search.cpan.org/~sbeck/Data-NDS-Multiele-3.00/
A set of data structures with the same structure 
----
Data-NDS-Multifile-3.00
http://search.cpan.org/~sbeck/Data-NDS-Multifile-3.00/
A multi-file version of Data::NDS::Multiele 
----
File-ShareDir-PAR-0.04
http://search.cpan.org/~smueller/File-ShareDir-PAR-0.04/
File::ShareDir with PAR support 
----
FirePHP-Dispatcher-0.02_01
http://search.cpan.org/~willert/FirePHP-Dispatcher-0.02_01/
sends log messages to a FirePHP console 
----
FreeBSD-Ports-0.0.0
http://search.cpan.org/~vvelox/FreeBSD-Ports-0.0.0/
A simple wrapper for working with the FreeBSD ports. 
----
Gtk2-Ex-WidgetBits-8
http://search.cpan.org/~kryde/Gtk2-Ex-WidgetBits-8/
miscellaneous Gtk widget helpers 
----
HTML-Parser-Simple-1.02
http://search.cpan.org/~rsavage/HTML-Parser-Simple-1.02/
Parse nice HTML files without needing a compiler 
----
HTTP-Server-Simple-0.38_01
http://search.cpan.org/~jesse/HTTP-Server-Simple-0.38_01/
Lightweight HTTP server 
----
IO-Async-Loop-Epoll-0.03
http://search.cpan.org/~pevans/IO-Async-Loop-Epoll-0.03/
a Loop using an IO::Epoll object 
----
Kools-Okapi-263.005
http://search.cpan.org/~muguet/Kools-Okapi-263.005/
Perl extension for the OKAPI api of Kondor+ 2.6 
----
List-Parseable-1.05
http://search.cpan.org/~sbeck/List-Parseable-1.05/
routines to work with lists containing a simple language 
----
Math-Permute-List-1.0
http://search.cpan.org/~prbrenan/Math-Permute-List-1.0/
Generate all permutations of a list. 
----
MediaWiki-Bot-2.2.0
http://search.cpan.org/~dcollins/MediaWiki-Bot-2.2.0/
a Wikipedia bot framework written in Perl 
----
MooseX-Declare-0.08
http://search.cpan.org/~flora/MooseX-Declare-0.08/
Declarative syntax for Moose 
----
MooseX-Method-Signatures-0.11
http://search.cpan.org/~flora/MooseX-Method-Signatures-0.11/
Method declarations with type constraints and no source filter 
----
MooseX-Types-0.09
http://search.cpan.org/~phaylon/MooseX-Types-0.09/
Organise your Moose types in libraries 
----
Net-Mollom-0.03
http://search.cpan.org/~wonko/Net-Mollom-0.03/
interface with Mollom web API 
----
PAR-0.988
http://search.cpan.org/~smueller/PAR-0.988/
Perl Archive Toolkit 
----
PAR-0.989_01
http://search.cpan.org/~smueller/PAR-0.989_01/
Perl Archive Toolkit 
----
POE-Component-IRC-5.98
http://search.cpan.org/~bingos/POE-Component-IRC-5.98/
A fully event-driven IRC client module 
----
Parse-BooleanLogic-0.08
http://search.cpan.org/~ruz/Parse-BooleanLogic-0.08/
parser of boolean expressions 
----
Parse-Eyapp-1.146
http://search.cpan.org/~casiano/Parse-Eyapp-1.146/
Extensions for Parse::Yapp 
----
PerlIO-via-EscStatus-4
http://search.cpan.org/~kryde/PerlIO-via-EscStatus-4/
dumb terminal status display layer 
----
RDF-Simple-0.405
http://search.cpan.org/~mthurn/RDF-Simple-0.405/
read and write RDF without complication 
----
Simo-Wrapper-0.0209
http://search.cpan.org/~kimoto/Simo-Wrapper-0.0209/
Object wrapper to manipulate attrs and methods. 
----
Sort-DataTypes-2.04
http://search.cpan.org/~sbeck/Sort-DataTypes-2.04/
Sort a list of data using methods relevant to the type of data 
----
String-BufferStack-1.14
http://search.cpan.org/~alexmv/String-BufferStack-1.14/
Nested buffers for templating systems 
----
Template-Plugin-MultiMarkdown-0.01
http://search.cpan.org/~andrewf/Template-Plugin-MultiMarkdown-0.01/
----
Template-Plugin-MultiMarkdown-0.02
http://search.cpan.org/~andrewf/Template-Plugin-MultiMarkdown-0.02/
TT plugin for Text::MultiMarkdown 
----
Template-Plugin-NDS_Multi-3.00
http://search.cpan.org/~sbeck/Template-Plugin-NDS_Multi-3.00/
Interface to Data::NDS::Multi* modules 
----
Term-ANSIColor-Markup-0.05
http://search.cpan.org/~kentaro/Term-ANSIColor-Markup-0.05/
Colorize tagged strings for screen output 
----
Test-Grian-Data-Dumper-0.04
http://search.cpan.org/~grian/Test-Grian-Data-Dumper-0.04/
Perl extension for blah blah blah 
----
Text-RewriteRules-0.18
http://search.cpan.org/~ambs/Text-RewriteRules-0.18/
A system to rewrite text using regexp-based rules 
----
WebService-Solr-0.04
http://search.cpan.org/~bricas/WebService-Solr-0.04/
Module to interface with the Solr (Lucene) webservice 
----
XML-TreePP-0.38
http://search.cpan.org/~kawasaki/XML-TreePP-0.38/
Pure Perl implementation for parsing/writing XML documents 
----
ZConf-1.0.0
http://search.cpan.org/~vvelox/ZConf-1.0.0/
A configuration system allowing for either file or LDAP backed storage. 
----
ZConf-Weather-0.0.0
http://search.cpan.org/~vvelox/ZConf-Weather-0.0.0/


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: Tue, 03 Mar 2009 00:55:39 GMT
From: mike <no_th@nks.org>
Subject: open for writing without immediately erasing
Message-Id: <m3sklva0hi.fsf@localhost.localdomain>


is there a way to do 'open(FH, ">", x)' without erasing what's in the
file?  I want to open a file for writing then when I actually do the
write, keep replacing just the first line (all that's ever in the file is
a single line at the top) - but I don't want the (original) first line
erased until I do my first new write.

I tried ">>" and iterations of "seek(FH, -20, 0);" fiddling with
position/whence but it seems (to me) that with ">>" perl treats the
'beginning' of the file as whatever position followed what existed in the
file when it was opened; iow I can't go to absolute 0 in the file (or
rather am having trouble figuring out how to go to 0).

thanks.

-- 


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

Date: Mon, 02 Mar 2009 17:04:47 -0800
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: open for writing without immediately erasing
Message-Id: <Qm%ql.18277$l71.8474@newsfe23.iad>

mike wrote:

> 
> is there a way to do 'open(FH, ">", x)' without erasing what's in the
> file?  I want to open a file for writing then when I actually do the
> write, keep replacing just the first line (all that's ever in the file
> is a single line at the top) - but I don't want the (original) first
> line erased until I do my first new write.
> 
> I tried ">>" and iterations of "seek(FH, -20, 0);" fiddling with
> position/whence but it seems (to me) that with ">>" perl treats the
> 'beginning' of the file as whatever position followed what existed in
> the file when it was opened; iow I can't go to absolute 0 in the file
> (or rather am having trouble figuring out how to go to 0).
> 
> thanks.
> 
> --

Open with +< or +> to open for read and write (for overwrite, but not
append).  +> will open and create (if the file doesn't exist) and
otherwise will truncate (which you seem to not want), so try +<.  Open
the file, read in the current value and write the new value.  Yes, you
should also read up on seek() as well as use the now preferred 3
argument open.


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

Date: Tue, 03 Mar 2009 01:04:30 GMT
From: ddunham@taos.com (Darren Dunham)
Subject: Re: open for writing without immediately erasing
Message-Id: <ym%ql.13185$8_3.6645@flpi147.ffdc.sbc.com>

Nathan Keel <nat.k@gm.ml> wrote:
> Open with +< or +> to open for read and write (for overwrite, but not
> append).  +> will open and create (if the file doesn't exist) and
> otherwise will truncate (which you seem to not want), so try +<.  Open
> the file, read in the current value and write the new value.  Yes, you
> should also read up on seek() as well as use the now preferred 3
> argument open.

And then you'll probably want to truncate() as well.  Otherwise if you
write a short line while a longer line was present, it'll leave remnants
past the end of the recent write.

-- 
Darren


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

Date: Mon, 02 Mar 2009 20:35:16 -0600
From: Chris Mattern <syscjm@sumire.gwu.edu>
Subject: Re: open for writing without immediately erasing
Message-Id: <slrngqp5r2.hjn.syscjm@sumire.gwu.edu>

On 2009-03-03, mike <no_th@nks.org> wrote:
>
> is there a way to do 'open(FH, ">", x)' without erasing what's in the
> file?  I want to open a file for writing then when I actually do the
> write, keep replacing just the first line (all that's ever in the file is
> a single line at the top) - but I don't want the (original) first line
> erased until I do my first new write.
>
> I tried ">>" and iterations of "seek(FH, -20, 0);" fiddling with
> position/whence but it seems (to me) that with ">>" perl treats the
> 'beginning' of the file as whatever position followed what existed in the
> file when it was opened; iow I can't go to absolute 0 in the file (or
> rather am having trouble figuring out how to go to 0).
>
I recommend Tie::File.

-- 
             Christopher Mattern

NOTICE
Thank you for noticing this new notice
Your noticing it has been noted
And will be reported to the authorities


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

Date: Mon, 02 Mar 2009 23:01:51 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: open for writing without immediately erasing
Message-Id: <x7r61fqmog.fsf@mail.sysarch.com>

>>>>> "CM" == Chris Mattern <syscjm@sumire.gwu.edu> writes:

  CM> On 2009-03-03, mike <no_th@nks.org> wrote:
  >> 
  >> is there a way to do 'open(FH, ">", x)' without erasing what's in the
  >> file?  I want to open a file for writing then when I actually do the
  >> write, keep replacing just the first line (all that's ever in the file is
  >> a single line at the top) - but I don't want the (original) first line
  >> erased until I do my first new write.
  >> 
  >> I tried ">>" and iterations of "seek(FH, -20, 0);" fiddling with
  >> position/whence but it seems (to me) that with ">>" perl treats the
  >> 'beginning' of the file as whatever position followed what existed in the
  >> file when it was opened; iow I can't go to absolute 0 in the file (or
  >> rather am having trouble figuring out how to go to 0).
  >> 
  CM> I recommend Tie::File.

the OP isn't clear about what he really wants. 

  >> keep replacing just the first line (all that's ever in the file is
  >> a single line at the top)

if all he really has is a single line then why is he worrying about
overwriting it? and saying he only has a single line at the top of the
file makes little sense as a single line is ALWAYS at the top (and the
bottom) of the file. if he always wants the file in a known state then
Tie::File may not be good enough unless it locks it and all readers obey
the lock (not likely).

File::Slurp's write_file with the atomic option would do the trick. it
writes to a temp file and does a rename to the original file name which
is an atomic operation. then the file is always in a known and clean
state. but the OP still needs to clear up the muddy requirements IMO.

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: Mon, 2 Mar 2009 22:34:29 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl dates: a notify alert window
Message-Id: <lg3u76-37a.ln1@osiris.mauzo.dyndns.org>


Quoth cartercc <cartercc@gmail.com>:
> On Mar 2, 3:25 pm, Jürgen Exner <jurge...@hotmail.com> wrote:
> 
> > Or even better use an array slice:
> >         my ($hour, $wday) = localtime(time)[2,6];

It's a list slice, and it needs another set of parens:

    my ($hour, $wday) = (localtime(time))[2,6];

Of course the (time) is optional:

    my ($hour, $day) = (localtime)[2,6];

> > to extract exactly those elements you are interested in.
> 
> ... at the risk of confusing someone who doesn't know what an array
> slice is, as I myself at one time didn't. The differences between
> @var, $var, and $var[0] are confusing enough without throwing in @var
> [0]. ;-)

Programming for those who don't know the language is stupid, especially
when you're talking about a language feature as basic as slices. If you
were objecting to use of *foo{THING}, or %Foo::, or something equally
obscure, you might have a point.

In any case, my objection to the list slice is that noone should be
expected to remember which magic numbers correspond to which elements.
I'd write something more like

    use Time::localtime;

    my $tm = localtime;
    return ($tm->wday == 5 and $tm->hour > 17) 
        or ($tm->wday == 6)
        or ($tm->wday == 0 and $hour < 17);

if I wasn't going to use Date::Calc or DateTime.

Ben



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

Date: Mon, 2 Mar 2009 17:50:58 -0800 (PST)
From: Eric <ericcire@gmail.com>
Subject: Re: perl dates: a notify alert window
Message-Id: <35e40ddc-b1a5-4a9c-92c8-807a5d1a1fe5@v38g2000yqb.googlegroups.com>

On Mar 2, 5:34=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth cartercc <carte...@gmail.com>:
>
> > On Mar 2, 3:25=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
>
> > > Or even better use an array slice:
> > > =A0 =A0 =A0 =A0 my ($hour, $wday) =3D localtime(time)[2,6];
>
> It's a list slice, and it needs another set of parens:
>
> =A0 =A0 my ($hour, $wday) =3D (localtime(time))[2,6];
>
> Of course the (time) is optional:
>
> =A0 =A0 my ($hour, $day) =3D (localtime)[2,6];
>
> > > to extract exactly those elements you are interested in.
>
> > ... at the risk of confusing someone who doesn't know what an array
> > slice is, as I myself at one time didn't. The differences between
> > @var, $var, and $var[0] are confusing enough without throwing in @var
> > [0]. ;-)
>
> Programming for those who don't know the language is stupid, especially
> when you're talking about a language feature as basic as slices. If you
> were objecting to use of *foo{THING}, or %Foo::, or something equally
> obscure, you might have a point.
>
> In any case, my objection to the list slice is that noone should be
> expected to remember which magic numbers correspond to which elements.
> I'd write something more like
>
> =A0 =A0 use Time::localtime;
>
> =A0 =A0 my $tm =3D localtime;
> =A0 =A0 return ($tm->wday =3D=3D 5 and $tm->hour > 17)
> =A0 =A0 =A0 =A0 or ($tm->wday =3D=3D 6)
> =A0 =A0 =A0 =A0 or ($tm->wday =3D=3D 0 and $hour < 17);
>
> if I wasn't going to use Date::Calc or DateTime.
>
> Ben


Perl is a great language but there is no better support community than
the perlers. A. Sinan, this is exactly the kind of elegance that I
suspected was possible and was looking for, Thank you.  Ben, Thank you
for taking a great idea and making it even better. You've taught me
something that I'll likely use in every perl script or program that I
write going forward.

Thanks everyone for the help with this.





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

Date: Mon, 2 Mar 2009 19:12:05 -0800 (PST)
From: cartercc <cartercc@gmail.com>
Subject: Re: perl dates: a notify alert window
Message-Id: <82a9e4a0-98ed-40da-b6fc-e4d355361dc8@q11g2000yqh.googlegroups.com>

On Mar 2, 5:34=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Programming for those who don't know the language is stupid,

Hey, that's what they pay me for! If the people who I work for knew
how to do it for themselves, I'd be out of a job!

> In any case, my objection to the list slice is that noone should be
> expected to remember which magic numbers correspond to which elements.

I cheated. I copied directly from the documentation of localtime().
Did the old Ctl-C, Ctl-V (on a Windows machine). I realize it's not
kosher to cheat, but I won't tell anyone if you won't.

CC


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

Date: Mon, 02 Mar 2009 22:18:53 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: variables that won't stay shared
Message-Id: <Xns9BC2B02163C3Basu1cornelledu@127.0.0.1>

Ben Morrow <ben@morrow.me.uk> wrote in
news:pqrt76-iq9.ln1@osiris.mauzo.dyndns.org: 

> 
> Quoth cartercc <cartercc@gmail.com>:

>> $ perl -cw console
>> Variable "$calendarhash" will not stay shared at CONSOLE.pm line 191
>> (#1)
> <snip>
>> 
>> I want to place the bydate() function WITHIN the lexical scope of the
>> display function, and can't understand why Perl complains. (Actually,
>> I can understand why Perl complains, I just can't understand why it
>> SHOULD complain.)
> 
 ...
>> Is this error message significant?
> 
> Yes, it's absolutely significant. A cutdown version of your code with
> enough program round it to test it might look like:
> 
>     #!/usr/bin/perl -l
> 
>     sub output {
>         my $calendarhash = { @_ };
>         
>         foreach my $key (sort bydate keys %{$calendarhash}) {
>             print $key;
>         }
> 
>         sub bydate {
>             my $date_a = $calendarhash->{$a};
>             my $date_b = $calendarhash->{$b};
>             return $date_a cmp $date_b;
>         }
>     }

<snip output illustrating wrong results>

An alternative if the comparator is long and one does not want to inline 
it with the sort call would be to use:

#!/usr/bin/perl -l

use strict;
use warnings;

sub output {
    my $cal = { @_ };

    my $bydate_comparator = sub {
        my $date_a = $cal->{$a};
        my $date_b = $cal->{$b};
        return $date_a cmp $date_b;
    };
    
    for my $key (sort $bydate_comparator keys %$cal) {
        print $key;
    }
    return;
}

print "FIRST TIME:";
output a => 1, b => 2;

print "SECOND TIME:";
output a => 2, b => 1;

__END__

E:\Home\asu1\Downloads> t.pl
FIRST TIME:
a
b
SECOND TIME:
b
a

-- 
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: Mon, 2 Mar 2009 21:53:53 -0800 (PST)
From: djslls@sina.com
Subject: Re: Why the same script have different behavior when executed in  Normal or Debug mode?
Message-Id: <ad5fe217-9117-4aff-a569-f6d597fd152b@y33g2000prg.googlegroups.com>

After refreshing perl to v5.10, the problem does not exist any more.

Thanks, Bob


On 3=D4=C23=C8=D5, =CF=C2=CE=E712=CA=B112=B7=D6, Bob Walton <bwal...@nospam=
 .invalid> wrote:
> djs...@sina.com wrote:
> > I'm a beginner in perl. I met a problem today. I don't know why. Here
> > is the scenario:
>
> > Test on Windows XP, Perl v5.8.6, Locale: English
>
> > #!/usr/bin/perl
> > use strict;
> > use warnings;
> > use Encode;
> > use Text::ParseWords qw(parse_line);
>
> > my $teststr=3D"123#abc#xyz";
> > $teststr=3Ddecode("ascii",$teststr);   ###(1) pay attention here
>
> > my @testarray=3Dparse_line("#",0,$teststr);
> > my $test=3D$testarray[0];
>
> > print $test;
>
> > in Normal executing mode, I get "123" in output;
> > however, when debugging, I type "p $test" just before the last line, I
> > get nothing. It should be "123".
>
> > What happens here? Is there anybody know something about it?
>
> Well, when I try your program verbatim, it works fine -- "p $test" at
> the indicated point gives "123":
>
> c:\junk>perl -d junk605.pl
>
> Loading DB routines from perl5db.pl version 1.3
> Editor support available.
>
> Enter h or `h h' for help, or `perldoc perldebug' for more help.
>
> main::(junk605.pl:7):   my $teststr=3D"123#abc#xyz";
>
>    DB<1> n
> main::(junk605.pl:8):   $teststr=3Ddecode("ascii",$teststr);   ###(1) pay
> attentio
> n here
>
>    DB<1> n
> main::(junk605.pl:10):  my @testarray=3Dparse_line("#",0,$teststr);
>
>    DB<1> n
> main::(junk605.pl:11):  my $test=3D$testarray[0];
>
>    DB<1> n
> main::(junk605.pl:13):  print $test;
>
>    DB<1> p $test
> 123
>
>    DB<2> n
> 123Debugged program terminated.  Use q to quit or R to restart,
>    use o inhibit_exit to avoid stopping after program termination,
>    h q, h R or h o to get additional info.
>
>    DB<2> q
>
> c:\junk>perl -v
>
> This is perl, v5.10.0 built for MSWin32-x86-multi-thread
> (with 5 registered patches, see perl -V for more detail)
>
> Copyright 1987-2007, Larry Wall
>
> Binary build 1004 [287188] provided by ActiveStatehttp://www.ActiveState.=
com
> Built Sep  3 2008 13:16:37
>
> Perl may be copied only under the terms of either the Artistic License
> or the
> GNU General Public License, which may be found in the Perl 5 source kit.
>
> Complete documentation for Perl, including FAQ lists, should be found on
> this system using "man perl" or "perldoc perl".  If you have access to th=
e
> Internet, point your browser athttp://www.perl.org/, the Perl Home Page.
>
> c:\junk>
>
>
>
> > Thanks in advance!
>
> > ps. if we comment the decode line, the script will work well in both
> > mode.
>
> HTH.
> --
> Bob Walton
> Email:http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Mon, 2 Mar 2009 18:58:23 -0800 (PST)
From: djslls@sina.com
Subject: Why the same script have different behavior when executed in Normal  or Debug mode?
Message-Id: <efb58dad-b899-4ffe-bc58-368aab540635@v5g2000prm.googlegroups.com>

I'm a beginner in perl. I met a problem today. I don't know why. Here
is the scenario:

Test on Windows XP, Perl v5.8.6, Locale: English

#!/usr/bin/perl
use strict;
use warnings;
use Encode;
use Text::ParseWords qw(parse_line);

my $teststr="123#abc#xyz";
$teststr=decode("ascii",$teststr);   ###(1) pay attention here

my @testarray=parse_line("#",0,$teststr);
my $test=$testarray[0];

print $test;

in Normal executing mode, I get "123" in output;
however, when debugging, I type "p $test" just before the last line, I
get nothing. It should be "123".

What happens here? Is there anybody know something about it?

Thanks in advance!

ps. if we comment the decode line, the script will work well in both
mode.


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

Date: Mon, 02 Mar 2009 23:12:19 -0500
From: Bob Walton <bwalton@nospam.invalid>
Subject: Re: Why the same script have different behavior when executed in Normal  or Debug mode?
Message-Id: <49acae2a$0$383$9a6e19ea@unlimited.newshosting.com>

djslls@sina.com wrote:
> I'm a beginner in perl. I met a problem today. I don't know why. Here
> is the scenario:
> 
> Test on Windows XP, Perl v5.8.6, Locale: English
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Encode;
> use Text::ParseWords qw(parse_line);
> 
> my $teststr="123#abc#xyz";
> $teststr=decode("ascii",$teststr);   ###(1) pay attention here
> 
> my @testarray=parse_line("#",0,$teststr);
> my $test=$testarray[0];
> 
> print $test;
> 
> in Normal executing mode, I get "123" in output;
> however, when debugging, I type "p $test" just before the last line, I
> get nothing. It should be "123".
> 
> What happens here? Is there anybody know something about it?

Well, when I try your program verbatim, it works fine -- "p $test" at 
the indicated point gives "123":

c:\junk>perl -d junk605.pl

Loading DB routines from perl5db.pl version 1.3
Editor support available.

Enter h or `h h' for help, or `perldoc perldebug' for more help.

main::(junk605.pl:7):   my $teststr="123#abc#xyz";

   DB<1> n
main::(junk605.pl:8):   $teststr=decode("ascii",$teststr);   ###(1) pay 
attentio
n here

   DB<1> n
main::(junk605.pl:10):  my @testarray=parse_line("#",0,$teststr);

   DB<1> n
main::(junk605.pl:11):  my $test=$testarray[0];

   DB<1> n
main::(junk605.pl:13):  print $test;

   DB<1> p $test
123

   DB<2> n
123Debugged program terminated.  Use q to quit or R to restart,
   use o inhibit_exit to avoid stopping after program termination,
   h q, h R or h o to get additional info.

   DB<2> q

c:\junk>perl -v

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 5 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 1004 [287188] provided by ActiveState 
http://www.ActiveState.com
Built Sep  3 2008 13:16:37

Perl may be copied only under the terms of either the Artistic License 
or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.


c:\junk>


> 
> Thanks in advance!
> 
> ps. if we comment the decode line, the script will work well in both
> mode.

HTH.
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


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

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


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