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

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

Replies are listed 'Best First'.
Re^5: Finding a Letter at Last line
by smokemachine (Hermit) on Nov 08, 2006 at 16:58 UTC
    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
Re^5: Finding a Letter at Last line
by Anonymous Monk on Nov 08, 2006 at 17:02 UTC
    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
      you can do this too... but you dont need use the ls insight of for...
      for file in *.txt do perl -e 'open FILE, "<'$file'"; $_ = join "", <FILE>; print "true" +if /^t[^\n]*\Z/msi' done
        Hi smokemachine
        excellent...thanks many..you saved my day...thanks again for the quick help
        Thanks & Regards
        Sridhar