Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: help with cyrillic characters in odd places

by Aldebaran (Curate)
on Feb 07, 2019 at 00:44 UTC ( [id://1229508]=note: print w/replies, xml ) Need Help??


in reply to Re: help with cyrillic characters in odd places
in thread help with cyrillic characters in odd places

Thx, hippo, this syntax gets us started

my @children = $pt->children;

, but it seems to draw me away from Path::Tiny because @children appears to be a bunch of strings. (Progress is having them all there, so yay that.)

children are /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/caption_filled.gif /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/за
ва‚ /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/изоб€ажение /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/подписи /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/eugene
dyetya is /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/caption_filled.gif
dyetya is /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/захват
Can't locate object method "basename" via package "/home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/захват" (perhaps you forgot to load "/home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/захват"?) at ./7.cw2.pl line 83.
$ 

I suppose one could pull out File::Basename, but that's a module I'm trying to abrogate.

my @children = $vars{cw}->children;
say "children are @children";

foreach my $child (@children) {
  $child = decode( 'UTF-8', $child );
  say "dyetya is $child";
  next unless -d $child;

  my $base_dir = $child->basename;
  say "base dir is $base_dir";
  $vars{$base_dir} = path($child);
  say "dir is $vars{$base_dir}";

}
Update:

I believe that the Path::Tiny way to do this is using the iterator method:

my $iter = $vars{cw}->iterator; while ( my $next = $iter->() ) { say "next is $next"; my $next_decode = decode( 'UTF-8', $next ); my $base = $next->basename(); say "base is $base"; my $base_decode = decode( 'UTF-8', $base ); say "next decode is $next_decode"; say "base decode is $base_decode"; }
next is /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/изоб€ажение
base is изоб€ажение
next decode is /home/bob/2.scripts/pages/7.cw/template_stuff/crosswords/изображение
base decode is изображение

Replies are listed 'Best First'.
Re^3: help with cyrillic characters in odd places
by hippo (Bishop) on Feb 07, 2019 at 10:18 UTC
    but it seems to draw me away from Path::Tiny because @children appears to be a bunch of strings.
    say "children are @children";

    They only appear to be a bunch of strings because you've stringified them in the say statement.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1229508]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-25 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found