I am trying to analyze some syntax I found in a book by breaking it down and making code that uses a subset of those special characters but, I have not been able to manage to get anything running successfully.
Here is the syntax I found in the book.:
Code:
#!/usr/bin/perl
@lines = `perldoc -u -f atan2`;
foreach (@lines) {
s/\w<([^>]+)>/\U$1/g; #This is the line that I am most confused about.
print;
}
For example, here is my failed attempt to modify the above code sample so that it simply converts all the letters to uppercase letters.:
Code:
#!/usr/bin/perl
#@lines = `perldoc -u -f atan2`;
@lines = "one\ntwo\n";
foreach (@lines) {
#s/\w<([^>]+)>/\U$1/g; #This is the line that I am most confused about.
s/\U$1/g;
print;
}
When I attempt to run this code, I get the following error message.:
Substitution replacement not terminated at /tmp/testperlfile.pl line 7.
What must I do differently in order to make my broken-down code work as intended?
Any help in successfully breaking down what I found in the book in order to fully understand it would be greatly appreciated!
Bookmarks