Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Finding a Letter at Last line

by smokemachine (Hermit)
on Nov 08, 2006 at 16:42 UTC ( [id://582916] : note . print w/replies, xml ) Need Help??


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

yes... you can use "<$filename"

Replies are listed 'Best First'.
Re^4: Finding a Letter at Last line
by mantra2006 (Hermit) on Nov 08, 2006 at 16:49 UTC
    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
        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