Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Data::Dumper
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sergey Gernichenko  
View profile   Translate to Translated (View Original)
 More options Jan 29 2011, 4:38 am
Newsgroups: fido7.ru.perl
From: Sergey Gernichenko <Sergey.Gerniche...@p90.f46.n5079.z2.fidonet.org>
Date: Sat, 29 Jan 2011 12:38:42 +0300
Local: Sat, Jan 29 2011 4:38 am
Subject: Data::Dumper
   Доброго времени суток тебе, *All*!

Как сохранить результат работы Data::Dumper в файл так, чтобы нормально был
виден русский текст, а не в виде юникодных кодов?

Делаю так:

use Encode;
use encoding "cp1251", STDOUT=>"cp866";
$d->{russian}='Рашн текст';
#open F,">:utf8","sells";
open F,">:encoding(cp1251)","sells";
print F Data::Dumper->Dump([$d],['d']);
close F

в итоге в файле получаю:
'russian' => "\x{420}\x{430}\x{448}\x{43d}
'russian' => \x{442}\x{435}\x{43a}\x{441}\x{442}",

А как получить исходный "Рашн текст" ?

До скорых встреч, *All*                 С уважением, *Sergey*.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Pozharski  
View profile   Translate to Translated (View Original)
 More options Jan 29 2011, 6:45 am
Newsgroups: fido7.ru.perl
From: Eric Pozharski <Eric.Pozhar...@p101.f94.n463.z2.fidonet.org>
Date: Sat, 29 Jan 2011 14:45:47 +0300
Local: Sat, Jan 29 2011 6:45 am
Subject: Re: Data::Dumper
with <MSGID_2=3A5079=2F46.90_4d43c...@fidonet.org> Sergey Gernichenko wrote:

 SG> Data::Dumper ,
 SG> , ?

 SG> :

 SG> use Encode;
 SG> use encoding "cp1251", STDOUT=>"cp866";

(note , , )
.   .

 SG> $d->{russian}=' ';
 SG> #open F,">:utf8","sells";
 SG> open F,">:encoding(cp1251)","sells";
 SG> print F Data::Dumper->Dump([$d],['d']);
 SG> close F

 SG> :
 SG> 'russian' => "\x{420}\x{430}\x{448}\x{43d}
 SG> 'russian' => \x{442}\x{435}\x{43a}\x{441}\x{442}",

(Subj : " ")   ,
.   Dump ,
s{}{}ge, ( 'open F, ">:encoding"')
.   , *internal encoding*.  
.   .

 SG> " " ?

        print "russian => $d->{russian}";

, .

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sergey Gernichenko  
View profile   Translate to Translated (View Original)
 More options Jan 31 2011, 3:20 pm
Newsgroups: fido7.ru.perl
From: Sergey Gernichenko <Sergey.Gerniche...@p90.f46.n5079.z2.fidonet.org>
Date: Mon, 31 Jan 2011 23:20:18 +0300
Local: Mon, Jan 31 2011 3:20 pm
Subject: Re: Data::Dumper
   Доброго времени суток тебе, *Eric*!

В субботу, 29 января 2011 года, в 14:45, ты писал(а) мне:

 SG>> Как сохранить результат работы Data::Dumper в файл так, чтобы
 SG>> нормально был виден русский текст, а не в виде юникодных кодов?

 SG>> Делаю так:

 SG>> use Encode;
 SG>> use encoding "cp1251", STDOUT=>"cp866";

 EP> (note для экспериментаторов, если такие есть, ессно) Заменить
 EP> кодировку на местную.  Пока не поправил было вообще весело.
В смысле? исходник в виндовой кодировке, вывод в консоль - в досовской. Просто
print "Русский тескст" норамльно отрабатывает.

 SG>> $d->{russian}='Рашн текст';
 SG>> #open F,">:utf8","sells";
 SG>> open F,">:encoding(cp1251)","sells";
 SG>> print F Data::Dumper->Dump([$d],['d']);
 SG>> close F

 SG>> в итоге в файле получаю:
 SG>> 'russian' => "\x{420}\x{430}\x{448}\x{43d}
 SG>> \x{442}\x{435}\x{43a}\x{441}\x{442}",

 EP> (Subj должен был быть: "хочу странного")  В общем, я обломался делать
 EP> работающий пример.  Печатаем вывод Dump в строку, проходим по строке с
 EP> s{}{}ge, потом печатаем эту строку (с 'open F, ">:encoding"') должно
 EP> взлететь.

 EP> Однако, заменять надо на *internal encoding*.
Это как? ведь в строки-то так и хранятся во внутренней кодировке.

 EP> Вот тут я и
 EP> обломался.  Или получается мусор или ничего не меняется.
С присваиванием в переменную вывод сабжа у меня тоже ничего не вышло...

 SG>> А как получить исходный "Рашн текст" ?
 EP>     print "russian => $d->{russian}";
 EP> Мне кажется, ты копаешь не в том направлении.
Предлагаешь переписать функционал Data::Dumper? не, неохота... :)

До скорых встреч, *Eric*                С уважением, *Sergey*.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Pozharski  
View profile   Translate to Translated (View Original)
 More options Feb 3 2011, 1:20 am
Newsgroups: fido7.ru.perl
From: Eric Pozharski <Eric.Pozhar...@p101.f94.n463.z2.fidonet.org>
Date: Thu, 03 Feb 2011 09:20:44 +0300
Local: Thurs, Feb 3 2011 1:20 am
Subject: Re: Data::Dumper
with <MSGID_2=3A5079=2F46.90_4d46f...@fidonet.org> Sergey Gernichenko wrote:
 *SKIP*
 SG>>> use Encode;
 SG>>> use encoding "cp1251", STDOUT=>"cp866";

 EP>> (note , , )
 EP>> .   .
 SG> ? , -
 SG> . print " " .

slrn utf8.   .

*SKIP*

 EP>> , *internal encoding*.
 SG> ? - .

.

 EP>>
 EP>> .   .
 SG>
 SG> ...

        my $dump;
        open my $fh, q|>|, \$dump or die $!;
        print $fh Data::Dumper->Dump([$d],['d']);

 SG>>> " " ?
 EP>>     print "russian => $d->{russian}";
 EP>> , .
 SG> Data::Dumper? , ... :)

perldoc YAML::Syck ( , perldoc YAML::Tiny (
, pure perl)).

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dmitry E. Oboukhov  
View profile   Translate to Translated (View Original)
 More options Feb 4 2011, 3:52 am
Newsgroups: fido7.ru.perl
From: "Dmitry E. Oboukhov" <Dmitry.E.Obouk...@p100.f830.n5020.z2.fidonet.org>
Date: Fri, 04 Feb 2011 11:52:42 +0300
Local: Fri, Feb 4 2011 3:52 am
Subject: Re: Data::Dumper
SG>> в итоге в файле получаю:
SG>> 'russian' => "\x{420}\x{430}\x{448}\x{43d}
SG>> 'russian' => \x{442}\x{435}\x{43a}\x{441}\x{442}",

EP> (Subj должен был быть: "хочу странного")  В общем, я обломался делать
EP> работающий пример.

ничего странного. при отладке вебприложений очень часто хочется
сделать die Dumper и поглядеть что там внутри объектов. соответственно
русские символы хочется видеть правильными.

мы тоже извратнулись на эту тему написав свой регулярник после вызова
дампера.

EP> Печатаем вывод Dump в строку, проходим по строке с
EP> s{}{}ge, потом печатаем эту строку (с 'open F, ">:encoding"') должно
EP> взлететь.  Однако, заменять надо на *internal encoding*.  Вот тут я и
EP> обломался.  Или получается мусор или ничего не меняется.

но с кодировками мы не парились, везде utf8 и все тут.
зачем сейчас лезть в поддержку не utf8? оно все равно помрет

... Природа мудра! у гомиков, либералов и прочих извращенцев обычно нет детей.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Pozharski  
View profile   Translate to Translated (View Original)
 More options Feb 5 2011, 5:26 am
Newsgroups: fido7.ru.perl
From: Eric Pozharski <Eric.Pozhar...@p101.f94.n463.z2.fidonet.org>
Date: Sat, 05 Feb 2011 13:26:41 +0300
Local: Sat, Feb 5 2011 5:26 am
Subject: Re: Data::Dumper
with <MSGID_2=3A5020=2F830.100_06d98...@fidonet.org> Dmitry E  Oboukhov wrote:
 *SKIP*
 EP>> Печатаем вывод Dump в строку, проходим по строке с s{}{}ge,
 EP>> потом печатаем эту строку (с 'open F, ">:encoding"') должно
 EP>> взлететь.  Однако, заменять надо на *internal encoding*.  Вот тут
 EP>> я и обломался.  Или получается мусор или ничего не меняется.

 DEO> но с кодировками мы не парились, везде utf8 и все тут.  зачем
 DEO> сейчас лезть в поддержку не utf8? оно все равно помрет

Вообще-то напоминает чтение текста в cp866 с экрана в cp437.  Неа?  Со
временем научимся читать эти кракозябры напрямую.

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sergey Gernichenko  
View profile   Translate to Translated (View Original)
 More options Feb 5 2011, 2:05 pm
Newsgroups: fido7.ru.perl
From: Sergey Gernichenko <Sergey.Gerniche...@p90.f46.n5079.z2.fidonet.org>
Date: Sat, 05 Feb 2011 22:05:32 +0300
Local: Sat, Feb 5 2011 2:05 pm
Subject: Re: Data::Dumper
   Доброго времени суток тебе, *Dmitry*!

В пятницу, 04 февраля 2011 года, в 11:52, ты писал(а) Eric Pozharski:

 DEO> мы тоже извратнулись на эту тему написав свой регулярник после вызова
 DEO> дампера.
Дай, пожалуйста, работающий пример такой регулярки. У меня не получилось
сделать.

До скорых встреч, *Dmitry*              С уважением, *Sergey*.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dmitry E. Oboukhov  
View profile   Translate to Translated (View Original)
 More options Feb 6 2011, 10:15 am
Newsgroups: fido7.ru.perl
From: "Dmitry E. Oboukhov" <Dmitry.E.Obouk...@p100.f830.n5020.z2.fidonet.org>
Date: Sun, 06 Feb 2011 18:15:01 +0300
Local: Sun, Feb 6 2011 10:15 am
Subject: Re: Data::Dumper
EP>>> Печатаем вывод Dump в строку, проходим по строке с s{}{}ge,
EP>>> потом печатаем эту строку (с 'open F, ">:encoding"') должно
EP>>> взлететь.  Однако, заменять надо на *internal encoding*.  Вот тут
EP>>> я и обломался.  Или получается мусор или ничего не меняется.

DEO>> но с кодировками мы не парились, везде utf8 и все тут.  зачем
DEO>> сейчас лезть в поддержку не utf8? оно все равно помрет

EP> Вообще-то напоминает чтение текста в cp866 с экрана в cp437.  Hеа?  Со
EP> временем научимся читать эти кракозябры напрямую.

суть в том что внутренности самого скрипта надо в любом случае делать
в utf8,
а вот со внешним миром можно общаться с установкой encoding'ов в
значение соответствующее локали. тогда можно думать только об utf8, а
о том как подать это пользователю можно уже не париться

... Слабый пол сильнее сильного в силу слабости сильного пола к слабому.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Dmitry E. Oboukhov  
View profile   Translate to Translated (View Original)
 More options Feb 6 2011, 10:31 am
Newsgroups: fido7.ru.perl
From: "Dmitry E. Oboukhov" <Dmitry.E.Obouk...@p100.f830.n5020.z2.fidonet.org>
Date: Sun, 06 Feb 2011 18:31:58 +0300
Local: Sun, Feb 6 2011 10:31 am
Subject: Re: Data::Dumper
On 22:05 Sat 05 Feb     , Sergey Gernichenko wrote:
SG> , *Dmitry*!

SG> , 04 2011 , 11:52, ( ) Eric Pozharski:

DEO>>
DEO>> .
SG> , , .
SG> .

$dump  =~ s/(\\x\{[\da-fA-F]+\})/eval "qq{$1}"/eg;

/ee , -
,
, :)

:

:

sub StringDumper
{
    my $dump = Dumper(@_);
    $dump  =~ s/(\\x\{[\da-fA-F]+\})/eval "qq{$1}"/eg;
    $dump;

}

my $test = {
    => ' ',

};

print StringDumper $test;
print Dumper $test;

:

{
  " " => " "

}

{
  "\x{442}\x{435}\x{441}\x{442}" =>
"\x{437}\x{43d}\x{430}\x{447}\x{435}\x{43d}\x{438}\x{435}"

}

... , , !

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Eric Pozharski  
View profile   Translate to Translated (View Original)
 More options Feb 7 2011, 7:28 am
Newsgroups: fido7.ru.perl
From: Eric Pozharski <Eric.Pozhar...@p101.f94.n463.z2.fidonet.org>
Date: Mon, 07 Feb 2011 15:28:54 +0300
Local: Mon, Feb 7 2011 7:28 am
Subject: Re: Data::Dumper
with <MSGID_2=3A5020=2F830.100_64428...@fidonet.org> Dmitry E  Oboukhov wrote:
*SKIP*

 DEO> суть в том что внутренности самого скрипта надо в любом случае
 DEO> делать в utf8, а вот со внешним миром можно общаться с установкой
 DEO> encoding'ов в значение соответствующее локали. тогда можно думать
 DEO> только об utf8, а о том как подать это пользователю можно уже не
 DEO> париться

Вот это как раз то, чего мне в понималке то и не хватало.  Now, I feel
much better.

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »