Thread Ersetzen von Zeichen "/" In Variablen (9 answers)
Opened by bora99 at 2010-05-10 13:09

bora99
 2010-05-10 13:09
#136954 #136954
User since
2009-12-05
54 Artikel
BenutzerIn
[default_avatar]
Hallo,

Habe folgendes Problem , wenn ich einer Variable Zeichen mit "/" (z.B: Pfad von einem Directory) habe, funktioniert folgende Ersetzung:

Richtiger Output : G:/Dir-Save

Code (perl): (dl )
1
2
3
4
5
6
7
8
my $akt_root_dir  = 'G:/Dir';
my $save_root_dir = 'G:/Dir-Save';

print "Root_Dir       : $akt_root_dir\n";
print "Save_Dir       : $save_root_dir\n";
$akt_save_directory =  $akt_root_dir ;
$akt_save_directory   =~ s#$akt_root_dir#$save_root_dir#g;
print "Pfad-Save      : $akt_save_directory\n";


Zeichen mit "\" funktioniert leider nicht:

Code (perl): (dl )
1
2
3
4
5
6
7
8
my $akt_root_dir  = 'G:\Dir';
my $save_root_dir = 'G:\Dir-Save';

print "Root_Dir       : $akt_root_dir\n";
print "Save_Dir       : $save_root_dir\n";
$akt_save_directory =  $akt_root_dir ;
$akt_save_directory   =~ s#$akt_root_dir#$save_root_dir#g;
print "Pfad-Save      : $akt_save_directory\n"


Falscher Output : G:\Dir , Richtig wäre G:\Dir-Save

gruss,

mod-edit pq: perl-tags hinzugefügt
Last edited: 2010-05-10 13:31:11 +0200 (CEST)

View full thread Ersetzen von Zeichen "/" In Variablen