[7929] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1554 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 30 22:07:46 1997

Date: Tue, 30 Dec 97 19: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           Tue, 30 Dec 1997     Volume: 8 Number: 1554

Today's topics:
     Re: 100.90  NOT  100.90000000000000568   HELP (M. S. Sriram)
     Re: bug? (was: Bitwise XOR (^) doesn't work on strings? <rootbeer@teleport.com>
     Re: cgi script for binary images <rootbeer@teleport.com>
     CGI y comandos SSI <nicolasr@arrakis.es>
     E-mail address formatting. Newbie question <Hendrik.Klompmaker@net.iend.wau.nl>
     Re: E-mail address formatting. Newbie question <rootbeer@teleport.com>
     Re: flock v.s. Sun OS <rootbeer@teleport.com>
     Re: How to get unique list value (Terry Michael Fletcher - PCD ~)
     Re: How would you do this... (John Stanley)
     importing subroutines <jrt@llnl.gov>
     Re: Is Serial I/O possible in PERL? <tchrist@mox.perl.com>
     Re: Mysterious FileHandle + fork() behavior; possible P <rootbeer@teleport.com>
     Need help hand-coding an HTTP POST request <chris@ixlabs.com>
     Novice needs advice <KE4FOM@TECHNOLOGIST.COM>
     Re: Novice needs advice <rootbeer@teleport.com>
     Re: Perl 5 and Win95 <rootbeer@teleport.com>
     Re: Perl editor needed (Jeff R. Stone)
     problem when Perl abends WIN32 <NoSpam/w6089@cloudnet.com>
     Re: Removing "last" reference to an Object <rootbeer@teleport.com>
     Re: Substitute variables when reading file (William R. Ward)
     Re: Tech writer lifts burden from programmers <rootbeer@teleport.com>
     Testing for null and spaces (Andy Squires)
     Re: UNINITIALIZED VALUE at TIE (%HASH.... <rootbeer@teleport.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 30 Dec 1997 20:04:58 -0500
From: sriram@maps.tempo.bell-labs.com (M. S. Sriram)
Subject: Re: 100.90  NOT  100.90000000000000568   HELP
Message-Id: <k2hd8iewced.fsf@maps.tempo.bell-labs.com>

hermit@cats.ucsc.edu (William R. Ward) writes:

> You're right, that is actually faster.  I came up with the arithmetic
> method because I thought it would be faster, but apparently it isn't.
> Here's the results using Benchmark to time:

	It also seems to depend on whether the result is to be used in
numeric or string context --- s/\"&round/\"0 + &round/g to more than
triple the execution times ...

> timethese(100000, {'sprintf' => "&round_sprintf",
>                    'arith' => "&round_arith" });

- Sriram


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

Date: Tue, 30 Dec 1997 17:39:57 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Jack H. Ostroff" <jack_h_ostroff@groton.pfizer.com>
Subject: Re: bug? (was: Bitwise XOR (^) doesn't work on strings?)
Message-Id: <Pine.GSO.3.96.971230173534.7945V-100000@user2.teleport.com>

On Mon, 29 Dec 1997, Jack H. Ostroff wrote about my docpatch:

> I am still unclear about one point in the last few paragraphs

Then clearly I have work left to do. :-)  (I have other people's
suggestions waiting to be integrated, I hope within the next week.)

> > +If you are intending to manipulate bitstrings, you should be certain that
> > +you're supplying bitstrings: If an operand is a number, that will imply
> > +a B<numeric> bitwise operation. You may explicitly show which type of
> > +operation you intend by using C<""> or C<0+>, as in the examples below.
> > +
> > +    $foo =  150  |  105 ;      # yields 255  (0x96 | 0x69 is 0xFF)
> > +    $foo = '150' |  105 ;      # yields 255
> > +    $foo =  150  | '105';      # yields 255
> > +    $foo = '150' | '105';      # yields string '155' (under ASCII)
> > +
> > +    $baz = 0+$foo & 0+$bar;    # both ops explicitly numeric
> > +    $biz = "$foo" ^ "$bar";    # both ops explicitly stringy

> Do the bitwise logical operators ALWAYS produce integral results?  The
> fourth foo example implies that the result is string if both operands
> are strings. 

If you give strings, you get strings. If either operand is a number, the
result is an integer.

> the comment on integral results might be expanded to say
> what they do if the operands are not integral. 

Good idea. Thanks!

-- 
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: Tue, 30 Dec 1997 18:01:28 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: sam wong <skwong@slip.net>
Subject: Re: cgi script for binary images
Message-Id: <Pine.GSO.3.96.971230175854.7945Y-100000@user2.teleport.com>

On Tue, 30 Dec 1997, sam wong wrote:

> I'm running into a problem having a perl cgi script send a adobe pdf
> file to the browser, the browser receives the header and launches
> acrobat reader, but the acrobat reader complains about no data in
> document.  

Sounds as if you're not properly using the protocol. If you can't find
your error after you've read the docs about the protocol you're using, you
may ask in a newsgroup about that protocol. 

>    open (BL, "6341258.pdf");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

Thanks!

-- 
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: 31 Dec 97 01:27:15 GMT
From: "NICOLAS" <nicolasr@arrakis.es>
Subject: CGI y comandos SSI
Message-Id: <01bd158b$e4511b40$754f05c3@xxx>

Pregunta:
Para hacer que un CGI se ejecute automaticamente al cargar una pagina WEB
se consigue, mediante el uso de comandos SSI,  de la forma:

<!--#EXEC CGI="cgi-bin/fichero.cgi"-->               

el problema es que el 'fichero.cgi' requiere un parametro y al hacer la
llamada de la forma:


<!--#EXEC CGI="cgi-bin/fichero.cgi?parametro"-->               

da un mensaje de error

?Como se puede pasar un parametro al CGI ?
?Existe otra forma de hacer que se auto-ejecute el CGI al cargar la pagina
WEB?

Gracias por vuestra ayuda y Feliz 1998




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

Date: Wed, 31 Dec 1997 01:46:37 +0100
From: Hendrik Klompmaker <Hendrik.Klompmaker@net.iend.wau.nl>
Subject: E-mail address formatting. Newbie question
Message-Id: <34A995ED.94E8DD23@net.iend.wau.nl>

Hi,

I'm new to perl so this might be a faq although I couldn't find specific
in fo about it.
I have a string that needs to be formatted to correct e-mail adresses
like <hendrik.klompmaker@net.iend.wau.nl> or
"Hendrik Klompmaker" <hendrik.klompmaker@net.iend.wau.nl>.
The string might also have multiple adresses seperated by a ','
Is there a way to format this string into the correct way independent of
the user inputs.
Thus if the user types "Hendrik Klompmaker"
<hendrik.klompmaker@net.iend.wau.nl>
no modifications are needed. Neither if
<hendrik.klompmaker@net.iend.wau.nl> is typed but
hendrik.klompmaker@net.iend.wau.nl needs the < and >
So I'm looking for something that looks for the @ sign and check if it
has a < and > before and after the word. If not then inserts it.

TIA

Hendrik

PS. Please (also) repond by e-mail as I'm not a regualr reader of this
news group.

--
-----------------------------------------------------------------
|************** Wageningen Agricultural University. ************|
|  Department of Information Management and Datacommunication   |
-----------------------------------------------------------------
Hendrik Klompmaker: Senior Technologist
Internet          : Hendrik.Klompmaker@Net.IenD.Wau.Nl
X400              : c=nl;a=400net;p=surf;o=wau;ou1=IenD
                  : ou2=Net;s=klompmaker;gi=hendrik
Phone             : +31 (0)317-484059
Fax               : +31 (0)317-482970
Snail             : Dreijenplein 2
                    6703 HB Wageningen / The Netherlands
--------------------------------------------------------




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

Date: Tue, 30 Dec 1997 18:29:58 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Hendrik Klompmaker <Hendrik.Klompmaker@net.iend.wau.nl>
Subject: Re: E-mail address formatting. Newbie question
Message-Id: <Pine.GSO.3.96.971230181650.7945d-100000@user2.teleport.com>

On Wed, 31 Dec 1997, Hendrik Klompmaker wrote:

> I have a string that needs to be formatted to correct e-mail adresses
> like <hendrik.klompmaker@net.iend.wau.nl> or
> "Hendrik Klompmaker" <hendrik.klompmaker@net.iend.wau.nl>.

I don't know why you want to correct them. Those look fine to me. :-) 

> The string might also have multiple adresses seperated by a ','

> Is there a way to format this string into the correct way independent of
> the user inputs. 

Not in general - if the user inputs "@ foo fizzbargle", there's no good
way to correct that! :-) 

> Thus if the user types "Hendrik Klompmaker" 
> <hendrik.klompmaker@net.iend.wau.nl> no modifications are needed.

Okay...

> Neither if <hendrik.klompmaker@net.iend.wau.nl> is typed

Right...

> but hendrik.klompmaker@net.iend.wau.nl needs the < and > 

Okay, that's easy to add, once you've parsed the address. 

> So I'm looking for something that looks for the @ sign and check if it
> has a < and > before and after the word.

Like here?

    "fred<@>barney"@redcat.com

(Be careful not to assume too much about an email address. That one is a
valid address; send it some mail!) I think you want to actually parse the
addresses according to the standard, RFC822. Then you can work with them
properly. 

    http://ds.internic.net/rfc/rfc822.txt

If there isn't a module to do this, there should be. 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: Tue, 30 Dec 1997 17:29:44 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: John Bokma <john@castleamber.com>
Subject: Re: flock v.s. Sun OS
Message-Id: <Pine.GSO.3.96.971230172500.7945U-100000@user2.teleport.com>

On 29 Dec 1997, John Bokma wrote:

> > Did your perl binary pass all of the 'make test' tests when it was
> > compiled?
> 
> I run this code on a system to which I don't have root access and
> I didn't (can't) compile perl on it. 

You may need to ask a system administrator to help you to run the tests or
to recompile perl. 

> > did you try installing Randal's original code to see
> > whether the same problem occurs?
> 
> No, but the important part, i.e. the file locking is the same.

I trust that you were careful, but it would be easy to do something wrong.
For example, if you used the wrong constants, that would be a problem.

> The flock isn't working, the rest of the code is not the problem.

Well, let's test flock and find out for sure. I'm appending a test script; 
what does it do for you? 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!

#!/usr/bin/perl -w

use strict;
use Fcntl qw(:flock);

my $filename = $0;

$| = 1;

my $fork_count = 3;	# Make three children
# (Total number of processes is one larger.)

my @children;
for (1..$fork_count) {
    my $pid = fork;
    unless (defined $pid) {
	print "Harmless fork error: $!\n";
	sleep 1;
	redo;
    }
    last if $pid == 0;
    push @children, $pid;
}

open T, "+<$filename" or die "Can't open '$filename': $!";

print "\n($$): About to lock $filename!\n";
flock T, LOCK_EX or die "Can't lock: $!";
sleep 1;	# just to let the IO catch up
print "($$): Lock acquired...";
for (reverse ('Boom!', 1..3) ) {
    sleep 1;
    print " $_ "; 
}
print "\n($$): Unlocking $filename!\n";
close T;
# Wait for the kids
for (@children) {
    waitpid $_, 0;
}
exit;

__END__



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

Date: 31 Dec 1997 01:27:06 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: How to get unique list value
Message-Id: <68c71a$l3d$1@news.fm.intel.com>

Joseph N. Hall (joseph@5sigma.com) so eloquently and verbosely pontificated:
> Here's the grep-free, temporary-free version from my book:
> 
>   @uniq = sort keys %{ { map { $_, 1 } @list } }
> 

i thought using a hash slice (mmm, tasty) seemed pretty cool:

 @uniq = keys %{ local @temp{@list} = @list; \%temp };

but i can't get rid of the %temp hash.  anyone know how to declare an
anonymous hash slice?  it seems there's no way to tell perl that the curly
braces are actually indexing a hash, without naming the hash.  too bad
this doesnt work:

 @uniq = keys %{ { ->{@list} = @list } };

or this:

 @uniq = keys %{ ({}->{@list}) = @list };

oh well!

-- 
#!/usr/local/bin/perl -w- tfletche@pcocd2.intel.com
sleep 1;$"=(time-$^T)<<1;$SIG{ALRM}=sub{print};${q$_$}=join"",
map{chr(hex)}split/(..)/,"4a75737420";alarm$";<>;s y(\0\w){4}.
?yreverse q brehtonabyex;alarm$";<>;for(;length>4;chop){}tr&to
an&empti&;alarm$";<>;s@$_@reverse',ret'.q csaw c@e;alarm$";<>;


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

Date: 31 Dec 1997 01:36:22 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: How would you do this...
Message-Id: <68c7im$ppl$1@news.orst.edu>

In article <34A821AE.6B49036@mystech.com>,
Mark S. Reibert <reibert@mystech.com> wrote:
>As for your solution, great if one is on UNIX, but many persons on this NG are
>Windows based. NT has a command-line sort routine, but I'm not sure if Windows
>4 (er, uh, 95) does.

I am amazed at those who will happily run one piece of free software on
their PC but refuse to believe that there might be another piece of free
software available.



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

Date: Tue, 30 Dec 1997 18:06:36 -0800
From: John Tannahill <jrt@llnl.gov>
Subject: importing subroutines
Message-Id: <34A9A8AB.9632C2B7@llnl.gov>

I have just spent quite a while trying to figure out how to call a perl
subroutine that is
in one file from a perl program in another file.  I have tried various
"use" commands,
but I keep getting the following error message:

Undefined subroutine &main::seait ...

There must be a simple way to do what I want?

Thanks,
John Tannahill
 
 



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

Date: 31 Dec 1997 00:31:49 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Is Serial I/O possible in PERL?
Message-Id: <68c3pl$2ap$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, fletcher@paccar.com (Arlen Fletcher) writes:
:I need to communicate with a weather station via RS232.  I wasn't able to
:find any modules on CPAN that fit the bill...  Is serial I/O do-able in 
:PERL?

As opposed to what, asynchronous DMA block transfers? :-)

Certainly.  This is talked about in the FAQ.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    You can't set a breakpoint on a subroutine that hasn't been
    defined yet (yet).  This is a topic for ongoing research...  :-)
	--Larry Wall in <1994Feb25.192042.17196@netlabs.com>


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

Date: Tue, 30 Dec 1997 16:01:06 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Allen Chen <achen@nssdc.gsfc.nasa.gov>
Subject: Re: Mysterious FileHandle + fork() behavior; possible Perl bug?
Message-Id: <Pine.GSO.3.96.971230152939.7945L-100000@user2.teleport.com>

On Tue, 30 Dec 1997, Allen Chen wrote:

> As I understand it, after a fork, the child process gets a duplicate set
> of the parent's file descriptors which point to the exact same file
> table entries.  So even if I *did* use the filehandle in the children,
> the file pointer should have the same offset throughout every process
> and not cause any problems. 

I'm not sure, but you may be right. Here's what I find in the manpage for
fork(2) on my system.

          o The child process has its own copy  of  the  parent's
            file  descriptors and directory streams.  Each of the
            child's file descriptors shares a common file pointer
            with the corresponding file descriptor of the parent.

As I understand that, the child process could mess up the parent's copies
of the data. But my understanding of such things is less than total... :-)

> I wonder, again, if this could be some kind of bug in Perl...

Not likely. :-)  But I'm appending a simple test case which shows the
behavior (on my system). Let's see if anyone reading along in the
newsgroup can tell us whether the problem is in Perl or in the code below! 

-- 
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!

#!/usr/bin/perl -w

use strict;
my $filename = $0;
open FILE, "<$filename" or die "Can't open file '$filename': $!";
my $count = 0;

while (<FILE>) {
    print "$.. $_";
    last if $count++ > 25;
}

my $pid;
{
    if (not defined($pid = fork) ) {
	# Probably harmless fork failure
	sleep 1; redo;
    }
}

if ($pid) {
    # parent process here
    print "$.. Parent: $_" while <FILE>;
    exit;
} else {
    # child process here
    print "Child here\n";
    seek FILE, 0, 0 or warn "Can't seek: $!";
    exit;
}

__END__



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

Date: Tue, 30 Dec 1997 15:58:44 -0800
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: Need help hand-coding an HTTP POST request
Message-Id: <34A98AB4.57E6@ixlabs.com>

Hi I recently got the SSL-Leay/LWP bridge up and running and now can
create SSL Sockets with it.

My next task is to perform POST submissions to an SSL webserver. I have
had a hard time finding easily replicable examples of this, however (I'm
so used to having LWP do it for me!).

I came up with this:

POST /cgi-bin/theprogram.exe/W024/NJD0/?VId=00?KrId=0 HTTP/1.0
Content-type: text/plain
Content-length: 19
RF.FED.02=1st Page

But I got the response:
Server: Netscape-Enterprise/3.0
Your browser sent a message this server could not understand.

Analysis:

Line 1: Now the URL, although quite odd looking, is correct - I pasted
it right from the source. I used HTTP/1.0 for lack of a better idea.
Does HTTPS idendify itself as HTTPS? I figured it is unimportant at this
point since it is the socket which is encrypted. If I should put
something else, please let me know. 

Line 2: I didn't URL-encode this, so I put text plain. I also tried
URL-encoding the POST data and used x-www-form-url-encoded but that
didn't work either. Do I need to URL encode the URL and POST data? 

Line 3: Accurate. I THink I got this right.

Line 4: Here is the key-value pair. Again, does this need to be
URL-encoded? I did it once but it made no difference.


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

Date: 31 Dec 97 01:48:54 GMT
From: "David Perdue" <KE4FOM@TECHNOLOGIST.COM>
Subject: Novice needs advice
Message-Id: <01bd158a$43fbfda0$010000c0@perdue>


I'm trying to learn CGI programming. To that end I decided to *attempt* to
teach myself Perl. Assume no previous programming experience.

In this short script, I'm attempting to learn how to use filehandles. I
getting some data (one record per loop), and trying to write each record to
a file.  Here it is:

#!/usr/bin/perl
$cont = "y";
open(LIST,">>listfile");
while ($cont eq "y")
   {
     print "Please Enter Fname: ";
     $fname = <STDIN>;  
     chop($fname);
     print "Please Enter Lname: ";
     $lname = <STDIN>;
     chop($lname);

     $ARR{$fname} = $lname;

     print "would you like to Continue? ";
     $cont = <STDIN>;
     chop($cont);
   }
while (($FST,$LST) = each(%ARR))
      {
       print(LIST "$FST:$LST");  #  write the record   
      }
close(LIST);

The problem I have is that the only record written to the file is the last
record entered.
If I change the last loop to:

while (($FST,$LST) = each(%ARR))
   {
print(LIST "$FST:$LST\n");     
close(LIST);
open(LIST, ">>listfile");
    }
All the records are now written to the file one record per line as I
intended. this seems like an awfully sloppy way to accomplish this. any
suggestions?

Thanks, --dp


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

Date: Tue, 30 Dec 1997 18:41:09 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: David Perdue <KE4FOM@TECHNOLOGIST.COM>
Subject: Re: Novice needs advice
Message-Id: <Pine.GSO.3.96.971230183116.7945h-100000@user2.teleport.com>

On 31 Dec 1997, David Perdue wrote:

> Subject: Novice needs advice

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> open(LIST,">>listfile");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

> while ($cont eq "y")

Although there's nothing wrong with this, it's more Perlish to use the
'last' and 'next' operators to control a loop. In this case, you could
loop until an empty string is entered for the first name, for example, and
that would make the text entry faster.

> The problem I have is that the only record written to the file is the 
> last record entered.

That doesn't happen for me when I run your code, although I did add a
newline to the print statement in the loop. Could you check again to see
whether this works for you? 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: Tue, 30 Dec 1997 18:06:52 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "G. Helms" <amazon@wenet.com>
Subject: Re: Perl 5 and Win95
Message-Id: <Pine.GSO.3.96.971230180522.7945a-100000@user2.teleport.com>

On Tue, 30 Dec 1997, G. Helms wrote:

> I'm finding lots of downloads for Perl on Win32, and I've been told
> Win32==Win95....

Yes....

> yet another doc I've found says that Perl has problems with Win95, and
> one has to hand-edit several files to get it to function.

That sounds as if it's talking about compiling it yourself, which you
shouldn't need to do.

> The other issue is, I'd prefer to snag the binary version,
> as I don't have any development compilers on this system.

Getting the binary is a good idea. Use Sarathy's, which you can find on
CPAN. 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: 30 Dec 1997 21:06:07 -0500
From: jstone@america.net (Jeff R. Stone)
Subject: Re: Perl editor needed
Message-Id: <x6lnx2gtbk.fsf@stone.america.net>



>>>>> "scott" == scott  <scott@softbase.com> writes:

[snip]

    scott> Emacs is the best all around editor for programming.  Its
    scott> drawback is you have to learn how to use it, which puts off
    scott> a lot of people who don't want to bother with this kind of
    scott> thing. Learning Emacs is a good investment in your
    scott> programming career, though, since it is available on most
    scott> platforms and has an unmatched degree of advanced editing.

Emacs does have a steeper learning curve than most people are
accustomed to.  However, it pays big dividends in the long run.

[snip]

    scott> Note: Even if you use Emacs, it has pitiful printer support
    scott> in Windows, so PFE or Multi-edit is nice to have for
    scott> printing.

Actually, I think Emacs prints fine from Windows.  It just doesn't
integrate with Windows' own printer drivers and requires a lot of
initial configuration.  If you have a PostScript printer, Emacs can
print right to it (even on a network).  If you don't have a PostScript
printer the output can be filtered thru the Win32 version of
GhostScript and then sent on its way to the printer.  2-up printing,
printing with faces, printing in color, and other common output
requirements are all supported.

Jeff

- -- 
Jeff R. Stone <jstone@america.net>
PGP Key:     http://www.america.net/~jstone/
Fingerprint: A6 70 4D 2E A1 F9 CF 08 58 96 A9 45 0A 06 99 59


Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBNKmoiVyDISb92kqpAQGSXQP/eynYPWMmIZVCreHfZ3C6pe0agNQbgXdV
O/+jCpDVLC5OGkcMPp3nf3HKmPi0Fd5NJFCWx5bXzCEEEhQfSHS5tz452kBo0iKi
8nYni4UcoeyfEaOsRcWRQJ1CEUNo/kTu1bPyDHKafXxGRxgKN79oSc+jvcx/6QS9
IXYAWHeVDw4=
=LCeQ
-----END PGP SIGNATURE-----


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

Date: Tue, 30 Dec 1997 20:23:04 -0600
From: <NoSpam/w6089@cloudnet.com>
Subject: problem when Perl abends WIN32
Message-Id: <34a9aaa8.0@news.cloudnet.com>

I wrote a program that was on the way toward
using up all my disk space.
I Killed the program, but by did not
release the disk space.
Before the program I had 3/4 of
a gigabyte. afterward I had about
5 megabytes.
I deleted what I thought was the
file created. it used 0 bytes.
I even deleted everything in
the temp directory after
rebooting.
I've rebooted about 4 times.
and still all this disk space
is still held.
I'm thinking I'm going to have to
reinstall the operating system
top get it all back. I shouldn't
have to do this.
Can anyone out there, please,
help me?
Thank you
Dennis Woolsey
w6089@cloudnet.com





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

Date: Tue, 30 Dec 1997 18:04:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mark Kahn <mkahn@vbe.com>
Subject: Re: Removing "last" reference to an Object
Message-Id: <Pine.GSO.3.96.971230180311.7945Z-100000@user2.teleport.com>

On Tue, 30 Dec 1997, Mark Kahn wrote:

> How do I release memory allocated to the object that the "previous" 
> record's ref points to? 

In Perl, you never release memory directly. But perl will recycle the
memory when you no longer have any use for it. In the case of objects, in
most cases you should simply discard your reference to the object. 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: 30 Dec 1997 15:53:12 -0800
From: hermit@cats.ucsc.edu (William R. Ward)
Subject: Re: Substitute variables when reading file
Message-Id: <waaafdi2xsn.fsf@ese.UCSC.EDU>

neal@valinet.com writes:
> I have a Perl program which opens up a text file, and in this text file
> there are $variables.  How can I get Perl to map these
> $variables without explicity mapping each one.
> For example,
> 
> Here's my Perl file;
> $name = "Neal";
> open (FILE, "file.txt");
> while (<FILE>) {
>   print "$_";
> }
> 
> ----------file.txt-------
> Hi, my name is $name
> -------
> 
> The output would be "Hi, my name is $name." BUT, I want it to be
> "Hi, my name is Neal."
> 

The way I approach this problem is usually something like this.
1. Put the variables you want to substitute into a hash:
  %vars = (name => Neal,
	   email => neal@valinet.com,
	   ...etc...
	  );

2. Figure out some easy syntax for the substitution.  I usually use
@@KEYWORD@@ since that is very unlikely to appear normally.  Using
$KEYWORD as you suggest is bad becuase it makes it basically
impossible to have a $ sign in your file for any other purpose (like
listing a dollar amount, for example.

3. Do the substitution like this:
my $filename = 'file.txt';
open(FILE, $filename) or die "Can't read $filename: $!\n";
while(<FILE>) {
  s/@@([\w_]+)@@/$vars{$1}/g;
  print;
}
close(FILE);

A couple of other notes:
  1. Put the filename in a variable; you'll probably want to change it
sometime.
  2. Always check the return code from open().
  3. print with no arguments prints $_, and you shouldn't put double
quotes around a plain variable: it's superfluous.

HTH.

--Bill.

[posted and mailed]

-- 
William R Ward          Bay View Consulting   http://www.bayview.com/~hermit/
hermit@bayview.com     1803 Mission St. #339        voicemail +1 408/479-4072
hermit@cats.ucsc.edu  Santa Cruz CA 95060 USA           pager +1 408/458-8862
 PGP Key 0x2BD331E5; Public key at http://www.bayview.com/~hermit/pubkey.txt


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

Date: Tue, 30 Dec 1997 17:52:53 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "James C. Hoffman" <tdsjms@ix.netcom.com>
Subject: Re: Tech writer lifts burden from programmers
Message-Id: <Pine.GSO.3.96.971230175138.7945X-100000@user2.teleport.com>

On Tue, 30 Dec 1997, James C. Hoffman wrote:

> Hi-I'm a technical writer that can help you with your online help
> systems and end-user documentation needs.

Great! The Perl docs are available online, and the documentation is a
neverending task. Please submit your documentation patches using the
perlbug program which comes with Perl. Thanks!

-- 
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: Wed, 31 Dec 1997 01:03:06 GMT
From: asquires@netcom.com (Andy Squires)
Subject: Testing for null and spaces
Message-Id: <asquiresEM1497.F80@netcom.com>

I'm trying to test whether or not a variable is blank or null and can't figure out why the following doesn't work.

str1="     ";

if(str1=~ /^\s*$/) {
    print "The field does not contain data\n";
} else {
    print "The field does contain data\n";
}

Sorry if this is a nuby question, but I couldn't seem to figure it out from the FAQ or the man pages.

I appreciate any help.

Thanks,

Andy


-- 
| Andy Squires                  "The trouble with life is
| asquires@netcom.com         there's no background music."
| Web Page is at http://www.announce.com/~asquires/andy.html



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

Date: Tue, 30 Dec 1997 17:49:21 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Gil Vidals <vidals@etica-entertainment.com>
Subject: Re: UNINITIALIZED VALUE at TIE (%HASH....
Message-Id: <Pine.GSO.3.96.971230174655.7945W-100000@user2.teleport.com>

On Mon, 29 Dec 1997, Gil Vidals wrote:

> The following line generates an "uninitialized value" error when
> compiling with "use strict" and "perl -w" in Perl 5.004.
> 
> tie (%HTML, "GDBM_File", $dbfilename, O__RDONLY, undef)
>     or die "Can't open $dbfilename $!";

I think you may need to file a bug report if it's truly complaining about
the valid parameter 'undef'. But, in the meantime, you can wrap your code
like this to avoid the message. 

    {
	local($^W);
	tie (...);
    }

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: 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 1554
**************************************

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