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
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
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
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
> 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
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
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 :
#!/usr/bin/perl
use strict;
my $file = "...";
open(FH, "<$file");
seek(FH,2,2);
my $curpos = tell(FH); $_ = ;
my $lastline = ;
close(FH);
print "$lastline \n";
print "$curpos \n";
# -
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: Reading File
Hi,
Let's say I'm
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
This is really ugly, but if you have the memory to handle a file that might
only use \r, and you don't mind using a temp file for the processing, here
is one possibility.
open(file, "c:/blah/sample.txt") || die "$!\n";
open(tempfile, ">c:/blah/temp.txt") || die "$!\n";
foreach () {
40 matches
Mail list logo