AvanTTix has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to remove a text string using the "~s///g" syntax from a list of directory paths which is stored in an array, and it's just not working.
I googled this topic for hours, double-checked my syntax over and over, but I just don't understand what I'm doing wrong.
Before I go down the road of using "substr" & "index", I'd like to see if anyone has any input/thoughts/suggestions on this.
The result makes no sense to me, and I cannot figure out what I'm doing wrong.# List of Directories within ACE Directory Template my @ACETmpltDirs = ("./dataoper/stagecdm.aceprd/stagepgms"); my $ACETmpltDir; # ACE Environment my $ACEEnvironment = "aceprd"; # Deal with each Directory within ACE Directory Template foreach $ACETmpltDir (@ACETmpltDirs) { if (index($ACETmpltDir,".$ACEEnvironment") == -1) { print "no env: $ACETmpltDir"; } elsif (index($ACETmpltDir,".$ACEEnvironment") != -1) { print "env : $ACEEnvironment\n"; print "w/ env : $ACETmpltDir\n"; $ACETmpltDir = ~s/$ACEEnvironment//g; print "w/o env: $ACETmpltDir\n"; } }
env : aceprd w/ env : ./dataoper/stagecdm.aceprd/stagepgms Use of uninitialized value in substitution (s///) at ./acedirs_build l +ine 192. w/o env: 18446744073709551615
Line 192 is "$ACETmpltDir = ~s/$ACEEnvironment//g;".
Any help/insight would be very much appreciated!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Use of uninitialized value in substitution (s///)
by BrowserUk (Patriarch) on Oct 06, 2011 at 23:57 UTC | |
by AvanTTix (Initiate) on Oct 07, 2011 at 00:02 UTC | |
by Anonymous Monk on Oct 07, 2011 at 02:36 UTC | |
Re: Use of uninitialized value in substitution (s///)
by armstd (Friar) on Oct 07, 2011 at 04:34 UTC |
Back to
Seekers of Perl Wisdom