[28222] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9586 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 10 06:07:02 2006

Date: Thu, 10 Aug 2006 03:05:07 -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, 10 Aug 2006     Volume: 10 Number: 9586

Today's topics:
    Re: convert structured strings to possibly deep hash of anno4000@radom.zrz.tu-berlin.de
    Re: Encrypt Windows Password <rprp@gmx.net>
    Re: How to send command line options into test scripts? <yusufm@gmail.com>
    Re: How to send command line options into test scripts? <mumia.w.18.spam+nospam.usenet@earthlink.net>
    Re: match 2D patterns with perl <fangqq@gmail.com>
    Re: match 2D patterns with perl <bik.mido@tiscalinet.it>
    Re: Need help with parsing data <tadmc@augustmail.com>
        new CPAN modules on Thu Aug 10 2006 (Randal Schwartz)
    Re: OO Perl : Struggling with hash data members in my C <mumia.w.18.spam+nospam.usenet@earthlink.net>
        Parsing indented text file <szpara_ga@tlen.pl>
    Re: Parsing indented text file <mumia.w.18.spam+nospam.usenet@earthlink.net>
    Re: Parsing indented text file <bik.mido@tiscalinet.it>
    Re: perl editor <ro.naldfi.scher@gmail.com>
    Re: perl editor <ro.naldfi.scher@gmail.com>
    Re: perl editor <bik.mido@tiscalinet.it>
    Re: Question about Arrays <josef.moellers@fujitsu-siemens.com>
        RPC::XML::Server make_method .xpl files - Not able to m <timo.news@xenomorph.de>
        Stopping the cpan shell from fetching the modules list <mumia.w.18.spam+nospam.usenet@earthlink.net>
    Re: Stopping the cpan shell from fetching the modules l anno4000@radom.zrz.tu-berlin.de
        ||== ,&&== ,|= ,&= <sujay.tukai@gmail.com>
    Re: ||== ,&&== ,|= ,&= <bik.mido@tiscalinet.it>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 10 Aug 2006 09:17:59 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: convert structured strings to possibly deep hash of hashes
Message-Id: <4k0bu7F9ofv5U1@news.dfncis.de>

Uri Guttman  <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "ASU" == A Sinan Unur <1usa@llenroc.ude.invalid> writes:
> 
>   ASU> anno4000@radom.zrz.tu-berlin.de wrote in news:4jum1bF9svqfU1
>   ASU> @news.dfncis.de:
> 
>   >> A. Sinan Unur <1usa@llenroc.ude.invalid> wrote in comp.lang.perl.misc:
>   >>> Uri Guttman <uri@stemsystems.com> wrote in
>   >>> news:x7psf9apgt.fsf@mail.sysarch.com: 
>   >>> 
>   >>> > i have similar code in my autoviv tutorial at:
>   >>> > 
>   >>> >      http://sysarch.com/Perl/autoviv.txt
>   >>> 
>   >>> Looking at your deep_exists sub:
>   >>> 
>   >>> sub deep_exists {
> 
>   ASU> ...
> 
>   >>> 
>   >>> return 0 unless exists( $hash_ref->{$key} ) ;
>   >>> #                  ^^^^^^^^
>   >>> # Shouldn't this be a plain return ?
>   >>> #
>   >> 
>   >> Absolutely not!
> 
>   ASU> ...
> 
>   >> If you called deep_exists in a map like this:
>   >> 
>   >> my @res = map deep_exists( $_, @keys), @hashes;
>   >> 
>   >> you'd expect an array as long as @hashes filled with true and
>   >> false values, not an array of only true values, as many as were
>   >> returned.
> 
> and that could be fixed by calling scalar on deep_exists.
> 
>   ASU> Ah-a! It makes a lot of sense with the usage example you give above.
> 
>   ASU> I can think of some other usage scenarios where the other way
>   ASU> seems to make sense to me, but since I have never written code
>   ASU> that uses a deep_exists style test, I'll assume that the example
>   ASU> you give is the appropriate case to consider. Thank you for the
>   ASU> clarification.
> 
> the issue of what to return for boolean is split. i currently prefer
> plain return as in stem it is needed in message delivery to denote NO
> VALUE returned as those methods are called in list context. return undef
> is a legit return and will cause a return message sent back whereas
> plain return won't.

I can see situations where that behavior would be useful, but I wouldn't
make it the standard.  You wouldn't write

    is_even {
        my $n = shift;
        return if $n % 2;
        return 1;
    }

would you?

Here is my take:

First, the question is clear for functions that return multiple values:
Returning empty is just the special case where the number of returned
values is 0.  If an error situation must be distinguished from that
case, another solution must be sought.

So the question only applies to functions that normally return a single
scalar.  In that case, returning empty should be reserved to signal
failure.  Even if the correct value to return is undef, the function
should return that as a single value.  The user can decide whether
the difference matters:

    my $res = func( ...);

will set $res to undef in failure situations and when a legit undef
is returned.  If the difference doesn't matter, that's all that's
needed.  If the difference does matter, the simple device of

    if ( my ( $res) = func( ...) ) {
        # got a value, use it
    } else {
        # failure
    }

brings it out.

> if you call something as in the map case above or in an arg list and do
> a plain return you get an empty list which will be thrown away. so some
> coders claim the sub should handle that and return a scalar value or a
> real undef. i say the caller should force the scalar context ...

Again, I can see that this might useful behavior for a certain set
of functions, but in general a function that is supposed to return
a scalar should only fail to return a scalar if there is no scalar
to return, not if the scalar happens to be undefined.  

Anno


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

Date: Thu, 10 Aug 2006 09:07:23 +0200
From: Reinhard Pagitsch <rprp@gmx.net>
Subject: Re: Encrypt Windows Password
Message-Id: <44dadb2c$0$15788$14726298@news.sunsite.dk>

Ben Morrow wrote:
> Quoth rpirpag@aon.at:
>> Hello,
>> 
>> Peter.Kramer wrote:
>> > Hello,
>> > I want to write a perl module that encrypts a clear password to a windows 
>> > hash.
>> > I didnt find any algorithm that builds the hash expect copypwd.exe which 
>> > works, but is an external program that does not run as scheduled task.
>> > 
>> > "cleartextpassword " ->
>> > "52616e646f6d4956dc110786f80987daa99d164016ba7d72b24eb2a2931e0ff7"
>> 
>> Copypwd uses the functions from the "Windows Management API" (MS
>> Platform SDK) and from the samsrv.dll.
> 
> ...in which case if you *really* want to you can use Win32::API or XS to
> get at them from Perl.

Not really, the functions are only to get the password hashes from
existing user accounts of a domain and not to pass them a clear text
password and get the encrypted hash. But maybe there are some functions
todo so, but till now I did not find them.


regards,
Reinhard


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

Date: 9 Aug 2006 22:07:17 -0700
From: "yusuf" <yusufm@gmail.com>
Subject: Re: How to send command line options into test scripts?
Message-Id: <1155186437.438640.101590@q16g2000cwq.googlegroups.com>


> Well, if you've read the documentation you know it's not when you call
> prove, because prove just runs your tests. Why is your test data not
> self-contained in the test file? Do you know why you're using this
> approach and not the debugger? I'm beginning to have my doubts.

I can't use preconfigured tests because the tests have to run against
running baseline and candidate processes. So the controller script will
start the baseline and candidate process and then it needs to send in
the process id of each to the test scripts.

I am not using the Test module to test perl class files, but against my
own executables.



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

Date: Thu, 10 Aug 2006 06:39:02 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: How to send command line options into test scripts?
Message-Id: <awACg.6226$xp2.1484@newsread1.news.pas.earthlink.net>

On 08/10/2006 12:07 AM, yusuf wrote:
> [...]
> I am not using the Test module to test perl class files, but against my 
> own executables.
> 

Then create stub scripts that supply the correct parameters.



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

Date: 9 Aug 2006 23:01:31 -0700
From: "FangQ" <fangqq@gmail.com>
Subject: Re: match 2D patterns with perl
Message-Id: <1155189691.684691.112410@h48g2000cwc.googlegroups.com>

no, as I said, I want to match any rectangular structure, no matter
what width/height and positions in the array.



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

Date: 10 Aug 2006 09:48:12 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: match 2D patterns with perl
Message-Id: <shold2dflkqu8apf4v9fc8rki8d9p7k15c@4ax.com>

On 9 Aug 2006 13:44:07 -0700, "FangQ" <fangqq@gmail.com> wrote:

>I am doing a very interesting work. The altimate goal is to generate a
>new style of bitmap font from an existing one. This involves finding
>and replacing 2D patterns.

At first sight I would regard that as a moderately complex task, i.e.
one that doesn't make me feel like looking at it and provide a quick
minimal example, because it would require me a somewhat
above-the-average time and effort to do so. OTOH I remember having
seen similar stuff done in golf!! So it shouldn't be that hard, after
all.

However there's something I don't understand: in your example the
"rectangular shape" is "empty", and the fact that the "top line" gets
untouched makes me think you do *not* consider it to be one such
shape, although it may be, albeit as a degenerate one. But, how 'bout,
say

00000
01110
01110
01110
00000

or

0000000
0111110
0110110
0110110
0111110
0000000

?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 9 Aug 2006 23:49:28 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need help with parsing data
Message-Id: <slrnedlemo.t6f.tadmc@magna.augustmail.com>

Shan <Shani718@gmail.com> wrote:

> Subject: Need help with parsing data


What part is it that you need help with?


(you should use a module that understands XHTML data if you need
 to process XHTML data.
)


> I would like to thank whoever can provide me with the code in advance,


What makes you think that someone will write your program for you?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 10 Aug 2006 04:42:07 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Aug 10 2006
Message-Id: <J3rME7.1J6q@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.

Algorithm-C3-0.04
http://search.cpan.org/~blblack/Algorithm-C3-0.04/
A module for merging hierarchies using the C3 algorithm
----
Bot-BasicBot-Pluggable-Module-Assemble-0.02
http://search.cpan.org/~book/Bot-BasicBot-Pluggable-Module-Assemble-0.02/
IRC frontend to Regexp::Assemble
----
CPAN-Reporter-0.10
http://search.cpan.org/~dagolden/CPAN-Reporter-0.10/
Provides Test::Reporter support for CPAN.pm
----
Chart-Clicker-1.0.1
http://search.cpan.org/~gphat/Chart-Clicker-1.0.1/
Powerful, extensible charting.
----
Class-Framework-1.228
http://search.cpan.org/~thinch/Class-Framework-1.228/
Interface which combines Class::Accessor, fields, and Class::MethodVars to ease creating a Class.
----
Crypt-SaltedHash-0.05
http://search.cpan.org/~esskar/Crypt-SaltedHash-0.05/
Perl interface to functions that assist in working with salted hashes.
----
DateTime-0.33
http://search.cpan.org/~drolsky/DateTime-0.33/
A date and time object
----
DateTime-Format-HTTP-0.37
http://search.cpan.org/~drolsky/DateTime-Format-HTTP-0.37/
Date conversion routines
----
File-Tempdir-0.01
http://search.cpan.org/~nanardon/File-Tempdir-0.01/
----
GStreamer-0.09
http://search.cpan.org/~tsch/GStreamer-0.09/
Perl interface to the GStreamer library
----
Gtk2-MozEmbed-0.06
http://search.cpan.org/~tsch/Gtk2-MozEmbed-0.06/
Perl interface to the Mozilla embedding widget
----
HTML-Form-ForceValue-0.002
http://search.cpan.org/~rjbs/HTML-Form-ForceValue-0.002/
who cares what values are legal, anyway?
----
Handel-0.99_05
http://search.cpan.org/~claco/Handel-0.99_05/
Simple commerce framework with AxKit/TT/Catalyst support
----
Hash-Merge-0.08
http://search.cpan.org/~mneylon/Hash-Merge-0.08/
Merges arbitrarily deep hashes into a single hash
----
IO-Socket-SecureSocks-0.2
http://search.cpan.org/~esskar/IO-Socket-SecureSocks-0.2/
Doing socks over a secure wire (sockss)
----
Image-Magick-Square-1.002
http://search.cpan.org/~leocharre/Image-Magick-Square-1.002/
Takes image and crops to a square
----
Image-Magick-Thumbnail-NotFound-1.008
http://search.cpan.org/~leocharre/Image-Magick-Thumbnail-NotFound-1.008/
Create thumbnails as http requests for them fail
----
Image-MetaData-GQview-1.1
http://search.cpan.org/~kethgen/Image-MetaData-GQview-1.1/
Perl extension for GQview image metadata
----
Image-MetaData-GQview-1.2
http://search.cpan.org/~kethgen/Image-MetaData-GQview-1.2/
Perl extension for GQview image metadata
----
Image-MetaData-GQview-1.3
http://search.cpan.org/~kethgen/Image-MetaData-GQview-1.3/
Perl extension for GQview image metadata
----
Log-Dispatch-2.12
http://search.cpan.org/~drolsky/Log-Dispatch-2.12/
Dispatches messages to one or more outputs
----
Log-Dispatch-Email-EmailSend-0.03
http://search.cpan.org/~drolsky/Log-Dispatch-Email-EmailSend-0.03/
Subclass of Log::Dispatch::Email that uses Email::Send
----
MediaWiki-1.01
http://search.cpan.org/~spectrum/MediaWiki-1.01/
OOP MediaWiki engine client
----
MediaWiki-1.02
http://search.cpan.org/~spectrum/MediaWiki-1.02/
OOP MediaWiki engine client
----
MediaWiki-1.03
http://search.cpan.org/~spectrum/MediaWiki-1.03/
OOP MediaWiki engine client
----
Module-CoreList-2.07
http://search.cpan.org/~rgarcia/Module-CoreList-2.07/
what modules shipped with versions of perl
----
Moose-Policy-0.01
http://search.cpan.org/~stevan/Moose-Policy-0.01/
moose-mounted police
----
Net-OICQ-1.0
http://search.cpan.org/~tangent/Net-OICQ-1.0/
Perl interface to an OICQ server
----
Net-Radius-1.49
http://search.cpan.org/~luismunoz/Net-Radius-1.49/
----
Net-UKDomain-Nominet-Automaton-1.04
http://search.cpan.org/~cliffordj/Net-UKDomain-Nominet-Automaton-1.04/
Module to handle the Nominet Automaton for domain registration and modification.
----
NetSNMP-ASN-5.0301
http://search.cpan.org/~hardaker/NetSNMP-ASN-5.0301/
Perl extension for SNMP ASN.1 types
----
NetSNMP-OID-5.0301
http://search.cpan.org/~hardaker/NetSNMP-OID-5.0301/
Perl extension for manipulating OIDs
----
NetSNMP-TrapReceiver-5.0301
http://search.cpan.org/~hardaker/NetSNMP-TrapReceiver-5.0301/
Embedded perl trap handling for Net-SNMP's snmptrapd
----
NetSNMP-agent-5.0301
http://search.cpan.org/~hardaker/NetSNMP-agent-5.0301/
Perl extension for the net-snmp agent.
----
NetSNMP-default_store-5.0301
http://search.cpan.org/~hardaker/NetSNMP-default_store-5.0301/
Perl extension for Net-SNMP generic storage of global data
----
PAR-Dist-0.15_02
http://search.cpan.org/~smueller/PAR-Dist-0.15_02/
Create and manipulate PAR distributions
----
POE-Component-Client-Traceroute-0.10
http://search.cpan.org/~ahoying/POE-Component-Client-Traceroute-0.10/
a non-blocking traceroute client
----
POE-Component-Client-Traceroute-0.11
http://search.cpan.org/~ahoying/POE-Component-Client-Traceroute-0.11/
A non-blocking traceroute client
----
POE-Component-JobQueue-0.55
http://search.cpan.org/~rcaputo/POE-Component-JobQueue-0.55/
a component to manage queues and worker pools
----
Params-Validate-0.86
http://search.cpan.org/~drolsky/Params-Validate-0.86/
Validate method/function parameters
----
Perlbal-1.43
http://search.cpan.org/~bradfitz/Perlbal-1.43/
Reverse-proxy load balancer and webserver
----
Pugs-Compiler-Rule-0.14
http://search.cpan.org/~fglock/Pugs-Compiler-Rule-0.14/
Compiler for Perl 6 Rules
----
RT-Client-REST-0.25
http://search.cpan.org/~dmitri/RT-Client-REST-0.25/
talk to RT installation using REST protocol.
----
RT-Extension-CommandByMail-0.03
http://search.cpan.org/~jesse/RT-Extension-CommandByMail-0.03/
Change metadata of ticket via email
----
SNMP-5.0301001
http://search.cpan.org/~hardaker/SNMP-5.0301001/
The Perl5 'SNMP' Extension Module for the Net-SNMP SNMP package.
----
Test-Parser-1.3.1
http://search.cpan.org/~bryce/Test-Parser-1.3.1/
Base class for parsing log files from test runs, and displays in an XML syntax.
----
Time-Local-1.13
http://search.cpan.org/~drolsky/Time-Local-1.13/
efficiently compute time from local and GMT time
----
libapreq2-2.08
http://search.cpan.org/~joesuf/libapreq2-2.08/
----
parrot-0.4.6
http://search.cpan.org/~chips/parrot-0.4.6/
----
v6-alpha-0.013
http://search.cpan.org/~fglock/v6-alpha-0.013/


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/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 10 Aug 2006 04:45:15 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: OO Perl : Struggling with hash data members in my Class
Message-Id: <vRyCg.6737$0e5.1153@newsread4.news.pas.earthlink.net>

On 08/09/2006 10:49 PM, Brett.R.Davis@gmail.com wrote:
> You said that you were able to get my original code to work.
> 
> Can you tell me specifically what it was - or was it the items you 
> specified in the message?
> [...]

Don't top post.

Everything was in the message: I assigned $color_set to 
$chash, and I made my_colors() return $self->{MY_COLORS}.




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

Date: 10 Aug 2006 00:29:45 -0700
From: "P" <szpara_ga@tlen.pl>
Subject: Parsing indented text file
Message-Id: <1155194985.108321.298460@i3g2000cwc.googlegroups.com>

Hi,

  I have an input file which looks like this:


aaaaaaa1
  bb1
    ccc1
    ccc2
    ccc3
  bb2
    ccc4
    ccc5
    ccc6
aaaaaaa2
  bb3
    ccc7
    ccc8
    ccc9
  bb4
    ccc10
    ccc11
    ccc12
  bb5
    ccc13
    ccc14
    ccc15
  bb6
    ccc16
    ccc17
    ccc18
aaaaaaa3
 ...

and so on. The letters are the same for the same indent
level. They don't mean that the data there is the same. I am
trying to do the following: as long as the indent level gets
deeper, I want to combine the lines into strings like this:

aaaaaaaa1/bb1/ccc1
aaaaaaaa1/bb1/ccc2
aaaaaaaa1/bb1/ccc3
aaaaaaaa1/bb2/ccc4
 ...
aaaaaaaa2/bb3/ccc7

and so on.

I have tried the following:

+start_of_code

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

my $prev_indent = -1;

my $curr_wanted_string = '';

while (<DATA>) {
    chomp;

    my $curr_indent = length $1 if m/^(\s*)/;

    s/^\s*|\s*$//;


    if ( $curr_indent > $prev_indent ) {
        $curr_wanted_string .= "$_/";
        $prev_indent = $curr_indent;
    }
    else {
        print "[$curr_wanted_string]\n";
        $curr_wanted_string = '';
    }
}


__DATA__
The above input here (didn't want to make post too long).

- end_of_code


The result, though, is that I get only the first string and
then many empty strings:

[aaaaaaa1/bb1/ccc1/]
[]
[]
[]
 ...


Can you please help me fix this?


Thank you,
Angie



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

Date: Thu, 10 Aug 2006 08:41:07 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: Parsing indented text file
Message-Id: <DiCCg.1960$Sn3.1430@newsread3.news.pas.earthlink.net>

On 08/10/2006 02:29 AM, P wrote:
> Hi,
> 
>   I have an input file which looks like this:
> 
> 
> aaaaaaa1
>   bb1
>     ccc1
>     ccc2
>     ccc3
>   bb2
>     ccc4
>     ccc5
>     ccc6
> aaaaaaa2
>   bb3
>     ccc7
>     ccc8
>     ccc9
>   bb4
>     ccc10
>     ccc11
>     ccc12
>   bb5
>     ccc13
>     ccc14
>     ccc15
>   bb6
>     ccc16
>     ccc17
>     ccc18
> aaaaaaa3
> ....
> 
> and so on. The letters are the same for the same indent
> level. They don't mean that the data there is the same. I am
> trying to do the following: as long as the indent level gets
> deeper, I want to combine the lines into strings like this:
> 
> aaaaaaaa1/bb1/ccc1
> aaaaaaaa1/bb1/ccc2
> aaaaaaaa1/bb1/ccc3
> aaaaaaaa1/bb2/ccc4
> ....
> aaaaaaaa2/bb3/ccc7
> 
> and so on.
> 
> I have tried the following:
> 
> +start_of_code
> 
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> my $prev_indent = -1;
> 
> my $curr_wanted_string = '';
> 
> while (<DATA>) {
>     chomp;
> 
>     my $curr_indent = length $1 if m/^(\s*)/;
> 
>     s/^\s*|\s*$//;
> 
> 
>     if ( $curr_indent > $prev_indent ) {
>         $curr_wanted_string .= "$_/";
>         $prev_indent = $curr_indent;
>     }
>     else {
>         print "[$curr_wanted_string]\n";
>         $curr_wanted_string = '';
>     }
> }
> 
> 
> __DATA__
> The above input here (didn't want to make post too long).
> 
> - end_of_code
> 
> 
> The result, though, is that I get only the first string and
> then many empty strings:
> 
> [aaaaaaa1/bb1/ccc1/]
> []
> []
> []
> ....
> 
> 
> Can you please help me fix this?
> 
> 
> Thank you,
> Angie
> 

Ultimately, you want to print a string consisting of three 
parts separated by slashes:

   print "$part1/$part2/$part3\n";

To do this, you need to set up the three parts before 
printing. You'll use a while loop to look at the lines in the 
data, so you'll only see one part at a time which means that 
you have to remember that part when you see it (store it in 
part#).

Let's start with the while loop:

while (<DATA>) {
   chomp;
}

You only want to print when you see something that at the 
second indent-level, e.g. "ccc1," so you should find out the 
current indent level:

while (<DATA>) {
   chomp;
   my $indent_level = 0;
   if (m/^( +)/) {
     $indent_level = length($1) / 2;
   }
   print "$indent_level: $_\n";
}

Now that you know the indent level, you can know which part 
each line belongs to:

while (<DATA>) {
   chomp;
   my $indent_level = 0;
   if (m/^( +)/) {
     $indent_level = length($1) / 2;
   }
   s/^\s*|\s*$//;
   if (0 == $indent_level) { $part1 = $_ }
   if (1 == $indent_level) { $part2 = $_ }
   if (2 == $indent_level) { $part3 = $_ }
}

You only want to print when you've gotten to the last indent 
level, e.g. "ccc3":

while (<DATA>) {
   chomp;
   my $indent_level = 0;
   if (m/^( +)/) {
     $indent_level = length($1) / 2;
   }
   s/^\s*|\s*$//;
   if (0 == $indent_level) { $part1 = $_ }
   if (1 == $indent_level) { $part2 = $_ }
   if (2 == $indent_level) { $part3 = $_ }
   print "$part1/$part2/$part3\n" if ($indent_level == 2);
}

__TA_DA__
:-)

This is not the completed program. Naturally, you'd enable 
strictures and warning first, and you'd have to define $part1, 
$part2 and $part3 before the while loop.

HTH


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

Date: 10 Aug 2006 11:40:02 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Parsing indented text file
Message-Id: <gfvld2p4cafsfklfb1afjc9ev6s2g5h6bo@4ax.com>

On 10 Aug 2006 00:29:45 -0700, "P" <szpara_ga@tlen.pl> wrote:

>and so on. The letters are the same for the same indent
>level. They don't mean that the data there is the same. I am
>trying to do the following: as long as the indent level gets
>deeper, I want to combine the lines into strings like this:

I think that there's a logic flaw in your approach. In fact to make
your text file into a structure as described, and reliably, you must
take into account the number of unindents, which seems possible,
because the indentation seems to always amount to an odd number of
spaces, with each level of indentation being two more spaces than the
former.

Thus the following may get you started:

  
  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  
  my @last;
  while (<>) {
      chomp;
      /^(\s*)(\w+)/ or next;
      my $l=(length $1)>>1;
      print join '/', @last[1..$l], $2;
      $last[$l+1]=$2;
  }
  
  __END__


Seems to work on your data set, but may issue warnings if indentation
is not by one step at a time, which is a condition you may want to
trap to check for malformed data. OTOH the above seems to differ from
your requirements in that appearently you only want to print items on
the third indentation level: the trivial modifications needed to make
it comply are left as an exercise to the reader! ;-)


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 10 Aug 2006 00:27:48 -0700
From: "Ronny" <ro.naldfi.scher@gmail.com>
Subject: Re: perl editor
Message-Id: <1155194868.379439.297390@75g2000cwc.googlegroups.com>

Michele Dondi schrieb:
> jed, and I suspect also vi* and the various incarnations of emacs,
> also recognizes a pattern which one often embeds in a comment (usually
> at the top), like thus
>
>   # -*- Perl -*-
>
> I find this feature very useful for modules, although I may set up
> another association for '.pm'.

I like this too, and this is really one thing I'm missing with jext.

I had a look at jed, but from what I see, jed does not have the feature
to shift a region to the right or the left, isn't it?. I guess this is
something one could add by writing a S-Program, but at least
it doesn't seem to offer this out of the box.

Ronald



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

Date: 10 Aug 2006 00:33:09 -0700
From: "Ronny" <ro.naldfi.scher@gmail.com>
Subject: Re: perl editor
Message-Id: <1155195189.144437.47540@m79g2000cwm.googlegroups.com>

AZSTYX schrieb:
> I use the editor from www.crimson.com, its free and highlights perl
> syntax and optionally saves file sin UNIX or Windows format.

In case you mean The Crimson Editor, the correct link is
http://www.crimsoneditor.com/

I used Crimson Editor too on the rare occasion I was working on
Windoze.
Sadly it is not available for other operating systems.

Ronald



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

Date: 10 Aug 2006 10:33:35 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: perl editor
Message-Id: <nhrld256g8t90vta0i225meshue8biprn5@4ax.com>

On 10 Aug 2006 00:27:48 -0700, "Ronny" <ro.naldfi.scher@gmail.com>
wrote:

>I had a look at jed, but from what I see, jed does not have the feature
>to shift a region to the right or the left, isn't it?. I guess this is
>something one could add by writing a S-Program, but at least
>it doesn't seem to offer this out of the box.

I'm quite sure it has, although I don't actually use. At the very
least it supports rectangular selections, and you can use those. OTOH
it also supports automatic indenting facilities, which generally make
just it a matter of pressing return and tab, speaking of which you can
select a region and indent, or unindent it for what it matters, too.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 10 Aug 2006 10:05:18 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Question about Arrays
Message-Id: <ebepfs$acc$1@nntp.fujitsu-siemens.com>

Big and Blue wrote:
> Guenther Sohler wrote:
>=20
>> sub add_fruits
>> {
>>     my $databaseptr=3Dshift;
>>     push  ... databaseptr .. fruits , "Banana";
>> # C Code would by: database-> fruits +=3D "Banana";
>=20
>=20
>    Then you have a strange C compiler.
>=20
>    +=3D is an integer operation.
>=20
>    "Banana" is a char *  (pointer to a string).
>=20
>    Whereas I expect some C compilers would let you do the  increment by=
=20
> converting the pointer to an integer first I doubt very much whether it=
=20
> would produce any reasonable result.

It's more likely he was talking about C++.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Thu, 10 Aug 2006 09:30:22 +0200
From: "Xeno" <timo.news@xenomorph.de>
Subject: RPC::XML::Server make_method .xpl files - Not able to make system calls
Message-Id: <ebenaf$bqv$1@news01.versatel.de>

Hi,

I am using the Perl Module RCP::XML::Server. There I am using the method 
"add_methods_in_dir". In this directory there are several .xpl files 
located. Each file contains a function which provides functionality for the 
RPC-XML-Client. So far this works fine.
Problem is that I have to make a system call within a function in the .xpl 
file. And exactly this does not work. The function is very simple:

sub ifconfig {
    my $result = `/sbin/ifconfig`;
    return $result;
}

If I call this function within a simple perl script, it works fine. But if 
I call this function within XML-RPC using the .xpl files, it does not work. 
The .xpl file looks like this:

-----
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE methoddef SYSTEM "rpc-method.dtd">
<!--
    Generated automatically by make_method v1.11, Mon Aug  7 18:13:40 2006

    Any changes made here will be lost.
-->
<methoddef>
<name>network.ifconfig</name>
<signature>string</signature>
<help>
Output ifconfig
</help>
<code language="perl">
<![CDATA[
#!/usr/bin/perl
sub ifconfig {
    my $result = `/sbin/ifconfig`;
    return $result;
}
__END__
]]></code>
</methoddef>
-----


The RPC-Client calls the method like this:
$cli = RPC::XML::Client->new('http://localhost:10000/RPCSERV');
$resp = $cli->simple_request('network.ifconfig');

The error (print $RPC::XML::ERROR;) I get is:
-----
RPC::XML::Client::simple_request:
not well-formed (invalid token) at line 3, column 53, byte 285 at 
/usr/share/perl5/RPC/XML/Client.pm line 345
-----

If I make the system call using the function system() instead of 
backqoutes, I do not get any error. Anyway I also do not get any data. The 
result is an empty variable.

Is anybody familiar with this technique and can help me?

Thanks
Xeno 




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

Date: Thu, 10 Aug 2006 07:45:56 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Stopping the cpan shell from fetching the modules list
Message-Id: <UuBCg.1959$Sn3.1580@newsread3.news.pas.earthlink.net>

Almost every time I use the cpan shell to search for some 
modules, it downloads the list of authors and modules. I'm on 
dialup, and this takes some time, and it annoys me.

How do I tell the cpan shell not to do this?




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

Date: 10 Aug 2006 09:25:32 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Stopping the cpan shell from fetching the modules list
Message-Id: <4k0cccF9ofv5U2@news.dfncis.de>

Mumia W. <mumia.w.18.spam+nospam.usenet@earthlink.net> wrote in comp.lang.perl.misc:
> Almost every time I use the cpan shell to search for some 
> modules, it downloads the list of authors and modules. I'm on 
> dialup, and this takes some time, and it annoys me.
> 
> How do I tell the cpan shell not to do this?

I don't think there's an official way, but I'd be amazed if touch-ing
the relevant files didn't fool it.

Anno


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

Date: 9 Aug 2006 23:51:23 -0700
From: "sujay.tukai@gmail.com" <sujay.tukai@gmail.com>
Subject: ||== ,&&== ,|= ,&=
Message-Id: <1155192683.691813.21680@h48g2000cwc.googlegroups.com>

What is the work done by these assignment operators...

            ||==,       &&==,    |=,    &=



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

Date: 10 Aug 2006 09:27:29 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: ||== ,&&== ,|= ,&=
Message-Id: <1nnld2ppb0g8rvops1vgfrouelq2qld9ai@4ax.com>

On 9 Aug 2006 23:51:23 -0700, "sujay.tukai@gmail.com"
<sujay.tukai@gmail.com> wrote:

>What is the work done by these assignment operators...
>
>            ||==,       &&==,    |=,    &=

This is easy:

  $x ||= $y;  # is equivalent to
  $x = $x || $y;  # and the same goes for the other ones

BTW: which was the part in

  perldoc perlop

that was difficult to understand?


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

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


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