[12440] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6040 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 18 05:07:23 1999

Date: Fri, 18 Jun 99 02: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           Fri, 18 Jun 1999     Volume: 8 Number: 6040

Today's topics:
    Re: 'use' not working on ISP's NT server <dave@dave.org.uk>
        A buggy intersection-method (Thomas Weholt)
    Re: A buggy intersection-method <uri@sysarch.com>
    Re: a thread on threads (Bart Lateur)
    Re: a thread on threads <uri@sysarch.com>
    Re: Afraid to ask about Y2K! (Tad McClellan)
    Re: Afraid to ask about Y2K! <uri@sysarch.com>
    Re: Afraid to ask about Y2K! (Larry Rosler)
    Re: Afraid to ask about Y2K! <gellyfish@gellyfish.com>
    Re: CGI Simple Question (Tad McClellan)
    Re: Formatting Unix file permissions eg., 755 -> rwxr-x <davidk@netscape.com>
    Re: help with unlink (Tad McClellan)
    Re: Is Perl4 Y2K compliant? <dave@dave.org.uk>
        Launch a New Browser Window <engp8518@nus.edu.sg>
        Locking of simple text file or database <glchy@cc21.com.sg>
    Re: newbie (Lee)
    Re: newbie (Jim Britain)
    Re: OO-Trap! I am confused <janning@vygen.de>
        parsing a compressed file <skraemer@iil.intel.com>
    Re: parsing a compressed file (Eric Bohlman)
        Perl scripts slows down servers? <toxid@rdtest.mm.atos-group.com>
    Re: Simple Questions (Tad McClellan)
    Re: sorting an array from 2nd element onwards (Tad McClellan)
    Re: sorting an array from 2nd element onwards (Jim Britain)
        split a string character by character bennycc@pacific.net.sg
    Re: split a string character by character (Andrew Johnson)
    Re: split a string character by character <fruffet@kaptech.com>
        sprintf and money <james@britlinks.co.uk>
    Re: sprintf and money (Eric Bohlman)
        Using cgi or servlets, now? <toxid@rdtest.mm.atos-group.com>
    Re: Using perl to run system commands (Tad McClellan)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 18 Jun 1999 09:21:30 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: 'use' not working on ISP's NT server
Message-Id: <376A018A.E8E9505C@dave.org.uk>



Jeff D wrote:
> 
> Trying to port some unix perl scripts for NT.
> NT box is at an ISP so I can't control its setup.
> I'd like some way of knowing if I'm doing something wrong here or
> the ISP has setup issues (I start off assuming the former).
> 
> --------------------------------------
> Here's the code snippet:
> 
>     # test perl script.
> 
>     use strict ;
> 
>     my $MyCGITextHeader = "Content-type: text/plain\n\n";
>     print $MyCGITextHeader;
> 
>     # Print something
>     print "Banana Exists\n\n";
> 
>     # Check Perl version
>     print "$]\n\n";
> 
>     # Check @INC
>     print "@INC\n\n";
> 
> --------------------------------------
> Here's what shows up in the browser:
> 
> CGI Error
> The specified CGI application misbehaved by not returning a complete
> set of HTTP headers. The headers it did return are:
> 
> Can't locate strict.pm in @INC at
> C:\export\pneumaticvalves\cgi-bin\test.pl line 4.
> BEGIN failed--compilation aborted at
> C:\export\pneumaticvalves\cgi-bin\test.pl line 4.
> 
> --------------------------------------
> If I comment out the 'use strict ;' line I get:
> 
> Banana Exists
> 
> 5.00307
> 
> C:\PERL5\lib\i386-win32
> C:\PERL5\lib
> .
> 
> Is it me or them?
> Please advise.

It's them. strict.pm has been a standard part of Perl for some
considerable time. If it's not in the @INC path then someone has
massively screwed up your Perl installation.

Dave...


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

Date: Thu, 17 Jun 1999 01:07:23 GMT
From: u970130@studbo.hit.no (Thomas Weholt)
Subject: A buggy intersection-method
Message-Id: <37684848.4807699@news1.c2i.net>

Hi,

I wrote earlier about how to create an intersection of several lists.
Well, it sorta works but ... not as I planned.

Here`s the code :

 my (@array1, @array2, @array3, @array4, @array5, @array6, @array7,
@array8, @array9, @array10, @array11, @array12, @array13, @array14);

        if (defined($ARGV[0])) {@array1 = getEntries(lc($ARGV[0])); }
        if (defined($ARGV[1])) {@array2 = getEntries(lc($ARGV[1])); }
        if (defined($ARGV[2])) {@array3 = getEntries(lc($ARGV[2])); }
        if (defined($ARGV[3])) {@array4 = getEntries(lc($ARGV[3])); }
        if (defined($ARGV[4])) {@array5 = getEntries(lc($ARGV[4])); }
        if (defined($ARGV[5])) {@array6 = getEntries(lc($ARGV[5])); }
        if (defined($ARGV[6])) {@array7 = getEntries(lc($ARGV[6])); }
        if (defined($ARGV[7])) {@array8 = getEntries(lc($ARGV[7])); }
        if (defined($ARGV[8])) {@array9 = getEntries(lc($ARGV[8])); }
        if (defined($ARGV[9])) {@array10 = getEntries(lc($ARGV[9])); }
        if (defined($ARGV[10])) {@array11 = getEntries(lc($ARGV[10]));
}
        if (defined($ARGV[11])) {@array12 = getEntries(lc($ARGV[11]));
}
        if (defined($ARGV[12])) {@array13 = getEntries(lc($ARGV[12]));
}
        if (defined($ARGV[13])) {@array14 = getEntries(lc($ARGV[13]));
}
        if (defined($ARGV[14])) {@array15 = getEntries(lc($ARGV[14]));
}
        
        my @lol = ();

        if (defined(@array1)) { push(@lol, \@array1); }
        if (defined(@array2)) { push(@lol, \@array2); }
        if (defined(@array3)) { push(@lol, \@array3); }
        if (defined(@array4)) { push(@lol, \@array4); }
        if (defined(@array5)) { push(@lol, \@array5); }
        if (defined(@array6)) { push(@lol, \@array6); }
        if (defined(@array7)) { push(@lol, \@array7); }
        if (defined(@array8)) { push(@lol, \@array8); }
        if (defined(@array9)) { push(@lol, \@array9); }
        if (defined(@array10)) { push(@lol, \@array10); }
        if (defined(@array11)) { push(@lol, \@array11); }
        if (defined(@array12)) { push(@lol, \@array12); }
        if (defined(@array13)) { push(@lol, \@array13); }
        if (defined(@array14)) { push(@lol, \@array14); }
        
        my %count = ();
        
        foreach my $array (@lol){
           foreach (@$array) { $count{$_}++ }
        }
        
        foreach (keys %count) {
           push(@words_to_lookup, $_) if $count{$_} == @lol;
        }

The keywords are give as parameters to the script at the command-line.
Each word is looked up with the getEntries-function in a hash-table
containing words and a list of locations where these words appear in
another hash.

The problem is that if I say

bash#:seachscript perl tar

the result is a listing of hits containing perl, some other lines, but
not lines containing tar, like
/somedir/perl/perl.txt
/somedir/perl/readme

If I do 

bash#:searchscript perl tar gz

The result is lines with perl, tar and gz, not just the lines that
contain all these words, like
/somedir/perl/perl.tar
/somedir/perl/perl.gz


Is the above included code faulty or is the bug somewhere else, in a
another script?

Thomas Weholt


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

Date: 18 Jun 1999 03:53:30 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: A buggy intersection-method
Message-Id: <x7674maqrp.fsf@home.sysarch.com>

>>>>> "TW" == Thomas Weholt <u970130@studbo.hit.no> writes:

  TW> Hi,
  TW> I wrote earlier about how to create an intersection of several lists.
  TW> Well, it sorta works but ... not as I planned.

  TW> Here`s the code :

  TW>  my (@array1, @array2, @array3, @array4, @array5, @array6, @array7,
  TW> @array8, @array9, @array10, @array11, @array12, @array13, @array14);

  TW>         if (defined($ARGV[0])) {@array1 = getEntries(lc($ARGV[0])); }
  TW> }
  TW>         if (defined($ARGV[14])) {@array15 = getEntries(lc($ARGV[14]));
  TW> }
        
  TW>         my @lol = ();

  TW>         if (defined(@array1)) { push(@lol, \@array1); }
  TW>         if (defined(@array14)) { push(@lol, \@array14); }

<lots o'snippin'>

uuuuggggllyyy!!!!

why do all that typing?

	@lol = map [getEntries( lc $_ ) ] @ARGV ;


  TW> The keywords are give as parameters to the script at the command-line.
  TW> Each word is looked up with the getEntries-function in a hash-table
  TW> containing words and a list of locations where these words appear in
  TW> another hash.

maybe the getEntries function is buggy? we can't tell since you didn't
post the code for it. 

uri

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


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

Date: Fri, 18 Jun 1999 07:32:48 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: a thread on threads
Message-Id: <376aef31.901978@news.skynet.be>

Ronald J Kimball wrote:

>P.S.  The new Deja site sucks for using the newsgroup archives.

I definitely agree. Yesterday, I went hunting for some old post with
benchmarks. I gave up. Having to loadi over 50k for each and every
article is total and utter nonsense. Slow as mail.

p.s. Funny thing is that THIS rant will appear in their archives. :-)

	Bart.


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

Date: 18 Jun 1999 03:48:02 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: a thread on threads
Message-Id: <x7909iar0t.fsf@home.sysarch.com>

>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:

  BL> Ronald J Kimball wrote:
  >> P.S.  The new Deja site sucks for using the newsgroup archives.

  BL> I definitely agree. Yesterday, I went hunting for some old post with
  BL> benchmarks. I gave up. Having to loadi over 50k for each and every
  BL> article is total and utter nonsense. Slow as mail.

  BL> p.s. Funny thing is that THIS rant will appear in their archives. :-)

what about the other new archives? i see one called remarq and abigail
seems to be posting from another. any good for searches? no reason to be
loyal to deja. i never care about anything there but searches.

uri

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


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

Date: Thu, 17 Jun 1999 21:51:51 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <nn8ck7.clk.ln@magna.metronet.com>

finsol@ts.co.nz wrote:

: For more Y2K problems 

: http://www.idg.co.nz/WWWfeat/Y2000/ja190499.htm
                                           ^^
                                           ^^ ??

   <shrug>

   Anxiously awaiting the ja0101100.htm article...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 18 Jun 1999 03:23:45 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Afraid to ask about Y2K!
Message-Id: <x7bteeas59.fsf@home.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@metronet.com> writes:

  TM> finsol@ts.co.nz wrote:
  TM> : For more Y2K problems 

  TM> : http://www.idg.co.nz/WWWfeat/Y2000/ja190499.htm
  TM>                                            ^^
  TM>                                            ^^ ??

  TM>    <shrug>

  TM>    Anxiously awaiting the ja0101100.htm article...

hoisted by her own petard. how sweet it is!!

uri

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


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

Date: Fri, 18 Jun 1999 00:26:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <MPG.11d3947fb1ea4f7d989bf7@nntp.hpl.hp.com>

In article <376a4a73.702051@news.skynet.be> on Thu, 17 Jun 1999 19:20:36 
GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Eric The Read wrote:
> 
> >But I think we'd better end this thread; it's making me Zeno-phobic.
> 
> It also lacks Perl content. ;-)

Here's Perl content:

printf '%.2d:%.2d:%.2d %s' =>
	    ($hour + 11) % 12 + 1, $min, $sec, $hour < 12 ? 'AM' : 'PM'
    if $format eq 'r'; 

Anything other than that (specifically, to make a special case for 
00:00:00 or 12:00:00) is madness.

Midnight is 12:00:00 AM, noon is 12:00:00 PM.  Period.

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


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

Date: 18 Jun 1999 09:30:55 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Afraid to ask about Y2K!
Message-Id: <376a03bf@newsread3.dircon.co.uk>

J. Moreno <planb@newsreaders.com> wrote:
> 
> Find a Y2K problem in code by Tom P, Jonathan, Larry, Abigail, Tad, David, Uri
> or Tom C and you'll convince *me* that it's something I need to give some extra
> consideration.
> 

<quickly greps any snippets of code that she might be able to look at :>

/J\
-- 
"You're blowing me off for a monkey?" - Joey, Friends


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

Date: Thu, 17 Jun 1999 21:43:34 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: CGI Simple Question
Message-Id: <688ck7.clk.ln@magna.metronet.com>

CacheBoy (chongsun@krdl.org.sg) wrote:

: How to open another web page in my perl script?


   use LWP::Simple;

: if ($in{'option'} eq 'open') {
:   ??? open another html document.

   $html = get $in{URL};

: }



--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 18 Jun 1999 01:16:59 -0700
From: davidk <davidk@netscape.com>
To: plb@concentric.net
Subject: Re: Formatting Unix file permissions eg., 755 -> rwxr-xr-x
Message-Id: <376A007B.9FF9EAB0@netscape.com>

check out chmod.pm and lsMode.pm on CPAN

plb@concentric.net wrote:

> I'm looking for a pointer to an algorithm that takes the
> octal unix file permissions (like 0755) and converts them
> to the symbolic output as used by 'ls -l' such as rwxr-xr-x.
> I've run across this once before, but can't seem to locate it now.
>
> Thanks in advance,
>
> --PLB
>
> --
> "Why oh why didn't I take the blue pill..."



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

Date: Thu, 17 Jun 1999 21:42:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with unlink
Message-Id: <168ck7.clk.ln@magna.metronet.com>

Jim (syt@email*@sp\am|@|spa/m@*.com) wrote:

: unlink just doesnt want to work in my perl script... any ideas why?

: here's what I'm using
: unlink("/home/a-e/bigboy/public_html/cgi-bin/scripts/greetcard1/cards/142.ht
: ml")
: || die $!;

: It says file not found but I'm 100% sure it's there.. 


   Yet you could still be wrong.

   What did you do to make yourself 100% sure?

   Try putting the full path into a variable, then print the
   path in your diagnostic message.

      my $filepath = '/home/a-e/bigboy/public_html/cgi-bin/'
                   . 'scripts/greetcard1/cards/142.html';

      unlink $filepath or die "'$filepath' $!";


   Does the below work?

      print "$filepath exists\n" if -e $filepath;


: I've tried using the
: following short syntax below too

: unlink("cards/142.html") || die $!;

: that corellates to the location of the file in relation to the script.


   Where the file is in relation to the script doesn't have anything
   to do with anything.

   Where the file is in relation to the current directory is
   what matters.


   But that can't be your real problem, since it doesn't work
   with the absolute path either.


: I've also tried chmodding it, but that shouldn't matter from what I
: understand.


   Not if you are getting "file not found".

   Permissions _do_ matter if you get "permission denied".


: Thanks for any help because i'm at my wit's end.. I'm suprised at how little
: information I found about the unlink command.


   Because file system operations are highly dependent on
   the Operating System.

   Try looking for info about deleting files for the OS (and/or
   the web server) that you are using instead of in Perl docs.

   Good luck!


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 18 Jun 1999 09:18:46 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Is Perl4 Y2K compliant?
Message-Id: <376A00E6.92B526FF@dave.org.uk>



"Daniel W. Burke" wrote:
> 
> Hopefully I can wade through all these messages to see the response...
> but, can perl4 be considered "Y2K Compliant"?  I imagine so, but we have
> an aweful lot of scripts at work that run off perl4/oraperl...
> I don't think anyone else has thought to ask at work wether or not we should
> take the time to make sure all the scripts work with perl 5, and just update
> the darn things, but I figured better I better ask :)

"There are no plans to make Perl 4 Y2K compliant."

hth,

Dave...


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

Date: Fri, 18 Jun 1999 15:54:49 +0800
From: "Lawrence Ng" <engp8518@nus.edu.sg>
Subject: Launch a New Browser Window
Message-Id: <7kcu0c$ji5$1@nuscc.nus.edu.sg>

How do I launch a new browser window on the client side to show him another
web page using PERL. I still want my homepage to be open.

Thanks

Lawrence




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

Date: Thu, 17 Jun 1999 23:31:23 -0800
From: glchy <glchy@cc21.com.sg>
Subject: Locking of simple text file or database
Message-Id: <929691084.16563@www.remarq.com>

Hi,
im trying to lock a simple text file (temporarily serving as
a database) but cant seem to get it to work. The file
contains some text and im trying to get only one process
to access/manipulate it.
OS: sun solaris 2.6, Perl 5.004.

$a='aaa';
$file="./x";
open(NUMBER,"$file") || die $!;
flock(NUMBER,2);
seek(NUMBER, 0, 2);
@num=<NUMBER>;
print "@num\n";

open(ALPHA, ">>$file") || die $!;
print ALPHA " $a";
close(ALPHA);

flock(NUMBER,8);
close(NUMBER);


However when running the script, nothing is displayed and $a
is appended to $file! I would expect content of $file to be
displayed and nothing appended to it.

More importantly how do i lock an Oracle 8 DB column?

Thanks

glchy.



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: Fri, 18 Jun 1999 02:44:08 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: newbie
Message-Id: <B38F62F89668692C2F@0.0.0.0>

In article <7kcf3d$6fr$1@nnrp1.deja.com>,
jvavatara@my-deja.com wrote:

>Is java overtaking perl?

Dear alt.rec.pets.cats:

Is it true that cats are nasty little beasts, and I should get a dog
instead?

Lee




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

Date: Fri, 18 Jun 1999 07:52:52 GMT
From: jbritain@home.com (Jim Britain)
Subject: Re: newbie
Message-Id: <3769f74d.53947762@news>

On Fri, 18 Jun 1999 03:40:30 GMT, jvavatara@my-deja.com wrote:

>I'm curious, I am just getting into web programming.  I'm a vb
>programmer by trade so I was going to approach the things by learning
>asp, javascript, and vbscript (html is a given).

That would work if you stick to a server (MicroSoft) that is losing
marketshare.

I believe MicroSoft web server installations has lost 0.5%/month over
the last 3 months, if I remember correctly, where Apache is gaining
1.5%/month over the same period.

>Is javascript easy to implement on the client for both browsers?

Not to difficult, but you have to write seperate scripts for both
browsers.

>Do I need to know any C or Perl??

Perl is the most versatile for writing server scripts.

C and C++ are only necessary if you need to write highly optimized
code, or systems code.  But, it is a real money language that will be
around for a long, long time, for serious applications.

>Is java overtaking perl?

No, Perl use is increasing, and Java use is decreasing, with Perl
being the 5 or 6 to one preferred language on the server (might be
even more than that) (on the internet, at least).

Java/Javascript is used mostly in tightly controlled intranets, where
there is control over the browsers used. And tight control over the
applications.




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

Date: Fri, 18 Jun 1999 10:04:45 +0200
From: Janning Vygen <janning@vygen.de>
Subject: Re: OO-Trap! I am confused
Message-Id: <3769FD9D.3EF296C5@vygen.de>

shouldn4t that be documented in the camel book. 
The my %fields=(); solution is not a very good idea, so it shouldnt be
used.
I just copied and varied it and so never thought that the error could be
nested in the objects model.

But thats the bad habit of ALL Computer Books. They present always easy
and small solutions and dont show how to build complex and robust
structures.

greetings, janning

Abigail wrote:
> 
between objects; there's no copy-on-write.
> 
> What you need to do is:
>    sub new {
>      my $class = shift;
>      my $self = {
>         cards => [],
>         coins => [],
>      };
>      return bless $self, $class;
>    }
> 
> such that all instances of the objects get their own copy of the anon arrays.


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

Date: Fri, 18 Jun 1999 10:44:07 +0300
From: "Sefi Kraemer" <skraemer@iil.intel.com>
Subject: parsing a compressed file
Message-Id: <7kctcg$ni8@news.or.intel.com>

Hi,

I am parsing compressed text files (gzip).

First I uncompress the file, then I parse it, then I compress the original
back.
This is very wasteful.

Is there a way to parse compressed (gzip'ed) files, in the same manner the
GNU function 'gzgrep' does it ?

Much obliged,

Sefi.





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

Date: Fri, 18 Jun 1999 08:23:34 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: parsing a compressed file
Message-Id: <ebohlmanFDIKnB.Ipw@netcom.com>

Sefi Kraemer (skraemer@iil.intel.com) wrote:
: I am parsing compressed text files (gzip).
: 
: First I uncompress the file, then I parse it, then I compress the original
: back.
: This is very wasteful.
: 
: Is there a way to parse compressed (gzip'ed) files, in the same manner the
: GNU function 'gzgrep' does it ?

Get the module Compress::Zlib and read the documentation for it.



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

Date: Fri, 18 Jun 1999 10:42:02 +0200
From: "moi" <toxid@rdtest.mm.atos-group.com>
Subject: Perl scripts slows down servers?
Message-Id: <824F4EA25713D311B1740000D11A1E05459A78@grp-nt1.segin.com>

that's the question...

Response:
toxid@rdtest.mm.atos-group.com
or killer@rdtest.mm.atos-group.com







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

Date: Thu, 17 Jun 1999 22:00:46 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simple Questions
Message-Id: <e89ck7.clk.ln@magna.metronet.com>

rt_daemon@yahoo.com wrote:

: Subject: Simple Questions

   Please put the subject in your Subject:


: 1. Is there a way to prevent the script being executed twice when
: someone's double click on the submit that makes the cgi script to write
: into a file.


   This is the Perl newsgroup.

   You should ask Perl questions here.

   "clicking on submit" sounds like a WWW type thing.

   There are newsgroups for discussing WWW type things:


      comp.infosystems.www.advocacy
      comp.infosystems.www.announce
      comp.infosystems.www.authoring.cgi
      comp.infosystems.www.authoring.html
      comp.infosystems.www.authoring.images
      comp.infosystems.www.authoring.misc
      comp.infosystems.www.authoring.site-design
      comp.infosystems.www.authoring.stylesheets
      comp.infosystems.www.authoring.tools
      comp.infosystems.www.browsers.mac
      comp.infosystems.www.browsers.misc
      comp.infosystems.www.browsers.ms-windows
      comp.infosystems.www.browsers.x
      comp.infosystems.www.misc
      comp.infosystems.www.servers.mac
      comp.infosystems.www.servers.misc
      comp.infosystems.www.servers.ms-windows
      comp.infosystems.www.servers.unix


: 2. How to take 3-4 lines from a certain file and then write it into
: another with a Perl Script ?


   I think you need to check the standard documentation that
   comes with the perl distribution.

      perldoc -f open
      perldoc -f print


: I really need help !!


   We can see that  :-)


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 17 Jun 1999 21:47:27 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: sorting an array from 2nd element onwards
Message-Id: <ff8ck7.clk.ln@magna.metronet.com>

JQ (pigs_can_fly@mindless.com) wrote:

: Is it possible to sort an array alphabetically only from the 2nd
: element onwards?

   Yes.

   Perl FAQ, part 4:

      "How do I sort an array by (anything)?"

   which contains this:

      "If you need to sort on several fields, the following 
       paradigm is useful."


: I know I could extract the first element (MONKEY) from the array, sort
: the array, then put MONKEY back in using "unshift", but is there a
: shorter and more efficient way to do this?


   What part of the FAQ about sorting are you having trouble with?


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 18 Jun 1999 08:04:13 GMT
From: jbritain@home.com (Jim Britain)
Subject: Re: sorting an array from 2nd element onwards
Message-Id: <376afcab.55321768@news>

[posted and mailed]
On Fri, 18 Jun 1999 06:05:24 GMT, pigs_can_fly@mindless.com (JQ)
wrote:

>Hi
>
>Is it possible to sort an array alphabetically only from the 2nd
>element onwards?

>I know I could extract the first element (MONKEY) from the array, sort
>the array, then put MONKEY back in using "unshift", but is there a
>shorter and more efficient way to do this?

The method you've already thought of makes the most sense, and is easy
to read, and write.  You'd have to copy out a slice in any case, and
then precede it with the first element.

Sounds like you're taking off a "field name" from a database file, and
then replacing it..




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

Date: Fri, 18 Jun 1999 15:07:03 +0800
From: bennycc@pacific.net.sg
Subject: split a string character by character
Message-Id: <3769F017.91808FAA@pacific.net.sg>

How can i split a string character by character into an array?

#my string...
$data = "foo bar.com";

#I require it inside an array
@data=('f','o','o',' ',b','a','r','.','c','o','m');

#using the split function? How?

Benny
bennycc@pacific.net.sg



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

Date: Fri, 18 Jun 1999 07:11:17 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: split a string character by character
Message-Id: <pima3.944$36.37756@news2.rdc1.on.home.com>

In article <3769F017.91808FAA@pacific.net.sg>,
 bennycc@pacific.net.sg <bennycc@pacific.net.sg> wrote:
! How can i split a string character by character into an array?
! 
! #my string...
! $data = "foo bar.com";
! 
! #I require it inside an array
! @data=('f','o','o',' ',b','a','r','.','c','o','m');
! 
! #using the split function? How?

read the documentation on the split function ...

perldoc -f split
    [snip]
    A pattern matching the null string (not to be confused with a null
    pattern C<//>, which is just one member of the set of patterns
    matching a null string) will split the value of EXPR into separate
    characters at each point it matches that way.  For example:

        print join(':', split(/ */, 'hi there'));

    produces the output 'h:i:t:h:e:r:e'.

regards
andrew


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

Date: Fri, 18 Jun 1999 09:27:54 +0200
From: "Fred Ruffet" <fruffet@kaptech.com>
Subject: Re: split a string character by character
Message-Id: <7kcse7$s2c$1@gatekeeper.ornano.kapt.com>

my answer doesn't give the chars but their ascii codes... I don't have my
camel book to retrieve all the unpack codes.

$data="foo bar.com";
@list=unpack("c*",$data);
foreach $car (@list) {
    print chr($car),"\n";
}


Fridiric Ruffet - fruffet@kaptech.com
"Rest is silence" - W. Shakespeare





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

Date: Fri, 18 Jun 1999 09:10:46 +0100
From: James Stewart <james@britlinks.co.uk>
Subject: sprintf and money
Message-Id: <ant180846345Lh==@ch0128.charis.co.uk>

Hi,

Can anyone point me to a place where I can find out how to zero pad
numerical values so they always have two zeros after the decimal point?

cheers. James.

-- 
James Stewart     - james@britlinks.co.uk      | "Telecom ignored us and 
The Britlinks     - http://www.britlinks.co.uk | democracy has died."
Phantom Tollbooth - http://www.tollbooth.org   |       -- Fat And Frantic

Sixpence None The Richer in the UK - http://www.britlinks.co.uk/sixpence/



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

Date: Fri, 18 Jun 1999 08:27:53 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: sprintf and money
Message-Id: <ebohlmanFDIKuI.Iw5@netcom.com>

James Stewart (james@britlinks.co.uk) wrote:
: Can anyone point me to a place where I can find out how to zero pad
: numerical values so they always have two zeros after the decimal point?

perldoc -f printf
perldoc -f sprintf



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

Date: Fri, 18 Jun 1999 10:41:42 +0200
From: "moi" <toxid@rdtest.mm.atos-group.com>
Subject: Using cgi or servlets, now?
Message-Id: <824F4EA25713D311B1740000D11A1E05459A6C@grp-nt1.segin.com>

that's the question...



Response:
toxid@rdtest.mm.atos-group.com
or killer@rdtest.mm.atos-group.com







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

Date: Thu, 17 Jun 1999 21:31:39 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Using perl to run system commands
Message-Id: <rh7ck7.clk.ln@magna.metronet.com>

R.Joseph (streaking_pyro@my-deja.com) wrote:
: I would like to use a Perl script to run the command "htpasswd."
: However, I want to do this using CGI because my web server does not
: allow Telnet.  Because htpasswd prompts you for a password twice after
: running it, would this script be possible to be used over a CGI-type
: interface, or am I totally delusional?  


   No, but you are totally silly for not looking in the docs that
   came with your perl.


      grep '^=.*password' perlfaq*.pod

perlfaq8.pod:=head2 How do I ask the user for a password?
perlfaq8.pod:=head2 How do I decode encrypted password files?
perlfaq8.pod:=head2 How do I modify the shadow password file on a Unix system?
perlfaq9.pod:=head2 How do I put a password on my web pages?


   The Expect module may also help you with that.


: Thanks in advance!!

   Uh huh.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

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

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