[6626] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 251 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 7 22:07:18 1997

Date: Mon, 7 Apr 97 19:00:21 -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           Mon, 7 Apr 1997     Volume: 8 Number: 251

Today's topics:
     Re: $ Terminator?? - <flg@vhojd.skovde.se>
     Battling the regular expression -- how do I fix this? <cherold@pathfinder.com>
     Re: Battling the regular expression -- how do I fix thi (Tad McClellan)
     Re: Can It Be Done (Tad McClellan)
     Debugging and my ($vars): Is the -d flag useless for lo <good.luck@getting.spam.to.zenin.at.best.com>
     Re: Debugging and my ($vars): Is the -d flag useless fo <tchrist@mox.perl.com>
     Re: Easy way to promote your web site (RM)
     Executing a small EXE on NT/IIS <_nospam_rasanen@sprynet.com>
     Re: Getting system function output into variable? (Matthew Cravit)
     Re: Help regarding Microsoft's Personal Web Server CGI  <pete@superpan.demon.co.uk>
     Re: HELP!  With MacPerl (Ben Brown)
     Re: Ousterhout and Tcl lost the plot with latest paper (Jeffrey Hobbs)
     Re: Ousterhout and Tcl lost the plot with latest paper <graham.matthews@maths.anu.edu.au>
     Re: print a hash with 2 columns (A. Deckers)
     Re: print a hash with 2 columns (A. Deckers)
     Re: Split and Print? (Tad McClellan)
     Re: system call (Tad McClellan)
     tail in perl (was Re: Help!  How do I pass filehandles  (Eric Hollander)
     Re: Unix and ease of use  (WAS: Who makes more ...) <tim@a-sis.com>
     What does "UNIX" stand for.. (Re: Who makes more $$..) (Lawrence Kirby)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 7 Apr 97 13:30:40 GMT
From: "Fredrik Lindberg" <flg@vhojd.skovde.se>
Subject: Re: $ Terminator?? -
Message-Id: <01bc4358$23352600$e20f10c2@odens.di.vhojd.skovde.se>

Tammy Cotter <cottert@sonic.net> wrote in article
<01bc42e8$1005e940$24e6c9d0@cottert>...
> What is a string terminator, and where do I put it.

The string terminator is the thingy you put at the end of a string, for
example
a " character or a ' character or whatever quotation you used. Normally
when you 
get this error you step through the code looking at the end of each line to
see if 
you can spot the missing quote...

I could not reproduce the error from your supplied code though. I e when i
ran
it through perl -c -w i did not get the kind of error you are referring to.

/Fredrik



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

Date: Mon, 07 Apr 1997 16:56:30 +0000
From: Charles Herold <cherold@pathfinder.com>
Subject: Battling the regular expression -- how do I fix this?
Message-Id: <3349354D.3ABA@pathfinder.com>

What I've got is a bunch of files that contains something like the below
HTML snippet, and what I want is to find every <TH></TH> combination and
put a <FONT> tag inside.  But the substitute expression I am using only
changing the last incidence of the <TH></TH> combo.  Why?

HTML snippet:

<TR VALIGN=TOP BGCOLOR="#99CCCC">
        <TH WIDTH="25%">
        INDUSTRY<BR>RANK
        </TH>
        <TH>
        INDUSTRY
        </TH>
        <TH WIDTH="25%">
        1996 $
        </TH>
</TR>

CODE that doesn't do what I expected ($intext contains the entire
document):

$intext =~ s#(<TH.*>)(.*)(</th>)#$1<FONT SIZE="-1">$2</FONT>$3#sgi;

-- 
Best regards,

       Charles Herold
         Pathfinder
          Production Assistant
           cherold@pathfinder.com
             (212) 522-5190


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

Date: Mon, 7 Apr 1997 18:59:46 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Battling the regular expression -- how do I fix this?
Message-Id: <ip1ci5.om.ln@localhost>

Charles Herold (cherold@pathfinder.com) wrote:
: What I've got is a bunch of files that contains something like the below
: HTML snippet, and what I want is to find every <TH></TH> combination and
: put a <FONT> tag inside.  But the substitute expression I am using only
: changing the last incidence of the <TH></TH> combo.  Why?
                                                       ^^^

greediness   ;-)

search for 'greed' in the perlre man page...


: HTML snippet:

: <TR VALIGN=TOP BGCOLOR="#99CCCC">
:         <TH WIDTH="25%">
:         INDUSTRY<BR>RANK
:         </TH>
:         <TH>
:         INDUSTRY
:         </TH>
:         <TH WIDTH="25%">
:         1996 $
:         </TH>
: </TR>

: CODE that doesn't do what I expected ($intext contains the entire
: document):

: $intext =~ s#(<TH.*>)(.*)(</th>)#$1<FONT SIZE="-1">$2</FONT>$3#sgi;


$intext =~ s#(<TH.*?>)(.*?)(</th>)#$1<FONT SIZE="-1">$2</FONT>$3#sgi;
                   ^     ^
                   ^     ^
             

Viola! It's fixed (kinda).

I think this is somewhat improved:


$intext =~ s#(<TH[^>]*>)(.*?)(</th>)#$1<FONT SIZE="-1">$2</FONT>$3#sgi;
                 ^^^^^

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Mon, 7 Apr 1997 19:25:41 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Can It Be Done
Message-Id: <5a3ci5.rq.ln@localhost>


[ please follow normal Usenet custom and limit your line lengths to
  70-72 characters. Else they get hard to read after being quoted a few
  times
]


jhardy@cins.com wrote:

: Come on guy's, give me a break! I know one of you Guru's know how to do this 
: and I just can't figure it out. 


This is very simple thing. The exalted status of guru is most
certainly not required.

As I am only a lowly Intermediate type perl programmer, I hope you
don't intend to exclude me from answering your question...

If you _did_ intend to exclude me, it didn't work   ;-)



: I have a flat file database whcih looks like this;

: Item 		Description		Price

: Monitor		MegaImage		$375.00
: Monitor		Toshiba			$800.00
: CPU		486			$100.00
: CPU		486 OD 100 MHZ		$235.00
: Motherboards	MB			$25.00		
: Motherboards	MN2			$100.00

: So far I can get the script to read the file and print out the database in a table. 
: Being a newbie to Perl I finally figured that out. Now instead of printing it to a 
: table I want to read it in like below

: #!/usr/bin/perl


Hey! You are a newbie to perl and you don't want perl to help
you debug your scripts?

perl will help you if you ask it to:

#!/usr/bin/perl -w
#               ^^    ALWAYS enable compiler warnings...


Isn't there like an autoFAQ or something that suggests this?

As you have said that you posted before, then you have already
received said autoFAQ. Yes?

Ignoring the collected wisdom of all of perldom may have some
connection to why perldom did not respond to your last posting...



: # Name: quoteSYS.pl
: # Version: 1.0
: # Last Modified: 04-03-97

: $tax1_label  ="7% GST - 8% PST";
: $tax2_label = "7% GST";
: $tax_rate1      = .08;
: $tax_rate2	= .07;
: $database = "./Data_files/crise.data";

: $| = 1;
:              
: open(DATABASE, "$database") || die "Content-type: 
: text/html\n\nCannot open database!";
: @database = <DATABASE>;
: close(DATABASE);


: Now that I have the file in the variable @database I want to somehow get it to 
: read the text in the first columb
: and extract all the monitor rows and send them to a drop down list in a form . 

I don't know what a 'drop down list form' is. 

Perl does not have such a construct.

Sounds like an HTML or CGI kinda thing. But you wouldn't be asking
about those things in the _perl_ newsgroup.

You would be asking about those things in an on-topic newsgroup such as:

comp.infosystems.www.authoring.cgi
comp.infosystems.www.authoring.html


Right?


: Then do the same for the CPU rows, etc. so my form will have a selection of drop 
: down boxes which will contain the entire database. Then items could be selected 
: sent back to the script and priced and sent back as an HTML quote. 

: I know how to do this from a form and I have seen many of them but I want to 
: avoid the updateing problems by just updating the database with the new items 
: which will then be read in by the script and sent to the form. This way I avoid 
: having to manually update the HTML everytime I want to add a new item . 

: I can figure out the rest of the script myself I just can't get the gist of the part to 
: seperate the incoming data from the database and send it to the form in a drop 
: down box. 


OK.

The perl part of your question will get answered here in the perl
newsgroup. I'll get you as far as separating the things into individual
arrays. You take it from there...



: Beleive me I have been trying to do it myself and don't want to trouble anyone. I 
: have searched Deja News and all other news groups and I think in the last week I 
: have covered pretty much the entire web with no success. The more I read about it 
: the more confused I get. To much data for this brain to handle:) If I could even see 
: one example of this being done I would be able to understand it.   

: Help me out and I'll credit you in the script (yeah I know, Big Deal!) Im broke or I 
: would pay you, whine,whine,whine. 

: I posted this same problem a while back and the post went unanswered and seems 
: to have disapeared? 

: any help would be much appreciated. 

:If you are willing to help can you email me with your suggestions if possible. 
                                    ^^^^^^^^

Ask it here. Get the answer here.


-----------------
#! /usr/bin/perl -w

@database = <DATA>;


# read perlfunc and perlre man pages, then just do this:

@cpu          = grep /^CPU/, @database;
@monitor      = grep /^Monitor/, @database;
@motherboard  = grep /^Motherboards/, @database;


print "CPUs:\n";
foreach (@cpu) {  # do something with each CPU line...
   print;
}
print "\n";


print "Monitors:\n";
foreach (@monitor) { # each Monitor line...
   print;
}
print "\n";


print "Motherboards:\n";
foreach (@motherboard) { # each Motherboard line...
   print;
}
print "\n";



__DATA__
Monitor         MegaImage               $375.00
Monitor         Toshiba                 $800.00
CPU             486                     $100.00
CPU             486 OD 100 MHZ          $235.00
Motherboards    MB                      $25.00
Motherboards    MN2                     $100.00
-----------------


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 7 Apr 1997 23:49:33 GMT
From: Zenin <good.luck@getting.spam.to.zenin.at.best.com>
Subject: Debugging and my ($vars): Is the -d flag useless for local vars and use strict?????
Message-Id: <5ic16d$mqc$1@nntp2.ba.best.com>


Try as I might, I can not get the bloody debugger to display vars that
have been declared using my().  I've checked the man pages and FAQ and found
no mention about this.

The script (foo.pl):

#!/usr/local/bin/perl -w
my $Foobar = 'Here I am!';
print "$Foobar\n";

Trying to debug:

$ perl -wd foo.pl
Stack dump during die enabled outside of evals.
 
Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.
 
Enter h or  h' for help.
 
main::(foo.pl:2):       my $Foobar = 'Here I am!';
  DB<1> s
main::(foo.pl:4):       print "$Foobar\n";
  DB<1> X ~Foobar
  DB<2> V main ~Foobar
  DB<3> X Foobar
  DB<4> V main Foobar
  DB<5> s
Here I am!
$


Now, if I don't localize the vars (bar.pl):
#!/usr/local/bin/perl -w
$Foobar = 'Here I am!';

print "$Foobar\n";

Trying to debug:

$ perl -wd bar.pl
Stack dump during die enabled outside of evals.

Loading DB routines from perl5db.pl patch level 0.94
Emacs support available.

Enter h or  h' for help.

main::(bar.pl:2):       $Foobar = 'Here I am!';
  DB<1> s
main::(bar.pl:4):       print "$Foobar\n";
  DB<1> X ~Foobar
$Foobar = 'Here I am!'
  DB<2> s
Here I am!
$

	HUH?????   PLEASE correct me if I'm wrong, but it would seem
	that the debugger is completely USELESS	if you localize your
	vars and in turn use strict.  Someone please tell me a way around
	this or point me to the documentation if it actually does exist!

-Zenin
 Zenin @ Best . com


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

Date: 8 Apr 1997 00:51:15 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Debugging and my ($vars): Is the -d flag useless for local vars and use strict?????
Message-Id: <5ic4q3$ibg$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting DENIED to cited author due to 
  screwed-up email address]

In comp.lang.perl.misc, 
    Zenin <good.luck@getting.spam.to.zenin.at.best.com> writes:

The only way to fight spam is legally.  Write your elected
representatives.  Complain to ISPs.  But this bullshit of making
it hard for me to help you is a pain in the butt.  Do you know how
much spam I get every day?  Why should you be any different? :-)

:Try as I might, I can not get the bloody debugger to display vars that
:have been declared using my().  I've checked the man pages and FAQ and found
:no mention about this.

Use the 'x' command instead.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    "It's ironic that you would use a language as large as English to express
    so small a thought."
    	--Larry Wall


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

Date: Tue, 08 Apr 1997 00:21:07 +0100
From: "Rodney Myers (RM)" <rmyers@patrol.i-way.co.uk>
To: Andreas Pfotenhauer <pfote@wh-gotha.de>
Subject: Re: Easy way to promote your web site
Message-Id: <33498163.1F87@patrol.i-way.co.uk>

http://www.webarrivals.com/main/submit.phtml
http://www.liquidimaging.com/submit/
-- 
Rodney Myers
Director : Catalogue InterConnect Ltd PO Box 679 Oxford OX2 7HL  UK
http://www.catalog.co.uk/   mailto:rmyers@patrol.i-way.co.uk
Telephone & Voice Mail : (01865) 200025  International +44 1865 200025
Fax                    : (01865) 726545  International +44 1865 726545


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

Date: 7 Apr 1997 20:07:27 GMT
From: "Rdsdnen" <_nospam_rasanen@sprynet.com>
Subject: Executing a small EXE on NT/IIS
Message-Id: <01bc438f$4009ce20$24e8aec7@vesa>

Below is a small perl script, which works perfectly if the very first line
with "system" is commented.
The program htu2.exe runs also perfectly, if the task is started from
"Start, Run, htu1.exe", and I verified that dcomcnfg has been set to allow
default permissions for the IUSR_<machine> to launch programs.

Why might the "system" line not be ok via a Perl script?

In case it matters, this is on a NT4 box with IIS3. All other perl scripts
run fine. 

system ("n:/vxw/htu2.exe") ;
$HOME='"file:\\\\mysrv\\z\\filename.htm"';
print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html\n\n";
print "<HTML>\n";
print '<BODY BACKGROUND="//mysrv/BKGRND.GIF">', "\n";
print '<meta http-equiv="Content-Type"', "\n";
print 'content="text/html; charset=iso-8859-1">', "\n";
print "<META HTTP-EQUIV='Refresh' 'CONTENT=15; URL=$HOME'>\n";
print "<HEAD>\n";
print "<P>\n";
print 'Executing a program...please wait..', "\n";
print "<P>\n";
print "</BODY>\n";
print "</HTML>\n";

-- 
rasanen@sprynet.com
http://home.sprynet.com/sprynet/rasanen/



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

Date: 7 Apr 1997 16:03:37 -0700
From: mcravit@shell3.ba.best.com (Matthew Cravit)
Subject: Re: Getting system function output into variable?
Message-Id: <5ibug9$nbs@shell3.ba.best.com>

In article <33494B65.E6D@wpo.borland.com>,
Anthony Boyd  <aboyd@wpo.borland.com> wrote:
>I couldn't find this in the FAQ, so here goes.  I have a tiny script:
>
>$Moz3 = system("'grep' -c \"Mozilla/3\" data/cppbreg.dat");
>print "The grep found $Moz3 Mozilla 3 users\n";
>
>However, when I run the script, I can see the grep results (25) on the
>command line, but the print statement shows:
>
>The grep found 0 Mozilla 3 users

The return value from system() is the exit code of the process which was
spawned. So, the 0 you're getting back means only that grep ran without 
returning an error.

What I think you're trying to do is this:

	$Moz3 = `grep -c \"Mozilla/3\" data/cppbreg.dat`;
	chomp($Moz3);	# Remove the trailing newline from the result
	print "The grep found $Moz3 Mozilla 3 users\n";

Hope this helps.

/MC
-- 
--
Matthew Cravit, N9VWG               | Experience is what allows you to
E-mail: mcravit@best.com (home)     | recognize a mistake the second
        mcravit@taos.com (work)     | time you make it.


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

Date: Mon, 7 Apr 1997 23:43:19 +0100
From: Pete Miller <pete@superpan.demon.co.uk>
Subject: Re: Help regarding Microsoft's Personal Web Server CGI configuration
Message-Id: <59XrzDAHiXSzEwQW@superpan.demon.co.uk>

Hey, I just cracked this last weekend...

See MS knowledge base 

article q158236 - 500 server error
--------q150629 - configuring and testing a perl script for IIS

The second one shows what to do with the registry, although for IIS, it's just about
the same for Win95.

Ensure that the directory on the server is marked for execute and NOT read.

Good luck...



In article <33489aa1.11446457@news.primenet.com>, Benson Trinh <benson@primenet.com>
writes
>Your approach to this is incorrect.  First, you need to create an
>association with .cgi or .pl in Explorer.  Then you need to add the
>.pl or .cgi mapping in the registry.  If you need further details,
>e-mail me.  I've done this but currently the problem I have is that I
>need to create one directory or each perl script.  However, others
>have added perl with this method and it has worked for them.
>
>Benson
>
>On Wed, 26 Mar 1997 01:25:12 -0800, Gunraj Singh
><Gunraj.Singh@atsys.com> wrote:
>
>>Hi 
>>
>>I am facing a problem regarding MicroSoft's Personal Web Server. I am
>>using this server on Win 95 system and I'am trying to run some cgi
>>scripts written in Perl in the cgi-bin directory, which also contains
>>the Perl for Win32 executable file. What happens is that 
>>
>>1) If I am using MS Internet Explorer then it gives error: 
>>               500 Server Error    for files with .cgi extension
>>   but opens files with .pl extension.
>>
>>2) If I am using Netscape 3.0 then it gives the same error for file 
>>   with .cgi extension i.e. 500 Server Error but opens .pl file
>>   as Save as to disk. I changed the Option for x-perl application to   
>>run the perl.exe file on win95 but it stills open as save as.
>>
>>
>>Both Netscape and IE opens cgi scripts if they are running on some other
>>servers. Certainly it has something to do with Microsoft's PWS. 
>>
>>Is there any way to configure PWS so that cgi scripts run successfully
>>on both IE and NEtscape and I don't get the above errors. If so, can
>>anybody help me in that ?
>>
>>I would greatly appreciate any help.
>>
>>
>>Gunraj Singh
>

-- 
Pete Miller     email: pete@superpan.demon.co.uk   
                Web:   http://www.superpan.demon.co.uk


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

Date: 7 Apr 1997 18:32:31 -0700
From: bbrown@eyrie.org (Ben Brown)
Subject: Re: HELP!  With MacPerl
Message-Id: <5ic77f$7j9@eyrie.org>

Thanks for responding to my earlier question.  that was extremely
helpful. so far I only have one (probably incredibly stupid) question about
the perl port for the mac.  Since "\n" has a different ascii value, can I
still us it in output to indicate a new line (I'm not real familiar with my
ASCII) or do I need some workaround?

Thanks again.

-Ben



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

Date: 7 Apr 1997 16:43:08 -0700
From: jhobbs@cs.uoregon.edu (Jeffrey Hobbs)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <5ic0qc$ene@psychotix.cs.uoregon.edu>

In article <5ibl1p$5et$2@csnews.cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
>    fellowsd@cs.man.ac.uk (Donal K. Fellows) writes:
>:  toplevel .t
>:  button .t.b -text Hi! -font {Times 16} -command {puts "Pressed at (%x,%y)"}
>:  pack .t.b -fill both -expand 1

>:How much extra Lisp would be needed to achieve this?

>Strange how often people seem to confuse Tk with Tcl.  You aren't
>talking about Tcl here.

Yes and no.  Some of the discussion has wandered off the main thrust of JO's
paper, but Donal's point here is LOC (or perhaps more generally syntactic
simplicity).  The use of Tk here proves a point because Tk has been grafted
onto so many other languages.  The example above is written most "plainly"
(concisely / fewest chars with greatest clarity / ...) when written in Tcl.

That is not to say "Tcl is the best, everyone else bugger off".  From
certain viewpoints, it is an advantage.  As for other's arguments about JO's
horrible injustices for neglecting to mention <your lang here>, get a clue.
This was a white paper of ~10 pages, not some PhD thesis on languages.  The
sum total of the comments alone so far are an order of magnitude longer.
Such a paper isn't just meant for language theorists or die-hard engineers,
but also managerial or business types who are being convinced to use a
scripting language.

Probably JO's worst infraction is the point that tchrist brought up about
portraying "systems" and "scripting" language features as absolutes instead
of breaking down the definitions further.

However, within the realm of JO's original paper, try the above example in
Java.  Then try and make it look not so ugly.

-- 
  Jeffrey Hobbs                          jhobbs@cs.uoregon.edu,@or.cadix.com
  Software Engineer, Oregon R&D          office: 541.683.7891
  CADIX International, Inc.              fax:    541.683.8325
             URL: http://www.cs.uoregon.edu/~jhobbs/


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

Date: Tue, 08 Apr 1997 10:32:07 +1000
From: Graham Matthews <graham.matthews@maths.anu.edu.au>
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <33499207.6438@maths.anu.edu.au>

fellowsd@cs.man.ac.uk (Donal K. Fellows) writes:
> >:  toplevel .t
> >:  button .t.b -text Hi! -font {Times 16} -command {puts "Pressed at (%x,%y)"}
> >:  pack .t.b -fill both -expand 1
Jeffrey Hobbs wrote:
> Yes and no.  Some of the discussion has wandered off the main thrust of JO's
> paper, but Donal's point here is LOC (or perhaps more generally syntactic
> simplicity).  The use of Tk here proves a point because Tk has been grafted
> onto so many other languages.  The example above is written most "plainly"
> (concisely / fewest chars with greatest clarity / ...) when written in Tcl.

But this statement is not true. Someone posted the above code in TkGofer
and it had fewer characters (or at worst a roughly similar number of
characters). Moreover the TkGofer code is more robust since its
statically typed check.

Jeffrey Hobbs wrote:
> However, within the realm of JO's original paper, try the above example in
> Java.  Then try and make it look not so ugly.

Try it in TkGofer and you will see the fallacy of your position.

graham

-- 
                beating on a tin drum marching to a sound
                         what is it I think?
             am I beating on a tin drum marching to a cause
                  when I don't know what it is I believe


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

Date: 8 Apr 1997 01:32:17 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: print a hash with 2 columns
Message-Id: <slrn5kj811.qoe.Alain.Deckers@nessie.mcc.ac.uk>

In <3344C4A6.7428@info.univ-angers.fr>,
	Candice Chauve <chauve@info.univ-angers.fr> wrote:
>I've got to print a hash composed of students'names and of their best
>mark.On the first, column we should see the name of the student and on
>the other column,we should see the students'mark.The first problem is
>that the second column must begin at the same position for all the marks
>and I don't know how to do that!

This part is easy. You can use either printf or sprintf to produce
formatted output. These Perl functions mimick your system library
functions. See the man pages for more details.

>Secondly, I've got to sort the students by the level of their mark.And
>if several students have the same mark ,I should sort them by
>alphabetical order.

You didn't tell us exactly how the data is stored in the hash, so it's
difficult to give specific help. You should however be able to find an
answer in the Perl FAQ. Look for for 'sort by value' and 'sort by key'.

HTH,
-- 
Alain.Deckers@man.ac.uk          <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
   Perl software: <URL:http://www.perl.com/CPAN/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: 8 Apr 1997 01:36:40 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: print a hash with 2 columns
Message-Id: <slrn5kj899.qoe.Alain.Deckers@nessie.mcc.ac.uk>

In <3344C4A6.7428@info.univ-angers.fr>,
	Candice Chauve <chauve@info.univ-angers.fr> wrote:
>I've got to print a hash composed of students'names and of their best
>mark.On the first, column we should see the name of the student and on
>the other column,we should see the students'mark.The first problem is
>that the second column must begin at the same position for all the marks
>and I don't know how to do that!

This part is easy. You can use either printf or sprintf to produce
formatted output. These Perl functions mimick your system library
functions. See the man pages for more details.

>Secondly, I've got to sort the students by the level of their mark.And
>if several students have the same mark ,I should sort them by
>alphabetical order.

You didn't tell us exactly how the data is stored in the hash, so it's
difficult to give specific help. You should however be able to find an
answer in the Perl FAQ. Look for for 'sort by value' and 'sort by key'.

HTH,
-- 
Alain.Deckers@man.ac.uk          <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
   Perl software: <URL:http://www.perl.com/CPAN/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<


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

Date: Mon, 7 Apr 1997 18:50:22 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Split and Print?
Message-Id: <u71ci5.om.ln@localhost>

Elizabeth Hamilton (hamilte@one.net) wrote:
: I have a text file that I have been able to parse for particular
: patterns. The file handles are defined in an earlier piece of code.
: This program worked fine until I tried to split and print!
: Example:
: while (<INFILE>){
: # This version of the if clause works fine.


It will work somewhat less than fine if $_ = '/gclc/membersshtml';   ;-)
                                                           ^

You need to escape the dot to match a literal dot:

m#/gclc/members\.html#


: if (m#/gclc/members.html#) {
:   print OUTFILE;
:   print MAIL;
:   }

: # This one produces error messages (See below)

: if (m#/gclc/members.html#) {
:   ($hits, $bytes, $size, $304, $URL) = split(/\s+/, $_);
                           ^^^^

This is the cause of the _only_ error message that you have included.
(the others are warning messages)

This is not a variable. You must choose a legal variable name...


[
  Wanna know how to troubleshoot this kind of thing yourself?

  Well, I'm gonna tell you how anyway ;-)

($hits, 
$bytes, 
$size, 
$304, 
$URL) = 
split(/\s+/, $_);

Now when the error message gives a line number, you will be able to
tell _which_ variable it is that perl is complaining about...

]


:   print $hits >OUTFILE;

print OUTFILE $hits;



:   print MAIL;
:   }
: }

: close <INFILE>;
: clsoe <OUTFILE>;
  ^^^^^

hmmm... methinks this is not your real code...


Perhaps you should *look up* the functions that you want to use
in the free documentation that is included with the perl distribution?

You should have done that before posting here you know...


Your print() and close() are deeply funkified..


: -------------------------
: Error messages:
: Identifier "main::size" used only once: possible typo at ./gclclog6.pl
: line 33.
: Identifier "main::bytes" used only once: possible typo at ./gclclog6.pl
: line 33
: Identifier "main::URL" used only once: possible typo at ./gclclog6.pl
: line 33.
: Modification of a read-only value attempted at ./gclclog6.pl line 33,
: <INFILE>
: hunk 106.

: Thank you in advance for your help!


Uh huh.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Mon, 7 Apr 1997 19:35:14 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: system call
Message-Id: <2s3ci5.7s.ln@localhost>

Po-shan Chang (pchang@sherman.cs.columbia.edu) wrote:
: Hi,

Hi Paul.


: Can someone tell me what does the error

: "ran with non-zero exit status 255" mean, when I was trying to use the 
: debug method suggested by Camel's book on page 230?


It means that whatever you tried to call within your system()
call had an error.

system() just passed through whatever exit status was returned
by the called program. You need to know what an exit status of
255 means to the program you tried to run.

Unix commands usually return zero if they executed successfully.

Any other exit status indicates some sort of error. The sort of
error depends entirely on the program you tried to execute...


: thanks.

You're welcome.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 7 Apr 1997 15:37:34 -0700
From: hh@scam.XCF.Berkeley.EDU (Eric Hollander)
Subject: tail in perl (was Re: Help!  How do I pass filehandles to subroutines?)
Message-Id: <5ibsve$pv2@scam.XCF.Berkeley.EDU>


The reason I needed to pass around filehandles was to write tail in perl,
for use as a subroutine of a larger program.  Here's tail in perl.  It uses
seek to move backwards through the file, so it handles large files
effeciently, but it also seeks and reads one char at a time (instead of
using a buffer) so it won't take big chunks off the end efficiently.
Anyway, the way people usually do this in perl is something like:

	@foo = <>;

and then they look at the last 10 lines of the array.  Obviously, that
doesn't work at all on big files, but this does.

It might be cool to have this (or an improved version) in the standard perl
library.


#!/usr/local/bin/perl -w

# tail in perl

use strict;

# DO NOT XRAY
# DO NOT BEND

# for example:
# note: can't use STDIN as a bare word with use strict.

print join("", tail(\*STDIN, $ARGV[0]));


sub tail {
	# given a file handle and a number, returns an array
	# of the last number of lines in the file
	# uses seek so it doesn't have to read the whole
	# file.  it seeks one character at a time, so you
	# don't want to use it to read in huge chunks of the file

	my($lines, $n, $pos, @buf, $byte, $FH);

	*FH = $_[0];
	$lines = $_[1];

	$n = $lines;
	$pos = -1;
	while($n >= 0) {
		if(seek(FH, $pos, 2)) {
#		print "now at: " . tell(*FH) . "\n";
			read(FH, $byte, 1) || die "read failed";
			$pos--;
			if($byte eq "\n") {
				$buf[$n] = reverse($buf[$n]);
				$n--;
				if($n >= 0) { $buf[$n] .= $byte; }
			} else {
				$buf[$n] .= $byte;
			}
		} else {
			$buf[$n] = reverse($buf[$n]);
			last;
		}
	}
	return @buf;
}


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

Date: 7 Apr 1997 22:57:51 GMT
From: "Tim Behrendsen" <tim@a-sis.com>
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <01bc43a7$0c0cdbe0$87ee6fce@timpent.a-sis.com>

Graham C. Hughes <graham.hughes@resnet.ucsb.edu>
> >>>>> "Tim" == Tim Behrendsen <tim@a-sis.com> writes:
> 
> Tim> Then don't work there.
> 
> <cackle> That implies that a) there exist better jobs, and b) they
> aren't already filled.
> 
> I'll be flogged before I work for a large company, precisely because
> I'm viewed as a commodity.  I get better treatment from my cat.
> 
> Tim> Remember: The Sistine Chapel was a commissioned project.  Should
> Tim> Michelangelo have done inferior work because he was getting paid
> Tim> for it?
> 
> Would he have done inferior work if the Pope was standing over him the
> entire time making ``suggestions'' and threatening him with
> performance reviews?

He had "performance reviews" his entire career.  How do you think
he *got* the project?

Everyone gets performance reviews, whether they are from bosses,
customers, or yourself.

> I work just fine if you get out of my way.  Free software (and often
> small startups) understand this much better than IBM does.  It's this
> morale thing, y'know?  Good programmers program because it's fun, not
> because it's their job.  When you make it not fun, you kill the entire
> enterprise.

Good programmers program for 1) Fun, and 2) Money, and the latter
inevitably produces better quality over the long haul (obviously
there can be momentary "blips" here and there).

> -----BEGIN PGP SIGNATURE-----
> -----END PGP SIGNATURE-----

BTW, no offense, but *why* do people post PGP signatures?  Is it just
me, or is it completely ridiculous?

-- 
==========================================================================
| Tim Behrendsen (tim@a-sis.com)        | http://www.cerfnet.com/~timb   |
| "Judge all, and be prepared to be judged by all."                      |
==========================================================================


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

Date: Tue, 08 Apr 97 00:52:30 GMT
From: fred@genesis.demon.co.uk (Lawrence Kirby)
Subject: What does "UNIX" stand for.. (Re: Who makes more $$..)
Message-Id: <860460750snz@genesis.demon.co.uk>

>> False - Unix doesn't stand for anything. It is a pun on the name of OS from
>> which it was derived - Multics. Check the relevant FAQs.
>
>Actually, "UNIX", (originally intended to be spelled as "Unics" and
>later, "Unix") was a pun on Multics which was one of Unix predecessors.
>Multics stood for "MULTiplexed Information and Computer System"
>(watch for those capitals). "UNIX" stands for "UNiplexed Information
>and Computer System". My references: FAQ for comp.unix.shell and a
>copy of original Multics manual. I think I also saw "UNIX" interpreted
>that way in one of O'Reilly books on Unix programming.

That looks suspiciously like somebody's guess of how they think it ought to
be. The Unix FAQ (contents section) says:

"...You
may also like to read the monthly article "Answers to Frequently Asked
Questions" in the newsgroup "news.announce.newusers", which will tell
you what "UNIX" stands for."

And that reference says:

"Subject: What does UNIX stand for?

     It is not an acronym, but is a pun on "Multics".  Multics is a
     large operating system that was being developed shortly before
     UNIX was created.  Brian Kernighan is credited with the name."

Also from "The UNIX Programming Environment" by Kernighan and Pike:

"``UNIX'' is *not* an acronym, but a weak pun on MULTICS, the operating
 system that Thompson and Ritchie worked on before UNIX."

The *'s indicate italicised text in the book, presumably for emphasis.

-- 
-----------------------------------------
Lawrence Kirby | fred@genesis.demon.co.uk
Wilts, England | 70734.126@compuserve.com
-----------------------------------------



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 251
*************************************

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