[10689] in Perl-Users-Digest
Perl-Users Digest, Issue: 4281 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 23 17:07:22 1998
Date: Mon, 23 Nov 98 14:00:21 -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 Mon, 23 Nov 1998 Volume: 8 Number: 4281
Today's topics:
"ELSE" command in Perl?? <lookitsme@cyberspam.com>
Re: "ELSE" command in Perl?? (John Moreno)
Re: "ELSE" command in Perl?? <Allan@due.net>
Re: "ELSE" command in Perl?? <ebohlman@netcom.com>
Re: "ELSE" command in Perl?? <Allan@due.net>
Re: "ELSE" command in Perl?? (Greg Bacon)
Re: 1st Edition of Learning Perl (brian d foy)
Re: 1st Edition of Learning Perl (Clinton Pierce)
Re: 1st Edition of Learning Perl (Clinton Pierce)
Re: accessing parent values with recursion <aqumsieh@matrox.com>
Re: another pod Q (was Re: Q: pod inside data structure (Chris Nandor)
Re: Changing the env variables? <baliga@synopsys.com>
Re: Changing the env variables? (I R A Aggie)
Re: Changing the env variables? <dan@clockwork.net>
Re: Changing the env variables? <Allan@due.net>
Re: Changing the env variables? <dan@clockwork.net>
Re: Deleting GDBM file records (Steve van der Burg)
Re: Deleting GDBM file records (Steve van der Burg)
Re: File descriptor/flock problem phukit@enteract.com
Re: FTP'ing within a perl script <scott.searle@noway.nz>
Re: How to call PGP from Perl Script? (brian d foy)
Re: How to call PGP from Perl Script? <dan@clockwork.net>
Re: How to print a simple character on the screen ? <baliga@synopsys.com>
Re: How to print a simple character on the screen ? <r28629@email.sps.mot.com>
Re: How to print a simple character on the screen ? (Larry Rosler)
Re: htpasswd source code (+ crypt) (brian d foy)
Q: Parents and childs <bnies@hsr.ch>
Re: Q: Parents and childs <bnies@hsr.ch>
Re: Q: Parents and childs (Andrew M. Langmead)
Re: The dumbest question ever - HELP!!! <scott.searle@noway.nz>
Re: Unified Scripting Environment? Re: A Smaller Tcl - lvirden@cas.org
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 23 Nov 1998 21:53:17 +0100
From: "Jeroen Roeper" <lookitsme@cyberspam.com>
Subject: "ELSE" command in Perl??
Message-Id: <73cht7$oib$1@news2.xs4all.nl>
Hi perl wizards,
a question, I have a Perl script that displays a flat text database. Now I
want to know if there is such thing as the If-Then-Else command such as in
VB
This is the chunk of code I use now, but it doesn't seem to work, any
ideas??
if( $web = "" )
{
print "<b>$com</b><br>";
else
print "<a href=\"$web\">$com</a>";
}
Jeroen Roeper
Tracks Online
E-mail: tracks@tracksonline.com
Web: http://www.tracksonline.com
------------------------------
Date: Mon, 23 Nov 1998 16:41:43 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: "ELSE" command in Perl??
Message-Id: <1diygs7.1hv3vy7g15km4N@roxboro0-028.dyn.interpath.net>
Jeroen Roeper <lookitsme@cyberspam.com> wrote:
> Hi perl wizards,
>
> a question, I have a Perl script that displays a flat text database. Now I
> want to know if there is such thing as the If-Then-Else command such as in
> VB
>
> This is the chunk of code I use now, but it doesn't seem to work, any
> ideas??
>
> if( $web = "" )
> {
> print "<b>$com</b><br>";
> else
> print "<a href=\"$web\">$com</a>";
> }
Yes - first use a sigdash (two dashes followed by a space) to separate
your sig from the body.
Secondly -- the "else" is supposed to be /between/ paired brackets. So
the above should be:
if( $web = "" )
{
print "<b>$com</b><br>";
}
else
{
print "<a href=\"$web\">$com</a>";
}
Of course I'd style it a bit differently and you are using a numeric
instead of character comparison, so it won't work even if you put in the
correct brackets. Try:
if( $web eq "" ) {
print "<b>$com</b><br>";
}
else {
print "<a href=\"$web\">$com</a>";
}
--
John Moreno
------------------------------
Date: Mon, 23 Nov 1998 16:49:32 -0500
From: "AmD" <Allan@due.net>
Subject: Re: "ELSE" command in Perl??
Message-Id: <73cl0r$t0c$1@camel21.mindspring.com>
Jeroen Roeper wrote in message <73cht7$oib$1@news2.xs4all.nl>...
>Hi perl wizards,
>a question, I have a Perl script that displays a flat text database. Now I
>want to know if there is such thing as the If-Then-Else command such as in
>VB
>This is the chunk of code I use now, but it doesn't seem to work, any
>ideas??
>
> if( $web = "" )
> {
> print "<b>$com</b><br>";
> else
> print "<a href=\"$web\">$com</a>";
> }
Someone needs to read a little documentation I fear.
if ( $web = "" ) {
print "<b>$com</b><br>";
}
else {
print "<a href=\"$web\">$com</a>";
}
Of course some would cuddle that else but I find that too much cuddling can
cause seperation anxiety later in life.
AmD
------------------------------
Date: Mon, 23 Nov 1998 21:47:42 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: "ELSE" command in Perl??
Message-Id: <ebohlmanF2w9vI.GJ5@netcom.com>
Jeroen Roeper <lookitsme@cyberspam.com> wrote:
: a question, I have a Perl script that displays a flat text database. Now I
: want to know if there is such thing as the If-Then-Else command such as in
: VB
Yep.
: This is the chunk of code I use now, but it doesn't seem to work, any
: ideas??
: if( $web = "" )
: {
: print "<b>$com</b><br>";
: else
: print "<a href=\"$web\">$com</a>";
: }
perldoc perlsyn will tell you that in Perl, unlike C or many other
languages, the consequent of an if statement must be a brace-enclosed
block, not a bare statement. It will also tell you some important things
about how to write a chain of tests: if() {} else if {}... won't work.
------------------------------
Date: Mon, 23 Nov 1998 16:58:53 -0500
From: "AmD" <Allan@due.net>
Subject: Re: "ELSE" command in Perl??
Message-Id: <73clid$ama$1@camel21.mindspring.com>
Shoot, I forgot to mention your code still won't work. Better check out eq
as compared to == when comparing because I am pretty darn sure you don't
mean = in your if statement, it is always true. It sets $web to "".
AmD wrote in message <73cl0r$t0c$1@camel21.mindspring.com>...
>Jeroen Roeper wrote in message <73cht7$oib$1@news2.xs4all.nl>...
>>Hi perl wizards,
>>a question, I have a Perl script that displays a flat text database. Now I
>>want to know if there is such thing as the If-Then-Else command such as in
>>VB
>>This is the chunk of code I use now, but it doesn't seem to work, any
>>ideas??
>>
>> if( $web = "" )
>> {
>> print "<b>$com</b><br>";
>> else
>> print "<a href=\"$web\">$com</a>";
>> }
>
>Someone needs to read a little documentation I fear.
>
>if ( $web = "" ) {
> print "<b>$com</b><br>";
>}
>else {
> print "<a href=\"$web\">$com</a>";
>}
>
>Of course some would cuddle that else but I find that too much cuddling can
>cause seperation anxiety later in life.
>
>AmD
------------------------------
Date: 23 Nov 1998 21:35:40 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: "ELSE" command in Perl??
Message-Id: <73ckfc$1t1$5@info.uah.edu>
In article <73cht7$oib$1@news2.xs4all.nl>,
"Jeroen Roeper" <lookitsme@cyberspam.com> writes:
: a question, I have a Perl script that displays a flat text database. Now I
: want to know if there is such thing as the If-Then-Else command such as in
: VB
The "Compound statements" section of the fine perlsyn manpage discusses
this.
Greg
--
Daphne: Don't tell me that you've never used sex to get what you want
Frasier: Men can't use sex to get what we want. Sex *IS* what we want.
------------------------------
Date: Mon, 23 Nov 1998 15:27:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: 1st Edition of Learning Perl
Message-Id: <comdog-ya02408000R2311981527020001@news.panix.com>
In article <3.0.32.19981123083014.00981e60@haas.berkeley.edu>, xma@Haas.Berkeley.EDU (Xiaoyan Ma) posted:
> I have inherited a 1st edition of Learning Perl. Should I start with it or
> it's better to spend the money for the 2nd edition?
the first edition is adequate. :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 23 Nov 1998 20:29:28 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Re: 1st Edition of Learning Perl
Message-Id: <365fc4e2.967173543@news.ford.com>
[Courtesy CC sent to poster in E-Mail]
On Mon, 23 Nov 1998 08:30:16 -0800, xma@Haas.Berkeley.EDU (Xiaoyan Ma)
wrote:
>I have inherited a 1st edition of Learning Perl. Should I start with it or
>it's better to spend the money for the 2nd edition?
>
>Thanks in advance for any suggestions.
>
>Xiaoyan
>
>
It's fine. :-) It's a good, gentle, introduction to the language, and
it's not horribly outdated, as far as it goes.
DO spring the money and get the Second Edition of Perl Programming when
you're ready for it. The First Edition won't quite cut it now.
--
"If you rush a Miracle Man, you get rotten miracles"
--Miracle Max, The Princess Bride
DNRC: "Grand Inquisitor of Out At 5 Doctrine" 06/96
------------------------------
Date: Mon, 23 Nov 1998 20:36:34 GMT
From: cpierce1@mail.ford.com (Clinton Pierce)
Subject: Re: 1st Edition of Learning Perl
Message-Id: <3662c72d.967760730@news.ford.com>
On Mon, 23 Nov 1998 20:29:28 GMT, cpierce1@mail.ford.com (Clinton
Pierce) wrote:
>[Courtesy CC sent to poster in E-Mail]
>
>On Mon, 23 Nov 1998 08:30:16 -0800, xma@Haas.Berkeley.EDU (Xiaoyan Ma)
>wrote:
>>I have inherited a 1st edition of Learning Perl. Should I start with it or
>>it's better to spend the money for the 2nd edition?
>>
>>Thanks in advance for any suggestions.
>>
>>Xiaoyan
>>
>>
>
>It's fine. :-) It's a good, gentle, introduction to the language, and
>it's not horribly outdated, as far as it goes.
>
>DO spring the money and get the Second Edition of Perl Programming when
>you're ready for it. The First Edition won't quite cut it now.
s/Perl Programming/Programming Perl/g;
------------------------------
Date: 23 Nov 1998 14:21:09 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: accessing parent values with recursion
Message-Id: <x3yww4mgqqi.fsf@tigre.matrox.com>
I see three problems.
1 on the tenth line after the third ! mark
1 around the 16th line next to the {
1 on the last line
Hope this helps.
pjgeer@my-dejanews.com writes:
>
> Here, Dejanews messed it all up, let me try again.
>
> I'm having problems getting at values from parent calls of a recursive
> subroutine. The script works with compound arrays that construct like this:
> ---------- @sets = ( [ { NAME => "FRANK", REGION => "03", } ], [ { NAME
> => "REGION ONE", CODE => "01", }, { NAME => "REGION TWO", CODE => "02", },
> { NAME => "REGION THREE", CODE => "03", } ] ); ###
> $sets[$setnumber][$rownumber]{'$key'} yields '$value' ---------- Directions
> about how the elements are displayed come from an input file. Here is an
> excerpt: ---------- <!--:for 0 --> Here is the data on $$0:NAME$$, edit it if
> you wish<BR> <INPUT TYPE=text NAME=name VALUE="$$0:NAME$$"> <SELECT
> NAME=region> <!--:for 1 --> <OPTION <!--:if ( $$1:CODE$$ eq $$0:REGION$$ )
> --> SELECTED <!--:endif --> VALUE="$$1:CODE$$"> $$1:NAME$$ </OPTION>
> <!--:next --> </SELECT> <INPUT Type=submit Value="Edit $$0:NAME$$"> <!--:next
> --> ---------- A subroutine parses the input file. It may come across
> commands like <!--:for $setnumber --> and <!--:if ( $condition ) --> which
> tell it to handle output differently. Here is the subroutine: ---------- sub
> parse_html { #Usage: parse_html( $first, $last ) #$first is the array
> reference of the first line we want to parse #$last is the array reference
> of the last line we want to parse my $accum; #$accum will hold the
> string of processed HTML my $first = shift( @_ ); #$first is the first line
> of HTML my $last = shift( @_ ); #$last is the last line of HTML my
> $htmllinenum; my $temp; for $htmllinenum ( $first..$last ) { if(
> $htmllines[$htmllinenum] =~ m/<!--: *for ([0-9]+) *-->/i ) { $global_index =
> $htmllinenum + 1; my $local_index = $htmllinenum + 1; for $rownum (
> 0..$#{$sets[$1]} ) { $accum .= parse_html( $local_index, $#htmllines ); #the
> for block } $accum .= parse_html( $global_index, $#htmllines ); #the rest
> of doc return $accum; } elsif ( $htmllines[$htmllinenum] =~ m/<!--: *next
> *-->/i ) { $global_index = $htmllinenum + 1; return $accum; } elsif (
> $htmllines[$htmllinenum] =~ m/<!--: *if (.+) *-->/i ) { $global_index =
> $htmllinenum + 1; if ( eval $1 == 0 ) { $null .= parse_html(
> $global_index, $#htmllines ); #current run for index } else { $accum .=
> parse_html( $global_index, $#htmllines ); } $accum .= parse_html(
> $global_index, $#htmllines ); return $accum; } elsif (
> $htmllines[$htmllinenum] =~ m/<!--: *endif *-->/i ) { $global_index =
> $htmllinenum + 1; return $accum; } else { $temp =
> $htmllines[$htmllinenum]; $temp =~
> s/\$\$([0-9]+):(\w+)\$\$/$sets[$1][$rownum]{$2}/g; $temp =~
> s/\$\$(\w+)\$\$/${$1}/g; #substitutes scalars $accum .= $temp; } #end if }
> #end for return $accum; } #end parse_html ---------- As shown for this input
> file, I need a way to compare data from the first set to the second within
> the recursive call. Which row it is can't be hardcoded into the input file.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 23 Nov 1998 15:40:37 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: another pod Q (was Re: Q: pod inside data structures)
Message-Id: <pudge-2311981540370001@192.168.0.77>
In article <x7vhkh5v3o.fsf_-_@sysarch.com>, Uri Guttman <uri@sysarch.com> wrote:
# i have another pod and data question. i think this is impossible but an
# interesting idea. i want to have a single usage text be in both a perl
# string AND pod text in the same file. you can see the advantage here of
# maintaining only one usage text and having it print from perl and in the
# pod2xxx output.
Uri, Uri, Uri. Our very own Boston.pm (that's Perl Module, not Perl
Mongers) does this (though it does not pull out a particular section).
I do it in the tpi-news program, too, but you don't have the source to
that. In there I just keep the Usage: text in POD, and then when needed
to print to STDERR by the program, I get it from DATA.
#!perl -w
my $text;
1 until (<DATA> =~ /^=head1 USAGE/); # whatever section you want here
while (<DATA>) {
last if /^=head1 /;
$text .= $_;
}
print $text;
__END__
=head1 NAME
Some Program
=head1 USAGE
Some stuff goes here.
=head1 DESCRIPTION
D'oh!
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Mon, 23 Nov 1998 12:01:37 -0800
From: Yogish Baliga <baliga@synopsys.com>
To: Emmanouil Spyridakis <espyrida@osf1.gmu.edu>
Subject: Re: Changing the env variables?
Message-Id: <3659BF21.1FC2461A@synopsys.com>
--------------CEDA0C92E7017166F71C36EE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
All the environment variable is set by the web server not by the web
browser.... When the HTML page is send to the web server by the web browser,
it collects the values in the form and construct a string which will be
placed after the ? sign. This string is read only.. This string is sent along
with
the URL to the web server and the web server parses the string and set the
environment for the CGI script and invoke the CGI script. Since the
environment
variables are the environment for the CGI script not to the Web Browser, it
cannot be changed...
-- Baliga
Emmanouil Spyridakis wrote:
> When I submit a form to a perl script in a web page I want to change the
> values of some of the variables before I create the new page on the fly
> through perl.
> I have been trying to do this by changing the environmental variable
> 'QUERY_STRING' but perl always puts the old variables on the Address line
> of my browser no matter what I do (i.e.
> http://www.one.com/entry.plx?name=steve&number=345234523)
> How do I change these values?
> This is what I tried with the 'QUERY_STRING' when trying to change the
> number to something else dut it didn't work:
>
> $vars= $ENV{'QUERY_STRING'} ;
> ($first, $second, $third) = split(/=/, $vars);
> $ENV{'QUERY_STRING'}=$first."=".$second."=".$newvalue;
--------------CEDA0C92E7017166F71C36EE
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
All the environment variable is set by the web server not by the web browser....
When the HTML page is send to the web server by the web browser,
<br>it collects the values in the form and construct a string which will
be placed after the ? sign. This string is read only.. This string is sent
along with
<br>the URL to the web server and the web server parses the string and
set the environment for the CGI script and invoke the CGI script. Since
the environment
<br>variables are the environment for the CGI script not to the Web Browser,
it cannot be changed...
<p>-- Baliga
<p>Emmanouil Spyridakis wrote:
<blockquote TYPE=CITE>When I submit a form to a perl script in a web page
I want to change the
<br>values of some of the variables before I create the new page on the
fly
<br>through perl.
<br>I have been trying to do this by changing the environmental variable
<br>'QUERY_STRING' but perl always puts the old variables on the Address
line
<br>of my browser no matter what I do (i.e.
<br><a href="http://www.one.com/entry.plx?name=steve&number=345234523">http://www.one.com/entry.plx?name=steve&number=345234523</a>)
<br>How do I change these values?
<br>This is what I tried with the 'QUERY_STRING' when trying to change
the
<br>number to something else dut it didn't work:
<p>$vars= $ENV{'QUERY_STRING'} ;
<br>($first, $second, $third) = split(/=/, $vars);
<br>$ENV{'QUERY_STRING'}=$first."=".$second."=".$newvalue;</blockquote>
</html>
--------------CEDA0C92E7017166F71C36EE--
------------------------------
Date: Mon, 23 Nov 1998 15:29:05 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Changing the env variables?
Message-Id: <fl_aggie-2311981529050001@aggie.coaps.fsu.edu>
In article <73c9t0$ue0@portal.gmu.edu>, espyrida@osf1.gmu.edu (Emmanouil
Spyridakis) wrote:
+ How do I change these values?
You don't. Child processes (like a cgi script) can not change the parent's
environment!
James
------------------------------
Date: Mon, 23 Nov 1998 14:58:10 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: Changing the env variables?
Message-Id: <3659CC62.3B680977@clockwork.net>
This question doesn't directly relate to perl, however ...
You sure can alter the environment; why are there two posts saying you
can't? Perl loads the %ENV variables at load time, but they are within the
local namespace, so you can do anything you want to them. Your problem
likely lies in that you're not splitting the QUERY_STRING correctly; these
elements are delimited with a '&', with each name/val being delimited by a
'=' (look at your own URL you posted below). Splitting the elements at '='
on this URL will give you values:
name, steve&number, 345234523
Which I really hope isn't what you wanted. Use CGI.pm, and set the $ENV's if
you want. CGI.pm also has it's own debugging, so you shouldn't need to mess
with $ENV at all (probably not a good idea anyway).
Emmanouil Spyridakis wrote:
> When I submit a form to a perl script in a web page I want to change the
> values of some of the variables before I create the new page on the fly
> through perl.
> I have been trying to do this by changing the environmental variable
> 'QUERY_STRING' but perl always puts the old variables on the Address line
> of my browser no matter what I do (i.e.
> http://www.one.com/entry.plx?name=steve&number=345234523)
> How do I change these values?
> This is what I tried with the 'QUERY_STRING' when trying to change the
> number to something else dut it didn't work:
>
> $vars= $ENV{'QUERY_STRING'} ;
> ($first, $second, $third) = split(/=/, $vars);
> $ENV{'QUERY_STRING'}=$first."=".$second."=".$newvalue;
------------------------------
Date: Mon, 23 Nov 1998 16:41:42 -0500
From: "AmD" <Allan@due.net>
Subject: Re: Changing the env variables?
Message-Id: <73cki5$qjj$1@camel21.mindspring.com>
[snip]
>Your problem
>likely lies in that you're not splitting the QUERY_STRING correctly; these
>elements are delimited with a '&', with each name/val being delimited by a
>'=' (look at your own URL you posted below). Splitting the elements at '='
>on this URL will give you values:
>
>name, steve&number, 345234523
>
>Which I really hope isn't what you wanted. Use CGI.pm, and set the $ENV's
if
>you want. CGI.pm also has it's own debugging, so you shouldn't need to mess
>with $ENV at all (probably not a good idea anyway).
Well, CGI.pm is good advice. Why did you hope that
name, steve&number, 345234523
isn't what he wanted?
$vars= 'name=steve&number=345234523';
($first, $second, $third) = split(/=/, $vars);
$newvalue = '10';
$ENV{'QUERY_STRING'}=$first."=".$second."=".$newvalue;
print $ENV{'QUERY_STRING'}
gives:
name=steve&number=10
Which is what he said he is trying to produce. Not how I would have done
it, but I don't think that is the primary source of his problem.
AmD
------------------------------
Date: Mon, 23 Nov 1998 15:49:07 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: Changing the env variables?
Message-Id: <3659D853.969A5252@clockwork.net>
True.
Whether the code 'works' or not, the '&' is the standard element delimiter;
splitting at '=' is only going to get him into trouble, especially if a
URL that differs in the slightest is posted to the script (different order of
name/vals, names w/o values).
It would help if he posted the result or error he gets. It would also help if
two people didn't post downright mistruths in response to his question ;).
AmD wrote:
> [snip]
>
> >Your problem
> >likely lies in that you're not splitting the QUERY_STRING correctly; these
> >elements are delimited with a '&', with each name/val being delimited by a
> >'=' (look at your own URL you posted below). Splitting the elements at '='
> >on this URL will give you values:
> >
> >name, steve&number, 345234523
> >
> >Which I really hope isn't what you wanted. Use CGI.pm, and set the $ENV's
> if
> >you want. CGI.pm also has it's own debugging, so you shouldn't need to mess
> >with $ENV at all (probably not a good idea anyway).
>
> Well, CGI.pm is good advice. Why did you hope that
> name, steve&number, 345234523
> isn't what he wanted?
>
> $vars= 'name=steve&number=345234523';
> ($first, $second, $third) = split(/=/, $vars);
> $newvalue = '10';
> $ENV{'QUERY_STRING'}=$first."=".$second."=".$newvalue;
> print $ENV{'QUERY_STRING'}
>
> gives:
> name=steve&number=10
>
> Which is what he said he is trying to produce. Not how I would have done
> it, but I don't think that is the primary source of his problem.
>
> AmD
------------------------------
Date: Mon, 23 Nov 1998 21:17:56 GMT
From: steve.vanderburg@lhsc.on.ca (Steve van der Burg)
Subject: Re: Deleting GDBM file records
Message-Id: <73cj8l$95j@falcon.ccs.uwo.ca>
In article <73cj1h$95j@falcon.ccs.uwo.ca>, steve.vanderburg@lhsc.on.ca (Steve van der Burg) wrote:
>In article <slrn75je93.bnr.jsd@hudsucker.gamespot.com>, jsd@gamespot.com wrote:
>>can't be done unless you copy the records you want to a new file.
>>gdbm files keep their unused space allocated. in fact, most dbm
>>implementations that i am aware of behave the same way.
>It can be done:
>
>use GDBM_File;
..
> my $y = $x->reorganize;
..
Of course, if you go looking in the source for gdbm, you'll find that this
call does precisely what "jsd" mentioned -- it copies all the records to a new
file, deletes the old one and renames the new one to the old. Of course, it
does all this for you, so it's pretty convenient.
..Steve
--
Steve van der Burg
Technical Analyst, Information Services
London Health Sciences Centre
London, Ontario, Canada
Tel: +1 519 663-3300 x 5559 (work)
+1 519 472-6686 (home)
Email: steve.vanderburg@lhsc.on.ca
WWW: http://www.lhsc.on.ca/~vanderbg/
------------------------------
Date: Mon, 23 Nov 1998 21:14:06 GMT
From: steve.vanderburg@lhsc.on.ca (Steve van der Burg)
Subject: Re: Deleting GDBM file records
Message-Id: <73cj1h$95j@falcon.ccs.uwo.ca>
In article <slrn75je93.bnr.jsd@hudsucker.gamespot.com>, jsd@gamespot.com wrote:
>In article <36585E86.4747D72B@magma.ca>, hassan wrote:
>>The code below would "delete" all the records in a GDBM file, but
>>the file size remains almost the same!! Anybody knows why? I tried
>>to vi the "myfile" and found all the records still in there! Does
>>anybody know how I can "sure delete" GDBM file records. That is, if
>>my GDBM file is 2MB big, I want to see the size of that file
>>considerably reduced after deleting all the records.
>
>can't be done unless you copy the records you want to a new file.
>gdbm files keep their unused space allocated. in fact, most dbm
>implementations that i am aware of behave the same way.
>
It can be done:
use GDBM_File;
while ( $database = shift @ARGV ) {
my %DB;
my $x;
if ( $x = tie(%DB,'GDBM_File',$database,&GDBM_WRCREAT,0640) ) {
die "Couldn't tie to $database ($!)" unless tied(%DB);
my $oldsz = -s $database;
my $y = $x->reorganize;
die "Reorganize call failed with this error code: $y" if $y < 0;
my $newsz = -s $database;
print "Reorganized $database: old size: $oldsz new size: $newsz\n";
untie %DB;
}
else {
print "Can't open $database for write\n";
}
}
..Steve
--
Steve van der Burg
Technical Analyst, Information Services
London Health Sciences Centre
London, Ontario, Canada
Tel: +1 519 663-3300 x 5559 (work)
+1 519 472-6686 (home)
Email: steve.vanderburg@lhsc.on.ca
WWW: http://www.lhsc.on.ca/~vanderbg/
------------------------------
Date: 23 Nov 1998 21:16:55 GMT
From: phukit@enteract.com
Subject: Re: File descriptor/flock problem
Message-Id: <73cjc7$qcm$1@eve.enteract.com>
phukit@enteract.com wrote:
<snip>
Anyone? =) I still haven't been able to figure it out.
Thanks!
------------------------------
Date: Tue, 24 Nov 1998 09:12:37 +1200
From: Scott Searle <scott.searle@noway.nz>
Subject: Re: FTP'ing within a perl script
Message-Id: <3659C1B5.D9CC2551@noway.nz>
Gary,
Not sure exactly what you are after here, but based on the subject of
the post, you might want to take a look at the Net::FTP module. It does
a nice job of hiding all the bits and pieces behind FTP. Hoep this
helps.
Cheers,
Scott
----------------------------------------
Scott Searle - Wholesale UNIX Support
National Bank of New Zealand Limited
Ph: +64 4 382 7841 Fax: +64 4 802 2356
email: scott.searle@nbnz.co.nz
Gary Morton wrote:
>
> I am a perl newbie (never heard of perl until 2 weeks ago.) Nonetheless, I've
> managed to write a CGI script for ESD that (so far) works properly. However,
> I'd like feedback from the http server that a download successfully completed,
> so that I don't bill the customer for a DL that was interrupted for some
> reason. After checking for credit info etc., my script currently executes a
>
> print "Location: http:// . . . ."
>
> instruction to deliver the file. But I don't get any feedback this way. Is
> there another way?
>
> Thanks to all the experts!
>
------------------------------
Date: Mon, 23 Nov 1998 15:30:04 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: How to call PGP from Perl Script?
Message-Id: <comdog-ya02408000R2311981530040001@news.panix.com>
In article <3659AEF8.9A0B8302@clockwork.net>, Dan Brian <dan@clockwork.net> posted:
> There is a module for calling PGP 2.6.2 properly at :
>
> http://www.perl.com/CPAN-local/modules/by-module/PGP/
it's much easier just to call it with IPC::Open3
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 23 Nov 1998 15:51:45 -0600
From: Dan Brian <dan@clockwork.net>
Subject: Re: How to call PGP from Perl Script?
Message-Id: <3659D8EA.C958CA5F@clockwork.net>
True, assuming he can figure out the command-line syntax on his own. :)
brian d foy wrote:
> In article <3659AEF8.9A0B8302@clockwork.net>, Dan Brian <dan@clockwork.net> posted:
>
> > There is a module for calling PGP 2.6.2 properly at :
> >
> > http://www.perl.com/CPAN-local/modules/by-module/PGP/
>
> it's much easier just to call it with IPC::Open3
>
> --
> brian d foy <comdog@computerdog.com>
> CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Mon, 23 Nov 1998 12:03:02 -0800
From: Yogish Baliga <baliga@synopsys.com>
To: Jean-Gael Gricourt <acetone@bigfoot.com>
Subject: Re: How to print a simple character on the screen ?
Message-Id: <3659BF76.378AF22@synopsys.com>
You can print using printf "%c", $letter
-- Baliga
Jean-Gael Gricourt wrote:
> I got a variable which contains the Ascii code of a letter for
> the alphabet: $letter=\x47; which represents the letter 'G'
>
> print "$letter";
>
> doesn't print the letter actually...
>
> Does anyone know how to do that in Perl ?
>
> Thank you,
>
> Jean
------------------------------
Date: Mon, 23 Nov 1998 14:50:38 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: baliga@synopsys.com
Subject: Re: How to print a simple character on the screen ?
Message-Id: <3659CA9E.A6EEB762@email.sps.mot.com>
[posted to c.l.p.m and copy emailed]
Yogish Baliga wrote:
>
> You can print using printf "%c", $letter
>
> -- Baliga
>
> Jean-Gael Gricourt wrote:
>
> > I got a variable which contains the Ascii code of a letter for
> > the alphabet: $letter=\x47; which represents the letter 'G'
> >
> > print "$letter";
> >
> > doesn't print the letter actually...
> >
> > Does anyone know how to do that in Perl ?
> >
> > Thank you,
> >
> > Jean
No, you can't. Please make sure you understand both the question and
your answer before posting.
$letter is a ref to (bareword) 'x47'. 'printf "%c", $letter' convert
$letter to number (from a ref), and print the char based on the least
significant value of the number.
Of course it wouldn't even compile if you had 'use strict' in the first
place.
-TK
------------------------------
Date: Mon, 23 Nov 1998 13:47:31 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to print a simple character on the screen ?
Message-Id: <MPG.10c377ce97d76f2b989888@nntp.hpl.hp.com>
[Posted to comp.lang.perl.misc and a copy mailed.]
In article <3659CA9E.A6EEB762@email.sps.mot.com> on Mon, 23 Nov 1998
14:50:38 -0600, Tk Soh <r28629@email.sps.mot.com> says...
> Yogish Baliga wrote:
> > You can print using printf "%c", $letter
> >
> > Jean-Gael Gricourt wrote:
> >
> > > I got a variable which contains the Ascii code of a letter for
> > > the alphabet: $letter=\x47; which represents the letter 'G'
>
> No, you can't. Please make sure you understand both the question and
> your answer before posting.
>
> $letter is a ref to (bareword) 'x47'. 'printf "%c", $letter' convert
> $letter to number (from a ref), and print the char based on the least
> significant value of the number.
>
> Of course it wouldn't even compile if you had 'use strict' in the first
> place.
Oh, come on, Tk! What does the bareword 'x47' have to do with the
letter 'G'? If *you* understand the question, you should be able to
infer that Jean-Gael meant to write this:
$letter=0x47; which represents the letter 'G'
Yogish understood both the question and his answer.
printf "%c", $letter;
is a quite viable (though about 20% slower) alternative to
print chr $letter;
Perhaps you owe him a small apology for flaming him unjustly.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 23 Nov 1998 15:29:17 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: htpasswd source code (+ crypt)
Message-Id: <comdog-ya02408000R2311981529170001@news.panix.com>
In article <73c4pd$3pr3@Talisker.taide.net>, "Andrew Chapas" <aka@takas.lt> posted:
> Need source code for Java of Unix htpasswd utility (together with crypt.c)
>
> Together with "crypt()" source code.
why not just look at the C source that comes with Apache?
ah, never mind. you're using a PoB system.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
a java question in a perl newsgroup with a C answer
------------------------------
Date: Mon, 23 Nov 1998 21:00:54 +0100
From: Bernd Nies <bnies@hsr.ch>
Subject: Q: Parents and childs
Message-Id: <3659BEF6.5F7A2F76@hsr.ch>
Hi,
How can I check (without blocking with wait) from
the parent process whether the forked child is still
running or not?
Thanks in advance,
Bernd
_
_____ | | ___________________________________________
\__ \| | Bernd Nies bernd.nies@astroinfo.org
/ __ \\| Chindismuelistr.6 http://www.astroinfo.org
(____ /_ CH-8626 Ottikon
\/\/
------------------------------
Date: Mon, 23 Nov 1998 21:13:03 +0100
From: Bernd Nies <bnies@hsr.ch>
Subject: Re: Q: Parents and childs
Message-Id: <3659C1CF.8C208F1A@hsr.ch>
Re: Q: Parents and childs
^
"Children" ... sorry! Need more sleep. %-)
------------------------------
Date: Mon, 23 Nov 1998 21:12:40 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Q: Parents and childs
Message-Id: <F2w894.9Ky@world.std.com>
Bernd Nies <bnies@hsr.ch> writes:
>How can I check (without blocking with wait) from
>the parent process whether the forked child is still
>running or not?
You can either use kill with the special signal "0" to test for the
existance of process without actually sending one, or you can use
"waitpid" with the "WNOHANG" argument to do a non-blocking wait.
--
Andrew Langmead
------------------------------
Date: Tue, 24 Nov 1998 09:06:32 +1200
From: Scott Searle <scott.searle@noway.nz>
Subject: Re: The dumbest question ever - HELP!!!
Message-Id: <3659C048.F2342C20@noway.nz>
=:-)
Michael,
Any text editor means that. As long as you can save the files in plain
ascii, you'll be alright. When I am writing perl code under win32, I
use a port of vi to win32. I would recommend not using this if you are
having problems figuring out what to write you perl scripts in. I'd say
the best would be to use notepad because it doesn't do any of the fancy
formatting or anything like that.
When you save under notepad, it has a nasty habbit of adding ".txt" to
whatever you specify as the filename. Just put the name of the file in
quotes "hello.pl" for example. To execute, be sure you've got you path
to point to the perl interpreter and just type either perl hello.pl, or
hello.pl (the last works only if you have registered the extension .pl
with the windows registry).
Hope this helps!
Cheers,
Scott
-------------------------------------------
Scott Searle - Wholesale UNIX Support
National Bank of New Zealand Limited
Ph: +64 4 382 7841 Fax: +64 4 802 2356
email: scott.searle@nbnz.co.nz
Michael Hamilton wrote:
>
> I thought I'd post this question before I put my fist through the
> computer screen.
>
> In the O'Reilly book on Perl for Win32 it gives the "Hello World"
> example.
>
> Its say to type - print ("Hello World"/n); - into any text editor and
> then invoke the proram. Easy right. Well I can't do it.
>
> 1. By "any text editor" does it mean something like WordPad or the
> little black screen you get when you double-click Perl.exe
>
> 2. How do you invoke it. I have tried to associate .plx file with the
> Perl.exe program, but I don't know if I have done it right.
>
> Could some kind person take pity on an idiot like me and give me an
> idiots step-by-step guide to where to write the code and how to run it.
>
> Thanks
------------------------------
Date: 23 Nov 1998 19:48:39 GMT
From: lvirden@cas.org
Subject: Re: Unified Scripting Environment? Re: A Smaller Tcl - S2K?
Message-Id: <73ce6n$gge$1@srv38s4u.cas.org>
In related topics, check out
<URL:http://nirvana.userland.com/tickets/stories/ticketReader$11>
or even, if you ignore the fact that his facts about unix users are
obviously bogus,
<URL:http://www.scripting.com:80/davenet/98/11/howWindowsDeveloperThinks.html>
--
<URL:mailto:lvirden@cas.org> Quote: Saving the world before bedtime.
<*> O- <URL:http://www.purl.org/NET/lvirden/>
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
------------------------------
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 4281
**************************************