This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Perl and the fly likes What does $str =~ m/\/// do? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Perl
Bookmark "What does $str =~ m/\/// do?" Watch "What does $str =~ m/\/// do?" New topic
Author

What does $str =~ m/\/// do?

Allen Chan
Ranch Hand

Joined: Jun 07, 2002
Posts: 64
Hi, all,
sorry for another perl question,
what does $str =~ m/shared/ do?
what is teh m option for?
yes, another one,
print qq~ <table>....</table>~
print qq|<table>....</table>|
print <<EOT <table>...</table> EOT
what is the difference between those three?
Thanks all!
Darryl A. J. Staflund
Ranch Hand

Joined: Oct 06, 2002
Posts: 303
Interesting, I didn't know that Perl was talked of at javaranch.com :-) Awesome, as I'm a long-time Perl-coder.
A great site to find answers to your questions about Perl's regular expressions can be found at perldoc.com. In particular, read the following perldoc for answers to your questions:
http://www.perldoc.com/perl5.6.1/pod/perlrequick.html
Cheers,
Darryl
Caitlin Gibson
Greenhorn

Joined: Nov 25, 2002
Posts: 12
what does $str =~ m/shared/ do?
what is the 'm' option for?
yes, another one,
print qq~ <table>....</table>~
print qq|<table>....</table>|
print <<EOT <table>...</table> EOT
what is the difference between those three?

Hi.
The first line of code is looking for the word
'shared' in the contents of $str. The other question is a little more complicated. Rather than
use double quotes ( "" ) to enclose the argument to the print function, you can use ( qq ) which means the same thing. Either of these also allow variable interpolation ( translating a variable to it's value ). A pair of single quotes would be a
( q ) on each side ( which doesn't allow variable interpolation ). The '~' and '|' symbols simply enclose the arguments in the same manner as this would:
print "I am going to the store.";
The last one is known as a 'Here' document and I would write it like this:
print <<EOF;
<TABLE>...</TABLE>
EOF
This saves you the trouble of using a print statement on every line. You must place both the beginning of the 'Here' document and the end against the left-most edge and there cannot be a space between the << symbols and the name of the 'Here' document ( EOF in this example ).
Hope this helps,
-Caitlin.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: What does $str =~ m/\/// do?
 
Similar Threads
Need Help with binding click events to table rows
parsing the xml returned from ajax call
sorting the result
how to parse a xml String?
Get data for child using jdom