On Mon, 2002-02-04 at 16:36, siren jones wrote: > > I'm trying to replace the ^ in a filename, which by the way, I did not > create. > > Here is the filename: Wind19^144^0.0^100^.grib > > Here is my test code: > > $a = "144^0.0^100^"; > $a = s/^/_/g; # replace ^ with underscore character for ftp > print "$a,"\n"; > exit; > > Here is what gets printed: > > 144^0.0^100^ > > > What am I doing wrong with the substitution operator? Thanks in advance.
First off, saying $a = s/^/_/g; means run this substitute against $_ and assign the number of replacements made to $a. What you want to do is bind the substitute command to $a like this: $a =~ s/^/_/g;. Secondly, the ^ character has special meaning in regexes: start of line. To get rid of this special meaning you must escape the character: $a =~ s/\^/_/g;. There are other characters you need to be careful with: +*$()\. Read "perldoc perlre" for more information. ^ is one of the special characters in regexes; it means . -- Today is Setting Orange the 35th day of Chaos in the YOLD 3168 P'tang! Missle Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]