Re: Question regarding while loops for reading files

2013-02-14 Thread Tiago Hori
Hi Jim, Thanks again. Very helpful as usual! T. On 2013-02-13, at 11:37 PM, Jim Gibson wrote: > > On Feb 13, 2013, at 6:47 PM, Tiago Hori wrote: > >> Hey Guys, >> >> I am still at the same place. I am writing these little pieces of code to >> try to learn the language better, so any advice

Re: Question regarding while loops for reading files

2013-02-14 Thread Tiago Hori
Hi John, Thanks. What I was trying to do there was to test if there was any numbers in the the first element of the first line. That was intended to get rid of the header line. I meant to use [0-9]* as character class to say "if there aren't any number of integers in the first element, next".

Re: Fwd: Question regarding while loops for reading files

2013-02-13 Thread John W. Krahn
Tiago Hori wrote: Hey Guys, Hello, I am still at the same place. I am writing these little pieces of code to try to learn the language better, so any advice would be useful. I am again parsing through tab delimited files and now trying to find fish from on id (in these case families AS5 and

Re: Question regarding while loops for reading files

2013-02-13 Thread Jim Gibson
On Feb 13, 2013, at 6:47 PM, Tiago Hori wrote: > Hey Guys, > > I am still at the same place. I am writing these little pieces of code to > try to learn the language better, so any advice would be useful. I am again > parsing through tab delimited files and now trying to find fish from on id > (i

Fwd: Question regarding while loops for reading files

2013-02-13 Thread Tiago Hori
Hey Guys, I am still at the same place. I am writing these little pieces of code to try to learn the language better, so any advice would be useful. I am again parsing through tab delimited files and now trying to find fish from on id (in these case families AS5 and AS9), retrieve the weights and

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

reading files and scope of $_

2011-02-24 Thread D
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 subroutine is cro

Re: Problem reading files

2010-10-17 Thread Kryten
I got to the bottom of this now. The file had previously been encrypted. Doh! Thanks, Stuart -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Problem reading files

2010-10-16 Thread Parag Kalra
Hi Kryten, Could you please post a sample content of the file and the actual content that is being displayed by the script on your editor. Also kind send the output of following script and check if its same as your previous output. #!/usr/bin/perl use strict; use warnings; use diagnostics; #ope

Re: Problem reading files

2010-10-16 Thread Shlomi Fish
Hi Kryten, On Friday 15 October 2010 08:42:07 Kryten wrote: > Hi, > I'm hitting a strange problem running simple perlscript on my new > laptop. > > To illustrate:- > > #!/usr/bin/perl > use strict; > use warnings; > use diagnostics; > > open my $configuration, 'H:\temp.txt' or die "my error: $!

Problem reading files

2010-10-16 Thread Kryten
Hi, I'm hitting a strange problem running simple perlscript on my new laptop. To illustrate:- #!/usr/bin/perl use strict; use warnings; use diagnostics; open my $configuration, 'H:\temp.txt' or die "my error: $!" ; my @info = <$configuration> ; chomp (@info); foreach my $i (@info) { print "$i\n

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 +=

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;

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 file

reading files c vs perl

2009-04-14 Thread Rick
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 fast as perl open FILE, $file or die "bad fil

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

Reading Files across directories and subdirectories

2008-12-02 Thread Koti
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 and files in them and those sub directories also contain more directori

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 >

Reading Files - Which approach is best

2008-10-26 Thread AndrewMcHorney
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 which way is best. $_ = join '',() or @SourceLine = () Which one i

Re: which is better when reading files

2008-01-13 Thread Lost Sheep Of the Porn
On Jan 11, 5:28 am, [EMAIL PROTECTED] (Rob Dixon) wrote: > Enjoy_Life wrote: > > > > > > > > hi, who can tell me which is better of the following codes? > > why there are different methods to read files? > > thanks > > > 1. open(INPUT, "< filedata") or die "Couldn't open filedata for reading: > >

Re: which is better when reading files

2008-01-11 Thread Rob Dixon
Enjoy_Life wrote: > hi, who can tell me which is better of the following codes? why there are different methods to read files? thanks 1. open(INPUT, "< filedata") or die "Couldn't open filedata for reading: $!\n"; while () { print if /blue/; } close(INPUT); 2. use IO::File;

Re: which is better when reading files

2008-01-11 Thread Enjoy_Life
thanks On Jan 11, 2008 5:04 PM, Jeff Pang <[EMAIL PROTECTED]> wrote: > On Jan 11, 2008 2:00 PM, Enjoy_Life <[EMAIL PROTECTED]> wrote: > > hi, who can tell me which is better of the following codes? > > why there are different methods to read files? > > thanks > > > > 1. open(INPUT, "< filedata")

Re: which is better when reading files

2008-01-11 Thread Jeff Pang
On Jan 11, 2008 2:00 PM, Enjoy_Life <[EMAIL PROTECTED]> wrote: > hi, who can tell me which is better of the following codes? > why there are different methods to read files? > thanks > > 1. open(INPUT, "< filedata") or die "Couldn't open filedata for reading: > $!\n"; > while () { > pr

which is better when reading files

2008-01-10 Thread Enjoy_Life
hi, who can tell me which is better of the following codes? why there are different methods to read files? thanks 1. open(INPUT, "< filedata") or die "Couldn't open filedata for reading: $!\n"; while () { print if /blue/; } close(INPUT); 2. use IO::File; $input = IO::File->ne

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

Reading files for values

2007-10-18 Thread Joseph L. Casale
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 might be able to search for

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
To: [EMAIL PROTECTED] Subject: Reading files 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. H

Reading files

2003-12-02 Thread mgoland
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 #!/usr/bin/perl -w $file="./tex

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

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]

Reading files in a directory

2003-10-30 Thread James Parsons
Hi all 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: perlre and reading files

2003-02-21 Thread John W. Krahn
"R. Joseph Newton" wrote: > > "John W. Krahn" wrote: > > > open() returns 'true' if the file was opened or 'false' if the file was > > not opened. > > Not exactly. At least not on my Perl installation [5.6.1 on W2K]. open > returns 1 on success, but does not return a value on failure. perldoc

Re: perlre and reading files

2003-02-21 Thread LaVei
William Olbrys wrote: > > > The problem is my search and replace does not work. I'm new to perl and > I find the perlre syntax very confusing. I simply want to replace one > word(a string) with a much bigger string! How are files accessed > differently than regular strings? I don't receive an

Re: perlre and reading files

2003-02-20 Thread R. Joseph Newton
"John W. Krahn" wrote: > open() returns 'true' if the file was opened or 'false' if the file was > not opened. Not exactly. At least not on my Perl installation [5.6.1 on W2K]. open returns 1 on success, but does not return a value on failure. #!/usr/bin/perl -w use strict; use warnings; my

Re: perlre and reading files

2003-02-20 Thread R. Joseph Newton
Corrections "R. Joseph Newton" wrote: > > What do you think you are dong here? As far as I know, open is a void function. I was forgetting that it returns a true value, that can be tested by open FILE, "< fileName" or fail_statement; > > perldoc -f open > > > $index = open (TEXT, "../htdocs/gam

Re: perlre and reading files

2003-02-20 Thread R. Joseph Newton
William Olbrys wrote: > I've started writing a simple perl script for a web site so I can update > it more quickly, but as I have a bit of a problem. > > Here is what I have: > > #!c:/Perl/bin/perl > print "Content-type: text/html\n\n"; > $game = open (TEXT, "../htdocs/gameplow/game"); What do yo

Re: perlre and reading files

2003-02-20 Thread John W. Krahn
William Olbrys wrote: > > I've started writing a simple perl script for a web site so I can update > it more quickly, but as I have a bit of a problem. > > Here is what I have: > > #!c:/Perl/bin/perl You should enable warnings and strictures when developing your program. use warnings; use stri

perlre and reading files

2003-02-20 Thread William Olbrys
I've started writing a simple perl script for a web site so I can update it more quickly, but as I have a bit of a problem. Here is what I have: #!c:/Perl/bin/perl print "Content-type: text/html\n\n"; $game = open (TEXT, "../htdocs/gameplow/game"); $index = open (TEXT, "../htdocs/gameplow/index")

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

reading files

2003-01-31 Thread mario kulka
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). thanks, M _ Protect

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 :

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

Reading files into arrays

2001-11-30 Thread Sandhya Sankaran
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 dgfdhjsfghdfjdksjdijkjdskj