summaryrefslogtreecommitdiff
path: root/lib/Text
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1996-03-17 09:33:03 +0000
committerCharles Bailey <bailey@genetics.upenn.edu>1996-03-17 09:33:03 +0000
commit0dbfbeefeba4b4e7aa312cb453da87aff56a7769 (patch)
treecfea1e79e92ac275a11b93726725ad7edf95f2df /lib/Text
parent4a6b6a6c94b931c21d2ab5c7599e2a15ac99171f (diff)
downloadperl-0dbfbeefeba4b4e7aa312cb453da87aff56a7769.tar.gz
Move quotewords() explanation into body of routine
Diffstat (limited to 'lib/Text')
-rw-r--r--lib/Text/ParseWords.pm53
1 files changed, 27 insertions, 26 deletions
diff --git a/lib/Text/ParseWords.pm b/lib/Text/ParseWords.pm
index 97d7beb896..89951387ef 100644
--- a/lib/Text/ParseWords.pm
+++ b/lib/Text/ParseWords.pm
@@ -40,32 +40,6 @@ to be a mis-feature.
string in $_ and then pulling off words a bit at a time until $_
is exhausted.
-The inner "for" loop builds up each word (or $field) one $snippet
-at a time. A $snippet is a quoted string, a backslashed character,
-or an unquoted string. We fall out of the "for" loop when we reach
-the end of $_ or when we hit a delimiter. Falling out of the "for"
-loop, we push the $field we've been building up onto the list of
-@words we'll be returning, and then loop back and pull another word
-off of $_.
-
-The first two cases inside the "for" loop deal with quoted strings.
-The first case matches a double quoted string, removes it from $_,
-and assigns the double quoted string to $snippet in the body of the
-conditional. The second case handles single quoted strings. In
-the third case we've found a quote at the current beginning of $_,
-but it didn't match the quoted string regexps in the first two cases,
-so it must be an unbalanced quote and we croak with an error (which can
-be caught by eval()).
-
-The next case handles backslashed characters, and the next case is the
-exit case on reaching the end of the string or finding a delimiter.
-
-Otherwise, we've found an unquoted thing and we pull of characters one
-at a time until we reach something that could start another $snippet--
-a quote of some sort, a backslash, or the delimiter. This one character
-at a time behavior was necessary if the delimiter was going to be a
-regexp (love to hear it if you can figure out a better way).
-
=head1 AUTHORS
Hal Pomeranz (pomeranz@netcom.com), 23 March 1994
@@ -87,6 +61,33 @@ sub shellwords {
sub quotewords {
+
+# The inner "for" loop builds up each word (or $field) one $snippet
+# at a time. A $snippet is a quoted string, a backslashed character,
+# or an unquoted string. We fall out of the "for" loop when we reach
+# the end of $_ or when we hit a delimiter. Falling out of the "for"
+# loop, we push the $field we've been building up onto the list of
+# @words we'll be returning, and then loop back and pull another word
+# off of $_.
+#
+# The first two cases inside the "for" loop deal with quoted strings.
+# The first case matches a double quoted string, removes it from $_,
+# and assigns the double quoted string to $snippet in the body of the
+# conditional. The second case handles single quoted strings. In
+# the third case we've found a quote at the current beginning of $_,
+# but it didn't match the quoted string regexps in the first two cases,
+# so it must be an unbalanced quote and we croak with an error (which can
+# be caught by eval()).
+#
+# The next case handles backslashed characters, and the next case is the
+# exit case on reaching the end of the string or finding a delimiter.
+#
+# Otherwise, we've found an unquoted thing and we pull of characters one
+# at a time until we reach something that could start another $snippet--
+# a quote of some sort, a backslash, or the delimiter. This one character
+# at a time behavior was necessary if the delimiter was going to be a
+# regexp (love to hear it if you can figure out a better way).
+
local($delim, $keep, @lines) = @_;
local(@words,$snippet,$field,$_);