pugs-6.2.8 problem with file slurp.

8 views
Skip to first unread message

Vadim Konovalov

unread,
Jul 20, 2005, 7:26:49 AM7/20/05
to perl6-c...@perl.org
I was trying using pugs at work and stepped into a problem.

I am reading a file with
my @titles = @*ARGS[1].slurp;
and then just
@titles.say

I am very fond of such a quick way of reading a file instead of every time
dance of "$fh = open...; <$fh>"

a problem is - my file contains characters /[\x80-\xFF]/, and all that
characters get replaced with the space.

There is something with binmode, encoding, unicode, but I just want get
binary stream out of my file.

Is it possible with "slurp"?

Another problem:
pugs -we "@*ARGS[0].say" foobarfluffy
outputs foobarfluffy as expected, whereas
pugs -we "@*ARGS[0].say" -foobarfluffy
outputs -f

TIA,
Vadim

Adriano Ferreira

unread,
Jul 20, 2005, 3:56:13 PM7/20/05
to perl6-c...@perl.org, Konovalov, Vadim
On 7/20/05, Konovalov, Vadim <vkono...@spb.lucent.com> wrote:
> a problem is - my file contains characters /[\x80-\xFF]/, and all that
> characters get replaced with the space.

> Is it possible with "slurp"?

What you want should be something like

"filename".slurp(:raw)

if Perl 6 is going to follow Perl6::Slurp according to Damian's CPAN
module. But it is not supported yet by Pugs, I think. Currently,
"slurp" accepts an only parameter (a filename or a handle). By now,
this seems to works:

open("filename", :raw).slurp()

Not so short, but at least it is there.

Regards,
Adriano.

Reply all
Reply to author
Forward
0 new messages