[12338] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5938 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 9 20:07:22 1999

Date: Wed, 9 Jun 99 17:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 9 Jun 1999     Volume: 8 Number: 5938

Today's topics:
        "borrowing perl" <sun_tong_nospam@zdnetmail.com>
    Re: Conditional END blocks (Matthew Bafford)
    Re: Eval loading modules (Andrew Allen)
        Flag in textfile <technology@workmail.com>
        Flag in textfile <technology@workmail.com>
    Re: Get Date in Perl <webmaster@chatbase.com>
    Re: How to get info from a file with sed/awk/perl (Kenny McCormack)
    Re: indexing into a hash (Andrew Allen)
    Re: indexing into a hash <rootbeer@redcat.com>
    Re: invoking a script (not in a subshell) (Andrew Allen)
    Re: Overflow error using an Array. (Marcel Grunauer)
        perl pager- help <divirgil@hotmail.com>
    Re: perl pager- help <rootbeer@redcat.com>
        problem with html pop mail <mitt@uninet.ee>
    Re: problem with html pop mail <rootbeer@redcat.com>
    Re: Regexpr for loop to handle e-address list dalehend@flash.net
    Re: Regexpr for loop to handle e-address list <rootbeer@redcat.com>
        Script times-out after x minutes <mikane@shell3.ba.best.com>
    Re: Script times-out after x minutes <rootbeer@redcat.com>
    Re: Separating array into alphabetical array of arrays (Matthew Bafford)
    Re: Sequently adding data to a hash with $x[x..x]??? (Dean Hudson)
        Slowness in flock? <$nospam$@please.$spam>
    Re: sorting <Webdesigner@NewWebSite.com>
        Sub on another drive <akadakia@my-deja.com>
    Re: Telnet monitor <dcooper@cts.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 09 Jun 1999 19:01:54 -0400
From: Tong <sun_tong_nospam@zdnetmail.com>
Subject: "borrowing perl"
Message-Id: <375EF262.3551105E@zdnetmail.com>

Hi,

How can I "borrow" someone else's installed perl & libs?

Normally I just install perl and its liberaries then use it. Now moving
to another unix machine and no longer have enough space. Howevery I
found another well installed perl with full libraries mounted on
/disk1.../perl5 

So, here comes my question. How can I "borrow" his well installed perl &
libs?

- Is that easy?
- Do I have to have the same dir name as he installed the perl?
- how to setup the @INC and what so ever...?

Thanks

-- 
remove _nospam to reply.


------------------------------

Date: Wed, 09 Jun 1999 22:07:33 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Conditional END blocks
Message-Id: <slrn7ltobn.bc6.dragons@dragons.duesouth.net>

On 9 Jun 1999 18:25:46 GMT, Gregory Snow <snow@biostat.washington.edu>
was experimenting with the one of Ilya's new Regex features, and quite was
astonished to find he had sent the following:
: sub test {
:   print "in sub\n";
:   END { print "ending stuff: $temp\n"; }
: 
: }

sub test {
    print "in sub\n";
    if ( $^O =~ /linux/i ) {
        eval qq{
            END {
                print "Linux!\n";
            }
        }
    }
}

: Thanks,

HTH,

--Matthew


------------------------------

Date: 9 Jun 1999 22:12:25 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Eval loading modules
Message-Id: <7jmos9$eba$7@fcnews.fc.hp.com>

Joakim Mared (joakim@champion.se) wrote:
: I've run in to something i can't really understand, and would greatly
: appreciate an explanation or a reference to some document that could
: explain why my code behaves like this.

: imagine that i want a conditional loading of a module, ie. if we have
: the module, use it, if we don't have it use another way, but don't die.
: 'ayrnieu, EFnet, #perl' suggested this:

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

: if (eval 'use MyModule', $@ eq '') {
:     print "We have our module\n";
: } else {
:     print "We don't have our module\n";
: }

: this did not work, the module was never really 'used', but this approach
: works:

It does, but it 'uses' it at run-time (which is practically a
require), which might be too late. You may want to wrap this in a
BEGIN block.

Andrew


------------------------------

Date: Wed, 09 Jun 1999 16:29:01 -0700
From: Raj <technology@workmail.com>
Subject: Flag in textfile
Message-Id: <375EF8BD.4FE9CA90@workmail.com>


I have an option provided for the user on the web page to make an
existing value online /offline
( not delete..but invisible to the user in that list).
all the values ( each in aline) will be store in txt file.
I'm thinking of implementing with the help of some flag against each
value...like

value1:flag_on
value2:flag_off
 ....
and so on....

what do u think is a better way...and any clue on that CGI/Perl Script
 ...

Thanx in Advance...



------------------------------

Date: Wed, 09 Jun 1999 16:30:15 -0700
From: Raj <technology@workmail.com>
Subject: Flag in textfile
Message-Id: <375EF907.F0073C9A@workmail.com>


I have an option provided for the user on the web page to make an
existing value online /offline
( not delete..but invisible to the user in that list).
all the values ( each in aline) will be store in txt file.
I'm thinking of implementing with the help of some flag against each
value...like

value1:flag_on
value2:flag_off
 ....
and so on....

please suggest a better way and i appreciate any clue on that CGI/Perl
Script ...

Thanx in Advance...



------------------------------

Date: Wed, 09 Jun 1999 16:46:33 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: Get Date in Perl
Message-Id: <375EFCD9.A21D5C4C@chatbase.com>

outlaw_torn wrote:
> 
> In article <x7btes8not.fsf@home.sysarch.com>,
>   Uri Guttman <uri@sysarch.com> wrote:
> 
> > that should be $current_time[5] and it is not a 2 digit year. you have
> > just propogated a y2k bug.
> 
> Yeah...everyone has to do their part

Yes, to help, just as Uri did for you. Something wrong with that?...
That's sort of the point to this NG.

> > the year value is an offset from 1900 which
> > you would have know had you consulted the documentation.
> 
> Doco...whats that?

Loco, who?
 
> > why do you post answers which are not correct? why are you guessing
> what
> > the values are?
> 
> Because I don't have my perl book with me, and I figure I wouldn't have
> have any fussy pricks that love to fuckin whinge reading my post.

Or people that spend a great deal of time in here helping people daily,
contributing to the evolution of the Perl language for the better. You
don't know how lucky you are to even be subjected to such people's
knowledge, and have them be so willing to share it with you and
personally email you, even to tell you that you're wrong -- which is
never a bad thing! How many other NG's are specifically geared towards
such a popular language and have the actual authors of the very books
you own (If you own any good one's!) post help to you and others every
day. You should be lucky and glad when someone like Tom Christiansen or
Uri takes the time to help people, let alone to email you.

I honestly don't see how they get the time, I really don't. I hardly
have the time myself to post here, so I rarely offer help. But how can
you overlook the obvious point of the post so easily? And then to
further embarrass yourself by using foul language? That just shows your
belligerent stupidity and doesn't impress anyone. Think about it for a
moment and calm down, no harm came of it, other then your brain getting
another wrinkle from learning something.
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


------------------------------

Date: 9 Jun 1999 17:38:33 -0500
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: How to get info from a file with sed/awk/perl
Message-Id: <7jmqd9$pqd$1@yin.interaccess.com>

In article <375eba3a.0@omega>, Claudio Gutierrez <cgutierr@firstcom.cl> wrote:
>This is a multi-part message in MIME format.

Generally, a mistake on the Usenet.

>Sorry if this a basic questionand, of course, the cross post.   I need =
>to process a text file containing statistics in the next way:=20
>1)find the lines where appear the string 4[0-9][0-9][0-9] and after the =
>4 digits a blank space
>2) once we find such line, join the previous line with the curren and =
>the next.
>
>Example
>
>aaaa aaaaaa aaaa
>bbbbbb bbbbbbb bbbbbbb
>4325 ccccc cccccc
>ddddd dddd ddd
>eeee eeeeeeeee eeee
>
>The result:
>
>bbbbbb bbbbbbb bbbbbbb 4325 ccccc cccccc ddddd dddd ddd

The general idiom is:

	/^4[0-9][0-9][0-9]/ { getline Next ; print Prev,$0,Next }
	{ Prev = $0 }

>Thanks

Hope it helps...

55 lines of crap that doesn't belong on the Usenet - mercifully deleted.


------------------------------

Date: 9 Jun 1999 22:07:26 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: indexing into a hash
Message-Id: <7jmoiu$eba$6@fcnews.fc.hp.com>

Jim Keefer (jim@sismicro.com) wrote:
: Since perl implements a hash as two parallel arrays, is there a way I
: can index into a hash?

Yes, but it won't be fast (but it is half-fast :)

$hash{(keys %hash)[0]}

Also, any changes to the keys of hash might rehash and change the
order.

Andrew


------------------------------

Date: Wed, 9 Jun 1999 16:11:34 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: indexing into a hash
Message-Id: <Pine.GSO.4.02A.9906091605320.26349-100000@user2.teleport.com>

On Wed, 9 Jun 1999, Jim Keefer wrote:

> Since perl implements a hash as two parallel arrays, is there a way I
> can index into a hash?

No more efficiently than the hash is already. At least, not without a tied
hash - which is probably not more efficient than the hash is already.

> I need the speed of a hash key look up, but I also need to be able to
> get the hash key from an integer index.

It sounds like what you want is something like an array whose indices are
(optionally) found via a hash ( $array[ $hash{$key} ] ), which (I think)
is what you're doing now. Alternatively, you could store a reference into
a hash and also into an array: $hash{$key} and $array[$num] would each be
a reference to the same item.

But there's not much you can do to speed up hash access. Hashes are
already about as speedy as they can get.

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: 9 Jun 1999 22:04:43 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: invoking a script (not in a subshell)
Message-Id: <7jmodr$eba$5@fcnews.fc.hp.com>

Dan Shea (dshea@taurus.pppl.gov) wrote:

: Hi,

: I've read the perl faq, which re-directs me to the comp.unix.questions
: faq, which points to a non-existant ftp site in the attempt to answer the
: following question.

: I have a perl script which needs to look at users environment variables,
: strip out duplicate instances of paths: 

: e.g. 

: $PATH = .:/bin:/usr/bin:/usr/bin

: would become

: $PATH = .:/bin:/usr/bin


: Now, what I am trying to figure out is how I can force my Perl script to
: run in the current shell, instead of forking a subshell.

Ain't gonna happen. Since your current shell isn't perl, you can't run
perl in your current shell.

You could print out the new path to stdout, and then write a shell
script that you source ('source myscript' or '. myscript', depending
on the shell) that looks something like

  PATH=`getridofdupsinperl $PATH`;
  export PATH

or

  setenv PATH `getridofdupsinperl $PATH`;

or however you'd do it in your particular shell.

Andrew


------------------------------

Date: Wed, 09 Jun 1999 22:57:39 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Overflow error using an Array.
Message-Id: <375ff04a.12062434@enews.newsguy.com>

On Sun, 16 May 1999 13:09:43 +0100, Tim Pickrell
<pickrell@hursley.ibm.com> wrote:

>I'm running a Perl script on Win32 which works fine using a
>small set of data. The program parses a file and loads it into
>two 2-D Arrays. With larger files I loose data - it gets corrupted. By
>larger -
>I mean each array has around 400 rows x 10 columns ( i.e not very
>large). 
>I'm reasonably confident of the program logic.
>
>I'd like to know if anyone has had a similar problem. Can I re-build
>Perl to handle a large array ? 
>

Yes, I imagine Perl might choke on huge data structures like these.
Yes, rebuild Perl with the -HUGEARRAY directive. Be sure to install
the PSI::ESP module.

Marcel



------------------------------

Date: Wed, 09 Jun 1999 21:35:07 GMT
From: divirgil <divirgil@hotmail.com>
Subject: perl pager- help
Message-Id: <7jmmma$vl8$1@nnrp1.deja.com>

Hey all,
I need some help.

I have been reading lots of perl books lately...
But I can only seem to get half the job done....

I am looking for a Win32 script <ouch, tell me about it!>
That will request a web page every 5 minutes or so,
from a SuiteSpot server on an NT4 Box.
(That's the easy part I have already done)

If there is no response-- ie: the server is down...
The script should send/post an e-mail message to
motorola.com web page with the proper fields filled in,
that will page me with the . $res->status_line message.

That way I will know If I have to high-tail it 2 work...
or call some other lackey to flip the server over 4 me.

any input would be appreciated
~diVirgil
--
thanx4playing
http://www.toad.net/~divirgil


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Wed, 9 Jun 1999 16:47:19 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: perl pager- help
Message-Id: <Pine.GSO.4.02A.9906091644090.26349-100000@user2.teleport.com>

On Wed, 9 Jun 1999, divirgil wrote:

> I am looking for a Win32 script <ouch, tell me about it!>

Are you looking for it or are you looking to write it? Here, we help
people to write things. But you can look for it by searching for software
archives on Yahoo.

> That will request a web page every 5 minutes or so,

Use the LWP package, from CPAN.

> If there is no response-- ie: the server is down...

Are you only trying to ensure that a server is running? Get Linux. :-)
But it may be that the server is running and you've just got some net
troubles between you and the server. 

> The script should send/post an e-mail message to

There are modules for sending mail on CPAN, too.

Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Thu, 10 Jun 1999 01:13:08 +0300
From: "Tarmo Mitt" <mitt@uninet.ee>
Subject: problem with html pop mail
Message-Id: <375ee713$0$2287@diablo.uninet.ee>

Hi.
The problem goes here:
I have looked the html based perl pop mail checkers and senders.
But the problem is that when i check mail and read it, then it deletes from
server it too.
Is it any possible to force the script to leave a copy of msg to server.
If anybody can help me i would be wery thankful.

Also a little example is welcome.

Thanks

All Best
Tarmo




------------------------------

Date: Wed, 9 Jun 1999 16:14:01 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: problem with html pop mail
Message-Id: <Pine.GSO.4.02A.9906091613230.26349-100000@user2.teleport.com>

On Thu, 10 Jun 1999, Tarmo Mitt wrote:

> I have looked the html based perl pop mail checkers and senders.
> But the problem is that when i check mail and read it, then it deletes from
> server it too.
> Is it any possible to force the script to leave a copy of msg to server.

It may be possible, if the protocol (and the server) allow it. Check with
the docs, FAQs, and newsgroups about the protocol and server you're using.
Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Wed, 09 Jun 1999 23:15:24 GMT
From: dalehend@flash.net
Subject: Re: Regexpr for loop to handle e-address list
Message-Id: <375ef4f7.25859463@news.flash.net>




No, I did not mean to imply that there were quotes as part of the
email address. In fact, there are not. 
But I am reading a file that has a variable defined using a quoted
list, like so -
$emaillist = "younme\@work.com shenhim\@work.com";

I would like to have the regexpr to get what is between the quotes.


thanks



On 9 Jun 1999 22:04:36 -0000, Jonathan Stowe <gellyfish@gellyfish.com>
wrote:

>On Wed, 09 Jun 1999 16:34:35 GMT dalehend@flash.net wrote:
>> On Wed, 9 Jun 1999 09:07:08 -0700, Tom Phoenix <rootbeer@redcat.com>
>> wrote:
>>>On Wed, 9 Jun 1999 dalehend@flash.net wrote:
>>>
>>>> Does have an example that I can expand on in order to parse a quoted
>>>> email list that can be 1 or more lines. In other words -
>>>> "john\@town.com ben\@town.com younme\@work.com
>>>>              sebastian\@town.org isaac\@town.org"
>>>
>>>What do you do with e-mail addresses containing quote marks or spaces?
>>>Write to <"fred & barney"@redcat.com> if you don't believe that there are
>>>such addresses. :-)
>>>
>>>To do this properly, you'd need to parse the addresses. See whether the
>>>Mail::Address module from CPAN will help you to do what you need. Good
>>>luck!
>>>
>> 
>> The email list is the value for a $variable, so all I am wanting to do
>> is parse a quoted list.
>> 
>
>Yeah but you still want to use Mail::Address (part of the Mail-tools
>package from CPAN) :
>
>
>#!/usr/bin/perl -w
>
>use strict;
>
>use Mail::Address;
>
>my $list =<<'BLAH';
>doris&sceptic@gellyfish.com blah@[194.112.49.16]
>"pager:1123567"@somepager.com
>normail@woof.com "Yowsa - its me"@thing.com
>BLAH
>
>my @addresses = Mail::Address->parse($list);
>
>foreach (@addresses)
>{
>  print $_->format,"\n";
>}
>
>/J\
>-- 
>Jonathan Stowe <jns@gellyfish.com>
>Some of your questions answered:
><URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
>Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>



------------------------------

Date: Wed, 9 Jun 1999 16:52:18 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Regexpr for loop to handle e-address list
Message-Id: <Pine.GSO.4.02A.9906091648290.26349-100000@user2.teleport.com>

On Wed, 9 Jun 1999 dalehend@flash.net wrote:

> $emaillist = "younme\@work.com shenhim\@work.com";
> 
> I would like to have the regexpr to get what is between the quotes.

I think you mean, you want a pattern which will pick out the well-formed
e-mail addresses within a single string. 

I've said it before and I'll say it again: You want a parser to properly
parse the e-mail addresses. A simple regular expression just ain't gonna
cut it.

Have you tried Mail::Address from CPAN yet? It may (or may not) be what
you need.

Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: 09 Jun 1999 21:55:32 GMT
From: <mikane@shell3.ba.best.com>
Subject: Script times-out after x minutes
Message-Id: <375ee2d4$0$222@nntp1.ba.best.com>


I have a Perl script (client) that executes a program on another UNIX box
(server) using RPC. The server has timeouts which sometimes fail stalling
the client. How can I code the client such that it terminates execution
after 5 min while it is waiting for a responce fron the server.


Mike





------------------------------

Date: Wed, 9 Jun 1999 16:13:12 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Script times-out after x minutes
Message-Id: <Pine.GSO.4.02A.9906091611530.26349-100000@user2.teleport.com>

On 9 Jun 1999 mikane@shell3.ba.best.com wrote:

> How can I code the client such that it terminates execution
> after 5 min while it is waiting for a responce fron the server.

Have you seen what the FAQ says about this? See section eight. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



------------------------------

Date: Wed, 09 Jun 1999 22:37:45 GMT
From: dragons@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Separating array into alphabetical array of arrays
Message-Id: <slrn7ltqhu.bdg.dragons@dragons.duesouth.net>

On Wed, 09 Jun 1999 18:59:29 GMT, Marc Bissonnette <dragnet@internalysis.com>
hacked a version of perlbug to post the following to comp.lang.perl.misc:
: I've recently completed a script that reads in a pipe deparate file of names, 
: addresses, etc, sorts them, formats them and prints to file, thanks to help 
: recieved from this group (thanks again!). Now here's what I need to do:

Gratz!
 
: Rather than print one long file sorted alphabetically, I need to have a 
: separate file for each letter (i.e. all names starting with 'a' then 'b', etc)

Ok.
 
: Can someone point me in the right direction to do this? (Either separating th
: array into separate arrays by letter, or printing to a file depending on the 
: first letter of an array)

If it's sorted, just do something like ('like', in this case, meaning I
didn't test it):

my $last_letter = '';

for ( @lines ) {
    next unless /^([a-zA-Z])/;
    
    if ( lc $1 ne $last_letter ) {
        open OUT, "my_dir/$1" or
            die "Couldn't open my_dir/$1: $!\n";          
    }

    print OUT;
}    

or, put it in a hash by letter:

my %letters;

for ( @lines ) {
    next unless /^([a-zA-Z])/;
    $letters{lc $1} = $_;
}

: Many thanks,

HTH,

--Matthew


------------------------------

Date: 9 Jun 1999 15:57:42 -0700
From: deanh@nwnet.net (Dean Hudson)
Subject: Re: Sequently adding data to a hash with $x[x..x]???
Message-Id: <7jmrh6$jau@cypress.nwnet.net>

In article <375EDC6B.FD9511C7@falukuriren.se>,
Mats Pettersson  <mats.pettersson@falukuriren.se> wrote:
>Sorry, i try to explain it better.
>
>I have a file with several lines of data. Each line has numeric (integer) values separated by comma, as follows...
>
>vv,ll,kk,dd,kk,dd,kk,dd....(...and so on)
>
>...where vv= some number (always first on the line),
>         ll = length of data (number of pairs of keys and values)
>         kk = key
>         dd = value
>
>The first two values of each line should NOT get in the %hash.
>
>Since there are several lines of data, i want to build a %hash and add data to it as i loop through the lines.
>
>Now, the problem is; if i (after an apropriate split, of course) do a "%hash = @line[2..5]", the previus line of data gets "lost" at each iteration through the loop.

If I remember correctly, the code in your original post was doing
something like:

while ( <> ) {
    # chomp and split into @ln
    %hsh = @ln[2..5];
}

This reassigns %hsh every time you step through your while loop.

>
>So, after the loop i end up with just the last line in the file, not a complete %hash of all the keys and values in the file put together.
>
>Is there somekind of operator like "+=" (tried it, doesn't work) i can use, or do i have to build a @scalar first and assign it to the %hash afterwards?
>
>Like i have it now, i use a for() loop to insert the keys and values, but it would be neat if there was a simpler way.

I'm not sure. This works, but is not particularly pretty:

# ----- code ----- #

#!/usr/bin/perl -w

use strict;
my ( %hsh, $k );

while ( <DATA> ) {
    chomp;
    /^[^,]+,[^,]+/g; 			# step past 1 & 2
    while ( /([^,]+),([^,]+)/g ) {      # grab a pair
        $hsh{$1} = $2;  		# assign to %hsh
    }
}

for $k ( sort keys %hsh ) {
    print "$k => $hsh{$k}\n";
}

__END__

1,1,2,2,3,3,4,4,5,5,6,6,7,7
8,8,9,9,10,10,11,11,12,12
13,13,14,14,15,15,16,16,17,17,18,18

# ----- code ----- #

Here's the output:

deanh@akira:~ > ./csvhash
10 => 10
11 => 11
12 => 12
14 => 14
15 => 15
16 => 16
17 => 17
18 => 18
2 => 2
3 => 3
4 => 4
5 => 5
6 => 6
7 => 7
9 => 9

Note that it's stepping past the first two values with the first regex 
and it's using /g to stay in the right spot on each line.

Good luck.

-- 
--
dean hudson, <deanh@verio.net>		Verio Systems Engineering


------------------------------

Date: Wed, 9 Jun 1999 16:25:52 -0700
From: "Bill vill" <$nospam$@please.$spam>
Subject: Slowness in flock?
Message-Id: <375ef4a4.0@news1.starnetinc.com>

I've looked in all my Perl books and have done Net searched, etc. and
looked in the Docs and FAQ's and I see nothing that mentions this, so
perhaps someone here can help?

I have a lot of people accessing my CGI scripts (written in Perl,
obviously), and I'm on a slow system, so in hopes to lessen errors, I've
put in some locking so my data won't go screwy from the slow server.

The problem is, it seems that since I've added this, everything is a lot
slower? Does "flock" in Perl slow things down? Or am I just doing this a
completely screwy way? I know that you don't have to "unlock", because
when you close the file it does that already, however if I use it
anyway, will it add double the time it uses to lock and then unlock and
THEN close it? I don't see why my scripts would be SLOWER now, UNLESS
it's because I'm opening a file, doing the work, unlocking the file and
then closing the file. I suppose I don't have to unlock, but does it
make that much of a difference?

I suppose it could be slower, due to the fact that it's waiting to free
up the file for the next person to write to it, but I didn't think it
would be that much slower!? I'm just trying to understand as much as I
can about it, so any help would be great!

# Here's an example of code that I use in one of my scripts:

  open(FILE,">>file$number/file.dat")
     or die "Open/append failed for file$number/file.dat: $!\n";
  LOCKME(FILE);
     syswrite (FILE, $size, length($size))
     or die "Syswrite failed for FILE $size: $!\n";
  UNLOCKME(FILE);
  close(FILE) or die "Close failed for FILE: $!\n";

## Here's the locking parts, obviously that I have in a subroutine
script:
sub LOCKME {
    my $locked = shift;
    flock($locked, 2) or die "Exclusive lock failed for $locked: $!\n";
}

sub UNLOCKME {
    my $locked = shift;
    flock($locked, 8) or die "Unlock failed for $file: $!\n";
}

## End...

Is there anything dreadfully wrong with this idea? I saw someone post
something similar to this and I thought it was a nice implementation so
worked off of it, perhaps it was a bad idea?

Thanks, please don't bother replying via email, I expect fully to read
any answers here. :)

Billy.




------------------------------

Date: Wed, 09 Jun 1999 22:32:45 GMT
From: Floyd Morrissette <Webdesigner@NewWebSite.com>
Subject: Re: sorting
Message-Id: <7jmq2d$v9$1@nnrp1.deja.com>

Thanks to John and Andrew.  The code worked just like I knew it would.
The places on where to find more info was also valuable.


In article <375ed3fd$0$213@nntp1.ba.best.com>,
  John Callender <jbc@shell2.la.best.com> wrote:
> Floyd Morrissette <Webdesigner@NewWebSite.com> wrote:
> > Hi, I have this perl script which sorts the records in a text file
> > database. Currently it sorts by ASCII format. I want it to sort
> > numerically.
>
> >         @sorted_rows = reverse sort (@new_rows);
>
> Use the numeric sort ("spaceship") operator: <=> and an explicit sort
> block:
>
> @sorted_rows = reverse sort {$a <=> $b} @new_rows;
>
> you could also lose the 'reverse' by switching the position of $a and
> $b:
>
> @sorted_rows = sort {$b <=> $a} @new_rows;
>
> Lots of additional detail available by entering:
>
> perldoc -f sort
> perldoc -q sort (which gives you the 'How do I sort an array by
> (anything)?' entry from perlfaq4)
>
> --
> John Callender
> jbc@west.net
> http://www.west.net/~jbc/
>

--
Get your web site from http://www.NewWebSite.com
Consultation is always free.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Wed, 09 Jun 1999 22:34:29 GMT
From: ANK <akadakia@my-deja.com>
Subject: Sub on another drive
Message-Id: <7jmq5k$109$1@nnrp1.deja.com>



Hi, I would like to use subroutine which is on another drive
I am using "use X:\\somedir\somefile" in myfile.pl on NT.
Subroutine is in somefile.pm which is on UNIX.

It doesn't work..
It gives me syntax error near "use X:


Is it right to use X:\\somedir\somefile where X refers to another drive
Should I include in my path somewhere?
Should there be any directory structure changes?

Thank You in Advance.

ANK


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Wed, 09 Jun 1999 23:49:10 -0700
From: Don Cooper <dcooper@cts.com>
Subject: Re: Telnet monitor
Message-Id: <375F5FE6.A360A956@cts.com>

to monitor telnet activity, try the netstat command.

show all connections:
% netstat -a | grep telnet

count all connections:
% netstat -a | grep telnet | grep -v LISTEN | wc -l

I hook my scripts to a visual monitor that cycles every 5 minutes and
lights up when connections exceed some threshold.
    Looks like this screen:
http://www.opensysmon.com/why/tour/alerts.html

"Kerry J. Cox" wrote:

>     Quick question.  I'm looking for some sort of script (I'm sure it
> would be easy enough to write but I'm not a programmer) that would
> monitor who is telnetting into my server and from what domain that are
> coming from.  Maybe by doing a "who" and checking either their IP
> address or domain name.  If it falls outside an acceptable range, as
> determined by a flat file or something similiar, then I could either be
> notified immediately by a write to my terminal.  This can either be a
> cron job that runs every 5 minutes or so or a daemon that runs in the
> background.
>     Also, perhaps this script could be modified to also monitor ftp
> processes.  If anyone knows of a script that might do this or something
> similiar that I could then modify, I would be much appreciative.
> Thanks.
> KJ
>
> --
> .-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-.
> | Kerry J. Cox          Vyzynz International Inc.       |
> | kjcox@vii.com         Systems Administrator           |
> | (801) 596-7795        http://www.vii.com              |
> | ICQ# 37681165         http://quasi.vii.com/linux/     |
> `-------------------------------------------------------'



------------------------------

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 5938
**************************************

home help back first fref pref prev next nref lref last post