Re: Working with files of different character encodings

2010-04-05 Thread Jim Gibson
On 4/5/10 Mon Apr 5, 2010 2:56 PM, "Doug Cacialli" scribbled: > I sincerely appreciate the tips on improving my code; I implement (or > at least take strong note) of all the suggestions I receive. In the > code I posted, however, I'm primarily interested in learning if > there's a way to avoid

Re: Working with files of different character encodings

2010-04-05 Thread Doug Cacialli
I sincerely appreciate the tips on improving my code; I implement (or at least take strong note) of all the suggestions I receive. In the code I posted, however, I'm primarily interested in learning if there's a way to avoid opening the file to determine the character encoding, and then opening it

Re: Working with files of different character encodings

2010-04-05 Thread Dr.Ruud
Doug Cacialli wrote: $datapath =~ s/^\s+//; $datapath =~ s/\s+$//; Alternative notation: s/\s+$//, s/^\s+// for $datapath; I have a "sub trim()" in my Toolbox, so I just call "trim($datapath);". open (my $filehndl , "<", "$datapath") || die ("Can't open .txt file $datapath. Ex

Re: Working with files

2007-02-23 Thread Dr.Ruud
Jeff Pang schreef: > [processing .h files] > next if $file eq '.' or $file eq '..'; > next if $file !~ /\.h$/; Those two lines can be replaced by file =~ /\.h$/ or next; > return $. if /$string/; If the string can contain regex-special characters, then always use quote

Re: Working with files

2007-02-23 Thread Ken Foskey
On Thu, 2007-02-22 at 23:20 +0530, Dharshana Eswaran wrote: > I forgot to mention, First step is to Search for the file in which the > string occurs A list of files use either function glob or opendir (perldoc -f ???) I wonder how you are going to check for a string without opening it. You may

Re: Working with files

2007-02-22 Thread Jeff Pang
>> I need to search a particular string in a set of files in a directory. The >> string appears only in one of the files in the directory. >> I need to retrieve the file name and then access the line of that >> particular file in which the string occurs. >> >> NOTE: The perl script also resides i

Re: Working with files

2007-02-22 Thread Tom Phoenix
On 2/22/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote: I need to search a particular string in a set of files in a directory. The string appears only in one of the files in the directory. I need to retrieve the file name and then access the line of that particular file in which the string occ

Re: Working with files

2007-02-22 Thread Dharshana Eswaran
On 2/22/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote: Hello All, I need to search a particular string in a set of files in a directory. The string appears only in one of the files in the directory. I need to retrieve the file name and then access the line of that particular file in which th