Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: How to print out package code ?

by Martin90 (Sexton)
on Mar 18, 2013 at 20:58 UTC ( #1024150=note: print w/replies, xml ) Need Help??

in reply to Reaped: Re: How to print out package code ?
in thread How to print out package code ?

open MODULE, "perldoc -m Session|" or die "Failed to open pipeline($!) +"; while (<MODULE>) { open(X,"> xxx_dump.txt")|| warn "Fail: ($!)"; print X $_; } close X; close S;
Unfortunatelly prints out "13695" ;/ What is wrong ?

Replies are listed 'Best First'.
Re^3: How to print out package code ?
by choroba (Bishop) on Mar 18, 2013 at 21:20 UTC
    You are opening the file for each line, overwriting the previous output. Open it just once before entering the loop.
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Unfortunatelly, still doesn't work. Now, I am getting empty file ;/
      my @tab; open MODULE, "perldoc -m ModuleX|" or die "Failed to open pipeline +($!)"; open(X,"> xxx_dump.txt")|| warn "Fail: ($!)"; while (<MODULE>) { @tab = split; foreach $_ (@tab) { print X $_; } } close X; close MODULE;
      What is wrong ? Maybe perldoc -m ModuleX doesn't work with used modules ?
        Why did you introduce @tab and the inner loop? This works for me:
        open MODULE, "perldoc -m ModuleX |" or die "Failed to open pipeline($! +)"; open(X,"> xxx_dump.txt")|| warn "Fail: ($!)"; while (<MODULE>) { print X $_; } close X; close S;
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024150]
[Discipulus]: ;=)
[Discipulus]: you are rigth: 2018 had less bad days than 2017, until now!
[Discipulus]: if i had to go to psycho i need to ask why i always end with over complex datastructure: now i have an HoHoAoH in my object

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2018-01-23 09:00 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (242 votes). Check out past polls.