Regex to find a file in Tcl -


i've never used tcl previously, however, need modify file project. have used regex perl, i'm unsure of syntax tcl.

what want allow user execute script , type in file name has searched. want search file once found , something. far, here's pseudo-code.

set file_name [lindex $argv 0]  while(true) { if { found file } {  puts "found file!"  {  else { file not found )  puts "file not found!"  } 

i'm not sure how check if file found or not? complete filename user via input ...

if want use regular expression instead of glob patterns periodically list of files (using glob) , search through it. helpfully, lsearch accepts regexp syntax:

# regexp: set file_pattern [lindex $argv 0]  # scan current directory: while 1 {     set files [glob -nocomplain *]     if {[lsearch -regexp $files $file_pattern] < 0} {         puts "file not found"     } else {         puts "file found"     }     after 1000 ;# sleep 1 second } 

note in tcl regexp not have special syntax. string.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -