Re: re-reading from already read file handle

2012-09-02 Thread Dr.Ruud
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

Re: re-reading from already read file handle

2012-08-20 Thread Bill Stephenson
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

Re: re-reading from already read file handle

2012-08-20 Thread John SJ Anderson
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

Re: re-reading from already read file handle

2012-08-20 Thread Rajeev Prasad
, 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

Re: re-reading from already read file handle

2012-08-20 Thread Rob Dixon
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

Re: re-reading from already read file handle

2012-08-20 Thread Jim Gibson
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

Re: re-reading from already read file handle

2012-08-20 Thread Rajeev Prasad
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

Re: re-reading from already read file handle

2012-08-20 Thread Jim Gibson
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>) >

Re: re-reading from already read file handle

2012-08-20 Thread Shawn H Corey
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\

Re: re-reading from already read file handle

2012-08-20 Thread Rajeev Prasad
($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

Re: re-reading from already read file handle

2012-08-20 Thread Shawn H Corey
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 (<

Re: re-reading from already read file handle

2012-08-20 Thread Andy Bach
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

re-reading from already read file handle

2012-08-20 Thread Rajeev Prasad
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

Re: read file attributes

2012-07-30 Thread Irfan Sayed
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

Re: read file attributes

2012-07-30 Thread Rob Coops
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

read file attributes

2012-07-30 Thread Irfan Sayed
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

Re: how to read file content into an array?

2008-11-24 Thread Chas. Owens
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).

Re: how to read file content into an array?

2008-11-24 Thread loody
> 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

Re: how to read file content into an array?

2008-11-23 Thread Chas. Owens
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; >>

Re: how to read file content into an array?

2008-11-23 Thread John W. Krahn
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 ) {

Re: how to read file content into an array?

2008-11-23 Thread Mr. Shawn H. Corey
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

Re: how to read file content into an array?

2008-11-23 Thread John W. Krahn
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: $!";

Re: how to read file content into an array?

2008-11-23 Thread John W. Krahn
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 $

Re: how to read file content into an array?

2008-11-23 Thread Mr. Shawn H. Corey
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

Re: how to read file content into an array?

2008-11-23 Thread John W. Krahn
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

Re: how to read file content into an array?

2008-11-23 Thread loody
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

Re: how to read file content into an array?

2008-11-23 Thread Mr. Shawn H. Corey
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

Re: how to read file content into an array?

2008-11-23 Thread Chas. Owens
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'

how to read file content into an array?

2008-11-22 Thread loody
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/

read file in hash array

2008-10-08 Thread [EMAIL PROTECTED]
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

Re: Read File Problem

2008-07-29 Thread Dr.Ruud
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

Re: Read File Problem

2008-07-23 Thread Gunnar Hjalmarsson
[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:/

Re: Read File Problem

2008-07-23 Thread Rob Dixon
[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. >

Read File Problem

2008-07-23 Thread andrewmchorney
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

Re: read file

2007-07-11 Thread Rob Dixon
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

Re: read file

2007-07-11 Thread Chas Owens
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 >

Re: read file

2007-07-11 Thread Chas Owens
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

Re: read file

2007-07-11 Thread Chas Owens
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

Re: read file

2007-07-11 Thread Chas Owens
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

Re: read file

2007-07-11 Thread Tom Phoenix
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

read file

2007-07-11 Thread jeniffer
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

Re: read file, search for a string, write results

2007-07-07 Thread Paul Lalli
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

read file, search for a string, write results

2007-07-07 Thread nomadcanuck
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

RE: perl crashing at $image->Read (file=> \*ARGV);

2004-09-13 Thread Brian Volk
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

RE: perl crashing at $image->Read (file=> \*ARGV);

2004-09-13 Thread Brian Volk
$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

RE: perl crashing at $image->Read (file=> \*ARGV);

2004-09-09 Thread Brian Volk
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

Re: perl crashing at $image->Read (file=> \*ARGV);

2004-09-09 Thread Wiggins d'Anconia
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

Re: perl crashing at $image->Read (file=> \*ARGV);

2004-09-09 Thread Wiggins d Anconia
> > 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

perl crashing at $image->Read (file=> \*ARGV);

2004-09-09 Thread Brian Volk
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

RE: read file in from bottom instead of top

2003-01-13 Thread Mark Anderson
> 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

RE: read file in from bottom instead of top

2003-01-13 Thread Wagner, David --- Senior Programmer Analyst --- WGO
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. > > >

Re: read file in from bottom instead of top

2003-01-13 Thread Paul Johnson
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

read file in from bottom instead of top

2003-01-13 Thread Larry Sandwick
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, "

Re: Read file from second line

2002-08-26 Thread Q
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

Re: Read file from second line

2002-08-26 Thread Felix Geerinckx
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

Re: Read file from second line

2002-08-26 Thread Tanton Gibbs
>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

Read file from second line

2002-08-26 Thread Q
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

Re: Read file symbol by symbol?

2002-04-17 Thread Ramis
"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

Re: Read file symbol by symbol?

2002-04-16 Thread Jonathan E. Paton
> 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..

Re: Read file symbol by symbol?

2002-04-16 Thread Sudarsan Raghavan
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

Re: Read file symbol by symbol?

2002-04-16 Thread Dave K
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"

Read file symbol by symbol?

2002-04-16 Thread Ramis
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]