LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-21-2008, 06:13 AM   #1
john83reuben
Member
 
Registered: Oct 2007
Location: Kuala Lumpur,Malaysia
Distribution: Debian Etch, OpenSuse
Posts: 132

Rep: Reputation: 17
tcl file handling


I want to print


Code:
#!/projects/ilinterf/bin/expect

set INFILE [open "jokes.txt" r]
set data [read $INFILE]
set data [split $data "\n"]
foreach line $data {
        puts $line
below is the jokes.txt
Quote:
hello
mars
world
earth
i want to print only world, how to put it in array and print world only
 
Old 07-21-2008, 07:44 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
without arrays
Code:
if ($line == "world") {
    puts $line
}

# or
if [string match "world" $line] {
    puts $line
}
Can you explain what you want to do with arrays?

Last edited by Wim Sturkenboom; 07-21-2008 at 07:47 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php file handling fmcgenesis Linux - Newbie 1 02-09-2007 07:20 PM
Cannot find Tcl dll ( Perl's Tcl bridge ) Xyem Linux - Software 2 08-08-2006 09:45 AM
File Handling In C/C++ vikasumit Programming 5 06-18-2006 11:43 PM
Checking file extension in TCL? liguorir Programming 2 06-14-2004 06:38 AM
naming a Tcl file liguorir Linux - Software 1 05-20-2004 08:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration