On 2012-08-20 22:39, Rajeev Prasad wrote:
just want to find out in how many records string was found:
my $count=0;
seek $tmp_FH,0,0;
while (<$tmp_FH>)
{
my $line=$_;chomp($line);
if ($line=~m/\"$str\"/) {$coun
On Aug 20, 2012, at 7:24 PM, John SJ Anderson wrote:
> On Monday, August 20, 2012 at 4:15 PM, Rob Dixon wrote:
>>
>> This question is double-posted on Stack Overflow
>>
> So what? I don't see anything in the list FAQ about cross-posting questions
> to other resources, just about cross-posting a
On Monday, August 20, 2012 at 4:15 PM, Rob Dixon wrote:
>
> This question is double-posted on Stack Overflow
>
So what? I don't see anything in the list FAQ about cross-posting questions to
other resources, just about cross-posting across the different beginner mailing
lists.
john.
--
John
, August 20, 2012 6:15 PM
Subject: Re: re-reading from already read file handle
Rajeev Prasad wrote:
>I opened a file to read from line by line.
>
>
>open(FH,"<","$myfile") or die "could not open $myfile: $!";
>while ()
>{
>...do somethin
Rajeev Prasad wrote:
>I opened a file to read from line by line.
>
>
>open(FH,"<","$myfile") or die "could not open $myfile: $!";
>while ()
>{
>...do something
>
>}
>
>later on in program, try to re-read the file (walk thru the file
>again):
>while ()
>{
>...do something
>
>}
>
>and realized tha
On Aug 20, 2012, at 3:32 PM, Rajeev Prasad wrote:
> Thx. I did some timestamp prints from within script, this piece is taking too
> long: almost 5 minutes to complete...!!!
>
> fyi, the strArr array contains about 1500 string elements. (this loop runs
> that many times)
> the file tmp_FH_SR i
PM
Subject: Re: re-reading from already read file handle
On Aug 20, 2012, at 1:39 PM, Rajeev Prasad wrote:
> thank you. seek did the job.
>
> by the way can this be made any better?
>
> just want to find out in how many records string was found:
>
> my $count=0
On Aug 20, 2012, at 1:39 PM, Rajeev Prasad wrote:
> thank you. seek did the job.
>
> by the way can this be made any better?
>
> just want to find out in how many records string was found:
>
> my $count=0;
> seek $tmp_FH,0,0;
> while (<$tmp_FH>)
>
On Mon, 20 Aug 2012 13:39:16 -0700 (PDT)
Rajeev Prasad wrote:
> my $count=0;
> seek $tmp_FH,0,0;
> while (<$tmp_FH>)
> {
> my $line=$_;chomp($line);
# Please put each statement on its own line
> if ($line=~m/\"$str\
($line=~m/\"$str\"/) {$count++;} #in the file $str
string would be in quotes
}
From: Andy Bach
To: Rajeev Prasad
Cc: perl list
Sent: Monday, August 20, 2012 2:10 PM
Subject: Re: re-reading from already read file handle
On Mon, 20 Aug 2012 12:00:55 -0700 (PDT)
Rajeev Prasad wrote:
> open(FH,"<","$myfile") or die "could not open $myfile: $!";
# You should used a my variable for the file handle
open(my $fh,"<","$myfile") or die "could not open $myfile: $!";
> while ()
# with the my variable file handle
while (<
On Mon, Aug 20, 2012 at 2:00 PM, Rajeev Prasad wrote:
> is this default behaviour? how to work around this? file is big and I do not
> want to keep in memory as array. so is my only option is to close and open
> the file again?
Yes, that's the default. "seek" lets you reset things though
perldo
I opened a file to read from line by line.
open(FH,"<","$myfile") or die "could not open $myfile: $!";
while ()
{
...do something
}
later on in program, try to re-read the file (walk thru the file again):
while ()
{
...do something
}
and realized that it is as if the control within file is a
thanks rob. how about Win32::File?
regards
irfan
From: Rob Coops
To: Irfan Sayed
Cc: "beginners@perl.org"
Sent: Monday, July 30, 2012 5:23 PM
Subject: Re: read file attributes
On Mon, Jul 30, 2012 at 1:24 PM, Irfan Sayed wrote:
hi,
&g
On Mon, Jul 30, 2012 at 1:24 PM, Irfan Sayed wrote:
> hi,
>
> i need to access the attributes of file.
> more precisely, i need to check if the file is digitally signed or not
>
>
> for example; if i right click on file, then i need to check if the
> "digital signature" tab is there or not for tha
hi,
i need to access the attributes of file.
more precisely, i need to check if the file is digitally signed or not
for example; if i right click on file, then i need to check if the "digital
signature" tab is there or not for that specific file and valid certificate is
there.
please suggest
On Mon, Nov 24, 2008 at 07:24, loody <[EMAIL PROTECTED]> wrote:
snip
> My question are:
> Q1:
> what is the differences of using
> "use bytes; use open IN => ":bytes";"
> and "binmode "?
snip
The bytes pragma changes how string functions work (char vs byte, some
chars take up more than one byte).
> You may also want to look into the pack** and unpack*** functions if you are
> going to be messing around with binary files.
>
Dear all:
I excerpt from web,
http://coding.derkeiler.com/Archive/Perl/perl.beginners/2004-05/0150.html,
and add them in my source code which looks like below:
#!/usr/bi
On Sun, Nov 23, 2008 at 08:29, loody <[EMAIL PROTECTED]> wrote:
> 2008/11/23 Chas. Owens <[EMAIL PROTECTED]>:
>>
>>
>> On Nov 23, 2008, at 2:52, loody <[EMAIL PROTECTED]> wrote:
>>
>>> Dear all:
>>> The prototype of read is
>>> read FILEHANDLE,SCALAR,LENGTH
>>> ex:
>>> read PATTERN, $line, 1920;
>>
Mr. Shawn H. Corey wrote:
On Sun, 2008-11-23 at 05:47 -0800, John W. Krahn wrote:
Mr. Shawn H. Corey wrote:
On Sun, 2008-11-23 at 05:34 -0800, John W. Krahn wrote:
You shouldn't "do something with $line" if $bytes_read is undefined:
while ( my $bytes_read = read PATTERN, $line, 1920 ) {
On Sun, 2008-11-23 at 05:47 -0800, John W. Krahn wrote:
> Mr. Shawn H. Corey wrote:
> > On Sun, 2008-11-23 at 05:34 -0800, John W. Krahn wrote:
> >> You shouldn't "do something with $line" if $bytes_read is undefined:
> >>
> >> while ( my $bytes_read = read PATTERN, $line, 1920 ) {
> >> unless
Mr. Shawn H. Corey wrote:
On Sun, 2008-11-23 at 05:34 -0800, John W. Krahn wrote:
You shouldn't "do something with $line" if $bytes_read is undefined:
while ( my $bytes_read = read PATTERN, $line, 1920 ) {
unless ( defined $bytes_read ) {
die "error reading $filename: $!";
loody wrote:
2008/11/23 Chas. Owens <[EMAIL PROTECTED]>:
On Nov 23, 2008, at 2:52, loody <[EMAIL PROTECTED]> wrote:
The prototype of read is
read FILEHANDLE,SCALAR,LENGTH
ex:
read PATTERN, $line, 1920;
that means the $line will content 1920 bytes.
if I want to modify the byte offset 720 of $
On Sun, 2008-11-23 at 05:34 -0800, John W. Krahn wrote:
> You shouldn't "do something with $line" if $bytes_read is undefined:
>
> while ( my $bytes_read = read PATTERN, $line, 1920 ) {
> unless ( defined $bytes_read ) {
> die "error reading $filename: $!";
> }
> # do s
Mr. Shawn H. Corey wrote:
On Sun, 2008-11-23 at 15:52 +0800, loody wrote:
The prototype of read is
read FILEHANDLE,SCALAR,LENGTH
ex:
read PATTERN, $line, 1920;
that means the $line will content 1920 bytes.
It means it will attempt to read 1920 bytes. The actual number of bytes
read is retur
2008/11/23 Chas. Owens <[EMAIL PROTECTED]>:
>
>
> On Nov 23, 2008, at 2:52, loody <[EMAIL PROTECTED]> wrote:
>
>> Dear all:
>> The prototype of read is
>> read FILEHANDLE,SCALAR,LENGTH
>> ex:
>> read PATTERN, $line, 1920;
>>
>> that means the $line will content 1920 bytes.
>> if I want to modify th
line, it seems impossible,
> since $line is a scalar not an array.
> I know I can read a byte to each array element one by one, but it
> seems pretty slow.
>
> Is there any read file function can read in the file content to an array?
> appreciate your help,
> miloody
>
Not
On Nov 23, 2008, at 2:52, loody <[EMAIL PROTECTED]> wrote:
Dear all:
The prototype of read is
read FILEHANDLE,SCALAR,LENGTH
ex:
read PATTERN, $line, 1920;
that means the $line will content 1920 bytes.
if I want to modify the byte offset 720 of $line, it seems impossible,
But happily it isn'
one by one, but it
seems pretty slow.
Is there any read file function can read in the file content to an array?
appreciate your help,
miloody
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
I want to ready file in Hash Array.
I have file in following format:
ID | Time | IP | Code
open(INFO, $file);
@lines = ;
Instead of this I want to use Hash Array. May be just ID and IP fileds.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
h
Rob Dixon schreef:
> my $contents = do {
> open my $fh, $source_file or die $!;
> local $/;
> <$fh>;
> };
That has the file's contents in memory twice. This is leaner:
my $contents;
{
open my $fh, $source_file or die $!;
local $/;
$contents = <$fh>;
};
--
Affi
[EMAIL PROTECTED] wrote:
How can I get the read line to read the entire file?
That's a FAQ.
perldoc -q "entire file"
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http:/
[EMAIL PROTECTED] wrote:
>
> I am trying to read a text file with carriage returns and line feeds on a
> unix system and for some reason it will read only one of text. I use the same
> code in a different perl script and I can read a file that does not have
> carriage returns and line feeds.
>
Hello
I am trying to read a text file with carriage returns and line feeds on a unix
system and for some reason it will read only one of text. I use the same code
in a different perl script and I can read a file that does not have carriage
returns and line feeds.
The existing code is :
open
jeniffer wrote:
I have a file of the format
action arg1 \
arg2 \
arg3 \
action2 arg1 \
arg2 \
arg3 \
I read this by :-
foreach $line (@lines)
{
($action , @argument_list) = split(/\s+/,$line);
This would work fine if the file is of the
format
ac
On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
> On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
> snip
> > my $rec = '';
> > while (<>) {
> > if (/\\$/) { #if line is a continuation
> > chop; #remove the continuation character
>
On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
snip
> my $rec = '';
> while (<>) {
> if (/\\$/) { #if line is a continuation
> chop; #remove the continuation character
> $rec .= $_;
> next;
> }
> my @rec = sp
On 7/11/07, Chas Owens <[EMAIL PROTECTED]> wrote:
snip
my $rec = '';
while (<>) {
if (/\\$/) { #if line is a continuation
chop; #remove the continuation character
$rec .= $_;
next;
}
my @rec = split ' ', $rec;
$rec = '';
#do stuff with @rec
}
snip
Who
On 7/11/07, jeniffer <[EMAIL PROTECTED]> wrote:
I have a file of the format
action arg1 \
arg2 \
arg3 \
action2 arg1 \
arg2 \
arg3 \
I read this by :-
foreach $line (@lines)
{
($action , @argument_list) = split(/\s+/,$line);
This would work fine
On 7/11/07, jeniffer <[EMAIL PROTECTED]> wrote:
I have a file of the format
action arg1 \
arg2 \
arg3 \
action2 arg1 \
arg2 \
arg3 \
In other words, some of the file's "lines" are more than a single line
each; a continued line ends with a backslash. Per
I have a file of the format
action arg1 \
arg2 \
arg3 \
action2 arg1 \
arg2 \
arg3 \
I read this by :-
foreach $line (@lines)
{
($action , @argument_list) = split(/\s+/,$line);
This would work fine if the file is of the
format
action arg1
On Jul 7, 6:16 am, [EMAIL PROTECTED] wrote:
> I am new to perl and would like to:
>
> 1. read preprocessed source code in multiple directories
> 2. searching these files for #line
> 3. build non duplicate array of path/filenames that follow #line
> 4. write results to a file
>
> Any direction, poin
I am new to perl and would like to:
1. read preprocessed source code in multiple directories
2. searching these files for #line
3. build non duplicate array of path/filenames that follow #line
4. write results to a file
Any direction, pointers, references or assistance would be greatfully
appreci
be more specific about it,
>so for instance, within the foreach you would have:
>
>open my $READHANDLE, $filename or die "Can't open file for reading: $!";
>$image->Read('file' => $READHANDLE);
>
>etc.
>
>Or there is an issue with the install
$img->Write("jpg:$image_dest_folder\\$image_source_file");
undef $img;
}
}
-Original Message-
From: Brian Volk
Sent: Monday, September 13, 2004 10:18 AM
To: 'Beginners (E-mail)'
Subject: RE: perl crashing at $image->Read (fi
Thank you Wiggins! I have changed everything that you suggested and I think
I am much closer. However, I have run into an error w/ the Read line.
foreach my $file (@files) {
$image->Read (file=> $file)
Bad filehandle: brian.jpg at C:/Program Files/PerlEdit/scripts/test_3.pl
line 17
Please bottom post
Brian Volk wrote:
Thank you Wiggins! I have changed everything that you suggested and I think
I am much closer. However, I have run into an error w/ the Read line.
foreach my $file (@files) {
$image->Read (file=> $file)
Bad filehandle: brian.jpg at C:/Program
>
> Hi All,
>
> I my perl script is crashing perl at this line;
>
> $image->Read (file=> \*ARGV);
>
> I know that it is this line because I have commented out everything else
> around it. When I just have the Read statment, perl will crash. Here is
Hi All,
I my perl script is crashing perl at this line;
$image->Read (file=> \*ARGV);
I know that it is this line because I have commented out everything else
around it. When I just have the Read statment, perl will crash. Here is
the script, can someone please suggest what I am
> I have tried to read a file in backwards in stead of from the top
> without any success !!!
http://search.cpan.org/author/URI/File-ReadBackwards-0.99/ReadBackwards.pm
/\/\ark
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAI
Larry Sandwick wrote:
> I have tried to read a file in backwards in stead of from the top
> without any success !!!
>
> The original code looks like this .
>
> open(DATABASE, " read!\n";
>
> I have tried the following.
>
> I do not get any errors from Perl, it just ignores the command.
>
>
>
On Mon, Jan 13, 2003 at 04:15:20PM -0500, Larry Sandwick wrote:
> I have tried to read a file in backwards in stead of from the top
> without any success !!!
http://search.cpan.org/author/URI/File-ReadBackwards-0.99/
> Any suggestion would be helpful.
_Always_ search CPAN first :-)
--
Paul Jo
I have tried to read a file in backwards in stead of from the top
without any success !!!
The original code looks like this .
open(DATABASE, "
Thank you Tanton, Felix;
- Original Message -
From: "Felix Geerinckx" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 26, 2002 5:32 PM
Subject: Re: Read file from second line
> on Mon, 26 Aug 2002 15:15:06 GMT, [EMAIL PROTECTED] (Q) wrote:
&g
on Mon, 26 Aug 2002 15:15:06 GMT, [EMAIL PROTECTED] (Q) wrote:
> Apologies for such a 'lame' question but i read the FAQ on
> http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq5-full.html
>
> How do i read on from the second line of a text file?
You start reading from the first line but throw
>How do i read on from the second line of a text file?
Just read in the first line and ignore it
open FILE, "file.txt" or die "Could not open file.txt: $!\n";
my $first_line = ;
# now FILE is at the second line.
while( ) {
# do your processing
}
Tanton
--
To unsubscribe, e-mail: [EMAIL
Apologies for such a 'lame' question but i read the FAQ on
http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq5-full.html
How do i read on from the second line of a text file?
thanks in advance
ICQ : 165709889
"Jonathan E. Paton" wrote:
> You don't want to, reading one character
> at a time is VERY slow. At worst, the
> operating system will cut short your
> time slot whilst it waits for the file
> access - perhaps limiting you to a few
> dozen characters per second...
>
> if you care much for that
> how read a file one by one symbols, not
> a whole string once at time?
You don't want to, reading one character
at a time is VERY slow. At worst, the
operating system will cut short your
time slot whilst it waits for the file
access - perhaps limiting you to a few
dozen characters per second..
Dave K wrote:
> Here is one script I used to inspect files
>
> use strict;
> my $fn;
> print"Enter the name of a file you want to examine ";
> while (<>) {
It is better to write this as while (). The reason being if all
the command
line arguments (if any are provided) have not been shifted
Here is one script I used to inspect files
use strict;
my $fn;
print"Enter the name of a file you want to examine ";
while (<>) {
$fn = $_;
last if $fn;
}
print "Opening $fn\n";
open TF, "$fn" or die "Cannot open $fn:$!\n";
my @ov;
my $ov;
while () {
@ov = unpack('U*',$_);
print;
print"\t\t"
Friends,
how read a file one by one symbols, not a whole string once at time?
Thanks.
--
---!
My blessing!
Ramis. !
---!
http://www.samtan.fromru.com
mailto: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
62 matches
Mail list logo