
localfilmmaker
stranger
Apr 19, 2001, 12:09 PM
Post #2 of 2
(797 views)
|
Well, first you would need to start out with quotes like this: $item_XYZ = "apple"; You can use a variable in a string like this "I like $item_XYZ" and get "I like apple", because the variable gets interpolated. But as you've probably noticed, you can't do "I like $item_XYZ_4" and get "I like apple_4". The problem is because it thinks that $item_XYZ_4 is a variable. The way around this is to enclose the variable name in curly braceslike this "I like ${item_XYZ}_4". Here's how to open a file using this technique: $item_XYZ = "apple"; open(FILE, "> ${item_XYZ}_4.txt") or die "can't write to file: $!"; Now, only the ${item_XYZ} is considered a variable, and the rest is just text. -localfilmmaker Spencer Christensen spencer@mecworks.com
|