Re: reading files and scope of $_

2011-02-24 Thread John W. Krahn
D wrote: I ran into something that I need help understanding. In the attached script, subroutine file_proc1 converts all elements of @molec to undef, while file_proc2 does not. adjusting file_proc1 to first slurp the file into an array "fixes it". My best guess (via dum_sub) is that the subrou

Re: reading files c vs perl

2009-04-16 Thread Emen Zhao
This is no surprise, regexp is a relatively heavy function, a lot of dirty work behind the scene. On Thu, Apr 16, 2009 at 2:13 PM, John W. Krahn wrote: > Emen Zhao wrote: > >> This is off topic. But I'm just curious about why "4096" is picked here. >> Is >> there any particular reason behind it?

Re: reading files c vs perl

2009-04-16 Thread Emen Zhao
Thank you, Chas! This is great to know. I guess I got used to taking a plethora of memory as granted. :-) --Emen

Re: reading files c vs perl

2009-04-15 Thread John W. Krahn
Emen Zhao wrote: This is off topic. But I'm just curious about why "4096" is picked here. Is there any particular reason behind it? I guess you can even calc the lines like this - perl -0777 -wne 'print scalar ($_=~s/\n//g)' filename Except that it's slower than using tr///: $ time perl -ln077

Re: reading files c vs perl

2009-04-15 Thread Chas. Owens
On Thu, Apr 16, 2009 at 00:58, Emen Zhao wrote: > This is off topic. But I'm just curious about why "4096" is picked here. Is > there any particular reason behind it? I guess you can even calc the lines > like this - > perl -0777 -wne 'print scalar ($_=~s/\n//g)' filename > > Thanks, > Emen > 409

Re: reading files c vs perl

2009-04-15 Thread Emen Zhao
This is off topic. But I'm just curious about why "4096" is picked here. Is there any particular reason behind it? I guess you can even calc the lines like this - perl -0777 -wne 'print scalar ($_=~s/\n//g)' filename Thanks, Emen

Re: reading files c vs perl

2009-04-15 Thread Jerry Rocteur
On 15 Apr 2009, at 13:01, John W. Krahn wrote: Dermot wrote: 2009/4/14 Chas. Owens : On Tue, Apr 14, 2009 at 11:49, Rick wrote: is it true that perl will be just as fast as c for reading files ? for example cow...@amans:~$ time cat /usr/share/dict/words | perl wc.pl my $count = 0; $/ =

Re: reading files c vs perl

2009-04-15 Thread John W. Krahn
Dermot wrote: 2009/4/14 Chas. Owens : On Tue, Apr 14, 2009 at 11:49, Rick wrote: is it true that perl will be just as fast as c for reading files ? for example cow...@amans:~$ time cat /usr/share/dict/words | perl wc.pl my $count = 0; $/ = \4096; while (<>) { $count += tr/\n//;

Re: reading files c vs perl

2009-04-15 Thread Dermot
2009/4/14 Chas. Owens : > On Tue, Apr 14, 2009 at 11:49, Rick wrote: >> is it true that perl will be just as fast as c for reading files ? >> >> for example >> > cow...@amans:~$ time cat /usr/share/dict/words | perl wc.pl > my $count = 0; > > $/ = \4096; > while (<>) { >        $count += tr/\n//

Re: reading files c vs perl

2009-04-14 Thread Chas. Owens
On Tue, Apr 14, 2009 at 11:49, Rick wrote: > is it true that perl will be just as fast as c for reading files ? > > for example > > will  below be as fast as if it were written in c? > I said this because on random posts, I see that perl is optimized to work w/ > text files and it should be as fas

Re: Reading Files across directories and subdirectories

2008-12-02 Thread Ganesh Babu N
Koti, You can use File::List module which does your task very easily. Regards, Ganesh On Tue, Dec 2, 2008 at 5:18 PM, Koti <[EMAIL PROTECTED]> wrote: > Hi Matt, A very Good Morning, Need a small Info for my problem. > > I have a directory named "X" which has many sub directories > "Y","Z","W" a

Re: Reading Files across directories and subdirectories

2008-12-02 Thread James Moser
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Dec 2, 2008, at 11:51 AM, John W. Krahn wrote: James Moser wrote: On Dec 2, 2008, at 5:48 AM, Koti wrote: I have a directory named "X" which has many sub directories "Y","Z","W" and many files about 20 , and these sub directories also contain

Re: Reading Files across directories and subdirectories

2008-12-02 Thread John W. Krahn
James Moser wrote: On Dec 2, 2008, at 5:48 AM, Koti wrote: I have a directory named "X" which has many sub directories "Y","Z","W" and many files about 20 , and these sub directories also contain some more sub directories and files in them and those sub directories also contain more directorie

Re: Reading Files across directories and subdirectories

2008-12-02 Thread James Moser
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Dec 2, 2008, at 5:48 AM, Koti wrote: Hi Matt, A very Good Morning, Need a small Info for my problem. I have a directory named "X" which has many sub directories "Y","Z","W" and many files about 20 , and these sub directories also contain some m

Re: Reading Files across directories and subdirectories

2008-12-02 Thread Chas. Owens
On Tue, Dec 2, 2008 at 06:48, Koti <[EMAIL PROTECTED]> wrote: > Hi Matt, A very Good Morning, Need a small Info for my problem. > > I have a directory named "X" which has many sub directories > "Y","Z","W" and many files about 20 , and these sub directories also > contain some more sub directories

Re: Reading Files - Which approach is best

2008-10-29 Thread Jenda Krynicky
From: AndrewMcHorney <[EMAIL PROTECTED]> > I am continuing work on my script. I know there are many ways to read > files. I am going to be opening files that are text and also that are binary. > > Here are my 2 ways that I have done it it in the past. I am wondering > which way is best. > > $_

Re: Reading Files - Which approach is best

2008-10-26 Thread Mr. Shawn H. Corey
On Sun, 2008-10-26 at 09:15 -0700, AndrewMcHorney wrote: > Hello > > I am continuing work on my script. I know there are many ways to read > files. I am going to be opening files that are text and also that are binary. > > Here are my 2 ways that I have done it it in the past. I am wondering >

Re: Reading files for values

2007-10-19 Thread John W. Krahn
Joseph L. Casale wrote: > I have to search for text strings in files and then do something with the > line that matches in one scenario and in another I need to store the > contents of the following n lines. > > In the first requirement I think I have it beat, but I am lost on the > second. I thou

Re: Reading files for values

2007-10-18 Thread Matthew Whipple
Joseph L. Casale wrote: > I have to search for text strings in files and then do something with the > line that matches in one scenario and in another I need to store the contents > of the following n lines. > > In the first requirement I think I have it beat, but I am lost on the second. > I th

Re: Reading files for values

2007-10-18 Thread Gunnar Hjalmarsson
Joseph L. Casale wrote: I have to search for text strings in files and then do something with the line that matches in one scenario and in another I need to store the contents of the following n lines. In the first requirement I think I have it beat, but I am lost on the second. I thought I m

Re: Reading files

2003-12-03 Thread drieux
On Dec 3, 2003, at 7:44 AM, [EMAIL PROTECTED] wrote: how can I dup file handles do you mean: open(LOG, ">>/tmp/logfile"); open(STDERR, ">&LOG"); hence you code is One $ over the line? #!/usr/bin/perl -w use strict; # this would help you with finding those

Re: RE: Reading files

2003-12-03 Thread mgoland
Hi Bob, Thanks for a good reply, see my coments under your questions. - Original Message - From: Bob Showalter <[EMAIL PROTECTED]> Date: Wednesday, December 3, 2003 9:54 am Subject: RE: Reading files > [EMAIL PROTECTED] wrote: > > Hello All, > > I am trying to o

RE: Reading files

2003-12-03 Thread Bob Showalter
[EMAIL PROTECTED] wrote: > Hello All, > I am trying to open a file once , and then duplicate it's > File Handle. I am trying to workout example straight from > FAQ5, with no luck. What does "no luck" mean? You never tell us what happens when you run your code. > I will basicly trying to open a f

RE: Reading files

2003-12-03 Thread Wiggins d Anconia
> OK, but how about: > > 1)where is $LOG being set? $LOG is the first opened filehandle... > 2)does it get past the dies shown below? > 3)got strict? it's 'fer your own good, you know! ;) > Good question, good point > -Tom Kinzer > > > > #!/usr/bin/perl -w > > $file="./text"; > $|=1;

RE: Reading files

2003-12-02 Thread Tom Kinzer
-Original Message- From: Mark Goland [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 7:40 PM To: [EMAIL PROTECTED] Subject: Re: Reading files Sorry for not being more clear. The problem is that it doesnt seem to be able to read of the duped handle { $line2 is empty on }. - Or

Re: Reading files

2003-12-02 Thread Mark Goland
Sorry for not being more clear. The problem is that it doesnt seem to be able to read of the duped handle { $line2 is empty on }. - Original Message - From: "Tom Kinzer" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 02, 2003 4:15 PM Subject: R

RE: Reading files

2003-12-02 Thread Tom Kinzer
I don't see $LOG being set...strict would catch that. -Tom Kinzer > Hello All, > I am trying to open a file once , and then duplicate it's > File Handle. I am trying to workout example straight from > FAQ5, with no luck. I will basicly trying to open a file, dup > off a few handles and sprea

RE: Reading files

2003-12-02 Thread Dan Muey
> Hello All, > I am trying to open a file once , and then duplicate it's > File Handle. I am trying to workout example straight from > FAQ5, with no luck. I will basicly trying to open a file, dup > off a few handles and spread them across other processes. > Here is the code > Try use strict;

RE: Reading files

2003-12-02 Thread Tom Kinzer
start off by putting some "or die"s on those file opens. where are you breaking or what is the error message? not sure what the problem is exactly. -Tom Kinzer -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, December 02, 2003 9:53 AM To: [EMAIL PROTE

Re: Reading files in a directory

2003-10-30 Thread Aman Raheja
didn't get you what do u need to ask? Aman Raheja Systems Analyst AGF Technologies www.agftech.com - Original Message - From: "James Parsons" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, October 30, 2003 1:23 PM Subject: Reading files in a directory > Hi all > > I've

RE: Reading files in a directory

2003-10-30 Thread Dan Muey
> Hi all Howdy > > I've this Perl script to read all files in a directory and > if it finds a file with a certain then rename the file to header > Sounds like it might be handy. DMuey -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: reading files

2003-02-01 Thread Bob Showalter
mario kulka wrote: > Before I upload a file with a random name I would like to make sure > that another file with the same name doesn't already exist. Is there > a way to look for a specific $name file within a directory (on UNIX). Be aware that algorithms using -e or similar to check for the exis

Re: reading files

2003-02-01 Thread Michael Kelly
Hi Mario, On Sat, Feb 01, 2003 at 06:35:55AM +, mario kulka wrote: > Before I upload a file with a random name I would like to make sure that > another file with the same name doesn't already exist. Is there a way to > look for a specific $name file within a directory (on UNIX). if( -e $fil

Re: reading files

2003-02-01 Thread Paul Johnson
On Sat, Feb 01, 2003 at 06:35:55AM +, mario kulka wrote: > Before I upload a file with a random name I would like to make sure that > another file with the same name doesn't already exist. Is there a way to > look for a specific $name file within a directory (on UNIX). To check whether a fi

Re: Reading files into arrays

2001-11-30 Thread Leon
- Original Message - From: "Sandhya Sankaran" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, November 30, 2001 8:35 PM Subject: Reading files into arrays > I have just started programming in Perl and i need a solution to the > following problem : > > I have a file like this :

Re: Reading files into arrays

2001-11-30 Thread Shawn
> I have just started programming in Perl and i need a solution to the > following problem : > > I have a file like this : > >gi|56746574| > fjhgfjhgfhgghdgfdhjsfghdfjdksjdijkjdskjdkjkjlopodlskdldkksjdkjf > fjhgfjhgfhgghdgfdhjsfghdfjdksjdijkjdskjdkjkjlopodlskdldkksjdkjffjhgfjhgfhggh > dgfdhjsfghdf

Re: Reading files into arrays

2001-11-30 Thread N_Dinesh
Hi, Try out this code, #!/usr/bin/perl @lines; $array_counter=0; open(fd, "file.txt"); $line=; while($line) { if($line =~ /\>gi\|[\d+]/) { $line=; @lines[$array_counter++]=$line; } $line=; } print @lines; close(fd); Assume file.txt is the file out here. And @lines wil