in reply to Remove a common prefix from two strings
No need to disable warnings, you don't need chr at all:
#!/usr/bin/perl use warnings; use strict; my $str0 = "C:/Build~~/Win/App/Experiments/1_0/"; my $str1 = "${str0}Experiments/Blood Pressure/_pieces"; my $str2 = "${str0}temp/Blood Pressure/_pieces"; my $commonLen = 0; ($str0 ^ $str1) =~ /^(\0*)/; $commonLen = $+[0]; my $commonStr = substr $str1, 0, $commonLen, ""; substr $str2, 0, $commonLen, ""; print "Common: $commonStr\n"; print "Tail 1: $str1\n"; print "Tail 2: $str2\n";
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Remove a common prefix from two strings
by GrandFather (Saint) on Aug 05, 2005 at 02:26 UTC |