[SP-pm] printenv em perl?

Thiago Glauco Sanchez thiagoglauco at ticursos.net
Sun Jun 20 15:17:46 PDT 2010


Te pago uma breja/choop no ES!!!

Em 20/06/2010 19:11, Daniel de Oliveira Mantovani escreveu:
> Arghhh!! Esqueci de retirar um espaço,
>
> perl -E 'say for keys%main::'
>
> -1 :D
>
> 2010/6/20 Daniel de Oliveira Mantovani<daniel.oliveira.mantovani em gmail.com>:
>    
>> perl -E 'say for keys %main::'
>>
>> 2010/6/20 Thiago Glauco Sanchez<thiagoglauco em ticursos.net>:
>>      
>>> Outch.. magoa mandar googar...
>>>
>>> perl -E 'map{ say } keys %main::'
>>>
>>> é isso???
>>>
>>> Diminui esse Mantovani!!!!
>>>
>>>
>>> Em 20/06/2010 19:00, Thiago Glauco Sanchez escreveu:
>>>        
>>>> Em 20/06/2010 18:52, Daniel de Oliveira Mantovani escreveu:
>>>>          
>>>>> ...
>>>>>
>>>>> Você quer hackear a tabela de símbolos...
>>>>>
>>>>> http://lmgtfy.com/?q=Perl+symbol+tables
>>>>>
>>>>>
>>>>>
>>>>> 2010/6/20 jimmy<jimmy.tty em gmail.com>:
>>>>>            
>>>>>> On Sun, Jun 20, 2010 at 05:34:20PM -0300, Thiago Glauco Sanchez wrote:
>>>>>>              
>>>>>>> Em 20/06/2010 15:25, Nelson Ferraz escreveu:
>>>>>>>                
>>>>>>>> Em 20 de junho de 2010 20:15, jimmy<jimmy.tty em gmail.com>      escreveu:
>>>>>>>>
>>>>>>>>                  
>>>>>>>>> Saudações amigos,
>>>>>>>>>
>>>>>>>>> Ando procurando uma forma de fazer em perl algo parecido com o
>>>>>>>>> comando
>>>>>>>>> printenv do coreutils faz no shell
>>>>>>>>>
>>>>>>>>>                    
>>>>>>>> Let me google that for you:
>>>>>>>>
>>>>>>>> http://lmgtfy.com/?q=printenv+perl
>>>>>>>> _______________________________________________
>>>>>>>> SaoPaulo-pm mailing list
>>>>>>>> SaoPaulo-pm em pm.org
>>>>>>>> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>>>>>>>>
>>>>>>>>
>>>>>>>>                  
>>>>>>> Você está procurando algo como:
>>>>>>>
>>>>>>> perl -M5.12.0 -e 'map { say "$_ =>      $ENV{$_}" } keys %ENV'
>>>>>>>
>>>>>>> ????
>>>>>>>                
>>>>>> Não, no caso eu "desconheço" as variáveis e funções exportadas também
>>>>>> porque estou usando um shell perl e fico fazendo testes com ele aberto,
>>>>>> chega o momento que não sei que pacotes, variáveis e funções já tenho
>>>>>> definidos no interpretador.
>>>>>>
>>>>>>              
>>>> Você quer saber quais as funções/módulos você carregou no seu name space?
>>>>          
>>>>>> Se alguém já usou o builtin "set" do bash, ele mostra além das variáveis
>>>>>> as funções correntes.
>>>>>>
>>>>>> tentando exemplificar com código:
>>>>>>
>>>>>> -----------------------------------------------------------------------
>>>>>> #!/usr/bin/perl
>>>>>>
>>>>>> use strict;
>>>>>> use warnings;
>>>>>> use Data::Dumper;
>>>>>>
>>>>>> use Dumpvalue;
>>>>>> my $dumper = Dumpvalue->new();
>>>>>>
>>>>>> sub _print {
>>>>>>     print(qq(sub\n));
>>>>>> }
>>>>>>
>>>>>> our($STRING);
>>>>>> $STRING = q(APENAS PARA TESTE);
>>>>>>
>>>>>> $dumper->dumpvars(q(:main));
>>>>>> -----------------------------------------------------------------------
>>>>>>
>>>>>> obtenho como saída:
>>>>>>
>>>>>> -----------------------------------------------------------------------
>>>>>>
>>>>>> $/ = '
>>>>>> '
>>>>>> FileHandle(stderr) =>    fileno(2)
>>>>>> %SIG = (
>>>>>>    'ABRT' =>    undef
>>>>>>    'ALRM' =>    undef
>>>>>>    'BUS' =>    undef
>>>>>>    'CHLD' =>    undef
>>>>>>    'CLD' =>    undef
>>>>>>    'CONT' =>    undef
>>>>>>    'FPE' =>    'IGNORE'
>>>>>>    'HUP' =>    undef
>>>>>>    'ILL' =>    undef
>>>>>>    'INT' =>    undef
>>>>>>    'IO' =>    undef
>>>>>>    'IOT' =>    undef
>>>>>>    'KILL' =>    undef
>>>>>>    'NUM32' =>    undef
>>>>>>    'NUM33' =>    undef
>>>>>>    'NUM34' =>    undef
>>>>>>    'NUM36' =>    undef
>>>>>>    'NUM37' =>    undef
>>>>>>    'NUM38' =>    undef
>>>>>>    'NUM39' =>    undef
>>>>>>    'NUM40' =>    undef
>>>>>>    'NUM41' =>    undef
>>>>>>    'NUM42' =>    undef
>>>>>>    'NUM43' =>    undef
>>>>>>    'NUM44' =>    undef
>>>>>>    'NUM45' =>    undef
>>>>>>    'NUM46' =>    undef
>>>>>>    'NUM47' =>    undef
>>>>>>    'NUM48' =>    undef
>>>>>>    'NUM49' =>    undef
>>>>>>    'NUM50' =>    undef
>>>>>>    'NUM51' =>    undef
>>>>>>    'NUM52' =>    undef
>>>>>>    'NUM53' =>    undef
>>>>>>    'NUM54' =>    undef
>>>>>>    'NUM55' =>    undef
>>>>>>    'NUM56' =>    undef
>>>>>>    'NUM57' =>    undef
>>>>>>    'NUM58' =>    undef
>>>>>>    'NUM59' =>    undef
>>>>>>    'NUM60' =>    undef
>>>>>>    'NUM61' =>    undef
>>>>>>    'NUM62' =>    undef
>>>>>>    'NUM63' =>    undef
>>>>>>    'PIPE' =>    undef
>>>>>>    'POLL' =>    undef
>>>>>>    'PROF' =>    undef
>>>>>>    'PWR' =>    undef
>>>>>>    'QUIT' =>    undef
>>>>>>    'RTMAX' =>    undef
>>>>>>    'RTMIN' =>    undef
>>>>>>    'SEGV' =>    undef
>>>>>>    'STKFLT' =>    undef
>>>>>>    'STOP' =>    undef
>>>>>>    'SYS' =>    undef
>>>>>>    'TERM' =>    undef
>>>>>>    'TRAP' =>    undef
>>>>>>    'TSTP' =>    undef
>>>>>>    'TTIN' =>    undef
>>>>>>    'TTOU' =>    undef
>>>>>>    'UNUSED' =>    undef
>>>>>>    'URG' =>    undef
>>>>>>    'USR1' =>    undef
>>>>>>    'USR2' =>    undef
>>>>>>    'VTALRM' =>    undef
>>>>>>    'WINCH' =>    undef
>>>>>>    'XCPU' =>    undef
>>>>>>    'XFSZ' =>    undef
>>>>>>    '__WARN__' =>    undef
>>>>>> )
>>>>>> $" = ' '
>>>>>> FileHandle(stdout) =>    fileno(1)
>>>>>> $$ = 32174
>>>>>> $^RE_TRIE_MAXBUF = 65536
>>>>>> $! = ''
>>>>>> $^X = '/usr/bin/perl5.12.1'
>>>>>> @_ = (
>>>>>>    0  ':main::'
>>>>>>    1  0
>>>>>>    2  '_'
>>>>>>    3  *main::_
>>>>>> )
>>>>>> FileHandle(STDIN) =>    fileno(0)
>>>>>> $^WARNING_BITS = "\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@\c@"
>>>>>> FileHandle(stdin) =>    fileno(0)
>>>>>> @INC = (
>>>>>>    0  '/usr/lib/perl5/site_perl/5.12.1/i486-linux'
>>>>>>    1  '/usr/lib/perl5/site_perl/5.12.1'
>>>>>>    2  '/usr/lib/perl5/5.12.1/i486-linux'
>>>>>>    3  '/usr/lib/perl5/5.12.1'
>>>>>>    4  '/usr/lib/perl5/site_perl/5.8.7'
>>>>>>    5  '/usr/lib/perl5/site_perl/5.8.8'
>>>>>>    6  '/usr/lib/perl5/site_perl'
>>>>>>    7  '.'
>>>>>> )
>>>>>> %INC = (
>>>>>>    'Carp.pm' =>    '/usr/lib/perl5/5.12.1/Carp.pm'
>>>>>>    'Data/Dumper.pm' =>    '/usr/lib/perl5/5.12.1/i486-linux/Data/Dumper.pm'
>>>>>>    'Dumpvalue.pm' =>    '/usr/lib/perl5/5.12.1/Dumpvalue.pm'
>>>>>>    'Exporter.pm' =>    '/usr/lib/perl5/5.12.1/Exporter.pm'
>>>>>>    'List/Util.pm' =>    '/usr/lib/perl5/5.12.1/i486-linux/List/Util.pm'
>>>>>>    'Scalar/Util.pm' =>    '/usr/lib/perl5/5.12.1/i486-linux/Scalar/Util.pm'
>>>>>>    'XSLoader.pm' =>    '/usr/lib/perl5/5.12.1/XSLoader.pm'
>>>>>>    'bytes.pm' =>    '/usr/lib/perl5/5.12.1/bytes.pm'
>>>>>>    'overload.pm' =>    '/usr/lib/perl5/5.12.1/overload.pm'
>>>>>>    'strict.pm' =>    '/usr/lib/perl5/5.12.1/strict.pm'
>>>>>>    'vars.pm' =>    '/usr/lib/perl5/5.12.1/vars.pm'
>>>>>>    'warnings.pm' =>    '/usr/lib/perl5/5.12.1/warnings.pm'
>>>>>>    'warnings/register.pm' =>
>>>>>>   '/usr/lib/perl5/5.12.1/warnings/register.pm'
>>>>>> )
>>>>>> $0 = 'perl.pl'
>>>>>> $^H = 256
>>>>>> $@ = ''
>>>>>> FileHandle(STDOUT) =>    fileno(1)
>>>>>> $] = 5.012001
>>>>>> $^W = 0
>>>>>> FileHandle(STDERR) =>    fileno(2)
>>>>>> -----------------------------------------------------------------------
>>>>>>
>>>>>> mas a função "_print" que defini e as funções provenientes do
>>>>>> Data:Dumper, não aparecem e era isso que eu estou tentando fazer,
>>>>>> imprimir tudo o que está definido no interpretador naquele momento.
>>>>>>
>>>>>> Se o problema fosse as estruturas de dados, o Data::Dumper resolveria
>>>>>> bem, mas nesse momento os dados são o que menos me interessam.
>>>>>>
>>>>>>              
>>>>>>> --
>>>>>>> Thiago Glauco Sanchez
>>>>>>> Intrutor Perl e Redes
>>>>>>> www.ticursos.net
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>>                
>>>>>> _______________________________________________
>>>>>> SaoPaulo-pm mailing list
>>>>>> SaoPaulo-pm em pm.org
>>>>>> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>>>>>>
>>>>>>              
>>>>>
>>>>>            
>>>>
>>>>          
>>>
>>> --
>>> Thiago Glauco Sanchez
>>> Intrutor Perl e Redes
>>> www.ticursos.net
>>>
>>> _______________________________________________
>>> SaoPaulo-pm mailing list
>>> SaoPaulo-pm em pm.org
>>> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>>>
>>>        
>>
>>
>> --
>> http://www.danielmantovani.com
>> "If you’ve never written anything thoughtful, then you’ve never had
>> any difficult, important, or interesting thoughts. That’s the secret:
>> people who don’t write, are people who don’t think."
>>
>>      
>
>
>    


-- 
Thiago Glauco Sanchez
Intrutor Perl e Redes
www.ticursos.net



More information about the SaoPaulo-pm mailing list