Deleting last 12 lines of a large file

2003-01-26 Thread Sukrit
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Listers,
How do i delete the last 12 (or so) lines of a large file (400+ lines)
without loading the whole into memory.

regards
sukrit

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 

iD8DBQE+M+BxWQMs1XfYH8QRAuaWAJ9VM65YLxvks64DjKNhCckhwWm8SQCgk2BP
G97VYH7ygmc+VAA5xAqGVWc=
=WZjT
-END PGP SIGNATURE-

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread Rob Dixon
Sukrit wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hi Listers,
> How do i delete the last 12 (or so) lines of a large file (400+ lines)
> without loading the whole into memory.

400 lines isn't too huge. I would say just read the file once to count
the
lines. Then re-read it, printing twenty less lines than you counted.
It's
dirty but it's quick :)

I'll even have a stab at the code for you:

use strict;
use warnings;

open FILE, 'ppm_search.txt' or die $!;
my $lines = grep 1, ;
seek FILE, 0, 0 or die $!;
$lines -= 20;
print .'' while ($lines--);

Cheers,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread Rob Dixon
Rob Dixon wrote:
> 400 lines isn't too huge. I would say just read the file once to count
> the
> lines. Then re-read it, printing twenty less lines than you counted.
> It's
> dirty but it's quick :)

Sorry, I don't know where I got 20 from! That should be $lines -= 12, of
course.

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Pairs have minimum difference

2003-01-26 Thread Nengbing Tao
Thanks!

Not quite yet! 
Each number can appear once in each column in the end output! This would
work for cases where those pair do not overlap. The problem comes in cases
like
@xa=(900,1000,1010,2040,2010,8000,);
@xb=(899,1005,1022,2020,2000,6000,,2);

I guess I have to track the various pairs of $i and $j if there are
multiple pairs for a particular $diff, and find the minimum
sum(abs($diff)) at the end, but not sure what data structure would be
better for the job. 


Nengbing




David wrote:

> Nengbing Tao wrote:


> > -90   87658675
> > 9012341324
> > -198  47654567
> >
> > Notice that |1500-1485|=|1500-1515|.
> > 

> how can you have negative if they are abs? anyway, have you try:

> #!/usr/bin/perl -w
> use strict;

> my @xa=(8765,6000,4765,3000,1530,1500,1465,1234,1000);
> my @xb=(8675,6000,4567,3100,3000,1545,1515,1485,1324,1005);
> my %hash;

> for my $i (@xa){for my $j (@xb){push(@{$hash{abs($i-$j)}},"$it$j")}};

> for my $diff (sort {$a <=> $b} keys %hash){
> print "$difft$_n" for(@{$hash{$diff}});
> }

> __END__

> prints:

> 0   60006000
> 0   30003000
> 5   10001005
> 15  15301545
> 15  15301515
> 15  15001515
> 15  15001485
> 20  14651485
> 45  15301485
> 45  15001545
> 50  14651515
> 80  14651545
>  etc

> not sure if that's what you want...

> david



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Rebuilding Devel Dir from Public Repository

2003-01-26 Thread John Baker

Greetings.

Apologies in advance if this is the wrong list.

Recently, my private development directory, containing
my entire module repository, was accidentally deleted.
Luckily, the public repository remained intact.

Question is: How do I go about rebuilding my private
repository from the public one? Ie, how do I rebuild
all the make, blib, the associated files and directories
for each pre-existing module in the

   /home/me/perl/modules/

..dir, from

   /usr/local/lib/perl5/site_perl/5.6.1/

...without having to hack around with h2xs for each and
every one?

Thanks in advance!
jab


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread Peter Scott
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Rob Dixon) writes:
>Sukrit wrote:
>> How do i delete the last 12 (or so) lines of a large file (400+ lines)
>> without loading the whole into memory.
>
>400 lines isn't too huge. I would say just read the file once to count
>the
>lines. Then re-read it, printing [12] less lines than you counted.

Maybe each line is a megabyte long? :-)

Anyway, here's a way that doesn't require keeping more than 12 lines
in memory and doesn't require reading twice:

$^I = ".bak";
my @queue;
while (<>) {
  push @queue, $_;
  print shift @queue if @queue > 12;
}

-- 
Peter Scott
http://www.perldebugged.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: used sendmail to send an attachment

2003-01-26 Thread Nilesh
I have download Sendmail module and installed.
I also copied Sendmail.pm in my lib path
as follows:
/opt/MIMperl5/lib/5.00503/sun4-solaris/ops.pm
/opt/MIMperl5/lib/5.00503/sun4-solaris/re.pm
/opt/MIMperl5/lib/5.00503/sun4-solaris/Sendmail.pm
/opt/MIMperl5/lib/5.00503/vars.pm
/opt/MIMperl5/lib/5.00503/Sendmail.pm

Now when i run my script,i still get
[usr@server] perl [28]./mail.pl
Can't locate Mail/Sendmail.pm in @INC (@INC contains:
/opt/MIMperl5/lib/5.00503/sun4-solaris /opt/MIMperl5/lib/5.00503
/opt/MIMperl5/lib/site_perl/5.005/sun4-solaris
/opt/MIMperl5/lib/site_perl/5.005 .) at ./mail.pl line 2.
BEGIN failed--compilation aborted at ./mail.pl line 2.
[usr@server] perl [29]

My Script is as follows
#! /usr/bin/perl
use Mail::Sendmail;

%mail = ( To  => '[EMAIL PROTECTED]',
  From=> '[EMAIL PROTECTED]',
  Message => "This is a very short message"
 );

sendmail(%mail) or die $Mail::Sendmail::error;

print "OK. Log says:\n", $Mail::Sendmail::log;



Thanks!
Nilesh Shirodkar





"Jerry Preston" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I use   $mailprog = '/usr/lib/sendmail'; to send e-mail with.  Can I use
> this to send an attachment?
>
> Thanks,
>
> Jerry
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Hide password on sign on

2003-01-26 Thread cuzican70
I do not want everyone hat clicks o m screen name to have access to my web 
page on email such as the cildren and my husband. how do i make it to where 
they have to know my password to get to my personal info.



Re: used sendmail to send an attachment

2003-01-26 Thread John Baker

>From the limited exposure I have to your lib path, it appears
as if Mail/Sendmail.pm doesn't exist.

"use Mail::Sendmail;" is looking for

   /some/path/to/Mail/Sendmail.pm

...but I don't see the Mail dir within

   /opt/MIMperl5/lib/5.00503/

Here's how mine looks:

   /usr/local/lib/perl5/site_perl/5.005/Mail/Sendmail.pm

jab

On Fri, 24 Jan 2003, Nilesh wrote:

> Date: Fri, 24 Jan 2003 14:38:04 -0800
> From: Nilesh <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: used sendmail to send an attachment
>
> I have download Sendmail module and installed.
> I also copied Sendmail.pm in my lib path
> as follows:
> /opt/MIMperl5/lib/5.00503/sun4-solaris/ops.pm
> /opt/MIMperl5/lib/5.00503/sun4-solaris/re.pm
> /opt/MIMperl5/lib/5.00503/sun4-solaris/Sendmail.pm
> /opt/MIMperl5/lib/5.00503/vars.pm
> /opt/MIMperl5/lib/5.00503/Sendmail.pm
>
> Now when i run my script,i still get
> [usr@server] perl [28]./mail.pl
> Can't locate Mail/Sendmail.pm in @INC (@INC contains:
> /opt/MIMperl5/lib/5.00503/sun4-solaris /opt/MIMperl5/lib/5.00503
> /opt/MIMperl5/lib/site_perl/5.005/sun4-solaris
> /opt/MIMperl5/lib/site_perl/5.005 .) at ./mail.pl line 2.
> BEGIN failed--compilation aborted at ./mail.pl line 2.
> [usr@server] perl [29]
>
> My Script is as follows
> #! /usr/bin/perl
> use Mail::Sendmail;
>
> %mail = ( To  => '[EMAIL PROTECTED]',
>   From=> '[EMAIL PROTECTED]',
>   Message => "This is a very short message"
>  );
>
> sendmail(%mail) or die $Mail::Sendmail::error;
>
> print "OK. Log says:\n", $Mail::Sendmail::log;
>
>
>
> Thanks!
> Nilesh Shirodkar
>
>
>
>
>
> "Jerry Preston" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I use   $mailprog = '/usr/lib/sendmail'; to send e-mail with.  Can I use
> > this to send an attachment?
> >
> > Thanks,
> >
> > Jerry
> >
> >
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: used sendmail to send an attachment

2003-01-26 Thread Johnathan Kupferer
Sendmail.pm should be at:

/opt/MIMperl5/lib/5.00503/sun4-solaris/Mail/Sendmail.pm

The Mail:: prefix translates into a directory, hence the message:

Can't locate Mail/Sendmail.pm in @INC

- Johnathan


Nilesh wrote:


I have download Sendmail module and installed.
I also copied Sendmail.pm in my lib path
as follows:
/opt/MIMperl5/lib/5.00503/sun4-solaris/ops.pm
/opt/MIMperl5/lib/5.00503/sun4-solaris/re.pm
/opt/MIMperl5/lib/5.00503/sun4-solaris/Sendmail.pm
/opt/MIMperl5/lib/5.00503/vars.pm
/opt/MIMperl5/lib/5.00503/Sendmail.pm

Now when i run my script,i still get
[usr@server] perl [28]./mail.pl
Can't locate Mail/Sendmail.pm in @INC (@INC contains:
/opt/MIMperl5/lib/5.00503/sun4-solaris /opt/MIMperl5/lib/5.00503
/opt/MIMperl5/lib/site_perl/5.005/sun4-solaris
/opt/MIMperl5/lib/site_perl/5.005 .) at ./mail.pl line 2.
BEGIN failed--compilation aborted at ./mail.pl line 2.
[usr@server] perl [29]
 

 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Hide password on sign on

2003-01-26 Thread Wiggins d'Anconia
[EMAIL PROTECTED] wrote:

I do not want everyone hat clicks o m screen name to have access to my web 
page on email such as the cildren and my husband. how do i make it to where 
they have to know my password to get to my personal info.


This has what to do with Perl? Whatever OS, web browser, or e-mail 
client you are using will determine this and should be asked of their 
help/support lists.

http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Deleting last 12 lines of a large file

2003-01-26 Thread Rob Dixon
Peter Scott wrote:
> Anyway, here's a way that doesn't require keeping more than 12 lines
> in memory and doesn't require reading twice:
>
> $^I = ".bak";
> my @queue;
> while (<>) {
>   push @queue, $_;
>   print shift @queue if @queue > 12;
> }

Neat. I like that :)

What's the $^I variable? Is it a 5.8 addition?

/R




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: used sendmail to send an attachment

2003-01-26 Thread R. Joseph Newton
Nilesh wrote:

> ...
> I also copied Sendmail.pm in my lib path ...

This might be the problem right here, or it might be benignly useless.  We use 
installers to do the work of installing files to the appropriate paths for a reason.  
The creators of a mofule know best how the elements interact with each other and the 
Perl installation as a whole.  There should be no reason to hand-crank your installs.  
If an installation screws up, then it might be time to roll up your sleeves and get 
under the hood, but generally, you should let PPM do its work, and trust it to get the 
job done.

I just installed this module--took about 15 seconds, and no effort on my part beyond 
the :
ppm> install Mail::sendmail
command.

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




how do I get a character at position index out of a string like c++ char * string[index] ?

2003-01-26 Thread Fleur Junier
how do I get a character at position index out of a string like c++ char 
* string[index] ?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Deleting last 12 lines of a large file

2003-01-26 Thread R. Joseph Newton
Peter Scott wrote:

> I$^I = ".bak";
> my @queue;

Hmmm.

push (@queue, $somevar);
somevar = pop(@queue);

...and double-H!

Could it be that that animal Perlites refer to as an array is really a linked list?

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread Peter Scott
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (R. Joseph Newton) writes:
>Peter Scott wrote:
>
>> I$^I = ".bak";
>> my @queue;
>
>Hmmm.
>
>push (@queue, $somevar);
>somevar = pop(@queue);
>
>...and double-H!
>
>Could it be that that animal Perlites refer to as an array is really a linked list?

It's both.  It can do everything a linked list can, and it can do everything an
array can.  All this in a single syntax!

-- 
Peter Scott
Perl classes in Los Angeles: http://www.psdt.com/services/classes/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread Peter Scott
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Rob Dixon) writes:
>Peter Scott wrote:
>> Anyway, here's a way that doesn't require keeping more than 12 lines
>> in memory and doesn't require reading twice:
>>
>> $^I = ".bak";
>> my @queue;
>> while (<>) {
>>   push @queue, $_;
>>   print shift @queue if @queue > 12;
>> }
>
>Neat. I like that :)
>
>What's the $^I variable? Is it a 5.8 addition?

No, it's a 4.0 addition (or earlier).  It's how to turn on the -i command-line
switch within code.  See -i in the perlrun page.

-- 
Peter Scott
Perl classes in Los Angeles: http://www.psdt.com/services/classes/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: how do I get a character at position index out of a string like c++ char * string[index] ?

2003-01-26 Thread Wiggins d'Anconia
Fleur Junier wrote:

how do I get a character at position index out of a string like c++ char 
* string[index] ?


perldoc -f index

Is this what you mean?

http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread Sukrit
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

> "Rob" == Rob Dixon <[EMAIL PROTECTED]> writes:

Rob> Sukrit wrote:
>> Hi Listers, How do i delete the last 12 (or so) lines of a
>> large file (400+ lines) without loading the whole into memory.

Rob> 400 lines isn't too huge. I would say just read the file once
Rob> to count the lines. Then re-read it, printing twenty less
Rob> lines than you counted.  It's dirty but it's quick :)

Rob> I'll even have a stab at the code for you:

Rob> use strict; use warnings;

Rob> open FILE, 'ppm_search.txt' or die $!; my $lines = grep
Rob> 1, ; seek FILE, 0, 0 or die $!; $lines -= 20; print
Rob> .'' while ($lines--);


While waiting for your reply, my goals changed a bit. i got some sort
of worm (redlof if you must know) on my windows machine (with some
11000 files affected). It tags to the end of every html file, so i
didn't want chomping of last 12 lines of files that hadn't got it :)
But i must say this brevity is the soul of wit and you guys sure are
witty (it'll take me a while to understand your codes!).

What i like about perl is that there are levels to it, my code works
it's no where as elgant as yours but it works. Elegance can wait but i
hope it'll come to me one day :)

sub clean_file1 {
my $file_to_clean = $_[0];
my @clean_array;
open(TO_CLEAN, $file_to_clean) || die "Can't Open File Stopping: $!";
#populate clean_array, with file without script
foreach(){
  if($_ =~ /\bKJ_start()\b/) {
last;} 
  else {
push(@clean_array, $_);}
}
close(TO_CLEAN) ||die "can't close1";

#write clean_array back to file
open(CLEANED,">$file_to_clean") || die "Hey Can't Open Stopping: $!";
foreach(@clean_array){print CLEANED $_;}
close(CLEANED);
}


Rob> Cheers,

Rob> Rob

Regards
sukrit Or 
Just Another Perl Lamer ;)
PS Sorry for onlist mail i always manage to forget that reply-to
isn't set to the list
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.8 

iD8DBQE+NC4aWQMs1XfYH8QRAi27AJ9xQjM1gu1IpC8075FeNFy0XBw2BQCeJ4NJ
BXOBx9bi/DZGal0jCWSr4lY=
=exW5
-END PGP SIGNATURE-

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Pairs have minimum difference

2003-01-26 Thread R. Joseph Newton
Nengbing Tao wrote:

> Thanks!
>
> Not quite yet!
> Each number can appear once in each column in the end output! This would
> work for cases where those pair do not overlap. The problem comes in cases
> like
> @xa=(900,1000,1010,2040,2010,8000,);
> @xb=(899,1005,1022,2020,2000,6000,,2);

What is it you are trying to accomplish here?  In practical terms, that is.  Something 
doesn't really click here, reading across lists of uneven length.  Its basically a 
design decision.  What is more appropriate, to take unmatched positions and view them 
as null?  Then your absolute difference would be undefined.  Or to view empty elements 
as 0--which would make the absolute difference equal to the absolute value of the 
element that is defined.

AS to sorting when you have matching values, the only solution I can see is to expand 
your ordering criteria, by adding a secondary sort field, perhaps doing the inner sort 
on the value of the element in the first list.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread John Baker
On Mon, 27 Jan 2003, Sukrit wrote:
>
> While waiting for your reply, my goals changed a bit. i got some sort
> of worm (redlof if you must know) on my windows machine (with some
> 11000 files affected). It tags to the end of every html file, so i
> didn't want chomping of last 12 lines of files that hadn't got it :)
> But i must say this brevity is the soul of wit and you guys sure are
> witty (it'll take me a while to understand your codes!).
>
As an aside, what you're seeing is the the "Microsoft Web Worm".
I've been tracking this on my home netwwork and over the course
of the past 24 hrs alone, I've been attacked from no less than
221 source addresses from 220 AS's (ah, the parsing power of
Perl).  This thing is massive.

The attack seems to be concentrated on port 1434 and is only
affecting MS SQL products.  Your friends told you to use FreeBSD
for a reason, and this is it. =)))

Anyway more info regarding the attack can be found at

http://news.yahoo.com/news?tmpl=story2&cid=569&ncid=738&e=4&u=
/nm/20030126/tc_nm/tech_microsoft_virus_dc

Notice one of the things MS says:

 "The unfortunate thing about this is when you know that this was a
problem and they (customers) hadn't updated," Charney said, "That's a bit
frustrating."

Nice.
jab


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




this should be simpel and short to answer right?

2003-01-26 Thread Fleur Junier
how do I get a character at position index out of a string like c++ char 
* string[index] ?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: this should be simpel and short to answer right?

2003-01-26 Thread John Baker

it is, yes. substr():

   http://www.perldoc.com/perl5.6/pod/func/substr.html

"perldoc -h" is your friend. =))
jab

On Sun, 26 Jan 2003, Fleur Junier wrote:

> Date: Sun, 26 Jan 2003 20:06:50 +0100
> From: Fleur Junier <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: this should be simpel and short to answer right?
>
> how do I get a character at position index out of a string like c++ char
> * string[index] ?
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread R. Joseph Newton
Sukrit wrote:

> While waiting for your reply, my goals changed a bit. i got some sort
> of worm (redlof if you must know) on my windows machine (with some
> 11000 files affected). It tags to the end of every html file, so i
> didn't want chomping of last 12 lines of files that hadn't got it :)
> But i must say this brevity is the soul of wit and you guys sure are
> witty (it'll take me a while to understand your codes!).

In that case, you can do it with a regualr expression, assuming that the text tagged 
on is always the same.  You would have to look for the first line of the garbage, then 
stop copying, although perhaps caching the discarded lines while scanning through, 
just in case there was a line that matched only by coincidence.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: how do I get a character at position index out of a string like c++ char * string[index] ?

2003-01-26 Thread R. Joseph Newton
Fleur Junier wrote:

> how do I get a character at position index out of a string like c++ char
> * string[index] ?

my $SourceString = "Hello, World!";
my @CharArray = split //, $SourceString;
foreach  (@CharArray) {
print "$_\n";
}



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread Rob Dixon
Peter Scott wrote:
> In article <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] (Rob Dixon) writes:
>> What's the $^I variable? Is it a 5.8 addition?
>
> No, it's a 4.0 addition (or earlier).  It's how to turn on the -i
> command-line switch within code.  See -i in the perlrun page.

Ah, my font let me down! I thought that was dollar, caret, pipe!

Yes, I knew all about -i, but always lamented the lack of
run-time control. Now I know my lamentations were
unnecessary.

Thanks Peter.

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Deleting last 12 lines of a large file

2003-01-26 Thread Rob Dixon
Peter Scott wrote:
> In article <[EMAIL PROTECTED]>,
>  [EMAIL PROTECTED] (R. Joseph Newton) writes:
>> Peter Scott wrote:
>>
>>> I$^I = ".bak";
>>> my @queue;
>>
>> Hmmm.
>>
>> push (@queue, $somevar);
>> somevar = pop(@queue);
>>
>> ...and double-H!
>>
>> Could it be that that animal Perlites refer to as an array is really
>> a linked list?
>
> It's both.  It can do everything a linked list can, and it can do
> everything an array can.  All this in a single syntax!

It's actually a 'deque', or double-ended queue (Knuth), with push/pop
working at one end and shift/unshift at the other. A deque
can be used as any of the lesser list forms but not as a linked list,
which provides insert and delete anywhere in the length of the list
without shifting existing data.

Cheers,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: how do I get a character at position index out of a string like c++ char * string[index] ?

2003-01-26 Thread Rob Dixon
Fleur Junier wrote:
> how do I get a character at position index out of a string like c++
> char
> * string[index] ?

The nearest equivalent is substr:

my $string = 'Mozzarella';
my $i = 6;
my $char = substr $string, $i, 1;# $char eq 'e'

which is subtly different from C's string[i] in that $char is not
a character (as Perl doesn't have such things) but a one-character
string.

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: this should be simpel and short to answer right?

2003-01-26 Thread Rob Dixon
John Baker wrote:
> it is, yes. substr():
>
>http://www.perldoc.com/perl5.6/pod/func/substr.html
>
> "perldoc -h" is your friend. =))

You should get out more John :-D

/R




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: this should be simpel and short to answer right?

2003-01-26 Thread Wiggins d'Anconia


Rob Dixon wrote:

John Baker wrote:


it is, yes. substr():

  http://www.perldoc.com/perl5.6/pod/func/substr.html

"perldoc -h" is your friend. =))



You should get out more John :-D



What or where is this "out" you speak of?

;-)...

http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Hash of Hashes of Arrays?

2003-01-26 Thread Jenda Krynicky
From: Pete Emerson <[EMAIL PROTECTED]>
> push @{$hash{$city}{$station}}, $add1;
> push @{$hash{$city}{$station}}, $add2;
> push @{$hash{$city}{$station}}, $state;
> push @{$hash{$city}{$station}}, $zip;
> push @{$hash{$city}{$station}}, $phone;

You can push several items into an array at once:

push @{$hash{$city}{$station}}, $add1, $add2, $state, $zip, $phone;

In this case it's actually not necessary to use push() at all:


my ($station, $add1, $add2, $city, $state, $zip, $phone)=split(/,/, 
$line);
$hash{$city}{$station} = [$add1, $add2, $city, $state, $zip, $phone];

or

my ($station, @data)=split(/,/, $line);
$hash{$city}{$station} = \@data;

Jenda

= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]