[6633] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 258 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 9 04:07:20 1997

Date: Wed, 9 Apr 97 01:00:33 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 9 Apr 1997     Volume: 8 Number: 258

Today's topics:
     "Rip the head of...." <pucko@lysator.liu.se>
     Re: A couple of questions on Forms... Please help!!! (A. Deckers)
     Re: beginner in Perl (Tad McClellan)
     Re: Can Perl be interactive like Python? (Brian Jepson)
     Re: Can't get 2 way communication using sockets <joeo@hpfcjoe.fc.hp.com>
     Re: CGI output HTML (Tad McClellan)
     Error when using Accept <joeo@hpfcjoe.fc.hp.com>
     help! buiding perl5.003 on Sequent pptse@uswnvg.com
     Re: How to use COOKIES from perl ??? (A. Deckers)
     Re: if statement doesn't work! (Tad McClellan)
     Re: if statement doesn't work! (David Alan Black)
     Re: Little beginers question (Jeff Stampes)
     Re: mkdir (Jeff Stampes)
     msql perl print columns <sys@notreallyahost.com>
     output duplication problem <sungwoo.cho@ebay.sun.com>
     Re: Perl-Books. (Mike Stok)
     Re: Question on Class method inheritance <tchrist@mox.perl.com>
     Re: sort array? (A. Deckers)
     Re: Substitution Question (Tad McClellan)
     Re: Unix and ease of use  (WAS: Who makes more ...) <tim@a-sis.com>
     Re: visit my first CGI/PERL project (Nizamettin KORKMAZ)
     Re: Win32 System() help (Duncan Harris)
     Re: Win32 System() help <dave@turfpit.demon.co.uk>
     Re: Win32 System() help <gordon.leslie.mcdorman@sap-ag.de>
     Re: Win95 opendir() (Mike Stok)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 09 Apr 1997 02:33:29 +0200
From: Magnus Holmberg <pucko@lysator.liu.se>
Subject: "Rip the head of...."
Message-Id: <334AE3D9.6F2B@lysator.liu.se>

HI!

Can someone tell me how to "rip the head" of a mail-file?
I have the mail-file stored by the elm-filter and it has som
real uggly rows at the beginnig that I like to remove.

It looks like this:

>From someone@ytko.nl  Mon Apr  7 12:05:01 1997
Received: from asd-gw2.euro.net (asd-gw2.euro.net [194.134.0.94])
	by lysander.lysator.liu.se (8.8.5/8.8.5) with SMTP id MAA23195
	for <pucko@lysator.liu.se>; Mon, 7 Apr 1997 12:04:55 +0200 (MET DST)
Received: (from uucp@localhost) by asd-gw2.euro.net (8.6.12/8.6.10) with
UUCP id MAA23802 for pucko@lysator.liu.se; Mon, 7 Apr 1997 12:04:33
+0200
Received: by ytko.nl (Mailcoach V2.10) via SMTP; Fri, 04 Jul 1997
11:31:53 
Comments: Routed through 'Mailcoach V2.10 for Win95/NT'
Received: by ytkopc03 with Microsoft Mail
	id <01BC4347.AA64C100@ytkopc03>; Mon, 7 Apr 1997 11:34:34 +-200
Message-ID: <01BC4347.AA64C100@ytkopc03>
From: =?iso-8859-1?Q?Maria_Sj=F6holm?= <maria@ytko.nl>
To: "'Magnus Holmberg'" <pucko@lysator.liu.se>
Subject: =?iso-8859-1?Q?RE=3A_Trevligt_att_h=F6ra_att_du_lever=21?=
Date: Mon, 7 Apr 1997 11:34:32 +-200
MIME-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by
lysander.lysator.liu.se id MAA23195
Status: RO
X-Status: 



I would be very glad if someone can tell me how to make a script that
removes all those heads from som files.

THANKS!

Magnus - PUCKO - The Water Of Life!


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

Date: 9 Apr 1997 00:12:26 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: A couple of questions on Forms... Please help!!!
Message-Id: <slrn5klnna.7dv.Alain.Deckers@nessie.mcc.ac.uk>

In <01bc1372$745a3680$fdeb1ec2@www.webads.gr.webads.gr>,
	Dimitris Vayenas <User_id@webads.gr> wrote:
>I would like to parse a form but I would like later not to report the
>Hidden fields...

This is a CGI issue, and as such should be asked in
comp.infosystems.www.authoring.cgi.

>How can I read and split, "name", "value" and "hidden" separately?

As far as reading the data in, use CGI.pm. As far as split is
concerned, have a look at one of the many forms of excelent
documentation available for free with the Perl distribution. the perlfunc
man page should get you started. Try grep'ing it for 'split'.

But I suspect you're asking about decoding the query string by hand,
which in general is a Bad Thing. Use CGI.pm.

>Also I would like to read an store only the first 2 characters of the
>"value" how can I do it in a very perl smart way? 

$first_2_chars = substr $input, 0, 2;

This is also in the perlfunc man page. In fact, since this is how to
extract the salt from a crypt'ed passwd, it's documented and illustrated
to death in most tutorials. You did read some tutorials before posting
your questions to the many thousands of machines that partake of USENET,
didn't you?

Cheers,
-- 
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: Tue, 8 Apr 1997 17:02:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: beginner in Perl
Message-Id: <q8fei5.1nf.ln@localhost>

Serginho (serginho@usa.net) wrote:
: Hi All!!

:    I'm a Perl Beginner and I'd like some help... :)) Well...Is it the same
: thing Perl and CGI ? Or CGI it's a perl program compiled ? In a Web Server
: (Novell Intranetware I'll use), a perl program is auto-executable if it's
: in cgi-bin directory ? And I need to compile the program or Perl run like
: html (interpret) ?


[ from the new Perl FAQ, part 9 ]

The useful FAQs are:

    http://www.perl.com/perl/faq/idiots-guide.html
    http://www3.pair.com/webthing/docs/cgi/faqs/cgifaq.shtml
    http://www.perl.com/perl/faq/perl-cgi-faq.html
    http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
    http://www.boutell.com/faq/


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


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

Date: 8 Apr 1997 21:39:57 GMT
From: bjepson@bjepson.ids.net (Brian Jepson)
Subject: Re: Can Perl be interactive like Python?
Message-Id: <slrn5kl0i2.b4.bjepson@bjepson.ids.net>

In article <334A360D.7D38@nortel.co.uk>, Peter Hamer wrote:
>Disclaimer: I'm a believer in horses for courses, and have no desire
>to start a language war. Perl is rightly an industrial standard for
>the mangling of text in batch mode.
>
>I note that Python has an interactive interpreter, which makes Python
>very suitable for implementing a command-line interface to other tools.
>Note that's an interactive command-line, not a batch-script interface.
>
>Am I right in thinking that the Perl interpreters do not offer such a
>feature? 
>

Actually, Perl offers this out-of-the-box. Try:

 perl -de 0

If you have Term::ReadLine (you may also need Term::ReadKey), and the
interactive interpreter will let you do lots of nice ReadLine things,
similar to bash.

Hope this helps,

Brian Jepson * (bjepson@ids.net)  *  http://www.ids.net/~bjepson
  Int(ra|er)net Database Developer, Author, Crypto-Fluxologist
Non-Prophet Arts Technology Flux:      http://www.ids.net/~as220
WWW/Database/NT,Java/Database: http://www.ids.net/~bjepson/books



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

Date: 08 Apr 1997 12:06:12 -0600
From: Joe Orth <joeo@hpfcjoe.fc.hp.com>
Subject: Re: Can't get 2 way communication using sockets
Message-Id: <yb6k9mdwfsb.fsf@hpfcjoe.fc.hp.com>

I actually got this working.  I'm not sure exactally what I did, but
it works now. (It really should have worked the first time as far as I
can tell).


-- Joe Orth


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

Date: Tue, 8 Apr 1997 17:00:27 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: CGI output HTML
Message-Id: <r5fei5.1nf.ln@localhost>

SAA (paull@saa-cons.co.uk) wrote:
: Hello,

: I am using Perl to produce the CGI functions behind a series of web-pages,
: nothing new there !

: I've got the script reading in various form-fields from the form which
: calls it, the script processes these values does a bit of jiggery-pokery
: with other information ( file sizes, system information etc. ) and produces
: an output HTML file which is returned to the browser with information and
: an href link supplied by the Perl script.
: All well and good.

: I'm now trying to make it easier to maintain the HTML which is returned as
: it is currently in the Perl code  i.e. 	print <<END_OF_HTML;
: 			        	<html goes here>
: 				END_OF_HTML;
: so I took the HTML and placed it in another file which the scripts reads in
: using 
: OPEN(IN, filename) and outputs it as before, unfortunately the variable
: values marked by $var_name in the HTML no longer get replaced with the Perl
: values but just get shown as '$var_name'.

: Has anybody managed to get this to work where Perl reads in the HTML file,
: replaces the $var_name with the Perl generated value and then outputs it to
: the browser ?

: Any ideas or comments are most welcome.
  ^^^^^^^^^

How about 'require'?

---------- my.html --------------
$html=<<ENDHTML;

<HTML>
This is bogus HTML for $yourword
</HTML>

ENDHTML
----------------------------------


---------- my.cgi ----------------
#! /usr/bin/perl -w

$yourword = 'testing';

require "my.html";       # suck in all the predefined HTML markup,
                         # interpolating variables as you go

print $html;
----------------------------------


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


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

Date: 08 Apr 1997 12:04:19 -0600
From: Joe Orth <joeo@hpfcjoe.fc.hp.com>
Subject: Error when using Accept
Message-Id: <yb6lo6twfvg.fsf@hpfcjoe.fc.hp.com>


I am running on HP-UX 10.20 using perl5.003 that I compiled on 10.20.

The script runs normally for a while but then, at random intervals, it
dies in accept.  $! has the value: Interrupted system call.  

Any Ideas?


-- Joe Orth


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

Date: Tue, 08 Apr 1997 17:22:09 -0600
From: pptse@uswnvg.com
Subject: help! buiding perl5.003 on Sequent
Message-Id: <860535745.15960@dejanews.com>

Hi,
   I am trying to build Perl 5.003 on Sequent running dynix/ptx 4.1.3
I have a linking error saying that the symbol _filbuf is undefined in
file  libperl.a(sv.o).  Can someone tell me what I did wrong?  I have
no idea which library _filbuf is located.
Philip Tse
pptse@uswnvg.com

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 9 Apr 1997 00:53:14 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: How to use COOKIES from perl ???
Message-Id: <slrn5klq3r.7dv.Alain.Deckers@nessie.mcc.ac.uk>

*sneck* Why in blazes did you cross-post to the tk group?

In comp.lang.perl.misc,comp.lang.perl.tk
	T. de Konink <konink@telebyte.nl> wrote:
>Hello,
>
>I want to use cookies for an internet-game I'm going to develop, soo I
>can identify the players. 
>
>QUESTION:
>How can I set and "read" cookies from a Perl script.

By using the CGI.pm module.

<URL:http://www.perl.com/CPAN/modules/>

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: Tue, 8 Apr 1997 16:31:00 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: if statement doesn't work!
Message-Id: <kedei5.6jf.ln@localhost>

Joe Weinman (josephw@tamu.edu) wrote:
: Howdy...

: I am having problems with the following perl script.  Basically, what I
: am trying to do is use a shell script "listconn" to list current
: connections to my database server.  Then I want to check this list
: against the UNIX "ps" command to see if the connection really has an
: active process.  If not, I can clear the process by "./listconn $line"
: where $line is the line number produced by ./listconn without an
: argument.

: Sample "./listconn" output is:
: 0       20723            tamu
: 1       20694           notis   AG03,AGA2,AG79,AG9A
: 2       20728            tamu
: 3       20409           notis   AG9A
: 4       20288           notis   AG9A
: 5       20732            tamu

: I have the following perl script (output follows):

: #!/public/bin/perl
: system("/usr/infoshare/sproot/bin/listconn >/sproot/bin/userlist.txt");
: open (LIST, "/sproot/bin/userlist.txt");        # open LIST for reading
: while (<LIST>)
:         { @line[$i++] = $_; }
: close (LIST);


Looks like you have programmed in C before ;-)

the perl idiom for the above is:

open (LIST, "/usr/infoshare/sproot/bin/listconn |") || die "could not fork";
@line = <LIST>;
close(LIST);


Cool, huh?

No intermediate file to remember to get rid of either.


: open (PROC, "/usr/bin/ps -ef | grep dbserver|");
: @howmany=<PROC>;


Oh.

It appears you already know that idiom. Why not use it above too?


: open (TEST, ">output");


Check return values, check return values, check return values...

open (TEST, ">output") || die "could not open 'output' file  $!";


: print TEST "There are $howmany lines of output from the greps\n";
                        ^^^^^^^^

If you had asked perl to help you debug your scripts, it would
have told you that $howmany is still undefined at this point...

#!/public/bin/perl -w
#                  ^^


: print TEST @howmany;

: foreach (@line)
:         {
:         print TEST;
:         ($linenum, $twomuch, $database) = split (/\t/, $_);
:                                         # linenum = line number
:                                         # twomuch = processid and
: username
:                                         # database = databases
:         ($processid, $username) = split (/ /, $twomuch);
:                                         # split twomuch into process and
: user
:         print TEST "$linenum $processid\n";
:         while (<PROC>)
:                 {


When you dropped a print statement in here, everything looked OK?

print "processid: '$processid'\n"; # no leading/trailing blanks in there?


:                 if (!/$processid/)
:                    { system("/sproot/bin/listconn $linenum") } # end IF
:                 }                               # end WHILE
:         };              # end FOREACH
: close (TEST);

: -----------OUTPUT-------------
: There are  lines of output from the greps
:     boss 17838     1  0 15:16:20 ?        0:00 ./dbserver -m
:     boss 20694 17838  0 11:37:52 ?        0:02 ./dbserver -m
:     boss 20732 17838  0 11:47:33 ?        0:01 ./dbserver -m
:     boss 20767 20766  0 11:59:20 pts/2    0:00 grep dbserver
:     boss 20766 20763  0 11:59:20 pts/2    0:00 sh -c /usr/bin/ps -ef |
: grep dbse
: rver
:     boss 20723 17838  0 11:44:29 ?        0:02 ./dbserver -m
:     boss 20728 17838  0 11:46:13 ?        0:01 ./dbserver -m
: 0       20723            tamu
: 0 20723
: 1       20694           notis   AG03,AGA2,AG79,AG9A
: 1 20694
: 2       20728            tamu
: 2 20728
: 3       20409           notis   AG9A
: 3 20409
: 4       20288           notis   AG9A
: 4 20288
: 5       20732            tamu
: 5 20732


: ----------------------------------

: As you can see, the $linenum and $processid variables are getting set to
: what they need to be because they print out on a separate line by
: themselves.

: What I can't figure out is why my if statement doesn't execute!  I used
: to have the form:

: if (/$processid/)
:       { next }
: else
:       { system("/sproot/bin/listconn $linenum") } # end IF

: but this didn't work either.  
           ^^^^^^^^^^^^^^^^^^

: Any ideas?  
  ^^^^^^^^^

Yes. Tell us what form of "didn't work" you are getting:

core dump
syntax error
program hangs
program returns without appearing to have done anything
doesn't clear any DB connections
clears too few DB connections
clears too many DB connections
clears all DB connections
 ...


: Please email privately at
: email address below.


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


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

Date: 8 Apr 1997 22:58:03 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: if statement doesn't work!
Message-Id: <5ieihr$lqq@pirate.shu.edu>

Hello -

Joe Weinman <josephw@tamu.edu> writes:

>@howmany=<PROC>;
   ...

>        while (<PROC>)

That while loop is never going to execute, since you've already
reached end-of-file on PROC.

You can either seek() back to the beginning of the PROC stream
with: seek (PROC, 0, 0);  or use a foreach loop with @howmany
(or a copy of it).

David Black
dblack@icarus.shu.edu




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

Date: 8 Apr 1997 20:37:20 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Little beginers question
Message-Id: <5ieaa0$2ff$1@neocad.com>

Eric Poindexter (eric@nettown.com) wrote:
: Josep Jover wrote:
: > 
: > Hello,
: > Just two little questions to help a beginner that doesn't write english
: > very well ;-)
: > 
: > How can I retrieve the current directory where I am ('chdir' is only use to
: > change it ?)

: $cwd = `pwd' # if unix
: $cwd = `cd`   #if NT 

use Cwd;
$cwd = cwd();     # if you want to be perlish and portable

--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: 8 Apr 1997 20:42:45 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: mkdir
Message-Id: <5ieak5$2ff$2@neocad.com>

Geoffrey Hebert (soccer@microserve.net) wrote:
: I wanted to mkdir xx/yyy 0777
: I would like to code to work on multiple OS's.

use File::Path;
mkpath($directory,boolean,mode);

the boolean value controls whether it prints the name of each directory
as it is created.  The mode defaults to 0777.  This will create a dir 
structure as deep as you need (ie, create /tmp/foo/bar, even if
/tmp/foo doesn't exist).

: And I want to be able to do it from web.

see a www newgroup for help on this.

: Sounds impossible, is it?

nothing's impossible (except doing difficult tasks through a GUI ;)

: Thanks in advance.

Sure.


--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: 9 Apr 1997 00:38:59 GMT
From: "Systems Group" <sys@notreallyahost.com>
Subject: msql perl print columns
Message-Id: <01bc447e$cfdbfc40$58056c81@rogue>

I am using the msql perl interphase version 1.03

I want to be able to retrieve all data from a column and print it out......
however I have no idea how to implement this.....
I understand FetchRow will allow me to retrieve a record...but how do I
retrieve a 
column?????????Help Please as soon as possible...!!


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

Date: Tue, 08 Apr 1997 14:32:48 -0700
From: Sungwoo Cho <sungwoo.cho@ebay.sun.com>
Subject: output duplication problem
Message-Id: <334AB980.58DD@ebay.sun.com>

I am trying to send both output and error messages to more than one
file
     and having a hanging problem.  I included my script at the bottom
of
     this message.  I am using Perl4 on Solaris 2.4.  The problem with
the
     script is that it hangs at the close(STDOUT); statement.  The only
     workaround that is found until now is to kill the 'tee' process
     as shown in the commented code segment.  Why is it hanging ??  Is
there
     any better way to work around this other than killing the process
??
     How can I gracefully close the pipe to 'tee' command ??
     Also once the file handles are opened for duplicate outputs, the
hot
     piping still shows some delay if I check in a debugging mode by
steping
     statements.  Why is it ??

     Basically I need to display both output and error messages of the
entire
     script to the terminal and a log file.  Is there a better way to do
this
     ??  Thank you for your help in advance.

                                                 Sungwoo Cho
                                                
sungwoo.cho@ebay.sun.com

 _______________________________ cut here
_____________________________________
#!/your-path/Perl
#
$LOGFILE='/tmp/zcom5.log';

select((select(STDERR), $| = 1)[$[]);
select((select(STDOUT), $| = 1)[$[]);
open(SAVEOUT, ">&STDOUT");
open(SAVEERR, ">&STDERR");
open(STDOUT, "|tee $LOGFILE") || die "error to open out\n";
open(STDERR, ">&STDOUT") || die "error to open err\n";
select(STDERR); $| = 1;
select(STDOUT); $| = 1;

print STDOUT "DEBUG testing out\n";
print STDERR "DEBUG testing err\n";

#@pids = `/bin/ps -aef | grep 'tee $LOGFILE' | grep -v grep`;
#@kill_pids = grep(s/\S+\s+(\S+)\s+.*/$1/, @pids);
#foreach $pid (@kill_pids)
#{
#   system("kill -HUP $pid");
#}

close(STDOUT);
open(STDOUT,">&SAVEOUT");
close(SAVEOUT);
close(STDERR);
open(STDERR,">&SAVEERR");
close(SAVEERR);

print STDOUT "DEBUG testing out after\n";
print STDERR "DEBUG testing err after\n";


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

Date: 8 Apr 1997 21:47:12 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl-Books.
Message-Id: <5ieed0$k9d@news-central.tiac.net>

In article <334A8ACA.1364@isy.liu.se>, Hulken  <n94magho@isy.liu.se> wrote:

>Can someone rekomend some good books about Lerning perl.

Tom Christiansen has some reviews of books at
http://www.perl.com/perl/critiques/index.html and I've found Learning Perl
by Randal Schwartz to cover the basics of perl (both 4 and 5) in a manner
which is accessible to someone who has a grasp of the fundamentals of
imperative programming.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 8 Apr 1997 21:16:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Question on Class method inheritance
Message-Id: <5iecip$hc7$3@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Hokee Chiu <chiue@nortel.ca> writes:
:class Inherited: fn A is defined (override Base::fnA),
:BUT fn B is NOT defined (i.e. I expect fn B in Base class to be reused)
:when I execute the perl script, the following happens:
:...
:Undefined subroutine &Inherited::fnB called at xxxx.

We can't help you without reading the source, which you didn't post.

Did you read perltoot yet, the tutorial on objects?

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    echo "Congratulations.  You aren't running Eunice."
        --Larry Wall in Configure from the perl distribution


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

Date: 8 Apr 1997 23:59:35 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: sort array?
Message-Id: <slrn5klmv8.7dv.Alain.Deckers@nessie.mcc.ac.uk>

In <5ib502$2va$1@news3.microserve.net>,
	Geoffrey Hebert <soccer@microserve.net> wrote:
>I want to sort lines.  So simple (ha), I thought I would 
>code is as below.  The nature of my real data is like that
>below.  
>
>help appreciated.
>
>Yeh, this is my first sort.  Read and re-read for a couple of hours
>I haven't given up.  But, I know this is an easy question for someone
>that knows the answer.  Thanks.
>
>#!/opt/bin/perl -w
>@line_is = (
>  ["10", "line data"],
>  ["1", "line data"],
>  ["31", "line data"],
>  ["3", "line data"],
>  ["6", "line data"],
>  ["2", "line data"],
>  ["22", "line data"],
>  ["202", "line data"],
>  ["41", "line data"],
>  ["4", "line data"],
>  ["5", "line data"],
>);                                    # problem one how to print line

Well, if you don't have duplicate numbers in this data, you'd be much
better of storing this in a array, using the numbers as the index for the
entry. 

If you do have duplicate numbers, but no duplicte line data, then strore
it in a hash, using the line data as the keys. They you can sort by value
(see the FAQ) to obtain the result you are looking for.

If you have duplicates of both... I just came back from the Pub, so I
wont try.

>foreach $line(@line_is) { 
>  print "$line\n";            # This of course prints ARRAY(0..etc

You should dereference this:

  print "@{$line}\n";

>}
>@sorted= sort {$line_is[$a][1] <=> $line_is[$b][1]} @line_is;
>                                     # sort gives OUT OF MEMORY

How big is your data list?

>foreach $line(@sorted) {
>  print "$line\n";
>}
>exit;
>

Cheers,
-- 
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: Tue, 8 Apr 1997 16:04:21 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Substitution Question
Message-Id: <lsbei5.ngf.ln@localhost>

Thomas Parker (thpr@vnet.ibm.com) wrote:
: Pardon my question on "Substitution" and "Quoting" (I think!), I've read
: the FAQs and such, and have a solution (see below) but would like to
: know from the more experienced people out there if there is a better way
: to solve this problem.

: Thanks!

: If I have:

: $temp_item = "A+B";
: $master_item = "((A+B)/C)+((A+B)-D)";

: how do I get $master_item to be:

: ((E)/C)+((E)-D)

: I have tried:

: $master_item =~ s/$temp_item/E/g;

: But this fails because $temp_item contains a "+" which seems to be
: evaluated as a regular expression.

: I know

: $master_item =~ s'$temp_item'E'g;

: will not work because it does not expand $temp_item.

: Do I have to [i.e. my current solution]

: ($replace_item = $temp_item) =~ s/([^\w\s])/\\$1/g;
: $master_item =~ s/$replace_item/E/g;

: ??



$master_item =~ s/\Q$temp_item/E/g;
                  ^^                 see perlop/perlre man pages



: Thanks.


You're welcome.


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


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

Date: 8 Apr 1997 23:51:50 GMT
From: "Tim Behrendsen" <tim@a-sis.com>
Subject: Re: Unix and ease of use  (WAS: Who makes more ...)
Message-Id: <01bc4477$bfb15c40$87ee6fce@timpent.a-sis.com>

Peter Seebach <seebs@solutions.solon.com> wrote in article
<5idpbv$kdf@solutions.solon.com>...
> In article <01bc43a7$0c0cdbe0$87ee6fce@timpent.a-sis.com>,
> Tim Behrendsen <tim@a-sis.com> wrote:
> >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).
> 
> This is an assertion you have made frequently, but it contradicts the best
> information we have about himan motivation.

I would say it's perfectly in line with the information we have
about human motivation.  It's why Capitalism succeeds where Socialism
fails.  If humans were more motivated by abstractions such as "wanting
to do a good job", Socialism would succeed.

But I don't even need to go there.  Name one freely available
*significant* product that is *clearly* better than *any* commercial
product, regardless of price.  There are some good programs of limited
size that are not worth a commercial entity rewriting (some may
say Emacs, but I wouldn't...), but I mean products of significant
size and complexity.

> In fact, while most people would rather get ten dollars of cash than a ten
> dollar discount, if you build an employee incentive scheme which gives
> out vacations, discounts, and other things, it produces more of an improvement
> in output than a cash incentive scheme worth the same amount of money per
> accomplishment.
> 
> (Someone just did some fairly heavy research on this...)
> 
> Why?  Dunno.  It seems to have to do with the difference between analytic
> evaluation and warm fuzzies.

I don't think it's any big mystery; it comes down to the difference
between being greedy and simply having a goal of financial success.
A greedy person earns money for the sake of itself, i.e., "The love
of money is the root of all evil" (note *love* of money, not money,
BTW).  Someone having a goal of financial success goes to the
survival instincts; they want money as a vehicle for a more comfortable
living for themselves and their family.

A "vacation" incentive, etc is a more direct benefit in these terms.

> For $N, I'll do $N worth of work.  Beyond that, I may start feeling that the
> company ought to hire more programmers if they need so much work done.  I
> won't stay very late for money, and I tend to assume that the $n/hour rate
> implies that that's all my time is worth.  Since I can typically earn $3n/hour
> on the side, this means I *analyze* the value or cost of the work.

Well, first, hourly wages are not necessarily a big incentive to
work hard.

Second, you can't judge average human behavior by specific examples
of anecdotal evidence.  Historically, financial success as a goal 
to a comfortable and safe life for you and your family has been the
most powerful incentive.

> When a coworker thanks me for getting something ready, I am *happy*.  I will
> stay later to get things done for a coworker I like than I will for overtime
> pay.
> 
> Important clue:  People are not entirely rational.  The thing that killed
> behaviorism is that we have more internal and intangible motivations than we
> do external or tangible ones.
> 
> This is why large companies can produce solid products, but almost never
> *brilliant* products.  Look at where the brilliance and innovation comes in...
> It's small companies with visionaries.  Visionaries don't do well in large
> companies *even when they run them*, because the company shackles them too
> much in our current design.  Even then, when they *do* make a brilliant
> product, it's because they were interested in it, not because of the money.

They don't always do it because of the money, and don't often do it
*only* for money, but on a societal average, most people have a goal
of making a lot of money *along with* doing what they love.

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


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

Date: 8 Apr 1997 19:28:29 GMT
From: e106168@orca.cc.metu.edu.tr (Nizamettin KORKMAZ)
Subject: Re: visit my first CGI/PERL project
Message-Id: <5ie68t$hg@mogan.cc.metu.edu.tr>

Bobo (yemoja@speakeasy.org) wrote:


: Ster <ster@stargazer.net> wrote in article
: <01bc3ce9$e28d2a40$0a7b65cf@cornholio>...
: > I welcome everyone to visit my first CGI/Perl project.  I am welcoming
: the
: ---Chris
 that is nice project  . It works..:)


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

Date: 8 Apr 1997 21:18:47 GMT
From: duncan@sapio.co.uk (Duncan Harris)
Subject: Re: Win32 System() help
Message-Id: <memo.970408221812.58B@sapio.compulink.co.uk>

In article <5idn8c$c58@myst.plaza.ds.adp.com>, jeffl@plaza.ds.adp.com 
(Jeff Lawrence) wrote:

> I have read the FAQ and couldn't find anything to answer
> or address my specific problem.
> 
> I am trying to use the System() function to execute:
> 
> net use v:  \\server\share
> 
> by doing:
> 
> $status=system('net use v: \\server\share');


Try:

$status=system('net use v: \\\\server\share');


Next time try printing out what you are about to execute.
e.g.

$command = 'net use v: \\\\server\share';

print STDERR qq{Executing "$command"\n}
    if $debugging;
    
$status = system($command);
    

--
Duncan Harris, Sapio Design Ltd, Manchester, U.K.
~~~~~~~~~~~ mailto:duncan@sapio.co.uk ~~~~~~~~~~~
Web on CD-ROM?  Check out http://www.sapio.co.uk/


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

Date: Tue, 08 Apr 1997 23:28:56 +0100
From: David Richards <dave@turfpit.demon.co.uk>
To: jeffl@plaza.ds.adp.com
Subject: Re: Win32 System() help
Message-Id: <334AC6A8.433F@turfpit.demon.co.uk>

Jeff Lawrence wrote:

> I am trying to use the System() function to execute:
> 
> net use v:  \\server\share
> 
> by doing:
> 
> $status=system('net use v: \\server\share');
> 

Jeff

Try

system("net use v: \\\\server\\share");
system("dir v:");

David



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

Date: Tue, 8 Apr 1997 23:11:28 GMT
From: "Gordon McDorman" <gordon.leslie.mcdorman@sap-ag.de>
Subject: Re: Win32 System() help
Message-Id: <01bc4472$35662b60$0df4389b@p23874>

Jeff Lawrence <jeffl@plaza.ds.adp.com> wrote in article
<5idn8c$c58@myst.plaza.ds.adp.com>...

> I am trying to use the System() function to execute:
> 
> net use v:  \\server\share
> 
> by doing:
> 
> $status=system('net use v: \\server\share');

$status=system("net use v: \\\\server\\share"); 

works for me.

-- 
-------------------------------------------------------------- 
The opinions expressed above are mine, not my employer's.
      
gordon.leslie.mcdorman@sap-ag.de                               



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

Date: 8 Apr 1997 22:15:02 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Win95 opendir()
Message-Id: <5ieg16$m54@news-central.tiac.net>

In particular this is not a personal attack.  Please remember this, I
usually bite my tongue and shut up at times like this...

In article <5ie2td$gu3@fridge-nf0.shore.net>,
Nathan V. Patwardhan <nvp@shore.net> wrote:

>Granted, the "\\" method works, as in:
>perl -e '$foo="C:\\nate\\text\\";print $foo,"\n";'
>
>but ... there's absolutely no reason to do it like "\\" if it can be done 
>like '/' or 'C:/'.  
>
>: I would agree that "C:\\nate\\eek\\" has the two characher sequences \n
>: and \e in it, but what's wrong with that?
>
>Tom Christiansen has a document about this on http://www.perl.com.

I can't find the document offhand, but in a windows environment the
convention wssms to be that \ is used as a path separator due to the
historical use of the / as an option flag.  One thing that perl can do is
fit into the culture in which a particular coder works, and if they are
used to using \\ in C strings, for example, as a path separator then why
should we force them to change - in perl there's more than one way to do
it, and implying that something's bad 'cos it looks like something else is
verging on programming by superstition.  Some people have different sets
of idioms and "theirs" may be more suited to their working environment.

If there's some pro unix and anti windows sentiment then be open about it
- my opinion is that slamming particular (including "humourous"
mi$$pellings of their name) operating systems and companies almost as a
matter of course reflects more on the person doing the slamming than the
slammed company.  One of the great things about the community that has
formed around perl is that there is a lot of talent from all areas, unix,
DOS, OS/2, VMS willing to pitch in and make perl work in all these
environments - yes perl has strong traces of unix and C throughout it, but
it has traces of many other things too and is richer for it. 

Maybe the \\ indicates an area in which perl can be improved, maybe a
special quote which doesn't do any backslash processing at all e.g.

  $string = qn'C:\Foo\Bar\Baz.exe';

could help a lot in avoiding backslash-itis when building regexes on the
fly.

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

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

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