[19851] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2046 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 1 06:05:36 2001

Date: Thu, 1 Nov 2001 03:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1004612706-v10-i2046@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 1 Nov 2001     Volume: 10 Number: 2046

Today's topics:
        Bijeenkomst Amsterdam Perl Mongers, Dinsdag 6 November  (Johan Vromans)
        Can't system from daemon service on WinNT (Stefan)
        Freeware Radius server written in Perl? <thesearcher@NOSPAMmac.com>
    Re: Getting one element of array return value (Anno Siegel)
        Help modifying a sort routine <markbright@optusnet.com.au>
    Re: Help with a tough algorithm (John J. Trammell)
    Re: MAC user question (Anno Siegel)
    Re: Need advice on getting off a SIGTTIN signal from my (Anno Siegel)
    Re: Private instance variables in Objects ?? (Damian James)
    Re: Real quick: What is the Server Name? (Jon Bell)
    Re: REGULAR EXP. HELP <Laocoon@eudoramail.com>
    Re: REGULAR EXP. HELP <uri@stemsystems.com>
    Re: REGULAR EXP. HELP <Laocoon@eudoramail.com>
        Replacing a Character <chris@intervolve.com.au>
    Re: Replacing a Character (Anno Siegel)
    Re: Replacing a Character <jens@irs-net.com>
        sorting hash of hash by values (Tim)
    Re: sorting hash of hash by values <BROWNHIK@Syntegra.Bt.Co.Uk>
    Re: Unsigned 8 bit math (addition and subtraction) (Ian Boreham)
    Re: XML parsing (Matt Sergeant)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 31 Oct 2001 21:39:02 +0100
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Bijeenkomst Amsterdam Perl Mongers, Dinsdag 6 November 2001
Message-Id: <m28zdrily1.fsf@phoenix.squirrel.nl>

[English version follows the dutch text]

Amsterdam.pm staat voor de "Amsterdamse Perl Mongers", een groep van
gebruikers van Perl. In tegenstelling tot wat de naam suggereert is
Amsterdam.pm niet beperkt tot alleen Amsterdam, maar functioneert, tot
er meer gebruikersgroepen in Nederland zijn, als Nederlandse
gebruikersgroep.

Amsterdam.pm organiseert informele bijeenkomsten waar Perl gebruikers
kunnen samenkomen en informatie en gebruikservaringen met betrekking
tot Perl kunnen uitwisselen. Deze bijeenkomsten vinden normaliter
plaats op elke eerste dinsdag van de maand. De voertaal binnen
Amsterdam.pm is in pricipe Nederlands, maar indien nodig zal Engels
worden gebruikt, b.v. om te communiceren met niet-Nederlandssprekende
aanwezigen.

De eerstvolgende bijeenkomst vindt plaats op dinsdag 6 november 2001
van 20:00 tot 22:00 uur op het kantoor van XS4All, Eekholt 42, Diemen.

Voor meer details, waaronder een routebeschrijving, zie
http://www.amsterdam.pm.org/Meetings/next_meeting.html

Liefhebbers van een etentje vooraf kunnen tussen 17:45 en 18:15
verzamelen. Om 18:15 (écht om 18:15!) zoeken we een restaurantje in de
buurt om een hapje te eten.

Bezoek onze Web site http://www.Amsterdam.pm.org voor meer details.

[English version]

Amsterdam.pm stands for the Amsterdam Perl Mongers. We're basically a
Perl user group. Despite its name, it is not local to the Amsterdam
environment, but it welcomes Perl mongers from all over the
Netherlands.

Amsterdam.pm organises informal meetings where Perl users can meet,
and exchange information and experiences with regard to using Perl.
The meetings are normally held every first Tuesday of the month.
Although the preferred language for communication is Dutch, English
will be spoken if necessary.

Our next meeting is Tuesday November 6th, from 20:00 till 22:00 at the
office of XS4All, Eekholt 42, Diemen.

See http://www.amsterdam.pm.org/Meetings/next_meeting.html for
more detail and the directions to get there.

Should you want to join some of us for dinner, please gather between
17:45 and 18:15. At 18:15 sharp we'll leave for a restaurant somewhere
nearby for dinner.

See http://www.Amsterdam.pm.org for more details.






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

Date: 1 Nov 2001 00:11:16 -0800
From: omtslug@my-deja.com (Stefan)
Subject: Can't system from daemon service on WinNT
Message-Id: <dfc3df4d.0111010011.179e46c2@posting.google.com>

Hi!
Could someone share some light on my service problem on WinNT.
Using ActiveState's perl and the Daemon module from roth for running
a perl script as a service. 

My problem is that a system call within the service script isn't 
executed. exec works fine but the service should continuously check
for files in a directory with a special name and execute that so
I can't do exec (need to be locked during build and continue afterwards)

Part of my script is here:
[Snip. Evaluate which makefile that has highest prio above]
if ( $newbuildfile ne "" ) {
	my $shfile = $newbuildfile;
	my $logfile = $newbuildfile;
	$logfile =~ s/^(bs_.*)W\.sh$/$1.log/;
	my $bashcmd = "c:/Cygnus/cygwin-b20/H-i586-cygwin32/bin/bash.exe";
	my $syscmd = $builddir.$shfile." > ".$builddir.$logfile." 2>&1";
	print LOG $bashcmd . "\n";
	print LOG $syscmd . "\n";
	my $retcode = system($bashcmd . " " . $syscmd);
	print LOG "Command, retcode: $retcode, \$!: $!, \$?: $?, \$^E: $^E\n";
}

Nothing happens with the system and the output to my log is this:
  Starting TsBuildD ver 1.0
  Time is Thu Nov  1 08:31:27 2001
  File bs_1031182440W.sh is OK. pushed: 1004549080. Time now: 1004599952
  File to Build: bs_1031182440W.sh
  c:/Cygnus/cygwin-b20/H-i586-cygwin32/bin/bash.exe
  e:/builddir/bs_1031182440W.sh > e:/builddir/bs_1031182440.log 2>&1
  Command, retcode: 65280, $!: , $?: 65280, $^E: The system could not find the 
    environment option that was entered
  File bs_1031182440W.sh is OK. pushed: 1004549080. Time now: 1004600018
  File to Build: bs_1031182440W.sh
  c:/Cygnus/cygwin-b20/H-i586-cygwin32/bin/bash.exe
  e:/builddir/bs_1031182440W.sh > e:/builddir/bs_1031182440.log 2>&1
  Command, retcode: 65280, $!: , $?: 65280, $^E:


Note the $^E which is empty on the other run?!, (1 minute later).
The buildscript does some echoes immediately so I know it's not run.
It then renames the running script so it's not evaluated again but
is not run at all.
65280d = FF00h = -1 and 0.

Running a stripped script (without the service stuff) works, both
from cygwin prompt and cmd prompt. And yes the service runs currently
with my own user so that's ok.

All ideas appreciated.
BR & TIA
 Stefan


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

Date: Thu, 1 Nov 2001 03:14:08 -0600
From: "The Searcher" <thesearcher@NOSPAMmac.com>
Subject: Freeware Radius server written in Perl?
Message-Id: <7n8E7.3$7b2.599@news1.mts.net>

Where can I find the Radius server written in perl, that used to be located
here:

http://www.iinet.net.au/~michael/radius.html




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

Date: 1 Nov 2001 10:48:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Getting one element of array return value
Message-Id: <9rr9ae$dve$1@mamenchi.zrz.TU-Berlin.DE>

According to Mona Wuerz  <wuerz@yahoo.com>:
> mauroid@csi.forth.gr (Dimitri) writes:
> 
> > Say we have a subroutine that returns an array (a big one).
> 
> There's the problem. Subroutines don't return arrays, they return
> lists. See the third item in perldoc -q list for an explanation.

This is true and pertinent to the problem.

It does not mean, however, that it doesn't matter if you return an
array or a list from a sub.  The behavior of "return ($x, $y)" and
"@array = ($x, $y); return @array" is quite different in scalar context.
Just a side note.

>                                                                   So
> there's no way (as far as I can see) to avoid assigning that list to
> an array variable if you want to address specific elements.

Why?  The (LIST)[INDEX] construct picks individual elements from a list.

Anno


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

Date: Thu, 1 Nov 2001 19:12:03 +1100
From: "Mark Bright" <markbright@optusnet.com.au>
Subject: Help modifying a sort routine
Message-Id: <3be1043a$0$13590$afc38c87@news.optusnet.com.au>

Hi all,

I was wondering if anyone can help me with this sort routine.
I am currently running the following sub:

sub sort_link {
# --------------------------------------------------------
#
     my (@unsorted) = @_;
     my ($num) = ($#unsorted+1) / ($#db_cols+1);
     my (%sortby, $hit, $i, @sorted);

     for ($i = 0; $i < $num; $i++) {
         $sortby{$i} = $unsorted[$db_sort_links + ($i * ($#db_cols+1))];
         }
     foreach $hit (sort {
                                 return lc($sortby{$a}) cmp lc($sortby{$b});
                                } (keys %sortby)) {
         $first = ($hit * $#db_cols) + $hit;
         $last  = ($hit * $#db_cols) + $#db_cols + $hit;
         push (@sorted, @unsorted[$first .. $last]);
     }
     return @sorted;
 }

This sorts all links in my database alphabetically,  what I want to do is
have the links sorted alphabetically but starting at a particular letter.
ie. if the trigger is "C" the database is sorted starting at "C" and ending
at "B"
and if the trigger is "M" links are listed starting at "M" and ending at "L"
etc.

The trigger I get from  sub rotate_alphabet
which returns $newtrigger
where @alpha[$newtrigger]  is the letter for the links to be sorted from for
that day.

I hope this makes sense, I am very much a newbie to perl and have spent many
hours trying to get this done, the rotate_alphabet sub I managed to put
together and it works  :)   but unfortunately it appears the second half of
my problem is currently way beyond my perl knowledge  :(

I would really appreciate anyone taking a look at this for me.

Thanks
Mark




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

Date: Wed, 31 Oct 2001 23:24:20 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Help with a tough algorithm
Message-Id: <slrn9u1pun.qd3.trammell@haqq.el-swifto.com>

On 31 Oct 2001 20:12:13 -0800, Tommy Butler wrote:
> I'm trying to get a six-character string *in stepped sequence*
> from the array of possible unique six-character strings for the
> character class of [a-zA-Z0-9_].

Booya!

#!/usr/bin/perl -lp
BEGIN {use integer;@f=('A'..'Z','a'..'z',0..9,"_");
sub x{!(caller(5))&&($_[0]%@f,x($_[0]/@f))}}
s/$_/reverse map($f[$_],x($_))/e;

Anybody got any more of that sweet sweet sweet Halloween candy?  :-)



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

Date: 1 Nov 2001 09:57:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: MAC user question
Message-Id: <9rr69u$ab5$1@mamenchi.zrz.TU-Berlin.DE>

According to Tom  <tom@tealcity.com>:
> Hi all,
> I'm new at this, looked for the faq,s but could find them.
> So here's the question. I know it a simple one --  sorry.
> Trying to run a script (os 9) set up as a server
> and I get a msg. "can't find CGI.pm in @inc. Any helpful
                                          INC
> hints appreacted. 

Presumably this means that you haven't installed CGI.pm.  Do so.

Anno


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

Date: 1 Nov 2001 09:37:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Need advice on getting off a SIGTTIN signal from my script.
Message-Id: <9rr54q$3n9$2@mamenchi.zrz.TU-Berlin.DE>

According to Edgar Avila <avila_edgar@hotmail.com>:
> Hi,
> I'm trying to do this..
> Need to send an alarm to a remote system thru rsh. If circuit=up -->Sev=1;
> else Sev4.
> I use diff to do so.  If the new file has differences-->circuits down.  If
> the old one has--> circuits up.
> I log the notifications using the original sintaxis for alarms.
> Ok, the remote program (called from rsh) is called 'al'.  When I run this
> script from another script manually... everything goes fine....
> The BIG problem is when I run it on background.  It sends a SIGTTIN signal
> and the program stops.
> My host is running Solaris. The remote runs HP-UX.
> This script runs ok from another HP-UX.
> Any advice is welcomed... except to change OS cause I can't.

Your problem description is as confused as it is confusing, but
have you considered the -n switch on rsh?  It may do just what you need.
Not that this has anything to do with Perl...

[code snipped]

Anno


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

Date: 1 Nov 2001 06:53:43 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Private instance variables in Objects ??
Message-Id: <slrn9u1s4h.dp3.damian@puma.qimr.edu.au>

On 29 Oct 2001 23:14:48 -0800, Real Newbie said:
>Is there a way to create private variables in Perl Objects? If yes,
>can someone give me a brief code example ...
>

By convention object privacy in Perl is a matter of trust, and there
are no explicit mechanisms enforcing it. You mark variables as 
private by naming them with a leading underscore. This does nothing
but indicate to other programmers that the variable is best left
alone.

You *can* encapsulate class variables pretty easily with scoping:

#!/usr/bin/perl -w

package Bleh;
use strict;
{                           # put the whole class in a bare block
	my $_secret = 'foo';	# lexical isn't accessible outside block
	sub new {
		my $class = shift;
		die "Class method called as instance method!\n" if ref $class;
		my $bleh = 'nothing useful';
		bless \$bleh, $class;
	};
	sub secret_is {         # method is the block, so it has access
		my $self = shift;
		die "Instance method called as class method\n" unless ref $self;
		@_? $_secret = $_[0] : $_secret;
	}
} # then no-one has access to $_secret, even if they define a new method

package main;
use strict;

my $bleh = Bleh->new();
print $bleh->secret_is(), "\n";
$bleh->secret_is('bar');
print $bleh->secret_is(), "\n";

__END__

As Damian Conway puts it in his book _Object Oriented Perl_,

   Oddly enough, that encapsulation is actually far
   stronger than is provided by most other object-
   oriented languages.

And that includes some of those in which there is an explicit
privacy machanism :-).

A slightly more sophisticated approach is needed to do the same
thing for instance data. If you really need to do this, I suggest
you read DC's book: http://www.manning.com/Conway/index.html.

HTH,

Cheers,
Damian *James*
-- 
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/}  __END__
Just another Damian, ####### http://home.pacific.net.au/~djames.hub


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

Date: Thu, 1 Nov 2001 05:58:27 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Real quick: What is the Server Name?
Message-Id: <GM3xxF.Juv@presby.edu>

In article <20011031185224.14892.00000557@mb-ff.aol.com>,
jkindahouse <jkindahouse@aol.com> wrote:
>I am training to configure Outlook to display the newsgroup and I need the
>Server Name. I've tried comp.lang.perl.misc and nmtp.comp.lang.perl.misc.

(I'm assuming you mean Outlook Express.)

No, OE wants the name of your ISP's news *server*, not the name of a
newsgroup.  Newsgroups don't run off single servers the way Web sites 
do.  They're "distributed" so that every ISP's news server carries 
copies of all the messages.

You can't access AOL's news server using OE or any other newsreading
software besides AOL's own proprietary software. However, you *can* access
*other* news servers that grant you access, using OE via your AOL Internet
connection.  See <http://news.cis.dfn.de/> for information about
registering for free access to a news server in Germany.  That site also
has information about configuring OE to access the server, I think.

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA


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

Date: Thu, 1 Nov 2001 08:17:42 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: REGULAR EXP. HELP
Message-Id: <Xns914C546643608Laocooneudoramailcom@62.153.159.134>

Uri Guttman <uri@stemsystems.com> wrote in 
news:x7r8rjw2ys.fsf@home.sysarch.com:

>>>>>> "L" == Laocoon  <Laocoon@eudoramail.com> writes:
> 
>   L> *snip*
>  >> file.doc
>  >> file2.doc
>  >> file3.doc
>  >> 
>  >> Input data:
>  >> 
>  >> /windows/program/file.doc /windows/program/file2.doc
>  >> /windows/tom/file/data/file3.doc 
> 
>   L> s#.+/##g
> 
> why the /g? it is not needed.

I assumed he got the data in a single string.

 
> uri
> 

Lao


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

Date: Thu, 01 Nov 2001 07:31:09 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: REGULAR EXP. HELP
Message-Id: <x7ofmnvte9.fsf@home.sysarch.com>

>>>>> "L" == Laocoon  <Laocoon@eudoramail.com> writes:

  L> Uri Guttman <uri@stemsystems.com> wrote in 
  L> news:x7r8rjw2ys.fsf@home.sysarch.com:

  >>>>>>> "L" == Laocoon  <Laocoon@eudoramail.com> writes:
  >> 
  L> *snip*
  >> >> file.doc
  >> >> file2.doc
  >> >> file3.doc
  >> >> 
  >> >> Input data:
  >> >> 
  >> >> /windows/program/file.doc /windows/program/file2.doc
  >> >> /windows/tom/file/data/file3.doc 
  >> 
  L> s#.+/##g
  >> 
  >> why the /g? it is not needed.

  L> I assumed he got the data in a single string.

doubtful that would be true with a list of file paths. and you should
have stated that assumption with the code.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Thu, 1 Nov 2001 09:07:25 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: REGULAR EXP. HELP
Message-Id: <Xns914C5CD449B38Laocooneudoramailcom@62.153.159.134>

Uri Guttman <uri@stemsystems.com> wrote in 
news:x7ofmnvte9.fsf@home.sysarch.com:

*snip*
>   L> *snip*
>  >> >> file.doc
>  >> >> file2.doc
>  >> >> file3.doc
>  >> >> 
>  >> >> Input data:
>  >> >> 
>  >> >> /windows/program/file.doc /windows/program/file2.doc
>  >> >> /windows/tom/file/data/file3.doc 
>  >> 
>   L> s#.+/##g
>  >> 
>  >> why the /g? it is not needed.
> 
>   L> I assumed he got the data in a single string.
> 
> doubtful that would be true with a list of file paths. and you should
> have stated that assumption with the code.

Maybe i should

> uri

Lao


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

Date: Thu, 1 Nov 2001 19:29:10 +1030
From: "Chris Intervolve" <chris@intervolve.com.au>
Subject: Replacing a Character
Message-Id: <3be11011$1@kastagir.senet.com.au>

Hi guys,

Just wondering how to replace a single character within a string to
something else.

IE

$mystring = "12345671123421313455"

How would I replace the "1" to something like "a"????

Thanks,

Chris Macko




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

Date: 1 Nov 2001 09:08:40 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Replacing a Character
Message-Id: <9rr3eo$3n9$1@mamenchi.zrz.TU-Berlin.DE>

According to Chris Intervolve <chris@intervolve.com.au>:
> Hi guys,
> 
> Just wondering how to replace a single character within a string to
> something else.
> 
> IE
> 
> $mystring = "12345671123421313455"
> 
> How would I replace the "1" to something like "a"????

The document available under "perldoc perlre" discusses this.  For
this particular substitution you'd probably use the tr/// operator.

Anno


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

Date: Thu, 01 Nov 2001 10:07:22 +0100
From: Jens Luedicke <jens@irs-net.com>
Subject: Re: Replacing a Character
Message-Id: <9rr3ht$b9s$03$1@news.t-online.com>

Chris Intervolve wrote:

> Hi guys,
> $mystring = "12345671123421313455"
> How would I replace the "1" to something like "a"????

$mystring =~ s/1/a/g;

-- 
Jens Luedicke
jens@irs-net.com


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

Date: 31 Oct 2001 23:33:58 -0800
From: tvn007@hotmail.com (Tim)
Subject: sorting hash of hash by values
Message-Id: <21724be2.0110312333.5bcd0cd6@posting.google.com>

Hi ,

Could someone please help me on this ?

Thanks in advance for your help.

Here is my script:

!/usr/local/bin/perl5
$file = "INPUT";
$file_out =  $file.".out";
open (OUTFILE,">$file_out")||die "cannot";
open (DATA,$file)||die "cannot";
	my (%columns,%rows);
	while (<DATA>) {
		chomp();
		my ($file,$lvmadr,$count)=split /:/;
		$rows{$lvmadr}{$file}=$count;
		$columns{$file}=1;
}
	print OUTFILE "\t",join("\t",sort keys %columns),"\n";
	print "\t",join("\t",sort keys %columns),"\n";
	foreach my $lvmadr (sort keys %rows) {
		print OUTFILE "$lvmadr\t";
		print "$lvmadr\t";
		foreach my $file (sort keys %columns) {
			print OUTFILE $rows{$lvmadr}{$file} if exists $rows{$lvmadr}{$file};
			print $rows{$lvmadr}{$file} if exists $rows{$lvmadr}{$file};
			print OUTFILE "\t";
			print "\t";
		} 	
			print  OUTFILE"\n";
			print  "\n";
	}

#system "clear";
print "=================================\n";
print "The output file is INPUT.out\n";
print "=================================\n";

##########################################
Here is the input file: INPUT

File1:David:23
File1:Tom:43
File1:Wan:21
File2:David:42
File2:Tom:28
File2:Wan:33

Here is the INPUT.out from the script above:

        File1      File2
David   23         42
Tom     43         28
Wan     21         33

##############################################
Here is the OUTPUT that I would like to have.
It should SORT base on the $count of File1


        File1      File2
Wan     21         33
David   23         42
Tom     43         28


#############################################
Again, thanks in advance for any help !!!


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

Date: Thu, 1 Nov 2001 10:56:53 -0000
From: "Kevin Brownhill" <BROWNHIK@Syntegra.Bt.Co.Uk>
Subject: Re: sorting hash of hash by values
Message-Id: <9rra0g$evd$1@pheidippides.axion.bt.co.uk>


"Tim" <tvn007@hotmail.com> wrote in message
news:21724be2.0110312333.5bcd0cd6@posting.google.com...
> Hi ,
>
> Could someone please help me on this ?
>
> Thanks in advance for your help.
>
> Here is my script:
>
> !/usr/local/bin/perl5
> $file = "INPUT";
> $file_out =  $file.".out";
> open (OUTFILE,">$file_out")||die "cannot";
> open (DATA,$file)||die "cannot";
> my (%columns,%rows);
> while (<DATA>) {
> chomp();
> my ($file,$lvmadr,$count)=split /:/;
> $rows{$lvmadr}{$file}=$count;
> $columns{$file}=1;
> }
> print OUTFILE "\t",join("\t",sort keys %columns),"\n";
> print "\t",join("\t",sort keys %columns),"\n";
> foreach my $lvmadr (sort keys %rows) {
> print OUTFILE "$lvmadr\t";
> print "$lvmadr\t";
> foreach my $file (sort keys %columns) {
> print OUTFILE $rows{$lvmadr}{$file} if exists $rows{$lvmadr}{$file};
> print $rows{$lvmadr}{$file} if exists $rows{$lvmadr}{$file};
> print OUTFILE "\t";
> print "\t";
> }
> print  OUTFILE"\n";
> print  "\n";
> }
>
> #system "clear";
> print "=================================\n";
> print "The output file is INPUT.out\n";
> print "=================================\n";
>
> ##########################################
> Here is the input file: INPUT
>
> File1:David:23
> File1:Tom:43
> File1:Wan:21
> File2:David:42
> File2:Tom:28
> File2:Wan:33
>
> Here is the INPUT.out from the script above:
>
>         File1      File2
> David   23         42
> Tom     43         28
> Wan     21         33
>
> ##############################################
> Here is the OUTPUT that I would like to have.
> It should SORT base on the $count of File1
>
>
>         File1      File2
> Wan     21         33
> David   23         42
> Tom     43         28
>
>
> #############################################
> Again, thanks in advance for any help !!!

See the following code: note the change in the line containing
    ... sort keys %rows ...


!/usr/local/bin/perl5
$file = "INPUT";
$file_out =  $file.".out";
open (OUTFILE,">$file_out")||die "cannot";
open (DATA,$file)||die "cannot";
my (%columns,%rows);
while (<DATA>) {
chomp();
my ($file,$lvmadr,$count)=split /:/;
$rows{$lvmadr}{$file}=$count;
$columns{$file}=1;
}
print OUTFILE "\t",join("\t",sort keys %columns),"\n";
print "\t",join("\t",sort keys %columns),"\n";
foreach my $lvmadr (sort { return ($rows{$a}{'File1'} <=> $rows{$b}{'File1'}
keys %rows) {
print OUTFILE "$lvmadr\t";
print "$lvmadr\t";
foreach my $file (sort keys %columns) {
print OUTFILE $rows{$lvmadr}{$file} if exists $rows{$lvmadr}{$file};
print $rows{$lvmadr}{$file} if exists $rows{$lvmadr}{$file};
print OUTFILE "\t";
print "\t";
}
print  OUTFILE"\n";
print  "\n";
}

#system "clear";
print "=================================\n";
print "The output file is INPUT.out\n";
print "=================================\n";




Hope this helps

Kevin Brownhill





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

Date: 31 Oct 2001 23:56:09 -0800
From: ianb@ot.com.au (Ian Boreham)
Subject: Re: Unsigned 8 bit math (addition and subtraction)
Message-Id: <f02c4576.0110312356.48d87be4@posting.google.com>

"Stuart Gall" <stuart@otenet.gr> wrote in message news:<9rpr5h$4r5$2@usenet.otenet.gr>...

> Yes they do! but they should not!!!!!!
> ((0-1) % 256) ahould equal  -1
> 
> perlop says
> Binary ``%'' computes the modulus of two numbers. Given integer operands $a
> and $b: If $b is positive, then $a % $b is $a minus the largest multiple of
> $b that is not greater than $a.
> 
> Hmmm. I guess what perl does is more likely to be usefull to a programmer,
> like most of what perl does. But it does not follow the mathematical
> definition of modulus

What definition of modulus do you normally use? Normally a contiguous
set of non-negative integers starting at zero are used, and the Perl
implementation (and other languages I have seen) implement it that
way. It appears to be the most logical and convenient range of
integers to use, and without explicitly specifying a different set,
I'm not sure how you could meaningfully use modulo arithmetic.

Regards,


Ian


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

Date: 1 Nov 2001 00:10:10 -0800
From: msergeant@star.net.uk (Matt Sergeant)
Subject: Re: XML parsing
Message-Id: <eb3031b9.0111010010.86c2ccb@posting.google.com>

clintp@geeksalad.org (Clinton A. Pierce) wrote in message news:<8JSD7.213443$K6.104895490@news2>...
> 
> I asked questions of the AxKit mailing list, in #AxKit on whichever
> IRC channel is listed in the docs, and a few other places.  The installation
> instructions didn't refer to the version of AxKit that was in the bundle
> ("we've made significant changes, but haven't had time to update the docs")
> and the prerequisites weren't listed anywhere except in the linker's error
> messages. 
> 
> I can dig up the IRC logs and the mail responses I received if you like.
> I still have them.  My frustration was clearly evident then, this rant
> hasn't changed in the intervening 4 months.

Well, it's not evident on the mailing list, where you posted twice in
this thread [1]. Maybe you vented your frustration on IRC, but it's
not a paid help channel. If you want paid technical support, I charge
a fixed fee of £12,000 [2].

> I admire your hard work, it's probably very good code.  Good luck.
> It's just wrong to tout a package as being ready to use for use when 
> it's clearly still under heavy development and not stable at all.  I wanted
> a package to do my job, not to tinker with someone else's development
> toys.

Now you're just being insulting. Lots of people have AxKit up and
running just fine, on commercial sites (e.g. Oakley sunglasses). AxKit
has suffered greatly due to Apache including expat (which is now
mostly fixed in Apache 1.3.22), and due to compilation problems with
libxml2. We'll fix those over time, and if you want to buy me a few
different computers so I can have a multitude of platforms to test it
on, then feel free. Otherwise send patches.

Matt.

[1] http://217.158.50.178/cgi-bin/ezmlm-cgi?3:sss:2424:200107:clhfhcoohpodjdfipfjn#b
[2] http://use.perl.org/journal.pl?op=display&uid=1087&id=1008


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

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.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.

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 V10 Issue 2046
***************************************


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