[7528] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1155 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 10 02:07:18 1997

Date: Thu, 9 Oct 97 23:00:24 -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           Thu, 9 Oct 1997     Volume: 8 Number: 1155

Today's topics:
     a newbie speaks:it won't work <jim@ficom.net>
     Re: a newbie speaks:it won't work <bholzman@mail.earthlink.net>
     Re: associative array <rootbeer@teleport.com>
     Re: can Perl do this? (Tad McClellan)
     Re: Can't open blah, blah, blah (Philip)
     Re: Coping with backslashes in Win32 Perl? (Hans Schrader)
     Re: cpan modules and isp <rootbeer@teleport.com>
     Re: CSV Split gives seg fault <rootbeer@teleport.com>
     Re: Emailing information from a Form which includes Lis <bholzman@mail.earthlink.net>
     Error - how do I know what it means and how to correct  (rigs)
     Re: glob in web script <bholzman@mail.earthlink.net>
     Re: How do I skip \, in a split /,/ (Tad McClellan)
     html2text gonzalo@interimagen.com
     Re: IO::Socket on Win32 (Standard bindist04 port) (Philip)
     Re: LLama book script (Philip)
     Re: Need Help Parsing ASCII File  (Jim Michael)
     Re: Need Help Parsing ASCII File (Tad McClellan)
     Oraperl Error... Please help.. <tbanchie@cisco.com>
     Re: Out of memory error? <bholzman@mail.earthlink.net>
     Re: Perl Installation Question <rootbeer@teleport.com>
     Re: Q: how to specify how many decimals a calcultaion s <md4calle@mdstud.chalmers.se>
     Re: Question: File locking (Mike Heins)
     Re: Reading Variable Names from a file (Tad McClellan)
     Seeing if service is alive, Is this a good idea? (Thomas Munn)
     sql in perl <louis@cheerful.com>
     sql on perl <louis@cheerful.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 09 Oct 1997 22:08:37 -0500
From: Jim Hendrix <jim@ficom.net>
Subject: a newbie speaks:it won't work
Message-Id: <343D9C35.7BE01D68@ficom.net>

hello,

can anyone tell me why the following code will not work:

{ # create directory from variable MailName
 mkdir "f:/Netscape/Server/Members/$regvars{'MailName'}",664;
}

I am trying to pull the variable MailName from a registration program to
create a user directory when a new customer signs up. If I run the
script without the variable example:

mkdir "f:/Netscape/Server/Members/directoryname",664;

it works fine. Any help would be greatly appreciated.

Thank You,
James Martin
System Administrator
First Internet Communications, LLC




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

Date: Thu, 09 Oct 1997 23:55:20 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Jim Hendrix <jim@ficom.net>
Subject: Re: a newbie speaks:it won't work
Message-Id: <343DA728.12A4F73B@mail.earthlink.net>

[posted & mailed]

Jim Hendrix wrote:
> 
> hello,
> 
> can anyone tell me why the following code will not work:
> 
> { # create directory from variable MailName
>  mkdir "f:/Netscape/Server/Members/$regvars{'MailName'}",664;
> }

To paraphrase some of the more venerable members of this group:
Even if your script is just an example (and perhaps _especially_ if your
script is an example) you should always check the return values of your
system calls.

> 
> I am trying to pull the variable MailName from a registration program to
> create a user directory when a new customer signs up. If I run the
> script without the variable example:
> 
> mkdir "f:/Netscape/Server/Members/directoryname",664;
> 
> it works fine. Any help would be greatly appreciated.
> 

I would bet that $regvars{'MailName'} is either empty, or perhaps
contains a '/' or '\'; take a look at where you assign to it for
possible syntax/logic errors.  Also, perhaps your mode should be '0664'
and not '664', although perhaps it doesn't matter on Win32. Just so you
know, the typical way to debug behavior like that is:

my $dir = "f:/Netscape/Server/Members/$regvars{'MailName'}";
mkdir $dir,0664 or die "Couldn't mkdir $dir: $!";

This will immediately show you what couldn't be made, and why.  This is
almost always exactly the information you need to solve the problem...
> Thank You,
> James Martin
> System Administrator
> First Internet Communications, LLC
Your welcome,

Benjamin Holzman




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

Date: Thu, 9 Oct 1997 18:12:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Robert <colte@hem.passagen.se>
Subject: Re: associative array
Message-Id: <Pine.GSO.3.96.971009180009.5084J-100000@usertest.teleport.com>

On Thu, 9 Oct 1997, Robert wrote:

> I have all the variables from a form in %input

That would be a web form, right? (Not that it matters for what you're
doing; Perl doesn't care where the data came from. But if you use the
CGI.pm module (or a similar one) you can step through your script with the
Perl debugger, which can be very helpful.)

> I want to replace all occurances of the scandinavian
> characters =E5=E4=F6 with the appropriate html-code.

In the values, not the keys. Right? (It's more complex (and usually
unneeded) to change the keys of a hash.)=20

> @input =3D join("|", %input);

I'm not sure what you want, but that's not it. :-)

> foreach $varde (%input) {

You can't edit a hash (associative array) by stepping through it with a
foreach loop, but you can step through the list of keys instead. (See my
example below.)

> =09 =09$varde =3D~ s/=E5/&aring;/g;
> =09=09$varde =3D~ s/=C5/&Aring;/g;
> =09=09$varde =3D~ s/=E4/&auml;/g;
> =09=09$varde =3D~ s/=C4/&Auml;/g;
> =09=09$varde =3D~ s/=F6/&ouml;/g;
> =09=09$varde =3D~ s/=D6/&Ouml;/g;

Eek, that's a lot of work. Let's make that faster. First, build a map
table, like this.

    %map =3D (
=09'=E5' =3D> 'aring',
=09'=C5' =3D> 'Aring',
=09'=E4' =3D> 'auml',
=09# and so on
    );

Now, one line converts the whole string:

    $varde =3D~ s/([=E5=C5=E4=C4=F6=D6])/$map{$1}/g;

Now, if you need to process every hash element (%map would already be
built) you could use this.

    foreach $key (keys %input) {
=09$input{$key} =3D~ s/([=E5=C5=E4=C4=F6=D6])/&$map{$1};/g;
    }

Having said all that, you may be able to do what you want with one of the
modules on CPAN. Does that get you any closer? Good luck!=20

--=20
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 9 Oct 1997 22:33:35 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: can Perl do this?
Message-Id: <fm7k16.vv.ln@localhost>

Chris Kahrhoff (cck@wwdg.com) wrote:
: I'm am to learn perl in order to write a program that will collect data
: from a syslog of a terminal server and make a report of that data,
: including duration of connection, name of connection, etc.  

: Will perl do this?  

Perl was created to do tasks just like that.


: How would I go about writing this program?  

Start at the beginning, proceed to the middle, and finish at the end ;-)

Learn how to program in Perl, and then write a Perl program that
does what you want.

"Learning Perl", published by O'Reilly (www.ora.com) would be a good 
start, but there are *hundreds* of 'pages' of *free* documentation 
that are included with the perl documentation itself. If you already
know how to program, those may well be enough to get you on your way...


: Does a similar
: program already exist?  

Perhaps.

That is what search engines are for.


: I prefer
: email responses.

I prefer answering in the newsgroup where the question was asked.

Helping thousands of people at once is something I am willing to
volunteer for.

Individual attention is billed at my usual rate ;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Fri, 10 Oct 1997 03:32:52 GMT
From: fil_nospam@login.net (Philip)
Subject: Re: Can't open blah, blah, blah
Message-Id: <343da194.12635518@nntphost.login.net>

On 9 Oct 1997 21:07:41 GMT, "Justin White" <whitek@thegrid.net> wrote:

>Hi,
>
>I'm a beginning CGI Scripter at an ISP and am having problems saving to a
>file.  I have a form that users fill out and submit.  When submitted, I
>told the perl script to send a few form variables ex.($FORM{'$name'}) to a
>couple of email boxes and some variables to a file, delimited by tildes
>(~).  All the mail stuff works fine, but when I try to print to the file on
>the BSDI server, I read in the error log - reason: Premature end of script
>headers.  Please tell me what this means.
It means you should read any good CGI tutorial, and the Perl FAQ and
so on.  Hint : make sure your CGI has write permissions to the file
and use CGI::Carp to get meaningful error messages.

-Philip


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

Date: Fri, 10 Oct 1997 05:03:57 GMT
From: hans.schrader@geol.uib.no (Hans Schrader)
Subject: Re: Coping with backslashes in Win32 Perl?
Message-Id: <61kd0u$e32$1@toralf.uib.no>

In article <343D11F2.4C1E@geocities.com>, Steve Harvey <egodeath@geocities.com> wrote:

This is completely new to me: I am using Perl32 5.00_3 and use "normal" 
Unix type forward slashes in both WinNT and Win95 and they are correctly 
interpreted! 


>I'm writing some maintainance scripts using Win32 Perl for our Netware
>servers, which means I have to dereference all the backslashes when
>referring to directory paths (i.e. I have to use '\\\\fs1\\sys\\foo'
>instead of just '\\fs1\sys\foo')
>
>My problem is with a subroutine which parses a list of pathnames,
>read from a user-maintained text file.  The program chokes if I don't
>dereference the backslashes, and I'd rather not make the
>(perl-illiterate) users have to deal with the ugly syntax.  In other
>words, if the program reads a line from the file:
>
>        \\fs1\sys\foo
>
>and assigns it to $pathname, I'd like to be able to do something like
>
>        $pathname =~ tr/'\'/'\\'/;
>
>in order to end up with the value '\\\\fs1\\sys\\foo' which the rest of
>the program can digest for purposes of evaluation, output, etc...  I
>have tried myriad combinations of weird quotes, but I have been unable
>to get the substitute/translate/etc. operators to recognize the single
>backslash in the original string for what it is.
>
>Suggestions?
>
>
>   Thanks,
>     Steve

Hans Schrader from Bergen in Norway "Web-Eureka"
hansPERIODschraderSPAMbigfootPERIODcom = http://hjs.geol.uib.no/
[PERIOD="."SPAM="@"]  


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

Date: Thu, 9 Oct 1997 17:58:35 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: David Turley <dturley@rocketmail.com>
Subject: Re: cpan modules and isp
Message-Id: <Pine.GSO.3.96.971009175347.5084I-100000@usertest.teleport.com>

On Thu, 9 Oct 1997, David Turley wrote:

> Can anyone give me a hint on how one would use perl modules, that are
> not part of the standard distribution, without direct access to perl on
> the server. 

If you can't install programs on the server, you can't install either
modules or your own scripts. But you can at least install your own Perl
scripts, right? So, you've got at least _some_ access to Perl on the
server. 

> If we are stuck with using an ISP for web hosting, are we out of
> luck since we don't have access to perl's path configuration?

No, because you can normally install your modules into any directory which
is writable by you and readable by the server. Then, near the top of your
scripts, you'll "use lib '/path/to/my/directory'" so that Perl will know
where to look for your nifty modules. 

Look in the docs for MakeMaker to find the LIB option, which should tell
you most of what you need to know to be able to install modules when
you're not the machine's sysadmin (or even when you are :-)  Hope this
helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 9 Oct 1997 18:19:32 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: William York <william@mathworks.com>
Subject: Re: CSV Split gives seg fault
Message-Id: <Pine.GSO.3.96.971009181618.5084L-100000@usertest.teleport.com>

On Thu, 9 Oct 1997, William York wrote:

> The problem is that perl 5.003 produces a seg fault when trying to split
> the string. 

It may be your system, rather than Perl, which is breaking down as you do
this, but there's no easy way to tell. But the thing to do is to install
5.004 and see whether the same problem happens there. Many (many!) bugs
were fixed between 5.003 and 5.004. Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!





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

Date: Fri, 10 Oct 1997 00:05:24 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Gerrard Leach <grleach@achilles.net>
Subject: Re: Emailing information from a Form which includes List Boxes
Message-Id: <343DA984.9206A994@mail.earthlink.net>

[posted & mailed]

Gerrard Leach wrote:
> 
> I am fairly new to CGI scripting, and am trying to create a script that
> emails information from a form to myself.  I have managed to complete

You should follow the advice already given by Faust & Tom.  However, if
you're still curious why your code doesn't do what you think it should,
here's why:

    # find profile/contsupp field names that begin with cs*_
>     if ($name =~ /cs\d_/)
>     {
>       #add the profile/contsupp pair to a list keyed on the name of the
> variable
>       $csarry{$name} = $value;
>     }
>     else
>     {
>        #add the field data pair to a list keyed on the name of the
> variable
>        $contents{$name} = $value;

This doesn't _add_ $value to $contents{$name}.  It _replaces_ the value
of $contents{$name} with $value.  If you want to keep all the $values
around, you probably want to make the value of $contents{$name} an
array.  Or more precisely, a _reference_ to an array.  At this point,
you should read and understand the perlref manpage.  Now, you can do fun
things like:
	push (@{$contents{$name}}, $value);

to add the field data, and
  foreach $value (@{$contents{$name}}) {
	...do stuff with $value...
  }

to iterate over them... ;-)

>     }
>   }
> }
> 
> The List box will fall into the else part of the if statement along with
> other elements if that helps at all.  I think that the name of the list
> box element is going to come in as an array, however being new at this,
> I am not sure how to split the array into different elements.  Any help
> will be appreciated.
> 
> Thanks in Advance
> Gerrard




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

Date: Fri, 10 Oct 1997 04:15:23 GMT
From: rigs@doghouse.com (rigs)
Subject: Error - how do I know what it means and how to correct it?
Message-Id: <343daba0.17780408@news.alt.net>

I have some web pages on the webcene.com server.

The are running NT4 and IIs 3 I believe

When trying to run perl scripts I am getting the following error:
"HTTP/1.0 500 Server Error (A dynamic link library (DLL)
initialization
routine failed.)"

They are trying to fix it, but haven't been successful yet.

I know these perl scripts run, because the run on my PC using,
Personal Web Server,  Website and OmniHTTPd.

If you don't know the answer, do you know someplace I can visit to get
the answer?

Thank you for taking the time to read this.
Dianne


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

Date: Thu, 09 Oct 1997 23:38:44 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Mordkoff@ACM.org
Subject: Re: glob in web script
Message-Id: <343DA344.A0822083@mail.earthlink.net>

[posted & mailed]

Jeremy Mordkoff wrote:
> 
> I have a web script (I guess it's a CGI script) that I just added a glob
> command to. It still works when I run it from the command line, but the
> glob fails (returns no filenames) when my web server runs it for me.
> Everything else works fine. Could this be a permissions problem on my
> web server? MS IIS with the ASP patch running on NT 4.0 w/ SP 3.

Not sure exactly, but since glob'ing on Win32 is done by an external
program, PerlGlob.exe, it's either a permissions problem or a path
problem; most likely the latter.  Perhaps you could try putting
perlglob.exe in the same directory as your cgi script?  Or, you could
avoid globbing altogether and use opendir and then readdir in list
context feeding to a grep.  Like:

opendir(DIR,$my_dir) or die "Couldn't open $my_dir: $!";
@files = grep /$my_pat/, readdir(DIR)
closedir DIR;

> 
> JLM
> 
> reply via email please.
> --
> Anne & Jeremy L. Mordkoff
> http://www.net1plus.com/users/jom




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

Date: Thu, 9 Oct 1997 23:18:12 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How do I skip \, in a split /,/
Message-Id: <4aak16.991.ln@localhost>


Ty Cage Warren (tycage@infi.net) wrote:
: Toutatis wrote:
: >
: > $line = 'xxxx,xx\,xx,xxxx'
: > How do I split this line into three fields, omitting the escaped comma?


With great difficulty ;-)

Seems like there must be a better way, but I include mine below.


: Try

: $line = 'xxxx,xx\,xx,xxxx';
: @fields = split(/[^\\],/,$line);


Well you can try that if you want, but it won't do what he asked for ;-)

I get these three array elements:

xxx
xx\,x
xxxx

(two 'x's went into the bit bucket)


: The /[^\\],/ means match anything that isn't a literal \ followed by a
: comma.

That's true enough, but since it is used in a split(), whatever
matches (including the non-backslash char that matched the char class)
is not included in the returned substrings...


What is needed here is lookbehind.

Perl does not have lookbehind, only lookahead.

So, the usual approach is to reverse the string, and then use lookahead
to get actual lookbehind, then reverse the string again.


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

$_ = 'abcd,lm\,no,wxyz';

# reverse the string, then split it
foreach ( split(/,(?!\\)/,  # split using negative lookahead
                reverse $_  # reverse the original string
               )
        ) {

   # unshift() instead of push() to reverse order of substrings
   #     back to their original order
   # reverse in scalar context to reverse the chars within each substring
   unshift @fields, scalar(reverse $_);
}

foreach (@fields) {print "$_\n"}
-------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Fri, 10 Oct 1997 00:03:02 -0600
From: gonzalo@interimagen.com
Subject: html2text
Message-Id: <876458973.9075@dejanews.com>

Hello guys:

    Do you know how I can discart HTML tags and anly take the text form a
HTML file?. I need open a file just to extract the text.


Thank you.

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


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

Date: Fri, 10 Oct 1997 03:22:43 GMT
From: fil_nospam@login.net (Philip)
Subject: Re: IO::Socket on Win32 (Standard bindist04 port)
Message-Id: <343d9dca.11665478@nntphost.login.net>

On Wed, 08 Oct 1997 13:31:47 GMT, Paul.Moore@uk.origin-it.com (Paul
Moore) wrote:

>I'm trying to get sockets to work on Win32. I'm using the following
>example code from Sriram Srinivasan's excellent book "Advanced Perl
>Programming":

>$sock = new IO::Socket::INET (PeerHost => $ARGV[0],
                               ^^^^^^^^ try PeerAddr

Works for me (Win95)

-Philip



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

Date: Fri, 10 Oct 1997 03:31:16 GMT
From: fil_nospam@login.net (Philip)
Subject: Re: LLama book script
Message-Id: <343da10d.12499710@nntphost.login.net>

On Thu, 09 Oct 1997 21:09:46 GMT, amacater@galactic.demon.co.uk
(Andrew Martin Adrian Cater [Andy]) wrote:

>Still having trouble with this one from page 10 of LLama book (2nd. ed).
You must be learning perl then, so the error is forgivable

>	$secretword = $words($name);	
			    ^^^^^^^ should be : {$name} 
                        (Note curley braces, not parens!)

HTH

-Philip


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

Date: Fri, 10 Oct 1997 03:03:15 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Need Help Parsing ASCII File 
Message-Id: <genepoolEHtF5F.HnA@netcom.com>

Rob Truban (rtruban@erols.com) wrote:
<deletia>
: Does that make sense??

No. Post an example of your result set and what you intend to do with it. 

Cheers,

Jim


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

Date: Thu, 9 Oct 1997 22:16:52 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Need Help Parsing ASCII File
Message-Id: <4n6k16.ku.ln@localhost>

Rob Truban (rtruban@erols.com) wrote:
: Hi all,

Hi.

: I'm a Perl Newbie in need of advice.  I want to take an ASCII text file
: (which is the result of an SQL query done on a Sybase DB), parse the

Is this the output from isql, with all those dashes and stuff?

I think I did something like this once before in a galaxy far, far away...


: text file and populate an Access DB with the info. For the record, this
: will not be a web based app...

: I've been reading Perl books (PERL 5 How-To & a couple of others) and
: searching the web all week and have not found any scripts similar to
: what I want.

: The text file will have a header and then the info from the SQL selects.

Why not just show us a sample text file instead of trying to describe
it in English?

It could also serve as input data should anyone want to bang out
some code for you...


: The only example I've found (parseHtm.pl from How-To) parses by looking
: through a file one character at a time.  Is there a way to do it more
: efficiently?  

I expect that there is.


: Essentially, what I need to do is take each word in the
: file and make it a scalar.  None of the elements in the header have
: white space,  if that helps.   I want the header data to be the keys in
: the associative array, then use the "actual" data to fill in the record
: portion of the array.  Each Array "key" would associate to a table field
: in the Access DB, and the "record" portion of the array would be used to
: fill in the records in Access table.

: Does that make sense??  

Not much ;-(


: I'm not sure if I'm approaching this the right
: way.   

: Any input would be greatly appreciated.


Any input data (and some output data too) would be greatly appreciated  ;-)

Give use some input, and what output you want, and someone will
likely write code to do the transform...


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 09 Oct 1997 20:19:22 -0700
From: Tony Banchieri <tbanchie@cisco.com>
Subject: Oraperl Error... Please help..
Message-Id: <343D9EBA.9B4@cisco.com>

I am converting some perl4 scripts to Perl5.

So I made only one change to my code to use: 
   #!/usr/local/bin/perl5
   use Oraperl;

rather than:
   #!/usr/local/bin/oraperl

I now get the error when executing the program: 
   fetchrow: handle  is not a hash reference at per_detail.cgi line 69.


my code reads:
-----
line 67: $marketing_resp_sql = "select marketing_resp from
marketing_response_table where per_num = $in_pernum";

line 68: $csr_marketing_resp = &ora_open($lda, $marketing_resp_sql);
line 69: @marketing_response = &ora_fetch($csr_marketing_resp);
line 70: &ora_close($csr_marketing_resp);


This kind of error is completley new to me in the world of Perl5.

Any help would be deeply appreciated - I completely stuck!

thanks!
Tony


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

Date: Thu, 09 Oct 1997 23:46:40 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: brian shields <Brian_shields.0192063@nt.com>
Subject: Re: Out of memory error?
Message-Id: <343DA520.6C1F7553@mail.earthlink.net>

[posted & mailed]

brian shields wrote:
> 
> Greetings,
>    I am running Perl version 5.001 on an HP-UX 712 9.05.  I am running a
> program to create an associative array of our internal e-mail
> addresses.  The array is keyed by employee id and it constructs a list
> for each id (dept number, first name, last name, and e-mail address).  I
> have set it up to have no more than 2 iterations of the e-mail address
> per employee (an employee can have more than one e-mail address).  The
> program runs out of memory.  I estimate there are about 60K records to
> be produced.  What I do not understand is why so much memory is used
> when the source file is only 1.5 MB?  My program is using a small
> portion of each record in this file(perhaps about 80 bytes of
> information).  Using the HP command 'top' to monitor memory usage, I can
> see the program went from initially using about 1 MB of memory to 80MB
> before it finally failed.  My system has 128MB RAM.  I would expect an
> internal file of less than 5 MB to be created.  So why is so much memory
> being consumed?  I am not running anything else at the same time either
> which would consume all available memory.  I would sure appreciate any
> suggestions on making full use of available memory without wasting it
> all somehow.  Any ideas?
> 
> Sincerely,
> 
> Brian
If you post your script, I'm sure someone will be happy to help you find
your memory leak :-)

Benjamin Holzman




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

Date: Thu, 9 Oct 1997 18:15:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Doug Seay <seay@absyss.fr>
Subject: Re: Perl Installation Question
Message-Id: <Pine.GSO.3.96.971009181232.5084K-100000@usertest.teleport.com>

On Thu, 9 Oct 1997, Doug Seay wrote:

> Tom Phoenix wrote: [concerning Perl version numbers]

> > _01 is the latest released version; _03 has not been officially released
> > (as I understand things). For most people, there's no real difference
> > between the two; just a few bug fixes for things you're not likely to
> > notice. :-)
> 
> Uhh, what happened to _02?  

If we can have one unreleased sub-version, why not two? :-)  In this case,
I believe it had an installation bug that affected only one or two
systems, so the folks in charge decided to not release it. Soon, _04 may
be ready and I hope that it will be released! :-)  But if you've got one
of the other 5.004 subversions, don't worry about it too much, but stay
tuned to c.l.p.announce!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Thu, 9 Oct 1997 22:55:07 +0200
From: Calle Aasman <md4calle@mdstud.chalmers.se>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Q: how to specify how many decimals a calcultaion shall have?
Message-Id: <Pine.GSO.3.95.971009225317.6778A-100000@grosse.mdstud.chalmers.se>

On Thu, 9 Oct 1997, Tom Phoenix wrote:

> > shall become
> > 23.3245
> 
> That looks like four digits. :-) 
:) sorry...well...ah...hmm.. I blame it on the coffee,

> But have you seen what the FAQ says
> about rounding, in perlfaq4?
Yes found it, shoudl perhaps have cancelled the posting, worked perfect
with sprintf.

all best,

/Calle

**************************************************************************
*         *         My homepage about the author Tom Holt:               *
*        /_\        http://www.mdstud.chalmers.se/~md4calle/holt/        *
*     { ~._.~ }                                                          *
*      (  Y  )      other things like OnLine Guitar Archive linkpage     *
*     ( )~*~( )     and heaps of musiclinks can be found at              *
*     (__)-(__)     http://www.mdstud.chalmers.se/~md4calle/             *
**************************************************************************




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

Date: 10 Oct 1997 05:51:44 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Question: File locking
Message-Id: <61kfpg$g3o$2@vixen.cso.uiuc.edu>

Tom Phoenix (rootbeer@teleport.com) wrote:
: On Wed, 8 Oct 1997, George J. Lee wrote:
: 
: > I need help with file locking. I am designing a web site for investing
: > (URL below) and it includes a stock simulation program. It uses a perl
: > script as a cgi interface to a msql database to keep track of trades.
: > Trouble is, if two people buy stock at precisely the same time, one of
: > them won't got the stock because both instances of my perl script assign
: > the same id # to it. Also, if one person clicks the submit button for
: > the buy form multiple times, they can get more shares than they should
: > be able to with their money. 
: 
: Good thing it's just a simulation. :-)
: 
: > I tried using file locking to prevent two instances from trying to buy
: > at the same time, but with no success. I know flock works on the server
: > because I have tested it using a test script, but I can still cheat by
: > clicking the buy button rapidly. Here as a portion of the relevant code: 
: > 
: >       open(PURCHASE, ">>$LOCK_FILE")     or die "open $LOCK_FILE: $!\n";
: >       flock(PURCHASE, 2);
: >       &add_to_the_cart;
: >       flock(PURCHASE, 8);
: >       exit;
: 
: Ah, you're releasing the lock. Don't do that. :-)  If you lock as soon as
: you open and close or exit as soon as you're all done, everything should
: work for you. (Closing releases the lock, and exiting closes the file, so
: you never need to (or should) explicitly release the lock.)
: 

Perhaps we have a misunderstandng here.

There is no need to close the file -- you simply have to guarantee
the operation is (or series of related operations are) atomic
within the lock.

I happen to know that the below program will generate completely reliable 
output, no matter how many copies are run. (You can't guarantee
interleaving unless you use a semaphore, but I don't believe that
is the question here.)

- 
Regards,
Mike Heins

This post reflects the
opinion of my employer.

#!/usr/local/bin/perl -w
# 
# test_flock.pl - test repeated flock() on outboard lock file

use Fcntl ':flock';

# test with:
#
#   ./test_flock.pl &; ./test_flock
#

# Allow both to start about the same time.

sleep 2;

sub do_out {

    open LOCK, ">>lock.file"
        or die "Couldn't open lock.file: $!\n";

    flock LOCK, LOCK_EX
        or die "Couldn't LOCK_EX lock.file: $!\n";

    open OUTPUT, ">>out.file"
        or die "Couldn't open out.file: $!\n";

    print OUTPUT @_;

    close OUTPUT;

    flock LOCK, LOCK_UN
        or die "Couldn't LOCK_UN lock.file: $!\n";

}

$pid_notice = "Process $$\n";

for( 1 .. 100 ) {
    do_out($pid_notice);
    # If you want to see it interleaved pretty well,
    # uncomment the line below
    # select(undef, undef, undef, 0.050);
}



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

Date: Thu, 9 Oct 1997 23:08:25 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Reading Variable Names from a file
Message-Id: <pn9k16.k71.ln@localhost>

peo@sprintmail.com wrote:

: I have a file that has a list of variable references in it of the form:

: MYPATH=$PATH:/HOME/MYDIR
: NEWPATH=${MYPATH}

: etc.

: What I want to do is read in the file and process each line picking out all
: the variable references (both types $VAR and ${VAR}) without having the
: variables interpolated and after performing my own substitution on the
: variable place them back into the string.  The problem I am having is pulling
: the variable names out of the read line.  Is there an easy way of doing
: this?


Since you don't describe what 'my own substitution' might mean,
I can only guess at that, but this should find the variable references.

(some of them anyway... might be an expression in the curlies:
   ${$one . $two}
)


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

while (<DATA>) {
   while ( s/\$          # a dollar sign
             (?:         # grouping only, no $\d memory
             \w+         # one or more word chars (the variable name)
             |           # or
             {\w+}       # open curly, one or more word chars, close curly
             )           # end of grouping
            /my own substitution/gx
         ) {
      print;
   }
}


__DATA__
MYPATH=$PATH:/HOME/MYDIR
NEWPATH=${MYPATH}
MYPATH=$PATH:/HOME/MYDIR NEWPATH=${MYPATH}
------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Fri, 10 Oct 1997 02:14:25 GMT
From: munn@bigfoot.com (Thomas Munn)
Subject: Seeing if service is alive, Is this a good idea?
Message-Id: <61k33c$lv9$1@nu-informer.alliance.net>

I am very new to perl, and have been diligiently reading the CAMEL book, 
anyway:  Here's what I want to do:

Have perl send an http request to the web server, to see if the server is up.  
Do I just send an http get command, then have a timeout?  Or is there a built 
in function that will do this automagically?

Also I am not sure how to install a "delay" (say a second or two) while perl 
waits for the answer, or do the web libraries automagically know how long to 
wait before returning a "fail" code.

So:

Conceptually:  

Send out http request
assign result to a variable (how??)
evalutate if variable is true/false (does an error return null??)
if variable is non-error, just exit the progam, but if its an error to execute 
a command....

Anyway, I will read chapter 6 in the reference book (programming perl) and see 
if I can figure it out, meantime, feel free to email/post here.

Thomas


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

Date: 10 Oct 1997 02:22:31 GMT
From: "Louis Emerson B. Ricohermoso" <louis@cheerful.com>
Subject: sql in perl
Message-Id: <01bcd524$bb4dfa80$0224a8c0@firewall>

does anybody know of a module or library that i can use to do sql in perl? 
i need relational database functionality, any ideas?



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

Date: 10 Oct 1997 02:26:07 GMT
From: "Louis Emerson B. Ricohermoso" <louis@cheerful.com>
Subject: sql on perl
Message-Id: <01bcd525$3bc0ab40$0224a8c0@firewall>

does anybody know of a module or library that i can use to do sql in perl? 
i need relational database functionality, any ideas?



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

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

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