User Tools

Site Tools


kurs:commen_path

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

kurs:commen_path [2014/09/10 21:22] (current)
Line 1: Line 1:
 +<​code>​
 +use strict;
 +use warnings;
 +
 +my @files = (
 +   '/​a/​b/​12.jpg',​
 +   '/​a/​b/​c/​d/​12.jpg',​
 +   '/​a/​b/​c/​12.jpg',​
 +   '/​a/​b/​e/​12.jpg',​
 +   '/​a/​b/​c/​f/​12.jpg',​
 +   '/​a/​b/​e/​12.jpg',​
 +   '/​a/​b/​12.jpg',​
 +   '/​b/​12.jpg',​
 +   );
 +
 +my $cp = 0;
 +foreach my $file (@files) {
 + $file =~ m#(.*/)#;
 + $cp = $1 if $cp eq '​0';​ # only for the first run
 + $cp = $1 if (length($cp) > length($1));​
 + print "$1 $file\n";​
 +}
 +
 +print "​Common Path is $cp\n";​
 +</​code>​
 +<​code>​
 +use strict;
 +use warnings;
 +use Data::​Dumper;​
 +
 +my $h = {
 +  '/'​ => 
 +    {a => [12, 13],
 +    b => [14]},
 +  };
 +  ​
 +print Dumper $h;
 +</​code>​
 +
 +
  
kurs/commen_path.txt ยท Last modified: 2014/09/10 21:22 (external edit)