in reply to Re: Finding a Letter at Last line
in thread Finding a Letter at Last line

Hey smokemachine
Thanks for the reply..it worked..just a small doubt how can i replace "<file" with variable filenames??
Thanks & Regards
Sridhar

Replies are listed 'Best First'.
Re^3: Finding a Letter at Last line
by smokemachine (Hermit) on Nov 08, 2006 at 16:42 UTC
    yes... you can use "<$filename"
      Hey smokemachine
      just a small clarification...
      for file in `ls -1 *.txt` do #echo $file perl -e 'open FILE, "<$file"; $_ = join "", <FILE>; print "true" i +f /^t[^\n]*\Z/msi' done

      when I run this for loop nothing is printing on command line but
      when I run with individual filenames its returning true..what is wrong with it..
      Thanks & Regards
      Sridhar
        because you are usin the for of shellscript to have the name of the file in $file and trying to use this in a perl program... you could do this?
        perl -e 'for $file(@ARGV){open FILE, "<$file"; $_ = join "", <FILE>; p +rint "true" if /^t[^\n]*\Z/msi;close FILE}' *.txt
        Almost there, just insert two extra quotes.
        for file in `ls -1 *.txt` do perl -e 'open FILE, "<'$file'"; $_ = join "", <FILE>; print "true" +if /^t[^\n]*\Z/msi' done