[11224] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4824 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 4 11:07:12 1999

Date: Thu, 4 Feb 99 08:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 4 Feb 1999     Volume: 8 Number: 4824

Today's topics:
    Re: $reponse->content(); <jdf@pobox.com>
        ActivePerl on Win95 - "perlglob" pops up Command Window <fjj@mediaone.net>
        ANN: Backwards.pm - read files backwards by lines <uri@sysarch.com>
        ANNOUNCE: MSSQL::DBlib and MSSQL::Sqllib 1.005 (Erland Sommarskog)
        ANNOUNCE: WinPDFdata 1.0 anface@geocities.com
        Announcing PAS Build 2. pault12@pacbell.net
        any comments on the Ultimate Bulleting Board? <23_skidoo@geocities.com>
    Re: any comments on the Ultimate Bulleting Board? <jdf@pobox.com>
    Re: are regular expression rationaly designed ? droby@copyright.com
    Re: Best string/hex/string conversion? (Greg Bacon)
    Re: can't seem to get an appropriat data structure - an <ebohlman@netcom.com>
    Re: libwww-perl and use strict <jdf@pobox.com>
    Re: mkdir problems <bmb@ginger.libs.uga.edu>
    Re: Network Messaging prabhashshrestha@my-dejanews.com
    Re: Newbie ? dmeilinger@cng.dl.nec.com
    Re: passing hash references across modules <ebohlman@netcom.com>
        Perl skills needed in the UK - work permits available <charles@a1assured.demon.co.uk>
    Re: Q: extracting tables from HTML document? <ebohlman@netcom.com>
    Re: Simple sort required. <bmb@ginger.libs.uga.edu>
    Re: Simple sort required. <jdf@pobox.com>
    Re: Simple sort required. (Larry Rosler)
    Re: Sorting with Matts simple search script? <ludlow@us.ibm.com>
    Re: SPARC SOLARIS 2.5.1 PERL executables <kperrier@blkbox.com>
    Re: The best way to learn C? latsharj@my-dejanews.com
        Timer2 dkelly@emhain.wit.ie
    Re: Timer2 (Larry Rosler)
    Re: UNIX 'tail' command in Perl?? <ebohlman@netcom.com>
    Re: Unlink Symlink <bmb@ginger.libs.uga.edu>
    Re: win32 perflib and processor statistics <david.richards@alderley.zeneca.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 04 Feb 1999 16:12:44 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: "Mike Watkins" <mwatkins@promotion4free.com>
Subject: Re: $reponse->content();
Message-Id: <m3lniefbir.fsf@joshua.panix.com>

"Mike Watkins" <mwatkins@promotion4free.com> writes:

> Like I said before, the actual submission works perfectly.  However,
> the response I get isn't what I want.  For the server code ($scode),
> I get 302 (RC_MOVED_TEMPORARILY), and for the content ($HTML), I get
> a blank page.

If you're really only interested in the content at an URL, you
probably want to use LWP::Simple.

         use LWP::Simple;
         $doc = get 'http://www.sn.no/libwww-perl/';

See the lwpcook manpage, and LWP::Simple.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 04 Feb 1999 14:15:58 GMT
From: "John Frendreiss" <fjj@mediaone.net>
Subject: ActivePerl on Win95 - "perlglob" pops up Command Window
Message-Id: <01be5049$3a4cd0e0$bd968318@fjj>

Hello.

Can someone tell me if it's possible to stop the DOS Command Window from
popping up on a Windows/95 (PWS) server when it's executing external
processes like "perlglob"?  If not, does anybody know whether or not
Windows/NT (IIS) servers operate in the same way?

I'm using:

ActivePerl (Build 509)
Windows 95
Personal Web Server (the version from the NT options pack)

TIA

John Frendreiss




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

Date: 4 Feb 1999 14:09:31 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: ANN: Backwards.pm - read files backwards by lines
Message-Id: <79c9mr$lc7$1@play.inetarena.com>


there has been a cry and hue for a long time for this and after a
suitable gestation period (including lots of laziness), i have finally
produced a Backwards.pm module.

it has both an object and a tied handle interface.

it is very fast. it typically is over 2 times faster than tom c's double
loop algorithm which builds an index of the lines and then seeks to each
one (that is without compile time, with compile time it depends on the
length of the file). the recipes in the cookbook are weak as they read
the file completely into memory. this module reads blocks of text from
the end of the file and returns lines from the block.

the beta version is at:

http://www.sysarch.com/perl/Backwards.pm

i am looking for testers to drive it hard before i post it to cpan. i
just applied for my cpan id so this will be my first official
submission.

I think it should go under the File:: hierarchy as
File::Backwards.pm. it doesn't use any of the IO:: modules, just Symbol,
Fcntl, Carp and integer.

BTW this code is published under my beer runtime license. every time it
is run, you have to drink a beer.

enjoy,

uri


here is the pod:

NAME
    Backwards.pm -- Read a file backwards by lines.

SYNOPSIS
            use Backwards ;

            # Object interface

            $bw = Backwards->new( 'log_file' ) ;

            while( $log_line = $bw->readline ) {
                    print $log_line ;
            }

            # Tied Handle Interface

            tie *BW, 'log_file' ;

            while( <BW> ) {
                    print ;
            }

DESCRIPTION
    This module reads a file backwards line by line. It is simple to
    use, memory efficient and fast. It supports both an object and a
    tied handle interface.

    It is intended for processing log and other similar text files
    which typically have new entries appended. It uses newline as
    the separator and not $/ since it is only meant to be used for
    text.

    It works by reading large (8kb) blocks of text from the end of
    the file, splits them on newlines and stores the other lines
    until the buffer runs out. Then it seeks to the previous block
    and splits it. When it reaches the beginning of the file, it
    stops reading more blocks. All boundary conditions are handled
    correctly. If there is a trailing partial line (no newline) it
    will be the first line returned. Lines larger than the read
    buffer size are ok.

  Object Interface

    There are only 2 methods in Backwards' object interface, new and
    readline.

  new

    New takes just a filename for an argument and it either returns
    the object on a successful open on that file or undef.

  readline

    Readline takes no arguments and it returns the previous line in
    the file or undef when there are no more lines in the file.

  Tied Handle Interface

    The only tied handle calls supported are TIEHANDLE and READLINE
    and they are typeglobbed to new and readline respectively. All
    other tied handle operations will generate an unknown method
    error. Do not seek, write or do any other operation other than
    <> on the handle.

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com




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

Date: 4 Feb 1999 14:09:20 GMT
From: sommar@algonet.se (Erland Sommarskog)
Subject: ANNOUNCE: MSSQL::DBlib and MSSQL::Sqllib 1.005
Message-Id: <79c9mg$lc6$1@play.inetarena.com>

I am happy to announce that MSSQL::DBlib and MSSQL::Sqllib 1.005 is out.
The biggest news is that now that all known Perl versions from 5.003 and
up are supported. Previously only ActiveState 5.003 was supported.

MSSQL::DBlib is a basically a port of Sybase::DBlib so that it runs
with Microsoft SQL Server and Microsoft's version of DB-Library. However,
since this port is based on Sybperl 2.03 and I have added a few things
on my own, they are not exactly one-to-one. But almost.

MSSQL::Sqllib is a high-level module built on top of MSSQL::DBlib. It
provides a clean and simple interface for sending SQL queries to the
server. It's default error handling is to abort on any error, but that
is configurable. While built on top of MSSQL::DBlib, the interface is
not very DB-Library specific, or even specific to MS SQL Server, so
you might be able to port it to another platform. (Yeah, I know about
DBI/DBD, but don't you people believe in competition? :-)

Anyway, this is not available at CPAN for the time being. (I first need
to find out how to get things there). But just visit my web site
http://www.algonet.se/~sommar/mssql/. There are three zip files to
choose from: 1) Source only 2) Intel binary for AS 5xx. 3) Intel
binary for AS 3xx. You can also find online manuals there, as well
as a history file detailing the changes.

Alas, Microsoft has discontinued development of DB-Library. It is
still supported, but when you run it with SQL Server 7, you cannot
use the goodies, and for instance you are still restricted to 255
as the max size for character data type.
--
Erland Sommarskog, Stockholm, sommar@algonet.se
A camel is a trotting horse that has been constructed by a committee.
-- 
Erland Sommarskog, Stockholm, sommar@algonet.se
A camel is a trotting horse that has been constructed by a committee.




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

Date: 4 Feb 1999 14:09:51 GMT
From: anface@geocities.com
Subject: ANNOUNCE: WinPDFdata 1.0
Message-Id: <79c9nf$lc8$1@play.inetarena.com>

WinPDFdata is a free Windows application, developed with PERL and Tk, that
permits you to extract information from PDF files and permits you to generate
an HTML file. WinPDFdata supports also the new PDF version 1.3.

WinPDFdata is composed of 6 buttons and a listbox.

Quit to close the application
Select File through a 'file select' window you can select only PDF files (the
control is made on the file extension .pdf and on the presence of %PDF in the
file). After the selection you see in the list box these fields separated by
' ++ ':
  File Name
  Size in bytes
  Number of pages
  PDF version
  Creation Date
  Author
  Title
  Subject
  Creator
  Producer
  Modification Date
  Keywords
Save As HTML through a 'file select' window you can select only a HTML file or
introduce (File field) a new HTML file.
WinPDFdata'll write all the information about your selected PDF files and will
remove them from the listobox.
Unselect All to clean the listbox
About
Help

You can remove only one entry form listbox with a double click with the left
button of the mouse on it.

You can find the software to SANFACE Software site http://fly.to/anface
or at CPAN/authors/Fabrizio_Pivari


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

Date: 4 Feb 1999 14:08:20 GMT
From: pault12@pacbell.net
Subject: Announcing PAS Build 2.
Message-Id: <79c9kk$lbv$1@play.inetarena.com>

Hello.

    http://www.iscusa.com/~paul/home/

    Perl Application Server Build 2 available for
    download. Pure perl solution.  Runs with any perl5
    distribution on UNIX and Win32 platforms.

         * Perl Application Server is a set of
           nested APIs for writing Web-based
           intranets in perl and Java. Most of
           APIs are tiny wrappers around 3rd party
           modules. To name a few:

              o Templates (Text::Template combined
                with Text::Basictemplate)
              o DB (Around DBI::DBD)
              o Java - Perl RPC
              o ... XML/XSL and EJB are in
                progress...

         * Please check docs/Pictures
         * Build 2 allows mixing perl and Java.
         * Kernel part is ready for enterprise usage.

      I'm making changes to PAS each day and I'm
      updating PAS site on weekly basics.

      I'm always glad to get your feedback on PAS.

Rgds.Paul.






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

Date: Thu, 04 Feb 1999 14:29:20 +0000
From: 23_skidoo <23_skidoo@geocities.com>
Subject: any comments on the Ultimate Bulleting Board?
Message-Id: <36B9AEBF.3EF@geocities.com>

hi,

i've had my share of problems using matt's wwwboard script and after
hanging round here long enough i kinda got the (slight) impression that
no one really rated this script at all. 

i'm looking into using the ultimate bulletin board instead as it looks a
tad more professionally done, has anyone else used this script? are
there any noteable problems? basically i want to know if i'm going to
re-experience the level of problems i had with wwwboard 'cos if i am, i
might as well attempt to write a board script myself from scratch,
however if this one will do the trick i'll be happy to shell out for a
legit. version rather than re-invent the wheel. any comments anyone? i
need to know how easy it is to modify the general layout, all of the
versions i've seen online look very similar and it's the functionality
i'm after, i intend to drastically modify the appearence.

thanks to anyone who has used this script and takes the time to share

-23


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

Date: 04 Feb 1999 16:17:13 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: 23_skidoo@geocities.com
Subject: Re: any comments on the Ultimate Bulleting Board?
Message-Id: <m3iudifbba.fsf@joshua.panix.com>

23_skidoo <23_skidoo@geocities.com> writes:

> i'm looking into using the ultimate bulletin board instead as it
> looks a tad more professionally done, has anyone else used this
> script?

This newsgroup is not really *for* the discussion of WWW middleware.
It's for the discussion of the Perl language.  Therefore, you're
unlikely to get knowledgable responses about WWW middleware here!

You might go to DejaNews and search for groups that deal with the web, 
CGI scripting, things like that.  HTH.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 04 Feb 1999 14:13:57 GMT
From: droby@copyright.com
To: ilya@math.ohio-state.edu
Subject: Re: are regular expression rationaly designed ?
Message-Id: <79c9uq$hmd$1@nnrp1.dejanews.com>

[A complimentary Cc of this posting was sent to
<ilya@math.ohio-state.edu> (Ilya Zakharevich)],
who wrote in article <79a50u$mv$1@mathserv.mps.ohio-state.edu>:
> [A complimentary Cc of this posting was sent to
> <droby@copyright.com>],
> who wrote in article <799lqj$d5i$1@nnrp1.dejanews.com>:
> > > > Yes, the theory of finite automata.
> > >
> > > Which has practically nothing to do with *Perl* regular expressions.
> > >
> >
> > Perhaps we should call them something else?  It would be nice if "regular
> > expression" could continue to mean what it means.
>
> Perhaps we should rename "expression" as well, so that it means "the
> way your face looks up in a particular moment", as it should.
>

Or perhaps not.  ;-)

I don't mind ambiguity in English, and since "expression" is used to mean
many quite different things in both English and in technical jargon, I don't
even mind ambiguity in that.  I suppose we could say "*Perl* regular
expressions" as you did to distinguish them from "regular expressions".  It
just feels a bit misleading to use the word "regular", as it means something
pretty specific in formal systems.

I suppose it's also too late to actually fix this though, and it's certainly
not worth a long argument.

--
Don Roby, sometime pedant

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 4 Feb 1999 15:21:31 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Best string/hex/string conversion?
Message-Id: <79cdtr$rsu$1@info.uah.edu>

In article <36B8CAB3.FB537C0D@action.cnchost.com>,
	Tom Williamson <tomw@action.cnchost.com> writes:
: This would print out something like "0xFF3FF4F5DD779346AACD663" (I never
: happen to have an ASCII table in front of me when I need one, so I can't
: vouch for the values <g>).

    sub printable {
        my $bytes = shift;

        $bytes =~ s/([\000-\377])/sprintf "%X", ord $1/eg;

        '0x' . $bytes;
    }

: And the reverse function, Y( $mystring ) would return the original string of
: ASCII "garbage" bytes.

    sub unprintable {
        my $string = shift;

        $string =~ s/^0x//;
        $string =~ s/([0-9A-Fa-f][0-9A-Fa-f])/pack "C", hex $1/eg;

        $string;
    }

Hope this helps,
Greg
-- 
When Primitive man screamed and beat sticks on the ground we called him a
Barbarian.  When Modern man does the same we call him a golfer.


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

Date: Thu, 4 Feb 1999 15:08:06 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: can't seem to get an appropriat data structure - any pointers?
Message-Id: <ebohlmanF6My1I.H38@netcom.com>

Bradley W. Langhorst <brad@langhorst.com> wrote:

: I am new to perl and am trying to build a data structure to
: hold some information
: specifically

You're in luck!  Perl comes complete with a Data Structures Cookbook, 
which can be found in the perldsc (man page | HTML document | POD file) 
on your system.  If you have trouble understanding it, you can check out 
perlref and perllol which lay some of the foundations.

One of the things you'll learn from the above resources is that you 
can't, without going through special gyrations, use a reference as a 
*key* to a hash and expect to get meaningful results.  That's a large 
part of the problem you're running into.


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

Date: 04 Feb 1999 15:51:03 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: mtettmar@mjtnet.com
Subject: Re: libwww-perl and use strict
Message-Id: <m3pv7qfciw.fsf@joshua.panix.com>

mtettmar@mjtnet.com (Marcus Tettmar) writes:

> syntax error in file Makefile.PL at line 5, next 2 tokens "use strict"
> syntax error in file Makefile.PL at line 20, next 2 tokens "getopts("

You have an old version of perl, one that predates the use() builtin.
You or your sysadmin must install an up-to-date perl.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 4 Feb 1999 09:39:06 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: Einar Gudmundsson <einar.gudmundsson@realtime.co.uk>
Subject: Re: mkdir problems
Message-Id: <Pine.A41.4.02.9902040935580.51658-100000@ginger.libs.uga.edu>

The mode, 0755, is modified by your current umask (see `man umask`).  You
can use 'chmod' to set the mode explicitely.

-Brad

On Thu, 4 Feb 1999, Einar Gudmundsson wrote:
> mkdir('test',0755) # Should cretae a test directory with drwxr-xr-x
> What am I missing?



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

Date: Thu, 04 Feb 1999 14:11:40 GMT
From: prabhashshrestha@my-dejanews.com
Subject: Re: Network Messaging
Message-Id: <79c9qj$hdu$1@nnrp1.dejanews.com>

In article <79abht$unv$1@nnrp1.dejanews.com>,
  prabhashshrestha@my-dejanews.com wrote:
Is there any Win32 submodule that will let me do this?  Please help...
> I would like to create a script that will pop up a dialog box with error
> message in different clients under same NT 4.0 network.  Is Win32::MsgBox
> combined with some other commands able to do this or is there another NET
> MESSAGE command availble in perl?
>
> I have an error log that is populated everytime there is an error. The purpose
> of my script is to inform other users about the error.  Thanks for help in
> advance.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 04 Feb 1999 14:54:16 GMT
From: dmeilinger@cng.dl.nec.com
Subject: Re: Newbie ?
Message-Id: <79ccaj$jol$1@nnrp1.dejanews.com>

Thanks for all the info guys.  I'll try them out.

Dirk

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 4 Feb 1999 15:37:14 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: passing hash references across modules
Message-Id: <ebohlmanF6MzE2.Izz@netcom.com>

mbjones@my-dejanews.com wrote:
: Is it possible to pass hash references across modules?  I want to pass
: a bunch of hashes that are created in my MAIN package to a sub in
: another package, but when I do and look at the dereferenced value
: for the hash ref that I get in the sub, it has been "stringified" (as
: is described in the docs and FAQ regarding using references as hash
: keys, which is not what I am doing).

[snip]
: #!/usr/local/bin/perl
: use lib qw(./TestMod );
: use TestMod;

: my %hash = ( 'a' => 'val-a', 'b' => 'val-b' );
: my $tm = new TestMod;

: &testRefPassing(\%hash);
: $tm->testRefModPassing(\%hash);

Ah, you're calling a method of TestMod.

[snip]

: package TestMod;

[snip]

: sub testRefModPassing {
:   my $href = shift;

Now class (hehe), can anyone tell me what the first argument a 
subroutine called as a method recieves is? (HINT: it *doesn't* appear in 
the syntax of the call)


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

Date: Thu, 4 Feb 1999 15:02:17 -0000
From: "Charles" <charles@a1assured.demon.co.uk>
Subject: Perl skills needed in the UK - work permits available
Message-Id: <918140489.15313.0.nnrp-01.c2ded930@news.demon.co.uk>

If you have knowledge of Perl you could be just the person I am looking for.
My name is Charles Goodall and I am the Business Manager of A1 Assured
Recruitment Ltd, a specialist IT recruitment company in the UK.
One of our clients, an on-line resourcing company with trading taking place
through both mail and on-line auction facilities, is currently looking for a
top-level Internet Programmer and are willing to pay up to #40,000 / year to
get him.
They want the best so they are willing to cast the net both within and
outside the UK and will even sponsor work permits.
The skills they are looking for are:
- 2 years of commercial Internet Programming experience
- OO Design
- Perl

On top of this they would like:
- modPerl
- Javascript
- SQL

If you are interested in this vacancy please contact Charles Goodall at
charles@a1assured.demon.co.uk or (44) 1323 417444




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

Date: Thu, 4 Feb 1999 15:30:24 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Q: extracting tables from HTML document?
Message-Id: <ebohlmanF6Mz2o.ILs@netcom.com>

anna@water.ca.gov wrote:
: Essentially, I'm looking to lift entire tables from an HTML document.  Any
: comments on the code below?

: For starters, I'd start here:

I wouldn't; this code isn't even close to doing what you want.

: $summaryIn = "SUMMARY.html";
: open(SUMMARY, "<$summaryIn") || die "\nCan't open file:  $!\n";
: while ($html = <SUMMARY>) {
:    ($junk, $table, $junk2) = split(/table/,$html);
: }

: print "<table${table}>\n";
: close(SUMMARY) || die "\nCan't close file:  $!\n";

What you really want to do is get ahold of the HTML::Filter module and
learn how to use it.  In fact, the documentation for the module contains
example code to do precisely the opposite of what you're trying to do
(output everything *but* tables); all you need to do is invert the logic. 



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

Date: Thu, 4 Feb 1999 09:58:53 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: bazza2000@yahoo.com
Subject: Re: Simple sort required.
Message-Id: <Pine.A41.4.02.9902040941331.51658-100000@ginger.libs.uga.edu>

Assuming your names are unique, you have a paired relationship that a hash
would handle better:

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

my %team_scores = ("name 1" => 2 , "name 2" => 5, "name 3" => 6);
foreach ( sort
    { $team_scores{ $b } <=> $team_scores{ $a } }  ### descending
    keys %team_scores ) {
  print "$_ => $team_scores{ $_ }\n";
}

### output:
### name 3 => 6
### name 2 => 5
### name 1 => 2
__END__

As for how that works, just read up on 'sort'.

On Thu, 4 Feb 1999 bazza2000@yahoo.com wrote:
> Anyway here the problem, I have an array of entries as follows:-
> @team_scores = { "name 1", 2 , "name 2", 5, "name 3" , 6} ;
                 ^                                        ^
Oops, anonymous hash composer.

> I want to get a sort function to put them back into an array on using the even
> positions in the array as the sort.  i.e. 2, 5 and 6 to be sorted accendingly
> leaving the following array
> @team_scores = { "name 3", 6 , "name 2", 5, "name 1" , 2} ;

Nope, that's descending.

Cheers,

-Brad



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

Date: 04 Feb 1999 16:08:35 +0100
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Simple sort required.
Message-Id: <m3n22ufbpo.fsf@joshua.panix.com>

bazza2000@yahoo.com writes:

> I've checked the FAQ's, but they seem either to brief or too
> complex.  For example none of them tell you what the $a and $b
> variables actually translate to from the input etc etc.

There is much more to Perl documentation than the faqs.  Builtins such 
as sort() are documented in perlfunc.

But you're ahead of yourself, in any case, because you haven't yet
learned about the Perl data type called a "hash".  I strongly
recommend that you buy a copy of the O'Reilly book _Learning Perl_,
and that you start reading the perldata man page.

You can read perl documentation on a Win32 system by typing

   C:\> perldoc perldata       [ read the perldata manpage ]
   C:\> perldoc perlfunc       [ read the entire perlfunc manpage ]
   C:\> perldoc -f sort        [ read about a particular function ]

> @team_scores = { "name 1", 2 , "name 2", 5, "name 3" , 6} ;

This really wants to be a hash.

  %team_scores = ( 'name 1' => 2, 'name 2' => 5, 'name 3' => 6 );

You'd then create an array of names, sorted in order of their
associated scores, and use the order of the array to access the
scores...  I'll show you one way to do it, but it won't make sense to
you until you've read the stuff I recommended above.

  my @sorted_names = 
    sort { $team_scores{$a} <=> $team_scores{$b} } 
         keys %team_scores;
  for (@sorted_names) { 
    printf "%-20s %2d\n", $_, $team_scores{$_};
  }

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 4 Feb 1999 07:20:50 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simple sort required.
Message-Id: <MPG.11235aa92c140c0f989a01@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <79c2dt$bee$1@nnrp1.dejanews.com> on Thu, 04 Feb 1999 
12:05:21 GMT, bazza2000@yahoo.com <bazza2000@yahoo.com> says...
 .... 
> Anyway here the problem, I have an array of entries as follows:-
> 
> @team_scores = { "name 1", 2 , "name 2", 5, "name 3" , 6} ;

This is not an array of six elements (which it would be if those curly 
braces were parentheses).  It is actually an array of one element, which 
is a reference to an anonymous hash which has three key-value pairs.

> I want to get a sort function to put them back into an array on using the even
> positions in the array as the sort.  i.e. 2, 5 and 6 to be sorted accendingly
> leaving the following array
> 
> @team_scores = { "name 3", 6 , "name 2", 5, "name 1" , 2} ;

You mean 'descendingly'!

The array of alternating associated value pairs is a poor data structure 
for the problem.  What you need is a data structure that associates the 
value pairs more usefully, which is in fact a hash like the one you 
inadvertantly showed above (using single quotes because there is no 
inerpolation):

  %team_scores = ( 'name 1', 2, 'name 2', 5, 'name 3', 6 );

So you can produce the sorted array you think you want thus:

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

my @team_scores = ( 'name 1', 2, 'name 2', 5, 'name 3', 6 );

my %team_scores = @team_scores;

@team_scores = map  { ($_, $team_scores{$_}) }
               sort { $team_scores{$b} <=> $team_scores{$a} }
               keys %team_scores;

print "@team_scores\n";
__END__

As you mull this over, you may find that you want to use the hash as 
your input and output data structures, instead of the awkward arrays.  
Then the two conversions to and from a hash in the above code can be 
eliminated.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 04 Feb 1999 09:32:59 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Sorting with Matts simple search script?
Message-Id: <36B9BDAB.A50BF6AD@us.ibm.com>

el_pollo_diablo wrote:
> 
> Hi ! Help!
> I inserted your modified code into the script and I am now receiving no
> output.

Well, the code I supplied was just an example.  You're going to have to
adapt it to your needs, not just blindly copy it in.  For one thing, it
appears that I used the hash %title, while the original script used
%titles.  There are other things too that you'll have to work on.  For
instance, my output isn't in HTML.  You probably want to add in whatever
tags you might need.

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


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

Date: 04 Feb 1999 09:56:37 -0600
From: Kent Perrier <kperrier@blkbox.com>
Subject: Re: SPARC SOLARIS 2.5.1 PERL executables
Message-Id: <ysi90eedux6.fsf@blkbox.com>

Ericsson User <leo.alexandropoulos@ericsson.com> writes:

> Hi all!
> 
> I am looking for one of the latest releases of Perl executable(s) for
> SPARC Solaris 2.5.1..

Go directly to www.sunfreeware.com, do not pass Go, do not collect $200.

> 
> It doesn't have to be the *very* latest, but it has to be an executable
> - ready to use, 'cause the Workstation I plan to install it on, doesn't
> have a C compiler - neither an Assembler, Loader, "make" etc etc. It
> would be very tedious to start downloading/compiling/installing,
> all of the above...
> 

You can get gcc from there as well.

> 
> Many thanks!
> Leo
> 
> mailto:leo.alexandropoulos@ericsson.com


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

Date: Thu, 04 Feb 1999 14:14:54 GMT
From: latsharj@my-dejanews.com
Subject: Re: The best way to learn C?
Message-Id: <79ca0k$hn3$1@nnrp1.dejanews.com>

In article <36B8D569.14C64624@crucibledesign.com>,
  Aidan Rogers <aidan@crucibledesign.com> wrote:
>However, I want to learn how to program in C (and eventually
> C++), for the usual job related reasons.  Is there a good book on the subject
>(like the Camel book is to Perl)?

You are looking for "The C Programming Language" by Kernighan and Ritchie,
ISBN 0-13-1100362-8, aka "K&R".  Complete all of the exercises and you will
know C.

When you are ready for C++, try "The C++ Primer, Third Edition" by Lippman.
(more readable than Stroustrup, IMHO).

Regards,
Dick

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 04 Feb 1999 14:58:45 GMT
From: dkelly@emhain.wit.ie
Subject: Timer2
Message-Id: <79ccj0$jte$1@nnrp1.dejanews.com>

I am working on a Perl script that is running on a Unix system.  I want tohave
my script run automatically at a fixed time each day.

I am not allowed to run it by use of the CRONTAB or BATCH facilities on the
Unix system (the reason being not because I don't have access to it but
because my lecturer (a very strict dude) won't let me use it for my project. 
I need it to run through the use of Perl code.

Is there any modules or code that can help me.

Cheers.





-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 4 Feb 1999 07:47:39 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Timer2
Message-Id: <MPG.112360ee4537d859989a02@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <79ccj0$jte$1@nnrp1.dejanews.com> on Thu, 04 Feb 1999 
14:58:45 GMT, dkelly@emhain.wit.ie <dkelly@emhain.wit.ie> says...
> I am working on a Perl script that is running on a Unix system.  I want tohave
> my script run automatically at a fixed time each day.
> 
> I am not allowed to run it by use of the CRONTAB or BATCH facilities on the
> Unix system (the reason being not because I don't have access to it but
> because my lecturer (a very strict dude) won't let me use it for my project. 
> I need it to run through the use of Perl code.

perldoc -f sleep
perldoc -f time

'sleep' for a while, check the current 'time', run the rest of the 
program if the time is right, go back to 'sleep'.

Yawn...

Zzzz...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 4 Feb 1999 14:50:50 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: UNIX 'tail' command in Perl??
Message-Id: <ebohlmanF6Mx8q.FzL@netcom.com>

Scott Dummer <scott.dummer@noaa.gov> wrote:
: Try:
: $i = 0;
: open(FILE,"<mybigfile");

Even in example, you should always test whether an open succeeded, and 
not pretend it did if it didn't.

: while(<IN>) {
:    $i++;
: }

You do know that Perl counts lines for you automatically, don't you?  
Take a look at the entry for $. in perlvar (paying special attention to 
the fact that it gets reset when you close a filehandle).

: close IN;
: #  There are $i lines in file (0-n lines)

Since there could be zero, you ought to check for this before doing the 
second pass.

: $tail_nmbr = 5; #no. lines wanted to access e.g. "tail -5"
: $nmbr = $i - $tail_nmbr;
: $i = 0;
: open(FILE,"<mybigfile");

See above.

: while(<IN>) {
:     $i++;
:     if ($i > $nmbr) {print $_;}
: }
: close IN;
: exit;

: I don't know if this the most efficient way of doing what you want it, but
: it works on my system.

Even among methods that have to read through the entire file, it's pretty 
inefficient because it has to read the file *twice*.  If we pretend that 
files can be accessed only randomly, not sequentially, the following is 
going to be about twice as fast:

my $tail_nmbr = 5; #no. lines wanted to access e.g. "tail -5"
my @lines;
open(FILE,'<mybigfile') or die "Couldn't open mybigfile: $!\n";
while(<IN>) {
  shift @lines if @lines >= $tail_nmbr;
  push @lines, $_;
}
close(IN);
print @lines;

But of course, if the file is really big you want to avoid plowing 
through the big beginning part just to get to the little end part.  How 
to do this depends on how often you need to access the file, how often 
it's updated, and *how* it's updated.  If you have to access it 
frequently but it's seldom updated, or almost all the updates involve 
simply adding lines to the end, you probably want to generate (at the 
time of creation or update) an index file containing the byte offset of 
each line in the file.  If the file is rewritten frequently, or you have 
to access it only occasionally, you're better off seek()ing to (end of 
file - size of a buffer that's likely to contain the number of lines you 
want), reading in that many characters with read() or sysread(), 
splitting the string up into lines, seeing if you got enough lines, and 
backing up by the same amount and reading more and prepending it if you 
didn't get enough lines.  Implementing this in code is left as an 
exercise to the reader; be careful to properly handle the case where the 
whole file has fewer lines than you're looking for.



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

Date: Thu, 4 Feb 1999 09:40:59 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
To: Artoo <r2-d2@REMOVEbigfoot.com>
Subject: Re: Unlink Symlink
Message-Id: <Pine.A41.4.02.9902040939330.51658-100000@ginger.libs.uga.edu>

On Thu, 4 Feb 1999, Artoo wrote:
> I was doing if (-e "$symliked_file"){unlink ($symlinked_file);}
                       ^^^^^^^^^^^^^
Where you really doing exactly that?

> For somereason it doesn't think it exists, if I just do unlink
> ($symlinked_file); it works fine.

-Brad



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

Date: 4 Feb 1999 14:00:39 GMT
From: "David Richards" <david.richards@alderley.zeneca.com>
Subject: Re: win32 perflib and processor statistics
Message-Id: <01be5046$c22092c0$55a0479c@UKMCPHISFW051.ukmcph.zeneca.com>

Jeff

Have a look at this - it came from Klebe's web site - I think he is the
author of Perflib.

The magic number id=674 can be found using
NTRESKIT\PERFTOOL\CNTRTOOL\SHOWPERF.EXE.

I have made a lot of fast progress (eventually)  on performance logging
using the utility PDL in  NTRESKIT\PERFTOOL\LOGTOOLS - this runs as an NT
service, can get individual counters and writes a CSV file.  I then proces
this for max, min, means using Perl and the results can be plotted with
GifGraph.

David


#! perl

# ********************************************************************
# * SystemUpTime.pl                                                  *
# * Copyright (C) 1998 by Jutta M. Klebe                   010398 JK *
# * All rights reserved.                               LU: 260598 JK *
# ********************************************************************
# * $Author:: Jmk                                                  $ *
# * $Date:: 26.05.98 8:20                                          $ *
# * $Archive:: /Jmk/scripts/saa/SystemUpTime.pl                    $ *
# * $Revision:: 1                                                  $ *
# ********************************************************************

use Win32::PerfLib;

($machine) = @ARGV;

$perf = new Win32::PerfLib($machine);
if(!$perf)
{
    die "Can't open PerfLib of $machine!\n";
}
my $objlist = {};
my $system = 2;
if($perf->GetObjectList("$system", $objlist))
{
    $perf->Close();
    my $Counters = $objlist->{Objects}->{$system}->{Counters};
    foreach $o ( keys %{$Counters})
    {
        $id = $Counters->{$o}->{CounterNameTitleIndex};
        if($id == 674)
        {
            $Numerator = $Counters->{$o}->{Counter};
            $Denominator = $objlist->{PerfTime};
            $TimeBase =  $objlist->{PerfFreq};
            $counter = int(($Denominator - $Numerator) / $TimeBase );
            $seconds = $counter;
            $hour = int($seconds / 3600);
            $seconds -= $hour * 3600;
            $minute = int($seconds / 60);
            $seconds -= $minute * 60;
            print "\t$hour hours $minute minutes $seconds seconds\n";
            last;
        }
    }
}


# ********************************************************************
# $History: SystemUpTime.pl $
# 
# *****************  Version 1  *****************
# User: Jmk          Date: 26.05.98   Time: 8:20
# Created in $/Jmk/scripts/saa
# Retrieve the system up time for any (NT) computer
# ********************************************************************

 


Jeff Beitzel <cheetah@epix.net> wrote in article
<79b13v$a1g$1@news1.epix.net>...
> Thanks for the direction, although I am still confused on how to turn the
> results into meaningful numbers...
> 
> Jeff
> 
> David Richards wrote in message
> <01be4e8e$c18e3ec0$55a0479c@UKMCPHISFW051.ukmcph.zeneca.com>...
> >Jeff
> >
> >Have a look at COUNTERS.HLP (counter types) in the NTRESKIT\CNTRTOOL
> >installation.
> >
> >David
> 
> 
> 
> 


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

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 4824
**************************************

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