f



Tcl 8,5 tutorial errata on page "More Examples Of Regular Expressions"

Hi,

In the Tcl 8.5 tutorial, a page titled "More Examples Of Regular Expressions" may contain errata in the following Tcl code:

"

set string "Again and again and again ..."
if { [regexp {(\y\w+\y).+\1} $string => word] } {
    puts "The word $word occurs at least twice"
}

"

You can see that the command 'regexp' sets a value into a variable called '=>'.
This can be proved by executing the following code:

"

set string "Again and again and again ..."
if { [regexp {(\y\w+\y).+\1} $string => word] } {
    puts "The word $word occurs at least twice"
}

upvar #0 "=>" x
puts "$x"

"

I guess that the author meant to write something else?
It doesn't make sense to have a variable named "=>".

Here's a link to the relevant page in the tutorial:
http://www.tcl.tk/man/tcl8.5/tutorial/Tcl20a.html

Thank you.
0
dor9990 (1)
11/11/2013 9:43:08 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

2 Replies
511 Views

Similar Articles

[PageSpeed] 38

On Tuesday, 12 November 2013 08:43:08 UTC+11, dor...@gmail.com  wrote:
> Hi,
>=20
>=20
>=20
> In the Tcl 8.5 tutorial, a page titled "More Examples Of Regular Expressi=
ons" may contain errata in the following Tcl code:
>=20
>=20
>=20
> "
>=20
>=20
>=20
> set string "Again and again and again ..."
>=20
> if { [regexp {(\y\w+\y).+\1} $string =3D> word] } {
>=20
>     puts "The word $word occurs at least twice"
>=20
> }
>=20
>=20
>=20
> "
>=20
>=20
>=20
> You can see that the command 'regexp' sets a value into a variable called=
 '=3D>'.
>=20
> This can be proved by executing the following code:
>=20
>=20
>=20
> "
>=20
>=20
>=20
> set string "Again and again and again ..."
>=20
> if { [regexp {(\y\w+\y).+\1} $string =3D> word] } {
>=20
>     puts "The word $word occurs at least twice"
>=20
> }
>=20
>=20
>=20
> upvar #0 "=3D>" x
>=20
> puts "$x"
>=20
>=20
>=20
> "
>=20
>=20
>=20
> I guess that the author meant to write something else?
>=20
> It doesn't make sense to have a variable named "=3D>".
>=20
>=20
>=20
> Here's a link to the relevant page in the tutorial:
>=20
> http://www.tcl.tk/man/tcl8.5/tutorial/Tcl20a.html
>=20
>=20
>=20
> Thank you.

From the man ...

EXAMPLES
Find the first occurrence of a word starting with foo in a string that is n=
ot actually an instance of foobar, and get the letters following it up to t=
he end  of  the word into a variable:

   regexp {\mfoo(?!bar\M)(\w*)} $string -> restOfWord

Note  that  the whole matched substring has been placed in the variable =93=
->=94, which is a name chosen to look nice given that we are not actually i=
nterested in its contents.
0
jonkelly (28)
11/12/2013 4:33:24 AM
dor9990@gmail.com writes:

> It doesn't make sense to have a variable named "=>".

It is a fine name for a variable that you don't want to use, but
must supply. The form directs attention to the variable that IS
of use.

-- 
Donald Arseneau                          asnd@triumf.ca
0
asnd (4601)
11/14/2013 9:47:19 AM
Reply:

Similar Artilces:

"::tcl::tm::UnknownHandler ::tclPkgUnknown msgcat 1.4" caused by replacing Tcl 8.4.1 with 8.5.7
In the blog http://planet.larrythecow.org/archives/2009-07-26.html "The Twouble with Tcl" Iain Buchanan shows that redefining OPEN proc leads to the errors similar to what I am getting - when I replaced Tcl 8.4.1 with Tcl 8.5.7. In my case I don't know the exact root cause though ... Any ideas how I should proceed with debugging this issue ? Thanks, Alex tclsh c:/Tornado/host/resource/hutils/tcl/makeSymTbl.tcl ppc tmp.o symTbl.c invalid command name "::tcl::tm::UnknownHandler" while executing "::tcl::tm::UnknownHandler ::tclPkgUnknown msg...

"dawn job opportunities" "dawn jobs" "dawn jobs page" "dawn jang express jobs" "express news" "express.com" "jang jang" "jang" "jobs dawn" "jobs dawn news" on www.paperpk-jobs.blogspot.com
"dawn job opportunities" "dawn jobs" "dawn jobs page" "dawn jang express jobs" "express news" "express.com" "jang jang" "jang" "jobs dawn" "jobs dawn news" on www.paperpk-jobs.blogspot.com "paperpk" "paper pk" "papers jobs" "dawn job opportunities" "dawn jobs" "dawn jobs page" "dawn jang express jobs" "express news" "express.com" "jang jang" "jang" "jobs dawn" ...

What's wrong with "fconfigure stdout -encoding utf-8" on windows in Tcl 8.5.10
With my built 8.5.10 I tried to issue command "fconfigure stdout - encoding utf-8" to tclsh on WinXP, the tcl prompt then was shown as two dots instead of percentage sign, C:\>tclsh85t.exe % fconfigure stdout -encoding utf-8 =E2=80=A5date The current date is: 11/29/2011 Tue Enter the new date: (mm-dd-yy) time The system cannot accept the date entered. Enter the new date: (mm-dd-yy) =E2=80=A5 =E2=80=A5 So wonder what's wrong with fconfigure on stdout? Is that the issue? On Nov 29, 7:46=C2=A0am, "wrena...@gmail.com" <wrena...@gmail.com> wrote: > With my b...

How to open a pty from Tcl (or "please translate C example to Tcl")
Hello out there, still struggling with getting TCP/IP to work in my somewhat bizarre setup (TCP/IP over 10.000 Volt power-line modems) I got a hint to try to use a pseudo tty. I got the advice --- What you would do is write a small C program (or perl, or any of a number of other languages). This program would call the "openpty" function, which: - Locates the next available (unused) pseudo-TTY device in the system, - Opens both ends of it, into two different descriptors, - Returns the file-descriptor numbers for the two ends (the "slave" end which mimics a tty, and t...

[2.5.1] wxRegEx
Hi ! I'm trying wxRegEx with these lines : wxRegEx reResource; reResource.Compile(_T("^(?:\\\\){2}(?:\\d{1,3}\\.){3}\\d{1,3}\\\\.+\\\\?$")) ; But when I launch the application, I get this error : 18:42:35: Invalid regular expression '^(?:\\){2}(?:\d{1,3}\.){3}\d{1,3}\\.+\\?$': quantifier operand invalid I'm new to regular expressions but this one works quite fine with The Regulator, a regex creation and test application. Even with the "Syntax of the builtin regular expression library" wx documentation paragraph under the eyes, I found ...

problem with "file executable" on windows, tcl 8.5.2
ActiveState TCL 8.5.2, Windows XP SP2 'file executable' always returns 0, even on .exe and .bat when asked for a file on a network share: % info patchlevel 8.5.2 % set file L:/ralf/si++aegis/si++.4.0.C443/bin/winnt/gen.exe L:/ralf/si++aegis/si++.4.0.C443/bin/winnt/gen.exe % file exists $file 1 % file readable $file 1 % file executable $file 0 % file executable {L:/ralf/si++aegis/si++.4.0.C443/bin/winnt/simenu.bat} 0 However, when copying the files to local disk, the files are qualified as executable: % cp L:/ralf/si++aegis/si++....

TCL 8.5.6 invalid command name "clock"
Hello, I running a c++ application with an Tcl 8.5.5. interpreter. Now I try to update TCL to version 8.5.6. While running the application with TCL 8.5.6 I get the following error: invalid command name "clock" while executing "clock seconds" Is there something I might have overseen, or is this a bug in version 8.5.6. Thank you for help in advance. Kind Regards sindbad0815@googlemail.com wrote: > I running a c++ application with an Tcl 8.5.5. interpreter. Now I try > to > update TCL to version 8.5.6. While running the application with TCL > 8.5.6 I ge...

tcl 8.5.2 gives error on runtime arg "-c"
Hi. I'm getting this error when launching a tcl script from a shell with "-c some_argument" with tcl 8.5.2 Application initialization failed: bad window path name "some_argument" I've searched the manpage and several documentation sources and have not found any restrictions over supplying runtime flag/arguments. Is this a bug or a hidden feature? dewuf wrote: > Hi. I'm getting this error when launching a tcl script from a shell > with "-c some_argument" with tcl 8.5.2 > > Application initialization failed: bad window path name > &...

""""""""""""""""""""""ADD ME""""""""""""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfo Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... We look forward to build a ve...

"""""""""ADD ME""""""""""
Hi , Hope you are doing great. Please let me take this opportunity to introduce myself, Iam Karthik working with BhanInfoi Inc, a NY based company. We have consultants on our bench on various technologies, my request is to add me to your distribution list and kindly do send me the requirements. i have the below list available 1. Mainframe 2. Java 3.. Financial Analyst 4. Data Architect If there is any vendor ship agreement which has to be signed then I would like to take an opportunity to represent my company and expect your cooperation... ...

3 problems with "A small editor in 8.5.0" ( http://wiki.tcl.tk/20542)
I'm using Tcl/Tk 8.6.4 under WinXP Pro. Problem 1. I don't see any where to specify desired font. There is a code fragment saying ----------- proc textfenster {mframe {master {}}} { if {$master eq {}} { text [set mframe].t -bg white -xscrollcommand [ ---------------------------- which I edited to be ----------- proc textfenster {mframe {master {}}} { if {$master eq {}} { text [set mframe].t -font "Courier 20" -bg white -xscrollcommand [ ---------------------------- It made no difference. Problem 2. Although moving the butto...

regular expression to parse {"hello", "hello world", "1hello-2*hello"}
Hi,I was trying to use Java's regular expression to parse the followingstring:{"hello", "hello world", "1hello-2*hello"}I'd like to extract the words inside the quotation marks as follows:hellohello world1hello-2*helloI've tried different ways to write the expression but didn't work thisout. Can anyone help?Thanks a lot.Roy Roy wrote:> I was trying to use Java's regular expression to parse the following> string:> hello> hello world> 1hello-2*helloWhy do you asking us to do your homework?Goto: http://java.sun.com/j2se/1.5.0/docs/api/ , class Patternand remember about double backslash (\\).-- Pozdrawiam, J.W. Jacek Wojciechowski wrote:> Why do you asking us to do your homework?> Hey Roy, here's a free tip: It is very likely to get responses like this when making requests of the form "Please solve my problem!" without showing and explaining *what you* have tried already and what your exact problem with your approach is.regards,/W On Jan 6, 7:59 am, Wildemar Wildenburger<lasses_w...@klapptsowieso.net> wrote:> Jacek Wojciechowski wrote:> > Why do you asking us to do your homework?>> Hey Roy, here's a free tip: It is very likely to get responses like this> when making requests of the form "Please solve my problem!" without> showing and explaining *what you* have tried already and what your exact> problem with your approach is.>> regards,&...

Unable to understand "uplevel" and "upvar" in TCL
Hi, I have never been able to understand "uplevel" and "upvar" in TCL and when to use them? Can anyone explain this to me in a way that I can understand, with examples please? Thanks, Ahmed Ahmed Omara wrote: > Hi, > > I have never been able to understand "uplevel" and "upvar" in TCL and > when to use them? > > Can anyone explain this to me in a way that I can understand, with > examples please? They are highly useful when implementing your own control structures, but it's not limited to. They make m...

checkbuttons in tcl 8.4.12 and 8.5a4 with -offvalue == ""?
Hello, I just realized some differences between the checkbuttons visualisation in tcl 8.4 and 8.5. If the offvalue of a checkbutton is set to "" (empty string) and the checkbutton is not "checked", than ... - in tcl 8.4.12 the background is white - in tcl 8.5a4 the background is grey and the "check" is still visible That's a bug, isn't it? If the offvalue is " " (one blank), than every thing works. Best regards, Martin Lemburg UGS - Transforming the Process of Innovation MartinLemburg@UGS wrote: > Hello, > > I just reali...

not equal? "5".to_i+ "6".to_i and "5".to_i +"6".to_i
ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-linux] >> "5".to_i+ "6".to_i => 11 >> "5".to_i +"6".to_i => 5 maybe it's a mistak? > >> "5".to_i+ "6".to_i > => 11 > >> "5".to_i +"6".to_i > => 5 The second case +"6".to_i is treated as an argument for to_i method. This will make it more obvious: >> "111".to_i +"2".to_i => 7 "111".to_i +"2".to_i is equivalent to "111".to_i(2), hence the result....

Urgent Requirement in """""""""""""NEW YORK""""""""""""""""
Hello Partners, Please find the requirement below. Please send the updated resume along with rate and contact no. REQ#1: Title : Java Developer ( Rating Project) Duration : 6 months Rate : open Location : NY strong java, WebLogic 9.2, Web Services, Oracle REQ#2: Title : Java Developer Duration : 4 months Rate : open Location : NY Strong java, SQL REQ#3: Title : VB.Net Consultant Location : NY Duration : 4 months Rate : open Primarily looking at someone who has Excel, VB.net and Oracle (good to have). Req #4: Title : Java Developer (MSA Project) Duration : 6+ months Rate : open Location : NY Note : Please send your updated resume along with contact no karthik@bhaninfo.com : No phone calls please. Thanks & Regards Karthik BhanInfo karthik@bhaninfo.com ...

"pipe" in Tcl 8.5ff
Hi, I am looking for a replacement of the "pipe" command of tclx. This command creates a FIFO and returns one fd for reading and one for writing. A similar command in C is #include <unistd.h> int pipe(int pipefd[2]); How do I do that with plain Tcl (version >= 8.5)? Best regards Ole Στις 8/8/2013 2:38 μμ, ο/η Olе Streicher έγραψε: > Hi, > > I am looking for a replacement of the "pipe" command of tclx. This > command creates a FIFO and returns one fd for reading and one for > writing. A similar command in C is > > #in...

"or" and "and"
Hi, I'm just getting to discover ruby, but I find it very nice programming language. I just still don't understand how the "or" and "and" in ruby... I was playing with ruby and for example made a def to print Stem and Leaf plot (for those who didn't have a statistics course or slept on it, e.g. http://cnx.org/content/m10157/latest/) Here is the Beta version of it: class Array def n ; self.size ; end def stem_and_leaf(st = 1) # if st != (2 or 5 or 10) then ; st = 1 ; end k = Hash.new(0) self.each {|x| k[x.to_f] += 1 } k = k.sort{|a, b| a[0].to_f <=&g...

"my" and "our"
Hi, while testing a program, I erroneously declared the same variable twice within a block, the first time with "my", the second time with "our": { my $fz = 'VTX_Link'; .... ( around 200 lines of code, all in the same block) our $fz = 'VTX_Linkset'; ... } So the initial contents of the $fz declared with "my" is lost, because "our" creates a lexical alias for the global $fz, thus overwriting the previous "my" declaration. It was my error, no question. But I wonder why Perl doesn't mention this - even with "use s...

"out" and "in out"
Hi i found the following explaination: In Ada, "in" parameters are similar to C++ const parameters. They are effectively read-only within the scope of the called subprogram. Ada "in out" parameters have a reliable initial value (that passed in from the calling subprogram) and may be modified within the scope of the called procedure. Ada "out" parameters have no reliable initial value, but are expected to be assigned a value within the called procedure. What does "have no reliable initial value" mean when considering the "out" parameter? By c...

about "++" and "--"
why this program snippet display "8,7,7,8,-7,-8" the program is: main() { int i=8; printf("%d\n%d\n%d\n%d\n%d\n%d\n",++i,--i,i++,i--,-i++,-i--); } > why this program snippet display "8,7,7,8,-7,-8" Ask your compiler-vendor because this result is IMHO implementation-defined. Check this out: http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.15 http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.16 Regards, Irina Marudina fxc123@gmail.com wrote: > why this program snippet display "8,7,7,8,-7,-8&q...

"/a" is not "/a" ?
Hi everybody, while testing a module today I stumbled on something that I can work around but I don't quite understand. >>> a = "a" >>> b = "a" >>> a == b True >>> a is b True >>> c = "/a" >>> d = "/a" >>> c == d True # all good so far >>> c is d False # eeeeek! Why c and d point to two different objects with an identical string content rather than the same object? Manu Emanuele D'Arrigo wrote: >>>> c = "/a" >>>&...

why "::", not "."
Why does the method of modules use a dot, and the constants a double colon? e.g. Math::PI and Math.cos -- Posted via http://www.ruby-forum.com/. On Oct 26, 2010, at 01:48 , Oleg Igor wrote: > Why does the method of modules use a dot, and the constants a double > colon? > e.g. > Math::PI and Math.cos For the same reason why inner-classes/modules use double colon, because = they're constants and that's how you look up via constant namespace. Math::PI and ActiveRecord::Base are the same type of lookup... it is = just that Base is a module and PI is a float....

"If then; if then;" and "If then; if;"
I have a raw data set which is a hierarchical file: H 321 s. main st P Mary E 21 F P william m 23 M P Susan K 3 F H 324 S. Main St I use the folowing code to read the data to creat one observation per detail(P) record including hearder record(H): data test; infile 'C:\Documents and Settings\retain.txt'; retain Address; input type $1. @; if type='H' then input @3 Address $12.; if type='P' then input @3 Name $10. @13 Age 3. @16 Gender $1.; run; but the output is not what I want: 1 321 s. main H 2 321 s. main P Mary E 21 F 3 321 s...

Web resources about - Tcl 8,5 tutorial errata on page "More Examples Of Regular Expressions" - comp.lang.tcl

Resources last updated: 3/7/2016 12:42:35 PM