App-FileTools-BulkRename

 view release on metacpan or  search on metacpan

lib/App/FileTools/BulkRename/UserCommands.pm  view on Meta::CPAN

    if( LIST )
      { my @dat = read_file($fil);
	my @ret;
	foreach my $line (@dat)
	  {
	    chomp $line;
	    utf8::decode($line);
	    utf8::decode($line);
	    push @ret,$line;
	  }
      }
  }

sub _USER::clip
  { my $out = Clipboard::paste();
    # no idea why I need to do this TWICE!
    utf8::decode($out);
    utf8::decode($out);

    if( VOID )
      { $_ = $out }
    if( SCALAR )
      { return $out }
    if( LIST )
      { return split("\n",$out); }
  }


# sub clip
#   { my $pat  = shift;
#     my $clip = Clipboard::paste();

#     if( SCALAR )
#       {
# 	return $clip unless defined $pat;
# 	my @list = ($clip =~ m($pat)mg);
# 	return join '',@list;
#       }

#     if( LIST )

# 	if( defined $pat )
#       {
# 	my @list = ($out =~ m($pat)mg);
# 	my $cap	 = $#+;

# 	print Dumper(\$pat,\$out,\@list,\$cap);
# 	exit -1;
#       }

#     # SCALARREF and ARRAYREF are autogenerated, so we don't
#     # bother defining them.
#     return
#       (
# 	::SCALAR  { $out		}
# 	::LIST    { split("\n",$out)	}
# 	::HASHREF { {}			}
#       );
#   }

use Data::Dumper;

sub _USER::rd
  { my @dirs = @_;

    push @dirs,$_ if !@dirs && defined($_);
    push @dirs,"." if !@dirs;

    my @ret;
    for my $dir (@dirs)
      {
	for my $ent (sort(read_dir($dir)))
	  {
	    utf8::decode($ent);
	    utf8::decode($ent);
	    push @ret, $ent;
	  }
      }

    if( VOID )
      { return modifiable($_[0], $_) = join("\n",@ret)."\n"; }
    if( SCALAR )
      { return join("\n",@ret)."\n"; }
    if( LIST )
      { return @ret; }
  }

1;



( run in 0.427 second using v1.01-cache-2.11-cpan-39bf76dae61 )