On Fri, Feb 8, 2013 at 2:06 AM, Jim Gibson jimsgib...@gmail.com 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?
Thanks
On 8 Feb 2013 07:37, shawn wilson ag4ve...@gmail.com 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 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 @ARGV) {
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 jimsgib...@gmail.com wrote:
On Feb 7, 2013, at 10:34 PM, shawn wilson wrote:
How do I take in a file or pipe input? What I
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;
sub sws {
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
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 All
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
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 the
next
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);
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 = INFILE);
@sorted =
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
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 name6 pre2 number6
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
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 would
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
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]
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:
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 adding an empty
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/value go away.
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 = FH_D;
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 = FH_D;
foreach $record (@file_list) {
@t_array = split(/\|/, $record);
$alpha_hash{$t_array[0]} = $t_array[1];
}
close(FH_D);
--- Tim
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 read such
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 = FH_D;
foreach $record (@file_list) {
And in
open (FILE, yourfile.txt);
my @FD = FILE;
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: Reading File
Hi,
Let's say I'm
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
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]
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 = FH;
print $array[-1];
Tor
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
.
-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 = FILE;
close (FILE);
my $lastline = $FD[$#FD]
Hope this help,
Smiley Connie =)
- Original Message -
From: Karen Liew
Message -
From: David vd Geer Inhuur tbv IPlib [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Monday, June 24, 2002 7:35 PM
Subject: Re: Reading File
I am try-ing to work something out with seek for you, but just can't find
it yet.
This is how far I am yet
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
, 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, with \n)
for this test, and have
: 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 -
From: Connie Chan
To: Timothy Johnson ; 'Karen Liew Ying Ping ' ; [EMAIL
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, LFCR, and I don't know
what uses simply CR as EOL.
Macs use just CR. No machine that I know of uses LFCR as a line
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, LFCR, and I don't know what
uses simply CR as EOL.
Macs use just CR. No machine that I know of uses LFCR as a line
terminator.
Right,
35 matches
Mail list logo