Thanks
On 8 Feb 2013 07:37, "shawn wilson" wrote:
>
> How do I take in a file or pipe input?
Please check this
http://perldoc.perl.org/functions/open.html
What I want is:
> script.pl file.txt
> or
> cat file.txt | script.pl
>
> What I'm trying is:
> my $logfile;
> if (@ARGV and $ARGV[0] =~ /^-.
> On Fri, Feb 8, 2013 at 2:06 AM, Jim Gibson wrote:
>>
>> The null filehandle (<>) will read from standard input if @ARGV is empty,
>> and from the members of @ARGV, interpreting each scalar as a file name to be
>> opened automatically in succession.
>>
>> Does that do what you want?
>>
>>
Act
Ah, yeah that'll work. I can just set a count and
die "blah" if $count == 0;
Didn't think I could do that with a diamond.
Thanks
On Fri, Feb 8, 2013 at 2:06 AM, Jim Gibson wrote:
>
> On Feb 7, 2013, at 10:34 PM, shawn wilson wrote:
>
>> How do I take in a file or pipe input? What I want is:
>> s
On Feb 7, 2013, at 10:34 PM, shawn wilson wrote:
> How do I take in a file or pipe input? What I want is:
> script.pl file.txt
> or
> cat file.txt | script.pl
>
> What I'm trying is:
> my $logfile;
> if (@ARGV and $ARGV[0] =~ /^-./) {
> open($logfile, '<', $ARGV[0]);
> } elsif (-t STDIN and not
How do I take in a file or pipe input? What I want is:
script.pl file.txt
or
cat file.txt | script.pl
What I'm trying is:
my $logfile;
if (@ARGV and $ARGV[0] =~ /^-./) {
open($logfile, '<', $ARGV[0]);
} elsif (-t STDIN and not @ARGV) {
$logfile = ;
} else {
doe "no data"
}
PS - I want to av
On Feb 16, 8:06 pm, jwkr...@shaw.ca ("John W. Krahn") wrote:
> Herb wrote:
> > Hi All,
>
> Hello,
>
> > I am a perl novice and am having some trouble with formatting a web
> > file to put into a hash. I have the following code:
>
> > #!/usr/bin/perl -w
>
> > use LWP::Simple;
> > #use strict;
>
> >
Herb wrote:
Hi All,
Hello,
I am a perl novice and am having some trouble with formatting a web
file to put into a hash. I have the following code:
#!/usr/bin/perl -w
use LWP::Simple;
#use strict;
sub sws {
my $file = shift;
You should probably pass the filehandle instead of the
Hi All,
I am a perl novice and am having some trouble with formatting a web
file to put into a hash. I have the following code:
#!/usr/bin/perl -w
use LWP::Simple;
#use strict;
sub sws {
my $file = shift;
while (!eof(FH)) {
$line = ;
push @temp
Thanks ...
Thanks,
Paryushan
-Original Message-
From: Rob Dixon [mailto:rob.di...@gmx.com]
Sent: Friday, February 06, 2009 9:23 PM
To: Perl Beginners
Cc: Sarsamkar, Paryushan
Subject: Re: Reading file and changing contents which are not in one
line
Sarsamkar, Paryushan wrote:
> Hi
Hi All,
I have one xconf file whose contents are as follows. I actually want to
search for a property and change its value. Now what happens in my code
is while reading the file, each line is stored in $_ so actually the
line in my file is slit up in 2 or more lines, so I can not find the
prope
You may want to consider using a mod for the mailer.
I usually use Mail::Mailer for a task such as this.
use strict;
use warnings;
Good practice.
Chance Ervin
Senior Systems Engineer
Intelenet Communications
NOC 949 784-7911
[EMAIL PROTECTED]
On Fri, 19 Oct 2007 14:14:44 -070
On 10/19/07, Juan B <[EMAIL PROTECTED]> wrote:
> I need a script to read /var/log messages and each
> time it sees a line with the word "IDS" it will send
> the whole line via mail to the administrator
> #!/usr/local/bin/perl
>
> $file = '/var/log/messages'; # Name the file
> open(INFO,
Hi all !!
im really new to perl so please bare with me and
help..
I need a script to read /var/log messages and each
time it sees a line with the word "IDS" it will send
the whole line via mail to the administrator of the
IDS, here is an example of such a line:
Oct 19 15:40:30 172.31.0.254 %PIX-4
Hi Shawn,
Thanks for the detailed explanations.
But Edward(see one of posts in my thread) tells me to
try Bio::SeqIO from www.bioperl.org. After I try I
think it is what I really need.
Once again thank you so much for the help.
Li
__
chen li wrote:
You are 50% right. This method is not correct for the
first record(which actually contains ">' only) but it
is correct for the last record(and others in between).
I want to edit the file first and try to delete the
first ">" in this big file. I browse Programming Perl
and Perl
Hi Tom,
Thanks for the reply.
> Although it's tempting to set $/ to "\n>" for the
> file format you
> describe, that's probably not correct for the first
> or last record in
> your file.
You are 50% right. This method is not correct for the
first record(which actually contains ">' only) but it
q() ) {
push @seqs, $seq->seq();
} #end while
return [EMAIL PROTECTED];
}
Hope that helps.
Regards,
Edward WIJAYA
- Original Message -
From: chen li <[EMAIL PROTECTED]>
Date: Saturday, January 7, 2006 9:27 am
Subject: Re: new for reading file containing multiple records
>
Hi Shawn,
I use the your code to do the job:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $filename='sequence.fasta';
open (DATA,$filename) or die;
{local $/ = '>';
while( ){
print Dumper \$_;
}
}
exit;
And I get the following output:
$VAR1 = \'>';
$VAR1 =
On 1/5/06, chen li <[EMAIL PROTECTED]> wrote:
> Each record starts with ">". I want to read each
> record once at a time.I hear about a special variable
> call $/ might do the job but not sure how to use it.
The perlvar manpage documents $/ and all of Perl's other special
variables. In particular,
chen li wrote:
Each record starts with ">". I want to read each
record once at a time.I hear about a special variable
call $/ might do the job but not sure how to use it. I
wonder if anyone could help me out.
See `perldoc perlvar` and search for INPUT_RECORD_SEPARATOR.
Here is a simple script
chen li am Freitag, 6. Januar 2006 11.27:
> Hi Xicheng,
Hi Chen
> Thanks. I search the list before I post the question
> but I can't find similar topics. Could you please tell
> me some ealier posts? Also I try to use your code to
> read a very small file containing only these two
> records. Here
> Word wrapping possibly mangled the example records,
> could you please
> upload a handful of them in a file somewhere?
>
> -- fxn
Hi,
I am just a newbie. What is word wrapping? Is it a
perl module or something else?
Thanks,
Li
Hi Xicheng,
Thanks. I search the list before I post the question
but I can't find similar topics. Could you please tell
me some ealier posts? Also I try to use your code to
read a very small file containing only these two
records. Here is what I got:
This is record 1.
This is sequence:
This is re
On Jan 6, 2006, at 4:12, chen li wrote:
Hi all,
I have a big file (2.7G) containing multiple records
in this format:
gi|618748|dbj|D21618.1| MUS74F01 mouse embryonal
carcinoma cell line F9 Mus mus culus cDNA clone 74F01,
mRNA sequence
GCTGCCTCGACGATCTTCGCTTGCNTCCTCGCTCGCTGTCCCGTTGTCCTAGCCCGCC
Hi all,
I have a big file (2.7G) containing multiple records
in this format:
>gi|618748|dbj|D21618.1| MUS74F01 mouse embryonal
carcinoma cell line F9 Mus mus culus cDNA clone 74F01,
mRNA sequence
GCTGCCTCGACGATCTTCGCTTGCNTCCTCGCTCGCTGTCCCGTTGTCCTAGCCCGCCGCCGCCCGCTGAGCTTGTCTTT
ACCCTGCTTGCAGACATGGC
On 7-mrt-04, at 00:00, R. Joseph Newton wrote:
Bjorn Van Blanckenberg wrote:
On 3-mrt-04, at 09:56, R. Joseph Newton wrote:
I understand how the code works
It reads the file end split every line according to the tabs and then
sorts everything.
For returning the info it looks at colomn 5 (1-base
Bjorn Van Blanckenberg wrote:
> On 3-mrt-04, at 09:56, R. Joseph Newton wrote:
>
>
> I understand how the code works
>
> It reads the file end split every line according to the tabs and then
> sorts everything.
> For returning the info it looks at colomn 5 (1-based indexing) and if
> colomn 5 of t
On 3-mrt-04, at 09:56, R. Joseph Newton wrote:
Bjorn Van Blanckenberg wrote:
#!/usr/bin/perl
use strict;
use Getopt::Long;
GetOptions(\my %opt, 'filepath=s');
my $filepath = (%opt->{'filepath'});
my @fields = ();
my @sorted = ();
my $lastbit = 1;
my @bits = ();
open(INFILE,$filepath);
chomp(
Bjorn Van Blanckenberg wrote:
>
> #!/usr/bin/perl
>
> use strict;
> use Getopt::Long;
>
> GetOptions(\my %opt, 'filepath=s');
>
> my $filepath = (%opt->{'filepath'});
>
> my @fields = ();
> my @sorted = ();
> my $lastbit = 1;
> my @bits = ();
>
> open(INFILE,$filepath);
>
> chomp(@fields = );
>
>
Bjorn Van Blanckenberg wrote:
>
> On 28-feb-04, at 20:32, R. Joseph Newton wrote:
>
> > Bjorn Van Blanckenberg wrote:
> >
> >> let say that the file contains these items (every item is seperated
> >> with a tab)
> >>
> >> one title3 state3 name3 pre number3
> >> dip title6 state6 na
On 28-feb-04, at 20:32, R. Joseph Newton wrote:
Bjorn Van Blanckenberg wrote:
let say that the file contains these items (every item is seperated
with a tab)
...
one title3 state3 name3 pre number3
dip title6 state6 name6 pre2 number6
So what changes have you made in the code t
Bjorn Van Blanckenberg wrote:
> let say that the file contains these items (every item is seperated
> with a tab)
>
...
>
> one title3 state3 name3 pre number3
> dip title6 state6 name6 pre2 number6
>
So what changes have you made in the code to reflect this diffeence in
speci
let say that the file contains these items (every item is seperated
with a tab)
one title state name testing number
two title2 state2 name2 final number2
one title3 state3 name3 pre number3
four title4 state4 name4 tesing2 number4
six title5 state5 name5 t
> Dan Muey said:
>
> >> my %codes_hash = ();
> >
> > Change this to my %codes_hash;
> > the = () is adding an empty key/value
>
> Are you sure?
I assumed (I know I know one shouldn't assume ;p) that since I've had the same issue
and once I changed
my %hash = (); to my %hash; the empty key/valu
> Yah - that didn't work. It still would have needed the chomp;
>
Then it must be getting added from the a blank line (IE ^\n$ or somilar) in the file.
> Tim
>
> Paul Johnson wrote:
> > Dan Muey said:
> >
> >
> >>>my %codes_hash = ();
> >>
> >>Change this to my %codes_hash;
> >>the = () is
Yah - that didn't work. It still would have needed the chomp;
Tim
Paul Johnson wrote:
Dan Muey said:
my %codes_hash = ();
Change this to my %codes_hash;
the = () is adding an empty key/value
Are you sure?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMA
Dan Muey said:
>> my %codes_hash = ();
>
> Change this to my %codes_hash;
> the = () is adding an empty key/value
Are you sure?
--
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
> This works great, except when I do:
>
> for (keys %codes_hash) {
> print "$_|$codes_hash{$_}\n";
> }
>
> for my own confirmation, I'm getting a blank line in the
> printout. I re-checked my config file and made sure there
> was not an extra blank line at the end of the file. Do you
>
Tim McGeary wrote:
This works great, except when I do:
for (keys %codes_hash) {
print "$_|$codes_hash{$_}\n";
}
for my own confirmation, I'm getting a blank line in the printout. I
re-checked my config file and made sure there was not an extra blank
line at the end of the file. Do you have
This works great, except when I do:
for (keys %codes_hash) {
print "$_|$codes_hash{$_}\n";
}
for my own confirmation, I'm getting a blank line in the printout. I
re-checked my config file and made sure there was not an extra blank
line at the end of the file. Do you have any ideas why it woul
On Mon, Jun 23, 2003 at 01:39:49PM -0700, Madhu Reddy wrote:
A little unasked-for code review :-)
> my %alpha_hash = ();
> open(FH_D,"$d_list") || die "File opening $d_list\n";
^ ^
You don't need to quote the variable.
> @file_list = ;
> foreach $record (@file_list) {
And in
Tim McGeary wrote:
>
> I'm still very green to perl, so please forgive this possibly stupid
> question.
>
> I want to setup a configuration file to have a list of alpha codes
> delimiter and a unique number that will match the code e.g.
>
> PACT | 23
> PART | 24
> etc
>
> How is the best way to
This will do ...
alpha_hash is u r hash...
-
my %alpha_hash = ();
open(FH_D,"$d_list") || die "File opening $d_list\n";
@file_list = ;
foreach $record (@file_list) {
@t_array = split(/\|/, $record);
$alpha_hash{$t_array[0]} = $t_array[1];
}
close(FH_D);
--- Tim
This will do ...
alpha_hash is u r hash...
-
my %alpha_hash = ();
open(FH_D,"$d_list") || die "File opening $d_list\n";
@file_list = ;
foreach $record (@file_list) {
@t_array = split(/\|/, $record);
$alpha_hash{$t_array[0]} = $t_array[1];
}
close(FH_D);
--- Tim
I'm still very green to perl, so please forgive this possibly stupid
question.
I want to setup a configuration file to have a list of alpha codes
delimiter and a unique number that will match the code e.g.
PACT | 23
PART | 24
etc
How is the best way to read such a file into my program (hash ?)
onnie Chan" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, June 25, 2002 12:34 PM
Subject: Re: Reading File
Hi Connie,
what's your $PrevEOL?
did you declare it somewhere?
sorry i'm still a very beginning beginner in PERL
thanks.
- Original Message
lib
Sent: Tuesday, June 25, 2002 12:51 AM
Subject: Re: Reading File
Hi everybody,
I've done a dummy test, and finalized that David's method is the
Goal Method, that's really Really Very Great !!!
I've made a 50MB Text file ( Fixed length, 1001 char per line
>Hi everybody,
>I've done a dummy test, and finalized that David's method is the
>Goal Method, that's really Really Very Great !!!
>I've made a 50MB Text file ( Fixed length, 1001 char per line, with \n)
>for this test, and have the following results :
> SCRIPT 1 # Suggested by Johnson
e, mine one will surely halt the system (WinMe).
Wish you have a nice day,
Smiley Connie =)
- Original Message -
From: "David vd Geer Inhuur tbv IPlib" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, J
to memory.
-Original Message-
From: Connie Chan
To: Karen Liew Ying Ping; [EMAIL PROTECTED]
Sent: 6/24/02 3:20 AM
Subject: Re: Reading File
open (FILE, "yourfile.txt");
my @FD = ;
close (FILE);
my $lastline = $FD[$#FD]
Hope this help,
Smiley Connie =)
- Original Message -
Fr
> could puting the entire file into an aray then i think there is a function to
> get the number of elements... then just use that to know what the last
> element would be?
my @array = ;
print "$array[-1]";
Tor
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EM
could puting the entire file into an aray then i think there is a function to
get the number of elements... then just use that to know what the last
element would be?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Hi,
I added one. The seek didn't work.
I don't have the ReadBackwards, but at least some timeing results :
Benchmark: timing 1 iterations of complete, frk, pop...
complete: 21 wallclock secs (16.93 usr + 0.80 sys = 17.73 CPU) @ 564.02/s (n=1)
frk: 83 wallclock secs ( 1.34 usr
txt");
> my @FD = ;
> close (FILE);
>
> my $lastline = $FD[$#FD]
>
> Hope this help,
> Smiley Connie =)
>
>
> - Original Message -
> From: "Karen Liew Ying Ping" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monda
Karen Liew Ying Ping wrote:
>
> Hi,
Hello,
> Let's say I'm opening a file.
> How do I read the last line of the file?
> is there any function in doing so?
use File::ReadBackwards;
my $bw = File::ReadBackwards->new( $file ) or die "Cannot read $file:
$!";
my $last_line = $bw->readline;
# OR
open (FILE, "yourfile.txt");
my @FD = ;
close (FILE);
my $lastline = $FD[$#FD]
Hope this help,
Smiley Connie =)
- Original Message -
From: "Karen Liew Ying Ping" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 24, 2002 6:05 PM
Subject: R
Hi,
Let's say I'm opening a file.
How do I read the last line of the file?
is there any function in doing so?
Thanks.
At 07:11 AM 08/04/2001 -0700, Arthur Klassen wrote:
>[EMAIL PROTECTED] wrote:
>>
>> > Michael Fowler <[EMAIL PROTECTED]> said:
>>
>> > You left out the Macintosh EOL sequence, , and I don't know
>> > what uses simply as EOL.
>>
>> Macs use just . No machine that I know of uses as a line
>> t
[EMAIL PROTECTED] wrote:
>
> > Michael Fowler <[EMAIL PROTECTED]> said:
>
> > You left out the Macintosh EOL sequence, , and I don't know
> > what uses simply as EOL.
>
> Macs use just . No machine that I know of uses as a line
> terminator.
I don't know this from experience, but I remember
On Fri, Aug 03, 2001 at 01:40:30PM -0700, [EMAIL PROTECTED] wrote:
> > Michael Fowler <[EMAIL PROTECTED]> said:
>
> > You left out the Macintosh EOL sequence, , and I don't know what
> > uses simply as EOL.
>
> Macs use just . No machine that I know of uses as a line
> terminator.
Right, th
unless ($_ eq '');
}
Like I said, ugly, but it will work and give you a consistent file format to
work with in the second loop
Steve
-Original Message-
From: Sherlock Holmes [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 03, 2001 7:33 AM
To: [EMAIL PROTECTED]
Sub
I would like to create a perl script that reads lines from an ascii
file, but that reads them regardless of whichever of the three variants
(, or ) is actually in use as end-of-line, *without*
knowing beforehand which is the case. The script should run on many
systems (so installing a special
62 matches
Mail list logo