|
Prev: Running system commands
Next: unicode
From: J?rgen Exner on 20 Jun 2006 10:11 Davy wrote: > Is ^$ mean a NULL line? In Perl a lot depends on context, e.g. scalar versus list context. Therefore you will have to tell us at least a little bit about in which context you stumbled across this character combination. jue
From: Tad McClellan on 20 Jun 2006 13:11 Nick of course <mol10metal(a)hotmail.com> wrote: > Mirco Wahab wrote: [snip full-quote] > A slightly shorter answer to the original question would have been "Yes" That would have been a slightly shorter *wrong* answer. (Since it will match when the string is "\n".) The original (poorly phrased) question was: Is ^$ mean a NULL line? The OP didn't say where these characters are used. I'll guess they are used with the pattern match operator. What does "NULL line" mean? I assume it means the "empty string" (in which case it cannot be a "line" since it has no newline character). So if a boolean response is required then "No" would be the accurate answer. A more helpful answer would be: /^$/ matches the empty string, or the 1-char long string where the 1 char is a newline. -- Tad McClellan SGML consulting tadmc(a)augustmail.com Perl programming Fort Worth, Texas
From: smarkham01 on 20 Jun 2006 16:24 I don't disagree with your definition Tadd, but I'm curious as to what meaning, other than "at the beginning of the (string | line) match the end of (string | line)" "^$" might have? Don't meta-characters remain remain meta-characters where ever they are, unless escaped of preceded by \Q? Tad McClellan wrote: > Nick of course <mol10metal(a)hotmail.com> wrote: > > Mirco Wahab wrote: > > [snip full-quote] > > > A slightly shorter answer to the original question would have been "Yes" > > > That would have been a slightly shorter *wrong* answer. > > (Since it will match when the string is "\n".) > > The original (poorly phrased) question was: > > Is ^$ mean a NULL line? > > The OP didn't say where these characters are used. I'll guess they > are used with the pattern match operator. > > What does "NULL line" mean? > > I assume it means the "empty string" (in which case it cannot be > a "line" since it has no newline character). > > So if a boolean response is required then "No" would be the accurate answer. > > A more helpful answer would be: > > /^$/ matches the empty string, or the 1-char long string where > the 1 char is a newline. > > > -- > Tad McClellan SGML consulting > tadmc(a)augustmail.com Perl programming > Fort Worth, Texas
From: Tad McClellan on 20 Jun 2006 19:55 [Please learn the proper way to compose a followup. Please do this before you make your next followup posting. Text trimmed and rearranged into a sensible order, like is should have been in the first place. ] smarkham01(a)yahoo.com <smarkham01(a)yahoo.com> wrote: > Tad McClellan wrote: >> The original (poorly phrased) question was: >> >> Is ^$ mean a NULL line? >> > I don't disagree with your definition Tadd, s/Tadd/Tad/; > but I'm curious as to what > meaning, other than "at the beginning of the (string | line) match the > end of (string | line)" "^$" might have? Don't meta-characters remain > remain meta-characters where ever they are, No, they don't. What the syntax means depends on what language the characters are in. If you had instead said: Is /^$/ mean a NULL line? Then we would have known that the language the metacharacters appear in is the regex language. (regex language) But if you had said: Is [^$] mean a NULL line? Then the answer would have been: No, it matches any single character that is not a dollar sign. (character class language) And if you had said: Is $vector^$mask mean a NULL line? Then the answer would have been: No, it is a bitwise exclusive-or and the sigil of a variable. (Perl language) Taking just the caret (^) character, it has 3 meanings in 3 different languages: Perl: bitwise exclusive-or regex: beginning of string char class: negates the class Apart from that, even in the *same* language the same character can have different meta-meanings. Take curly braces in Perl for example: part of a hash slice, code block, anonymous hash constructor, variable name delimiter, part of a hash access... So, we cannot talk about Perl symbols without knowing a bit about the context where the symbols appear, hence the encouragement to post Real Perl Code in the Posting Guidelines. Have you seen the Posting Guidelines that are posted here frequently? -- Tad McClellan SGML consulting tadmc(a)augustmail.com Perl programming Fort Worth, Texas
From: David Squire on 21 Jun 2006 19:52
smarkham01(a)yahoo.com wrote: > Thank you Tadd, I've read your guidlines, many times in fact. Notice > that I never post in your moderated group? > > You seem to be back to over-thinking the question. The question didn't > have anything to do with character classes or an XOR! Just two > charactors ^ followed by $. > .... but as Tad explained in detail, the question as posed was unanswerable. Those two characters mean different things in different contexts. The question gave no information on the context. Tad explained the various meanings in several contexts. What exactly do you find unhelpful about that? DS |