[10580] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4172 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 7 08:07:22 1998

Date: Sat, 7 Nov 98 05:00:36 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 7 Nov 1998     Volume: 8 Number: 4172

Today's topics:
    Re: #!/usr/local/bin/perl   USE in Win95??? <ours@casema.net>
    Re: And Or Comparisons <bill@sterzenbach.com>
    Re: CGI and Server Loads (Leslie Mikesell)
    Re: Comparative modularization (was: Not to start a lan <bear@sonic.net>
        Compilation error in /cgi-bin/feedback.cgi cyrnos@my-dejanews.com
    Re: CPAN mirrors using rsync? <jhi@alpha.hut.fi>
    Re: Form Information (Tore Aursand)
    Re: How do you delete files in a directory? <jerryp.usenet@connected.demon.co.uk>
        Making debugging methods work in a CGI environment <aravind@genome.wi.mit.edu>
    Re: Not to start a language war but.. <zenin@bawdycaste.org>
    Re: Perl at Webjump - lonely perler! <jerryp.usenet@connected.demon.co.uk>
        Perl Warning Message? (Abdul Ali)
    Re: Processing form (Tore Aursand)
        SEEK function on NT <mjd@sgi.net>
    Re: SEEK function on NT <rootbeer@teleport.com>
    Re: SEEK function on NT <zenin@bawdycaste.org>
    Re: SEEK function on NT <mjd@sgi.net>
    Re: Shared CGI.pm from various directories <mjd@sgi.net>
    Re: Shared CGI.pm from various directories <marks@webleicester.co.uk>
    Re: Split Variables? <r28629@email.sps.mot.com>
        Trouble compiling 5.005.50 with threads <sfoley@cisco.com>
    Re: Trouble compiling 5.005.50 with threads <jhi@alpha.hut.fi>
        Why single iterator over each hash? <stutzman@usa.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 7 Nov 1998 09:32:31 +0100
From: "Casema" <ours@casema.net>
Subject: Re: #!/usr/local/bin/perl   USE in Win95???
Message-Id: <7210kv$fve$1@sun4000.casema.net>

If You're on a Netsscape Enterprise server, you can skip the whole line.
Just make sure your .pl get's saved in a directory that the CGISHL mapping
(in Netscape) points to it.

Michel




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

Date: Sat, 7 Nov 1998 00:17:36 -0500
From: "Billsterz" <bill@sterzenbach.com>
Subject: Re: And Or Comparisons
Message-Id: <720i0s$28s$1@nntp.erinet.com>

Good advice.

Thanks a lot. It fixed me up!




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

Date: 6 Nov 1998 23:04:57 -0600
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: CGI and Server Loads
Message-Id: <720kdp$30m$1@Mars.mcs.net>

In article <71v14n$2qf$1@nnrp1.dejanews.com>,  <gabriel@communitech.net> wrote:
>Does anyone have any experience with the effect of mod_perl
>on the server loads, especially if the server is handling quite
>alot of CGI processes?

Yes.

>Our server loads are significant and it appears that mod_perl
>is the answer.  Theoretically, it should help with the load
>averages.  Can anyone speak for it in practice?
>
>Does mod_perl make CGI run more efficiently and reduce the
>server load averages?

Yes you can get about a 10x boost pretty easily.  The tradeoff
is that the httpd processes consume much more memory and you
may have lots of them busy delivering images to slow clients.
If you don't have lots of memory you may need to work around
this problem with a front-end proxy that consumes less memory
or runs on another machine.

  Les Mikesell
    les@mcs.com


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

Date: Fri, 06 Nov 1998 21:40:52 -0800
From: Ray Dillinger <bear@sonic.net>
Subject: Re: Comparative modularization (was: Not to start a language war but..)
Message-Id: <3643DD64.6B06@sonic.net>

Darren Bane wrote:
> 
> Darrin Edwards wrote:
> 
> [snipped]
> 
> The rules aren't that difficult.
> 
> > "What an impertinent thing to say!" exclaimed Aunt Selma.
> 
> Adjective.  It refers to thing (a noun).
> 
> > Turning to Marge, Aunt Patty intoned coldly, "That child of yours
> > always speaks so impertinently."
> 
> Adverb.  How the child speaks.  Refers to speaks (a verb).  Actually, I
> was taught in school that adverbs always end in ly, and haven't seen a
> counterexample yet.
 
You are a silly person.  (Silly, an adjective, ends in "ly") 

You always used adverbs that didn't end with "ly".
(always, an adverb, does not.  Note that you used it yourself above.)

			Ray 

---
The English have no respect for their language, 
and will not teach their children to speak it.
                -- George Bernard Shaw


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

Date: Sat, 07 Nov 1998 05:00:53 GMT
From: cyrnos@my-dejanews.com
Subject: Compilation error in /cgi-bin/feedback.cgi
Message-Id: <720k65$ebi$1@nnrp1.dejanews.com>

My perl script was created and run free of error with "Perl Builder".
Since it's my first i guess i missed something on the server side even though
the permission are set to:  r w x     r - x      r - x and i uploaded using
ASCII format. Can somebody help?
I try with 2 different servers/cgi-bin directories and in the first one i get
this error message:

Compilation error in /cgi-bin/feedback.cgi

failed to open log file
fopen: Permission denied

On the other server i get this messages:
Compilation error in /cgi-bin/feedback.cgi
Thx

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


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

Date: 07 Nov 1998 14:06:02 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: CPAN mirrors using rsync?
Message-Id: <oee67crr9lh.fsf@alpha.hut.fi>


Derek Sherlock <derek_sherlock@hp.com> writes:

> Hi folks,
> 
> Is there a list anywhere of CPAN mirrors that support the rsync
> protocol?  Or does anybody know of any in North America?

Well, I don't know of mirrors but will the CPAN master site,
ftp.funet.fi::CPAN, do?

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Sat, 07 Nov 1998 12:07:39 GMT
From: tore@forumnett.no (Tore Aursand)
Subject: Re: Form Information
Message-Id: <364637df.243446908@news.online.no>

On Fri, 6 Nov 1998 10:39:27 -0600, "Aamir Hanif"
<ahanif@eastbridgetech.com> wrote:
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);

Cheeeeze.  You should get the CGI.pm module as soon as possible.
Take a look at the CGI area at http://www.perl.com/


-- 
Tore Aursand
ForumNett Online AS
http://www.forumnett.no/


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

Date: Sat, 7 Nov 1998 10:37:46 +0000
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Re: How do you delete files in a directory?
Message-Id: <CAW$VSA6LCR2Ewou@connected.demon.co.uk>

In <comp.lang.perl.misc> 
Tom Christiansen <tchrist@mox.perl.com>, writes:
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc, 
>    Dariush <dazimi@oradev.csis.csd.metrotor.on.ca> writes:
>:How can I delete a file in a directory.
>
>% man perlfunc | gnugrep -C -i delete
>
>--tom
       replies to Ma*Tr**h Mime? 

You need to do some work on that killfile. :-)  
-- Jerry Pank                             http://www.netconnected.com/
                                        jerryp.usenet@netconnected.com

We already have a zillion miminalistic languages.  CS departments are
full of 'em.  Sometimes you have to go around stomping the little
beggars just to keep their population in check.
  (Larry Wall in <71npil$lo4@kiev.wall.org>)



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

Date: Fri, 06 Nov 1998 14:40:51 -0500
From: Aravind Subramanian <aravind@genome.wi.mit.edu>
Subject: Making debugging methods work in a CGI environment
Message-Id: <364350C3.FB5307EF@genome.wi.mit.edu>

I have scripts and modules that print out nicely formatted debugging
information (for example, contents of complex data structures viewed
with Data::Dumper) when a global $Debug variable is set to 1. Now I'm
beginning to use these scripts and modules from CGI programs where my
'nice formatting' is thrown off as its not in HTML. Its easy to apply a
filter (when run in a HTML context) to change the text formatting to
HTML. The problem however, is to have something that *intercepts* all
output to the browser and pipes it through the filter. Any suggestions?

Put another way, output to stdout becomes output to browser after piping
through a HTML conversion filter.

Just to be clear - I would like to see the debug info in the browser -
*not* in the log file. When run in debug mode, the HTML page would
render with debug info interspersed within the normal components
intended for that page.

Suggestions would be greatly appreciated.

aravind




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

Date: 7 Nov 98 04:44:01 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Not to start a language war but..
Message-Id: <910414036.641270@thrush.omix.com>

Scott <scott@chronis.icgroup.com> wrote:
: On Thu, Nov 05, 1998 at 02:47:51AM +0000, Zenin wrote:
	>snip<
: | 	__WARN__ is in no way depreciated or considered "bad style", neither
: | 	is CORE::.
:
: It's well known that altering CORE:: leads to confusing code.

	Who ever said anything about *altering* CORE::?  I thought
	we were only talking about *using* CORE::, no?

	Altering CORE:: would be like altering java.lang, ya just
	don't do it.

: It can
: be done in a readable fashion with great difficulty, but one often
: wishes the author just didn't call the builtin funcs and used their
: own instead.

	Er, huh?

	>snip<
: | 	## Add full stack traces to warnings:
: | 	use Carp 'cluck';
: | 	$SIG{__WARN__} = sub { cluck @_ };
:
: Wow! tracebacks in perl?!?  that's cool.  

	Hehe.  Tis one of the reasons I almost always call Carp's confess()
	instead of simply die().

	>snip<
: | 	A bare eval{} is equated to:
: | 
: | 	try {
: | 	    code
: | 	} catch (Exception e) {}
:
: cool.  maybe i can write some perl code now that don't croak everytime
: an unusual circumstance comes around.

	Unless of course, you call Carp::croak(). :-)

	Yes, a Carp::croak() function is part of the standard lib. :-)

: | 	Perl is not about syntactic salt as Java and Python are.
:
: I guess we all think different :)  To me, "Use Carp 'cluck';" is about
: as unintuitive a way to say "give me tracebacks when i call warn" as i
: could think of.

	You're right.

	But that's probably because a "use Carp 'cluck'" doensn't give you
	stack tracing warnings, it only imports the function Carp::cluck().

	To make warn() do anything with it requires the setting of a
	$SIG{__WARN__} handler as I showed above, which is quite a bit more
	explicit.

: to me, that's not just salt, it's like mixing vodka
: and mayonaise, or something.  i like the try: except: syntax because
: it's very reflective of what's going in the code (at least to me).

	And to any 5 day old Perl programmer, an 'eval{block}; if ($@){}'
	statement is equally as reflective.

	If the "Purer OO" languages could agree on any of this (Python has
	except: while Java has catch, etc) I might give you more points
	here.  But they don't, so I can't.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Sat, 7 Nov 1998 11:02:51 +0000
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Re: Perl at Webjump - lonely perler!
Message-Id: <pQu1RcAbjCR2Ewtj@connected.demon.co.uk>

In <comp.lang.perl.misc> 
John Porter <jdporter@min.net>, writes:
>The Tinman wrote:
>> print ("<BODY bgcolor=\"#FFE000\" background=\"bg.gif\">\n");
>
>bgcolor AND background, eh?  What's the point?

Colours in HR bars and table frames? 
-- Jerry Pank                             http://www.netconnected.com/
                                        jerryp.usenet@netconnected.com

I guess what I'm saying is that the croak in question is requiring
agreement (in the linguistic sense) that isn't buying us anything.
-- Larry Wall in <199709241628.JAA08908@wall.org>



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

Date: Sat, 07 Nov 1998 11:58:34 GMT
From: aali@ix.netcom.com (Abdul Ali)
Subject: Perl Warning Message?
Message-Id: <364433c6.40902620@nntp.ix.netcom.com>

Hi,

I'm getting the following Perl warning message: "Use of initialized
value at fix_it line xx". The "xx" line is:
$curr = join(/["]/, @FIELDS);.

I didn't see anything in the documentation that explained the warning
sufficiently for me to fix this. When I execute the program with -wc
it says the syntax is ok. Does anyone know why this error occurs and
what the fix is? The program follows.

Thanks,
Abdul

#!/usr/bin/perl5 -w
# Fix TAC PR and Final Response Outputs
#
# Problem: When I extract the PR and Final Response
#          outputs from the Oracle database with an
#          sql source script the output is a long stream
#          of text with embedded \n and \t in unquoted
#          parts of the text and with \\n and \\t in
#          areas of the text between quotes.
#
#          This script fixes these problems by putting
#          in real newlines and removing the tabs when
#          out side of the quotes and substituting a
#          single backslash for a double backslash when
#          inside quotes.
#
# History: Revision	Author		Date
#	    01		Abdul Ali	11/6/98
#
use strict;
my $K=0;
my $J=0;
my $filename="";
my $tempfile="";
my @LINES;
my @FIELDS;
my $curr="";
my $temp="";

($filename) = @ARGV; # Get the file.
$tempfile = "temp.txt"; # Hard code file for now.

open(MYTEMP, ">>$tempfile") || die "Can't open $tempfile file: $!\n";
open(MYFILE, "$filename") || die "Can't open $filename file: $!\n";

@LINES=<MYFILE>;
close(MYFILE);

print ("The number of lines is: ", $#LINES + 1, "\n");
for($K = 0; $K <= $#LINES; $K++)
{
  $curr = $LINES[$K];
  chomp($curr);

  if($curr =~ m/(["].+?["])/)
  {
     print STDOUT "It's a match\n";
    # print STDOUT "$1\n";
     @FIELDS = split (/(["].+?["])/, $curr);
    # print STDOUT "$#FIELDS\n";
     for($J = 0; $J <= $#FIELDS; $J++)
     {
        $temp = $FIELDS[$J];
        #print "$temp\n";
        if($FIELDS[$J] !~ /["]/)
        {
          $FIELDS[$J] =~ s/\\n/\n/g;
          $FIELDS[$J] =~ s/\\t//g;
          $FIELDS[$J] =~ s/\\r//g;
          
        }
        else
        {
          $FIELDS[$J] =~ s#\\\\#\\#g;
          $FIELDS[$J] =~ s#\\\\#\\#g;
        }
     }
      
      $curr = join(/["]/, @FIELDS);
      print MYTEMP "$curr\n";
   }
   else
   {
      $curr =~ s/\\n/\n/g;
      $curr =~ s/\\t//g;
      $curr =~ s/\\r//g;

      print MYTEMP "$curr\n";
   }
}



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

Date: Sat, 07 Nov 1998 12:00:46 GMT
From: tore@forumnett.no (Tore Aursand)
Subject: Re: Processing form
Message-Id: <3644364f.243046292@news.online.no>

On Fri, 6 Nov 1998 11:53:03 GMT, Brent Michalski
<perlguy@technologist.com> wrote:
>> #!/usr/bin/perl
>> use CGI;

> ..ADD THE FOLLOWING LINE:
> $cgi = new CGI;

That's right -- sorry I forgot that one.  So much for my head. :-)


-- 
Tore Aursand
ForumNett Online AS
http://www.forumnett.no/


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

Date: Fri, 6 Nov 1998 23:52:59 -0500
From: "Spider" <mjd@sgi.net>
Subject: SEEK function on NT
Message-Id: <IlQ02.990$BK3.238116@news.sgi.net>

I'm having a devil of a time getting the seek function to work for me. I'm
attempting to open a file and write to the top of the file then close it.
Here is what I'm doing...
#
open(TEXT, "+> ../comment.txt") || die "open: $!";
seek TEXT, 0, 0;
print TEXT <<NEW_TEXT;
$in{'INPUT'}\r\n
NEW_TEXT
close TEXT;
#
This blows away the existing contents of the file.

using open(TEXT, ">> ../comment.txt")
just appends to the end of file

using open(TEXT, "> ../comment.txt")
blows contents away

I've even tried using, to no avail,
binmode TEXT;
before seek.
I've tried seek and binmode in every combination of "" and () also no good.
What am i doing wrong to "seek" ?
I've got it working by using one open statement to read the contents into an
ARRAY and then close the file and open it again for writing, place the new
data and then the ARRAY.

This works but i get a indent in the text file each time...

-Mike




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

Date: Sat, 07 Nov 1998 05:04:12 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: SEEK function on NT
Message-Id: <Pine.GSO.4.02A.9811062102150.20411-100000@user2.teleport.com>

On Fri, 6 Nov 1998, Spider wrote:

> I'm having a devil of a time getting the seek function to work for me.
> I'm attempting to open a file and write to the top of the file then
> close it.

See what the FAQ says about appending to the beginning of a file.

> I've got it working by using one open statement to read the contents
> into an ARRAY and then close the file and open it again for writing,
> place the new data and then the ARRAY.
> 
> This works but i get a indent in the text file each time...

Are you doing something like this by chance? Maybe you don't want the
double quotes. 

    print "@array";		# indented?

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 07 Nov 1998 05:17:51 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: SEEK function on NT
Message-Id: <910415758.843926@thrush.omix.com>

[posted & mailed]

Spider <mjd@sgi.net> wrote:
: I'm having a devil of a time getting the seek function to work for me.

	I think your problem is with open(), not seek().

: I'm
: attempting to open a file and write to the top of the file then close it.

	Hmm, like a "prepend"?  To do this you must manually move all the
	current data "down" to make room for what you want to write.

: Here is what I'm doing...
: open(TEXT, "+> ../comment.txt") || die "open: $!";
              ^^

	+> is shorthand for open(2) with the flags of O_RDWR, O_CREAT,
	and O_TRUNC.

	In english:
	    if the file exists, open for read & write and truncate it
	    if the file does not exist, create it and open for read & write

	Probably not what you want. :-)

: seek TEXT, 0, 0;

	Your file is not 0 bytes long, so this does nothing. :-)

: print TEXT <<NEW_TEXT;
: $in{'INPUT'}\r\n
: NEW_TEXT
: close TEXT;
: #
: This blows away the existing contents of the file.

	Yep.

: using open(TEXT, ">> ../comment.txt")
: just appends to the end of file

	Yep.

: using open(TEXT, "> ../comment.txt")
: blows contents away

	Yep.  It's the same as +> just without read mode.

	>snip<
: What am i doing wrong to "seek" ?

	You're not.  It's open() that has you stumped. :-)

: I've got it working by using one open statement to read the contents into an
: ARRAY and then close the file and open it again for writing, place the new
: data and then the ARRAY.

	This is the easiest way to "prepend" to a file, although not the
	most efficient.

	You could use one sysopen() however, with something like this.  I
	like sysopen() more then open() myself for many uses, as it gives
	me much more direct control of how open(2) is called:

	use Fcntl;
	sysopen (SESAME, "../comment.txt", 0644, O_RDWR|O_CREAT)
	    or die "open(../comment.txt): $!";

	my $data;
	{
	    local $/;
	    $data = <SESAME>
	}
	seek SESAME, 0, 0
	    or die "seek(0, 0): $!";

	print SESAME "$in{'INPUT'}\r\n";
	print SESAME $data;
	close SESAME
	    or die "close(): $!";

	__END__

	No, this isn't the most efficient way, especially with large
	files, but it works and is far simpler.

: This works but i get a indent in the text file each time...

	An indent?  Like a tab?  Or an extra newline?  An extra
	newline is likely from the end of your here-doc
	statement (<<NEW_TEXT).

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Sat, 7 Nov 1998 00:42:42 -0500
From: "Spider" <mjd@sgi.net>
Subject: Re: SEEK function on NT
Message-Id: <j4R02.994$BK3.239494@news.sgi.net>

Here is the complete script. The indent I get is 2 spaces indented like a
tab before the array data so the text file looks like this.
NewData1
  Array data here
Next post will result in:
NewData2
  NewData1
    PreviousData
Then it goes to:
NewData3
  NewData2
    NewData1
      PreviousData
It is being read by an applet that left justifies each line so it still
"looks" ok thereI'd like to know what or where the 2 spaces are coming
from

Thanks for all the help.

-Michael

#!/perl/lib/perl
# parse the input information and retrieve arguments from the form.

require ("cgi-lib.pl") || die "Can't load cgi-lib";
&ReadParse;   #get the form arguments.

$TheDate=localtime(time);

## Make Text File
if($in{D1} eq "Left") {
open(TEXT, "../scroller/leftscroll.txt") || die "open: $!";
@textfile =<TEXT>;
close TEXT;
open(TEXT, "> ../scroller/leftscroll.txt") || die "open: $!";
print TEXT <<NEW_TEXT;
^^pause(1500) $TheDate
$in{'S1'}\r\n
@textfile
NEW_TEXT
close TEXT;
}
else {
open(TEXT, "../scroller/rightscroll.txt") || die "open: $!";
@textfile =<TEXT>;
close TEXT;
open(TEXT, "> ../scroller/rightscroll.txt") || die "open: $!";
print TEXT <<NEW_TEXT;
^^pause(1500) $TheDate
$in{'S1'}\r\n
@textfile
NEW_TEXT
close TEXT;
}

## Respond with Web Page
print "Location: http://www.wewishyou.com/home1.htm\n\n";



Zenin wrote in message <910415758.843926@thrush.omix.com>...
>[posted & mailed]
>
>Spider <mjd@sgi.net> wrote:
>: I'm having a devil of a time getting the seek function to work for me.
>
> I think your problem is with open(), not seek().
>
>: I'm
>: attempting to open a file and write to the top of the file then close it.
>
> Hmm, like a "prepend"?  To do this you must manually move all the
> current data "down" to make room for what you want to write.
>
>: Here is what I'm doing...
>: open(TEXT, "+> ../comment.txt") || die "open: $!";
>              ^^
>
> +> is shorthand for open(2) with the flags of O_RDWR, O_CREAT,
> and O_TRUNC.
>
> In english:
>     if the file exists, open for read & write and truncate it
>     if the file does not exist, create it and open for read & write
>
> Probably not what you want. :-)
>
>: seek TEXT, 0, 0;
>
> Your file is not 0 bytes long, so this does nothing. :-)
>
>: print TEXT <<NEW_TEXT;
>: $in{'INPUT'}\r\n
>: NEW_TEXT
>: close TEXT;
>: #
>: This blows away the existing contents of the file.
>
> Yep.
>
>: using open(TEXT, ">> ../comment.txt")
>: just appends to the end of file
>
> Yep.
>
>: using open(TEXT, "> ../comment.txt")
>: blows contents away
>
> Yep.  It's the same as +> just without read mode.
>
> >snip<
>: What am i doing wrong to "seek" ?
>
> You're not.  It's open() that has you stumped. :-)
>
>: I've got it working by using one open statement to read the contents into
an
>: ARRAY and then close the file and open it again for writing, place the
new
>: data and then the ARRAY.
>
> This is the easiest way to "prepend" to a file, although not the
> most efficient.
>
> You could use one sysopen() however, with something like this.  I
> like sysopen() more then open() myself for many uses, as it gives
> me much more direct control of how open(2) is called:
>
> use Fcntl;
> sysopen (SESAME, "../comment.txt", 0644, O_RDWR|O_CREAT)
>     or die "open(../comment.txt): $!";
>
> my $data;
> {
>     local $/;
>     $data = <SESAME>
> }
> seek SESAME, 0, 0
>     or die "seek(0, 0): $!";
>
> print SESAME "$in{'INPUT'}\r\n";
> print SESAME $data;
> close SESAME
>     or die "close(): $!";
>
> __END__
>
> No, this isn't the most efficient way, especially with large
> files, but it works and is far simpler.
>
>: This works but i get a indent in the text file each time...
>
> An indent?  Like a tab?  Or an extra newline?  An extra
> newline is likely from the end of your here-doc
> statement (<<NEW_TEXT).
>
>--
>-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
>BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
>Berkeley or thereabouts.  Similar in many ways to the prescription-only
>medication called "System V", but infinitely more useful. (Or, at least,
>more fun.)  The full chemical name is "Berkeley Standard Distribution".




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

Date: Sat, 7 Nov 1998 00:16:19 -0500
From: "Spider" <mjd@sgi.net>
Subject: Re: Shared CGI.pm from various directories
Message-Id: <zHQ02.992$BK3.238774@news.sgi.net>

I do this same thing with cgi-lib.pm and have it in the root folder of the
web server for easy access. x:\inetpub\cgi-lib.pm is the location, so in the
scripts i use:

#!/perl5/

require ("/inetpub/cgi-lib.pm") || die "Can't load cgi-lib";
&ReadParse;   #get the form arguments.

Now that i have the newest ActiveState port, i've noticed this path is not
needed?...Maybe Tom knows why/how?

-Michael



bill_mcintyre@my-dejanews.com wrote in message
<71vith$j0m$1@nnrp1.dejanews.com>...
>I know this is probably simple but I have a brain lock on it.
>
>i have quite a few scripts that use the CGI.pm module. To increase security
>and orderliness I have created subdirectories in CGI-BIN to store different
>types of scripts. My problem is that I can't figure out how to call CGI.pm
>from different locations. When I "USE CGI" CGI.pm seems to only work in the
>same directory as the script that is calling it. How can I have just one
copy
>of CGI.pm and call it from differnet scripts in differnet directories.
>
>TIA.
>
>Bill McIntyre (bill_mcintyre@hotmail.com)
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own




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

Date: Sat, 07 Nov 1998 12:51:49 +0000
From: Mark Simonetti <marks@webleicester.co.uk>
Subject: Re: Shared CGI.pm from various directories
Message-Id: <36444265.BB8FB6B5@webleicester.co.uk>

OKAY !!!  I made a mistake.  This method only works when you use require
<package-name>, instead of use.  I just assumed the same would work for
use, which was wrong of me and I appologise.

Mark.
--

Tom Phoenix wrote:

> On Sat, 7 Nov 1998, Mark Simonetti wrote:
>
> > Tom Phoenix wrote:
> >
> > > On Fri, 6 Nov 1998, Mark Simonetti wrote:
> > >
> > > > push(@INC, /somepath/somepath/blah/blah);
> > > > use CGI;
> > >
> > > What happened when you tried this before posting. Ouch!
>
> > okay so I forgot the quotes :p:p
> >
> > push(@INC, 'whatever');
>
> Okay, so you forgot the quotes. What happened _this_ time when you tried
> it before posting? Ouch again!
>
> Hint: 'use' is compile time, 'push' is run time. Hope this helps!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 06 Nov 1998 21:58:10 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Split Variables?
Message-Id: <3643B73D.AD780AF@email.sps.mot.com>

bigcheese@my-dejanews.com wrote:
> 
> I've been looking around for a script or something that splits up a variable
> (in this case taken from a form)
> 
> I need it to take something like
>  "kamura eta"
> and write img srcs for
>  ka,mu,ra, (space), e, and ta
> 

not sure what kind of logic behind, but this worked when I tried:

    push @list, $1 while /(\w[aeiou]| )/g

BTW, this is a lang newsgrp, suitable for those who write program, not looking
for programs.
 
-tk


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

Date: Fri, 06 Nov 1998 23:52:23 -0800
From: Steve Foley <sfoley@cisco.com>
Subject: Trouble compiling 5.005.50 with threads
Message-Id: <3643FC2F.EFB7DC71@cisco.com>

Still looking for help compiling this version with threads enabled.
regcomp.c fails with an error message indicating that it doesn't
recognize the usage of the (global) variable "thr". I can't find it
declared as an extern in any .h file

I find the following declarations in .c files:
deb.c:            (unsigned long) thr,
deb.c:            (unsigned long) thr);
mg.c:                     (unsigned long)thr, (unsigned long)sv);)
op.c:                     (unsigned long) thr, (unsigned long)
PL_curpad,
op.c:                     (unsigned long) thr, (unsigned long)
PL_curpad, po));
op.c:                     (unsigned long) thr, (unsigned long)
PL_curpad, po));
op.c:                     (unsigned long) thr, (unsigned long)
PL_curpad, po));
op.c:                     (unsigned long) thr, (unsigned long)
PL_curpad));
perl.c:    struct perl_thread *thr;

None of this helps regcomp.c though...

Any ideas?

Steve Foley



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

Date: 07 Nov 1998 14:19:03 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Trouble compiling 5.005.50 with threads
Message-Id: <oee3e7vr8zs.fsf@alpha.hut.fi>


Steve Foley <sfoley@cisco.com> writes:

> Still looking for help compiling this version with threads enabled.
> regcomp.c fails with an error message indicating that it doesn't
> recognize the usage of the (global) variable "thr". I can't find it
> declared as an extern in any .h file

(1) Assuming you are determined to play with unstable developer releases
    please do not use 5.005_50 but rather the latest release, 5.005_53.

(2) Please report your problems to the developers, not comp.lang.perl.*
    In the USENET nobody can hear you screaming...your report may well be
    be lost in the noise.

(3) Please read the INSTALL file, it tells you where to report build
    problems.  In this case, you must manually send email to
    perlbug@perl.com.  If you had managed in building perl but then
    the test suite / your programs / some modules had problems with
    this new perl you could have used the 'perlbug' script.

(4) Please include the output of the ./myconfig script because that
    tells details like which operating system, which compiler, and which
    compiler flags are you using.

> regcomp.c fails with an error message indicating that it doesn't
> recognize the usage of the (global) variable "thr". I can't find it

(5) Please include the error message verbatim in your report.

-- 
$jhi++; # http://www.iki.fi/~jhi/
        # There is this special biologist word we use for 'stable'.
        # It is 'dead'. -- Jack Cohen


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

Date: Sat, 07 Nov 1998 00:35:37 -0400
From: Daniel Stutzman <stutzman@usa.net>
Subject: Why single iterator over each hash?
Message-Id: <3643DC29.27ABCB2D@usa.net>

  My current project involves writing numerous HTML files.  Instead of
storing the filenames to write in one large array, I logically separated
them into categories by use of a hash of arrays which I'll call %HoL:

# Copied from the Blue Camel, page 267
%HoL = (
    flintstones => [ "fred", "barney" ],
    jetsons     => [ "george", "jane", "elroy" ],
    simpsons    => [ "homer", "marge", "bart" ],
);  

  So I loop over the %HoL with while and each.  Inside, I loop over over
the nested arrays with foreach, calling a function on each file:
(simplified)

CATEGORY: while (($categoryname, $filelist) = each %HoL) {
    FILE: foreach $file (@$filelist) {
        create_file($file);
    }     
}

  Unfortunately, in subroutine create_file I want to be able to loop
over %HoL yet again (to embed its contents within the file).  However, a
foreach or even while/each will reset the first each iterator, causing
an endless loop -- one category being processed over and over.

Quoted from the Blue Camel, p. 160:
  "There is a single iterator for each hash, shared by all each, keys,
and values function calls in the program.  This means that after a keys
or values call, the next each call will start again from the beginning."

  Question 1:  How can I nest keys or while/each loops of the same hash?

  Question 2:  I'm troubled by the messy interaction between these two
loops.  After all, the main loop and create_file() both work fine
seperately.  But combined, they get in each other's way.
  So what are the advantages for a single iterator for each hash?  Is
this a feature?

--Daniel Stutzman (new to Perl and loving it)


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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