Ram Assgn
Ram Assgn
1. Does TCL have any data types defined? 2. Write down all the possible ways of assigning variables, lists and arrays in TCL? 3. Part 1! Write a pro"ed#re to generate a single list, by reading the #ser inp#t fro$ "o$$and line. e.g. %ser &np#ts! 'a b " '"d de 'efg fgh((( 1 2 '3) )* '*+, +,-(( a. What is the length of the final list? b. .ow do yo# re"ogni/e, whether the final list has ele$ents whi"h are lists? ". 0#tp#t the inde1 of ea"h ele$ent in the final list. 2s an e1a$ple, the final inde1ing for the ele$ent 3"d4 sho#ld be 2.5, for the ele$ent 3de4 sho#ld be 2.1, ele$ent efg sho#ld be 32.2.54 et". ). Part 2! Write a pro"ed#re whi"h a""esses the final list of 63 #sing #pvar, print the final list fro$ this pro"ed#re. a. 2s7 the #ser to enter the ele$ent, and o#tp#t the re8#ired indi"es to a""ess any ele$ent. ' 9o for the inp#t ele$ent is 3efg4 the inde1 sho#ld be o#tp#t as 2.2.5( b. Display the length of the list and as7 the #ser to insert any new ele$ents. ' %ser "an indi"ate the inde1 and the ele$ent that he wishes to enter : ;or e1a$ple if the #ser indi"ates the inde1 to be 2.2.1 and the ele$ent to be 3def4 then 3def4 sho#ld "o$e between 3efg4 and 3fgh4 in the final list ". 2s7 the #ser to sele"t the range of ele$ents to be o#tp#tted. d. <epla"e the ele$ents in the list, as per #ser "hoi"e and o#tp#t the final res#lt. *. Create an array, with following fields ! 9t#dent =a$e, 9t#dent &D, >ar7s! >aths, Physi"s ? Che$istry a. Cal"#late the total $ar7s of the st#dent and ran7 hi$ a""ordingly and o#tp#t the final array with a proper for$at. b. <ead the #ser inp#t, and display the re8#ested st#dent infor$ation. ". <ead the #ser inp#t to o#tp#t only the 9t#dent =a$es@9t#dent &Ds and their <an7s. =0TA! Bo# "an sele"t either 9t#dent =a$e or 9t#dent &D as a 7ey to a""ess the 9t#dent &nfor$ation. +. Write a s"ript to display the attrib#tes of the #ser re8#ested file that is present in the present wor7ing dire"tory. The o#tp#t sho#ld be the read, write a""ess per$issions for the file. ,. <ead the "ontents of the file, and o#tp#t it into a new file. a. 0#tp#t the no. of lines present in the file and no. of words present in the file. b. Co#nt the ea"h word and 0#tp#t the res#lt into a new file. ". Ta7e the reg#lar e1pression inp#t, and display its o""#rren"e in the file. d. 2s7 the #ser to inp#t a sear"h pattern and a s#bstit#ting string and generate a new file. Chint! %se 3regs#b4D -. Write a pro"ed#re to re"reate an already e1isting file and ba"7#p the older "opy of the file and rena$e it by atta"hing the latest ti$e of "hange. E to#"h testfile.t1t
Fwhen yo# re"reate a file by na$e testfile.t1t, it sho#ld save the e1isting file as testfileG5HI#nG1HG55G11.t1t.J E ls testfile.t1t testfileG15I#nG15G32G11.t1t