> "R" == Ruud writes:
R> Thomas Bätzler wrote:
>> my $data = do {
>> local $/ = undef;
>> <$fh>;
>> };
R> Especially for big files, that is better written as:
define big. most files are still text or similar and not big by today's
ram sizes. slurping in a megabyte is nothing to
Thomas Bätzler wrote:
my $data = do {
local $/ = undef;
<$fh>;
};
Especially for big files, that is better written as:
my $data;
{ local $/;
$data = <$fh>;
}
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http
Doug Cacialli asked:
> Does anyone have any ideas how I can make the second block of code
> work? Or otherwise accomplish the task without opening the .txt file
> twice?
How large are your data files? If your available memory is much larger than
your maximum file size, you might get away with s
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
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
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
Thanks to much help from the list, and hours of reading up on Unicode,
the Encode module, and many posts to perlmonks, I've come up with a
hideous solution for processing text files with different character
encodings.
Can someone please explain why this first block of code works when
decoding .txt
Thanks Tom, it helped. :-)
I learned some more few things. ;-)
Regards,
Tom Phoenix <[EMAIL PROTECTED]> wrote:
On Dec 30, 2007 10:17 AM, oscar gil wrote:
> What I still don't understand is why $! and $^E are set as there was an
> error though there was not :-?.
Those variables may
On Dec 30, 2007 10:17 AM, oscar gil <[EMAIL PROTECTED]> wrote:
> What I still don't understand is why $! and $^E are set as there was an
> error though there was not :-?.
Those variables may be set when your perl binary internally needs to
use a system call or something similar. During or shortly
On Dec 29, 2007 9:18 AM, oscar gil <[EMAIL PROTECTED]> wrote:
> Using 'open' I cannot say if the 'del' command was done correctly
> or not, although there is a message probably to STDERR that I do
> not know how to manage. :-(
I believe you're talking about a piped open() to an external command
g the file handler.
Answering your question to 'Do you want to handle errors or do you want to
report errors?'
I would like to handle the errors and I thought using these variable would be a
good method, wouldn't be?
Thanks again.
"John W. Krahn" <[EMAIL PROTECT
oscar gil wrote:
Hello everybody,
Hello,
I wanted to learn a bit more about how to handle errors when I am
working with files,
Do you want to handle errors or do you want to report errors?
so I wrote this simple script to start with it
where you can see that first I show the normal perl
Hello everybody,
I wanted to learn a bit more about how to handle errors when I am working with
files, so I wrote this simple script to start with it where you can see that
first I show the normal perl errors variables, then I try to delete a file and
finally I show the errors variables again
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
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
>> 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
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
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
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 the string occurs.
NOTE: The perl script also resides in the
19 matches
Mail list logo