On Mon, 23 Sep 2002, Henry Wong wrote: > Actually, my code is something like this: > > print "\n\n\nPLEASE ENTER REQUIRED .LOG FILE:"; > $file = <STDIN>; > chomp ($file); > open (INFILE1, "$file"); > > So how can I use the $file variable to be splitted from its *.log and then > subsequently using it for appending to a "$file_temp.txt" format? Coz when i > print the $file, it gives me "xxx.log", which i actually want. But i only > want the front portion "xxx" and not the ".log" later when i create new > files like 'xxx_temp.txt'. Pls advise, thanks.
Well, then why do you want to accept the input as xxx.log. Why not just xxx. The simplest way would be to split, $file = <STDIN>; chomp ($file); ($file) = split (/\./, $file); # perldoc -f split Now $file will contain the xxx part of your xxx.log. But this assumes that input will not be of this form 'xxx.yyy.log'. One possible way to handle this scenario $file =~ s/\.log$//; # perldoc perlretut, perldoc perlre I would suggest you read through the docs of the modules too File::Basename (perldoc File::Basename) File::Spec (perldoc File::Spec) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]