Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Explanation of Perlop Documention

by eibwen (Friar)
on May 10, 2005 at 03:14 UTC ( [id://455411]=perlquestion: print w/replies, xml ) Need Help??

eibwen has asked for the wisdom of the Perl Monks concerning the following question:

The other day I was reading Style geekcode and decided to include my whitespace habits for all operators (not just the few mentioned in the node). I consulted perlop for the complete listing, only to discover that there were a few I either rarely used or simply didn't know. I read the perldoc for these operators, often discovering that I understood them, but didn't recognize the nomenclature (eg named unary operators). During this process I found the documentation for the operators unary - and ... somewhat confusing.

Unary "-" performs arithmetic negation if the operand is numeric. If +the operand is an identifier, a string con- sisting of a minus sign concatenated with the identifier is returned. + Otherwise, if the string starts with a plus or minus, a string starting with the opposite sign is returned. One e +ffect of these rules is that "-bareword" is equivalent to "-bareword".

The part I'm having trouble understanding is: One effect of these rules is that "-bareword" is equivalent to "-bareword". The string text is implies that it's a bareword with quotes added in much the same fashion as <code> tags, however I cannot seem to differentiate between the strings.

If you don't want it to test the right operand till the next evaluation, as in sed, just use three dots ("...") inste +ad of two. In all other regards, "..." behaves just like ".." does.

The above explanation is fairly self-evident; however given the liberal quantities of ellispes in perlop, I'd like confirmation that this is the only passage refering to the ... operator.

Replies are listed 'Best First'.
Re: Explanation of Perlop Documention
by Tanktalus (Canon) on May 10, 2005 at 03:30 UTC

    Try checking the HTML documentation - it parses the perldoc a bit differently and may make a bit more sense ;-). Thus, try perlop. You'll find the first -bareword is not in quotes, which shows a huge difference.

      It's still a bit odd though. The Pod source has what you'd expect:

      One effect of these rules is that C<-bareword> is equivalent to C<"-bareword">.

      The way C<...> snippets are rendered in plain text is to put double quotes round them, but it seems like there's something in there which avoids doing so to a snippet already surrounded by double quotes.

      In the HTML versions code snippets are usually rendered in a fixed-width typeface. Yet in this particular case on both Cpan Search and perldoc.perl.org those snippets aren't distinguished in any way from the surrounding text, but the bitwise negation snippet in the following paragraph is.

      Huh?

      Smylers

Re: Explanation of Perlop Documention
by tlm (Prior) on May 10, 2005 at 09:50 UTC

    ...given the liberal quantities of ellispes in perlop, I'd like confirmation that this is the only passage refering to the ... operator.

    I found one more mention, a few paragraphs below, in the same section:

    [The program above] will print only the line containing "Bar". If the range operator is changed to ... , it will also print the "Baz" line.

    the lowliest monk

Re: Explanation of Perlop Documention
by Steve_p (Priest) on May 10, 2005 at 14:34 UTC

    OK, the first is somewhat unclear. How does the following patch look to you?

    --- perlop.pod.old Tue Mar 29 01:27:36 2005 +++ perlop.pod Tue May 10 09:32:16 2005 @@ -191,7 +191,7 @@ concatenated with the identifier is returned. Otherwise, if the stri +ng starts with a plus or minus, a string starting with the opposite sign is returned. One effect of these rules is that -bareword is equivale +nt -to "-bareword". +to the string "-bareword". Unary "~" performs bitwise negation, i.e., 1's complement. For example, C<0666 & ~027> is 0640. (See also L<Integer Arithmetic> and

    As for the range operator question, actual operators are marked C<op> through perlop.pod. I'd suggest searching for that alone to see where its used.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://455411]
Approved by Tanktalus
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2024-04-25 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found