[6403] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 28 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 28 01:10:07 1997

Date: Thu, 27 Feb 97 22:00:20 -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           Thu, 27 Feb 1997     Volume: 8 Number: 28

Today's topics:
     Re: Delayed variable interpolation in string question (Tad McClellan)
     Re: File Locking (Nathan V. Patwardhan)
     Re: Filehandle: open(FILE) while{} close(FILE) <wkuhn@uconect.net>
     Re: Help: "! File contains no data" prompt (Nathan V. Patwardhan)
     Re: Help: "! File contains no data" prompt (Tad McClellan)
     How to delete a line from an array? (Lee Johnson)
     Re: How to delete a line from an array? (Dave Thomas)
     How to use HTML.pm in NT? bz7328113@gamma.ntu.ac.sg
     If you know perl this should be simple (Geoffrey Hebert)
     Re: Newsflash: Progressive Networks' RealMedia Conferen (Mike Heins)
     Re: Newsflash: Progressive Networks' RealMedia Conferen (Tad McClellan)
     Re: Optimizing nested loops <wkuhn@uconect.net>
     Re: Question on "eval" <billc@tibinc.com>
     Re: Question on "eval" <billc@tibinc.com>
     read/write file contents(new programmer) <zrnaqvi@mailbox.syr.edu>
     Re: Regular Expressions problem please help! <dbenhur@egames.com>
     Re: Regular Expressions problem please help! (Tad McClellan)
     Removing Tempfiles - a solution (Ken Williams)
     Re: Removing Tempfiles - a solution <baku@india.ti.com>
     Re: Returning a reference to a 'my' variable <tchrist@mox.perl.com>
     Re: Returning a reference to a 'my' variable <wkuhn@uconect.net>
     Re: Returning a reference to a 'my' variable <roderick@argon.org>
     Re: Scoping problem using my() [kinda long] (Dave Thomas)
     Sending SNMP traps from Perl <davidm@aus.hp.com>
     simple cgi perl question <dbowen@mtco.com>
     Re: sometimes > not greater than? <billc@tibinc.com>
     UCE, spam, Andreessen (was: Re: Newsflash...) (Tad McClellan)
     Re: Win95 can't always do this! ( Was: Re: Perl on Wind (Nathan V. Patwardhan)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Feb 1997 22:21:02 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Delayed variable interpolation in string question
Message-Id: <efm5f5.r71.ln@localhost>

Herschel Goldstein (herschel@waterw.com) wrote:
: The following script works, but seems to lack that perl prettiness (the eval
: line has backslash disease).

: $x = "The answer is \$y\n";		# don't interpolate $y here
: $y = 10 * 23 + 6;			# set $y here
: eval "print \"$x\"";			# now interpolate it


eval qq(print "$x");


: Mindful of the multitude of methods perl possesses, there should be another
: way. If it's in the faq, sorry, the pages loaded unbearably slowly.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 28 Feb 1997 04:27:55 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: File Locking
Message-Id: <5f5msb$8u@fridge-nf0.shore.net>

Abigail (abigail@ny.fnx.com) wrote:

: Isn't that dangerous? Another process can create the file
: right after your if, but before you open it.

Yeah, I should have thought of that.  :-)

: How about:
: -e $file or system "touch $file" and die "Oops: " . $? >> 8;
: open FILE, "+< $file" or die "Oops: $!";

If one is on Unix, yes, although there is a freeware version of touch
floating around the Virtually Unix site.  With all these questions about
Windows 95 recently, I've been using Windows (ick!) for an hour a week and
trying out all these ported apps.

--
Nathan V. Patwardhan
nvp@shore.net
"What is your favorite color?
Blue ... I mean yellow ... aieeeee!
	--From the Holy Grail"


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

Date: Thu, 27 Feb 1997 20:34:45 -0500
From: Bill Kuhn <wkuhn@uconect.net>
Subject: Re: Filehandle: open(FILE) while{} close(FILE)
Message-Id: <33163635.3023DFA3@uconect.net>

Jonathan Peterson wrote:
[snip]
> The $line = <INFILE>; will slurp the whole file into one scalar.
[snip]
Just one minor correction:
  $line = <INFILE> will only read a single line since $line is a
scalar.  If you do @lines = <INFILE> then the entire file will be
slurped into the array @lines.  Very bad for large files...

-Bill
-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: 28 Feb 1997 04:31:03 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Help: "! File contains no data" prompt
Message-Id: <5f5n27$8u@fridge-nf0.shore.net>

Keith Warner Colvin (colvin@aloha.net) wrote:

: My .cgi is running fine, yet when I access the file "...page=number.shtml&cart__id" 
: I get this response:
[snip]

: Any suggestions from those who know more?

Yes.  Post CGI questions to comp.infosystems.www.authoring.cgi.  You'll
get the best, detailed responses from groupmembers, and from the archives
at http://www.dejanews.com.

--
Nathan V. Patwardhan
nvp@shore.net
"What is your favorite color?
Blue ... I mean yellow ... aieeeee!
	--From the Holy Grail"


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

Date: Thu, 27 Feb 1997 22:42:17 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help: "! File contains no data" prompt
Message-Id: <9nn5f5.ce1.ln@localhost>

Keith Warner Colvin (colvin@aloha.net) wrote:
: Aloha from Hawai'i,

: My .cgi is running fine, yet when I access the file "...page=number.shtml&cart__id" 
: I get this response:

: "! File contains no data"
   ^^^^^^^^^^^^^^^^^^^^^^^

This is not a perl error message.


: Any suggestions from those who know more?


The ones who know more about CGI aren't in the Perl newsgroup.

They are in the CGI newsgroup:

comp.infosystems.www.authoring.cgi


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 28 Feb 1997 03:23:44 GMT
From: ljohnson@isys.ca (Lee Johnson)
Subject: How to delete a line from an array?
Message-Id: <5f5j40$o0v@nr1.ottawa.istar.net>

I would like to do something like:
delete @array[0] 

Is there a way to to this?

Also, what about deleting the last line of an array when you don't know 
how many lines are in the array?  I would like to do something like:

($ipaddress, $password, $number, $logdate, $logtime, 
$logtype, $inorout, $name) = split(/\:/, $matches[lastline]);

if ($inorout eq 'login') {
 delete $matches[lastline];
 ...

Any help would be appreciated.

Thanks;
Lee Johnson
ljohnson@isys.ca


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

Date: 28 Feb 1997 03:57:06 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: How to delete a line from an array?
Message-Id: <slrn5hcllv.b16.dave@fast.thomases.com>

On 28 Feb 1997 03:23:44 GMT, Lee Johnson <ljohnson@isys.ca> wrote:
> I would like to do something like:
> delete @array[0] 

Have a look for 'splice' in perlfunc



-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 28 Feb 97 11:18:55 +0800
From: bz7328113@gamma.ntu.ac.sg
Subject: How to use HTML.pm in NT?
Message-Id: <1997Feb28.111855@gamma.ntu.ac.sg>

Hi! I have problem running HTML.pm in NT environment. The program is as
follows:

use HTML::Base;
$body = new HTML::Base::Body;
new HTML::Base::Header 1;

new HTML::Base::Test "This is a header?";
new HTML::Base::Image ('SRC','pictures/Huh.gif);
$body->make_current;
new HTML::Base::Paragraph;
new HTML::Base::Text "This is a paragraph";

$body->realize;

<-----------------------------program ends------------------------------>


<--------------------------------Program ends here--------------------------->

Useless use of private variable in void context at E:\perl5\lib/HTML/Base.pm

1) Useless use of private variable in void context at E:\perl5\lib/HTML/Base.pmline 177.
printf (..
The error message is as follow:

1) Useless use of private variable in void context at E:\perl5lib/HTML/Base.pm


line 177.
ne 177.

printf(...) interpreted as function at E:\perl5\lib/HTML/Base.pm line 570 n 581
Identifier "HTML::Base::FileHandle" used only once: possible typo at E:\perl5\





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

Date: Fri, 28 Feb 1997 03:40:03 GMT
From: soccer@microserve.net (Geoffrey Hebert)
Subject: If you know perl this should be simple
Message-Id: <5f5j81$fme$1@news3.microserve.net>

Need help Received this message
Can't modify subroutine entry in scalar assignment at addlink7.cgi
line 398,
near "];"

line 398 is marked below


sub find_index_file {
    my($word) = @_;
    local $a_file= ' ';  ## tried this thought it might help
$first_char=substr($word,0,1);
   $first_char=lc($first_char);
   $a_dir=$first_char;
   if ($first_char lt 'a') {$a_dir='a';}
   if ($first_char gt 'u') {$a_dir='vwxyz';}
   $all_files = `ls $p_subject\/alpha\/$a_dir`;
print "all files $all_files \n";
   @all_files = split(/\s+/,$all_files);
   $num_files = @all_files;
print "num files is $num_files \n";
    if ($num_files==1) {  
       $a_file=@all_files[0];     ## line 398  ### here is the line 
print "return a_dir $a_dir, a file $a_file  \n";
      return $a_dir, $a_file;
   }

Please email answer also   heberts@microserve.net

Thanks



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

Date: 28 Feb 1997 04:39:23 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Newsflash: Progressive Networks' RealMedia Conference
Message-Id: <5f5nhr$mme@vixen.cso.uiuc.edu>

pnetwork@sbexpos.com (pnetwork@sbexpos.com) wrote:
:      
: As a part of the RealMedia Conference, on the evening of March 3,
: Atlantic Records recording artist Poe will headline a private concert
: which will also be carried live over the Internet at
[snip]
:      
: "The RealMedia Conference offers developers a training ground to learn
: how to utilize this technology to create extraordinary applications and
: content," said Rob Glaser, chairman and CEO, Progressive Networks.
: "RealMedia gives developers the freedom to create compelling content and
: gives end users the opportunity to experience multiple media types
: including animation, audio and video, all in real time."
:   
: 		This is your last chance to register for the RealMedia Conference!  

I don't think they know who their audience is -- they have been
promoting with unsolicited commercial email (UCE). I don't think
I would have gone this year -- but now I am unlikely ever to.

-- 
Regards,                                                      ___       ___
Mike Heins                          http://www.iac.net/~mikeh|_ _|____ |_ _|
                                    Internet Robotics         | ||  _ \ | |
This post reflects the              Oxford, OH  45056         | || |_) || | 
opinion of my employer.             <mikeh@iac.net>          |___|  _ <|___|
                                    513.523.7621 FAX 7501        |_| \_\   


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

Date: Thu, 27 Feb 1997 22:54:33 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Newsflash: Progressive Networks' RealMedia Conference
Message-Id: <9eo5f5.fh1.ln@localhost>

Mike Heins (mheins@prairienet.org) wrote:
: pnetwork@sbexpos.com (pnetwork@sbexpos.com) wrote:
: :      
: : As a part of the RealMedia Conference, on the evening of March 3,
: : Atlantic Records recording artist Poe will headline a private concert
: : which will also be carried live over the Internet at
: [snip]
: :      
: : "The RealMedia Conference offers developers a training ground to learn
: : how to utilize this technology to create extraordinary applications and
: : content," said Rob Glaser, chairman and CEO, Progressive Networks.
: : "RealMedia gives developers the freedom to create compelling content and
: : gives end users the opportunity to experience multiple media types
: : including animation, audio and video, all in real time."
: :   
: : 		This is your last chance to register for the RealMedia Conference!  

: I don't think they know who their audience is -- they have been
: promoting with unsolicited commercial email (UCE). I don't think
: I would have gone this year -- but now I am unlikely ever to.


Who are their competitors?

I need to go out and buy one, just on principle.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 27 Feb 1997 21:12:09 -0500
From: Bill Kuhn <wkuhn@uconect.net>
To: doug.alcorn@sonoco.com
Subject: Re: Optimizing nested loops
Message-Id: <33163EF9.4CD1B9DD@uconect.net>

I don't have your input files, but I recreated your example from the
data you provided.

I rewrote you program by taking advantage of perl's regular
expressions.  It should run *much* faster.

Check it out!

-Bill
--------------code-----------------------
#!/usr/local/bin/perl -w

# initialize some arrays with data
# this would normall be read from a
# file
@bom = qw(1004~1~TN~XXXXX~1325~0000.2000~TN~~~
	1006~1~TN~XXXXX~1210~0000.5000~TN~~~
	1006~1~TN~XXXXX~1330~0000.1500~TN~~~
	1008~1~TN~XXXXX~1340~0000.1000~TN~~~) ;

@part_num = qw(J40_00_1004.00310.0000~
	J40_00_1004.00312.0000~
	J40_00_1006.00412.0000~
	J40_00_1008.00300.0000~) ;

# begin code
# use an hash of arrays
# because we have a
# "one to many" relationship
# in our data
for (@part_num) {
	($value,$key) = /(\w+_(\d+)\..+)/ ;
	if (!exists($xref{$key})) {
		$xref{$key} = [] ;
	}
	push(@{$xref{$key}},$value) ;
}

# create the joined list
@join_list = () ;

for (@bom) {
	($key,$string2) = /(^\d+)\~(.+$)/ ;
	foreach $string1 (@{$xref{$key}}) {
		push(@join_list,$string1 . $string2) ;
	}
}

# print out the results of
# the join
for (@join_list) {
	print $_,"\n" ;
}
--------------code-----------------------

-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: Thu, 27 Feb 1997 22:35:26 -0500
From: Bill Cowan <billc@tibinc.com>
To: David Salisbury <salisbur@venus.fsl.noaa.gov>
Subject: Re: Question on "eval"
Message-Id: <3316527E.169A@tibinc.com>

David Salisbury wrote:
> 
> Okay, I admit it, I'm not a perl wiz.  Can someone please tell me
> why the code below doesn't work, and maybe even a solution.
> I've tried several ways, but I would think that the "\" escape
> protects the $ from the first pass of the eval.
> 
> -------------------
> #!/bin/perl
> 
> $sortorder='$date$type';
            ^^^        ^^^

Did you intend this to be interpolated?  As in double-quoted string?

> 
> $date='05/01/96';
> $type="bob";
> 
> $sometext = "this is some text";
> 
> eval "\$anArray{$sortorder} = \$sometext";  ##<--- why no work??

Try: 

print "\$anArray{$sortorder} = \$sometext";

as a confirmation.

> 
> foreach $i ( keys(%anArray) ) {
>    print "$i\n";
> }
> 
> exit;
> --
> 
> If the directory name is any indication, I'm running perl 5.
> 
> _____________________________
> Value is the predecessor of structure.  -Pirsig

I am assuming you want a hash key of "05/01/96bob".

-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: Thu, 27 Feb 1997 22:39:25 -0500
From: Bill Cowan <billc@tibinc.com>
Subject: Re: Question on "eval"
Message-Id: <3316536D.1795@tibinc.com>

After looking closer, why not drop the eval?  And do:

$anArray{$sortorder} = $sometext;


Bill Cowan wrote:
> 
> David Salisbury wrote:
> >
> > Okay, I admit it, I'm not a perl wiz.  Can someone please tell me
> > why the code below doesn't work, and maybe even a solution.
> > I've tried several ways, but I would think that the "\" escape
> > protects the $ from the first pass of the eval.
> >
> > -------------------
> > #!/bin/perl
> >
> > $sortorder='$date$type';
>             ^^^        ^^^
> 
> Did you intend this to be interpolated?  As in double-quoted string?
> 
> >
> > $date='05/01/96';
> > $type="bob";
> >
> > $sometext = "this is some text";
> >
> > eval "\$anArray{$sortorder} = \$sometext";  ##<--- why no work??
> 
> Try:
> 
> print "\$anArray{$sortorder} = \$sometext";
> 
> as a confirmation.
> 
> >
> > foreach $i ( keys(%anArray) ) {
> >    print "$i\n";
> > }
> >
> > exit;
> > --
> >
> > If the directory name is any indication, I'm running perl 5.
> >
> > _____________________________
> > Value is the predecessor of structure.  -Pirsig
> 
> I am assuming you want a hash key of "05/01/96bob".
> 
> -- Bill
> -----------------------------------------------------------------------
> Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
> Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707

-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: Thu, 27 Feb 1997 23:57:24 -0500
From: "Zahid R. Naqvi" <zrnaqvi@mailbox.syr.edu>
Subject: read/write file contents(new programmer)
Message-Id: <Pine.SOL.3.95.970227235310.11863A-100000@rodan.syr.edu>

I am a new PERL programmer and perhaps this is a very basic question.
Anyway how can I look for a specific string in a file, and then add some
text immediately after I find the text. I have been using "tell" and
"seek" but I just can't get it right.

Thanks
Zahid



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

Date: Thu, 27 Feb 1997 15:28:05 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: "Leonhard Brenner {13031} 7149 [ ]" <lab@slpabu.msd.ray.com>
Subject: Re: Regular Expressions problem please help!
Message-Id: <33161885.15D9@egames.com>

Leonhard Brenner {13031} 7149 [ ] wrote:
>             ###Problem###
>             $file =~ s/($srcmarker).*($srcmarker)/$1$dst$2/;

There are lots of other problems with your program but this 
substitute is indeed your core problem. '.' matches any character
*except* newline unless you use the s (single-line-mode) suffix
for your regexp. You probably also want a g suffix so
you replace all occurances and should also make your
 .* non-greedy.  Oh, and meta-quote those delimiters
so any regexp meta-characters used in them are treated literally.

   $file =~ s/(\Q$srcmarker\E).*?(\Q$srcmarker\E)/$1$dst$2/sg;

--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

Date: Thu, 27 Feb 1997 22:40:04 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Regular Expressions problem please help!
Message-Id: <4jn5f5.ce1.ln@localhost>

Leonhard Brenner {13031} 7149 [ ] (lab@slpabu.msd.ray.com) wrote:
: I have a script that I am writing to search through a list of
: files replacing:
: 	<!--Generic_javascript-->
: 	This will be replaced!
: 	<!--Generic_javascript-->
: with:
: <!--Generic_javascript-->
:     Just some junk;
: <!--Generic_javascript-->

: $srcmarker is created alright but substitution does not work.
: A have provided all files needed try this script. I have already
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

_Very_ good idea!

Oh that more questioners would take the time to make it easy
for the answerers to help...


: writen a working version loops and matching but I thought this
: would be cleaner. 


[snip]

: 	    ###Problem###
: 	    $file =~ s/($srcmarker).*($srcmarker)/$1$dst$2/;


$file =~ s/($srcmarker).*($srcmarker)/$1$dst$2/s;
                                               ^
                                               ^

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 27 Feb 1997 22:00:48 -0500
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Removing Tempfiles - a solution
Message-Id: <ken-2702972200480001@news.swarthmore.edu>

Hi there.

I've got a Perl program in which I create a temporary file, read from it
for a while, and at the end of the program delete it.  The problem is that
the users of this program are sitting at a web browser, and sometimes they
hit the 'stop' button before the program is done, leaving the tempfile
extant.  

I investigated solutions that seemed pretty hard - put cleanup routines in
an END{} routine (doesn't work since the program is killed externally, not
internally), try to trap the signal (I didn't have to stomach for it), and
other not-so-good ideas.

I think I finally found a solution, and I'm sharing it now: immediately
after I create the temporary file and open it, I delete it, like this:

   # Tie the tempfile:
   tie(%db, DB_File, $tempfile, O_RDONLY, 0660) or return 0;

   # Delete the tempfile:
   unlink ($tempfile) or print STDERR "Couldn't remove tempfile: $!\n";

   # Do a whole bunch of data-reads from the file....


In Unix, the actual file doesn't get deleted until the last opened version
of it is closed.  So I can keep reading from the file until I close it.

I think I'm happy with this solution - if anyone sees any problems with it
besides the problem of being a unix-dependent solution (I imagine a Mac
would probably complain, saying somebody still has the file open or
something), I'd appreciate your thoughts.  Thanks.

-Ken Williams
 ken@forum.swarthmore.edu


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

Date: Fri, 28 Feb 1997 10:18:44 +0530
From: Ajitesh Das <baku@india.ti.com>
To: Ken Williams <ken@forum.swarthmore.edu>
Subject: Re: Removing Tempfiles - a solution
Message-Id: <331663AC.FF6D5DF@india.ti.com>

Ken, 
  I have comment regarding this. Do we really need temp files 
at all. In most of the cases I have found, we can avoid using 
fork() and/or pipes.
  What do you say ?
Ken Williams wrote:
> 
> Hi there.
> 
> I've got a Perl program in which I create a temporary file, read from it
> for a while, and at the end of the program delete it.  The problem is that
> the users of this program are sitting at a web browser, and sometimes they
> hit the 'stop' button before the program is done, leaving the tempfile
> extant.
> 
> I investigated solutions that seemed pretty hard - put cleanup routines in
> an END{} routine (doesn't work since the program is killed externally, not
> internally), try to trap the signal (I didn't have to stomach for it), and
> other not-so-good ideas.
> 
> I think I finally found a solution, and I'm sharing it now: immediately
> after I create the temporary file and open it, I delete it, like this:
> 
>    # Tie the tempfile:
>    tie(%db, DB_File, $tempfile, O_RDONLY, 0660) or return 0;
> 
>    # Delete the tempfile:
>    unlink ($tempfile) or print STDERR "Couldn't remove tempfile: $!\n";
> 
>    # Do a whole bunch of data-reads from the file....
> 
> In Unix, the actual file doesn't get deleted until the last opened version
> of it is closed.  So I can keep reading from the file until I close it.
> 
> I think I'm happy with this solution - if anyone sees any problems with it
> besides the problem of being a unix-dependent solution (I imagine a Mac
> would probably complain, saying somebody still has the file open or
> something), I'd appreciate your thoughts.  Thanks.
> 
> -Ken Williams
>  ken@forum.swarthmore.edu

-- 
Regards
Ajitesh     baku@india.ti.com,baku@msg.ti.com


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

Date: 28 Feb 1997 03:01:10 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Returning a reference to a 'my' variable
Message-Id: <5f5hpm$c70$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, Luc St-Louis <lucs@cam.org> writes:
:I need to write a sub thats creates a huge list and would like to return
:a reference to the list, rather than the list itself. For example:
:
:  sub CreateList
:    {
:    my @x;
:    # ... Build up the list ...
:    return \@x;
:    }
:
:  $A = CreateList();
:  $B = CreateList();
:
:Does this work? Are references $A and $B guaranteed to be different and
:usable?

Yes.  You must be a C programmer. :-)

--tom


-- 
	Tom Christiansen	tchrist@jhereg.perl.com
"Our liberty depends upon the freedom of the press, and that cannot be
 limited without being lost."
	--Thomas Jefferson (1786)


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

Date: Thu, 27 Feb 1997 20:38:19 -0500
From: Bill Kuhn <wkuhn@uconect.net>
To: Luc St-Louis <lucs@cam.org>
Subject: Re: Returning a reference to a 'my' variable
Message-Id: <3316370B.345B9382@uconect.net>

I would avoid using the named array approach.

I tend to create a reference to an anonymous array, then fill the array:

sub CreateList {
  my $array_ref = [] ;
  # fill @{$array_ref}
  $array_ref ;
}

$A = CreateList() ;
$B = CreateList() ;

If you use a named array, then I think $A and $B will refer to the same
thing in your example.

-Bill
-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: 27 Feb 1997 22:40:52 -0500
From: Roderick Schertler <roderick@argon.org>
To: Luc St-Louis <lucs@cam.org>
Subject: Re: Returning a reference to a 'my' variable
Message-Id: <pzk9nt4n4u.fsf@eeyore.ibcinc.com>

On Wed, 26 Feb 1997 21:28:01 -0500, Luc St-Louis <lucs@cam.org> said:
> 
>   sub CreateList
>     {
>     my @x;
>     # ... Build up the list ...
>     return \@x;
>     }
> 
>   $A = CreateList();
>   $B = CreateList();
> 
> Does this work?

Yes.  Why didn't you just test it?

> Are references $A and $B guaranteed to be different and usable?

Yes.

-- 
Roderick Schertler
roderick@argon.org


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

Date: 28 Feb 1997 03:50:01 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Scoping problem using my() [kinda long]
Message-Id: <slrn5hcl8i.b16.dave@fast.thomases.com>

On Wed, 19 Feb 1997 13:29:30 GMT, Doug Alcorn <alcornd@conterra.com> wrote:
 
> $order_slit = 00260;
                ^^^^^
  
  This is an octal number. Put quotes around numbers with leading zeros.
  
> 	# get the fraction portion
> 	($order_slit, my $fraction) = ($order_slit =~ m/(\d*){\d\d)/);
                                                             ^^^^^^
							     
  Mismatched parens. This should have given you an error.
  
> 	# convert to decimal and drop of the leading zero
>       ($fraction /= 64) =~ s/^0*(\.\d*)/$1/;

Wow!

Might I suggest something a tad simpler?

   sub conv_fractional_inches($)
   {
     my ($whole, $fraction) = $_[0] =~ /^0*(\d*)(\d\d)$/;
     $result = $whole + $fraction/64;
   }

Or, altered to return 0 for incorrect values:

   sub conv_fractional_inches($)
   {
     my ($whole, $fraction) = $_[0] =~ /^0*(\d*)(\d\d)$/;
     $whole ||= 0;
     $fraction ||= 0;
     $result = $whole + $fraction/64; 
   }

Dave



-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Fri, 28 Feb 1997 15:16:47 +1100
From: Dave Mitchell <davidm@aus.hp.com>
Subject: Sending SNMP traps from Perl
Message-Id: <33165C2F.4FAB@aus.hp.com>

I'm trying to find a way of *generating* an SNMP trap from Perl.  I'm
certain I've seen a command line utility for doing this from Windows NT,
but I can't find it now...

Any solution I can run on either HP-UX or NT would work for me, although
I'd prefer NT.  Any ideas?

Dave Mitchell


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

Date: Thu, 27 Feb 1997 22:50:37 -0600
From: Don Bowen <dbowen@mtco.com>
Subject: simple cgi perl question
Message-Id: <3316641D.4822@mtco.com>

I want to be able to have my HTML file call my perl cgi script and
return the mime-type application/octet-stream and cause the client
browser to be prompted to save it as a specifically named file. 
Currently all I can get it to do is prompt me to save as script.cgi (the
name of my script) but I want to to be program.exe.

Can anyone help me out?  I see that Netscape does this on their
downloads.  You end up on a form that calls pick.cgi, but you get
prompted to save a file that defaults to n32something.exe.

Thanks.
-- 
Don;
          ...
      , '     ' ,
    ,'    /^\ _ -',
   /      [|]=_--_ \
  |       | |   -   |       Lighthouse Software, Inc.
  |       | |___    |
  |    ___| |   \   |               PO Box 9601
  |   /          '--|            Peoria, IL 61612
  |  /______________|
  |  ===============|         Phone: (309) 673-9886
  |   ===========   |           Fax: (309) 673-9895
  |'.     ======    |         Pager: (309) 497-4194
  |  '.   ==        |     
  -----'-------------       http://www.lighth.com/~lighth


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

Date: Thu, 27 Feb 1997 22:44:06 -0500
From: Bill Cowan <billc@tibinc.com>
To: oshmis1@pacbell.net
Subject: Re: sometimes > not greater than?
Message-Id: <33165486.1EC0@tibinc.com>

Marty McDowell wrote:
> 
> Michael Sadd wrote:
> >
> > Nothing here surprised me.  What you are seeing is that
> > your machine has finite precision to represent floating point numbers.
> > In some cases, what you think might be 5 will be represented as
> > 5.000000...1, giving the false true values you noted.
> >
> > It is a general rule of numerical programming that your results
> > should not be dependent on what a test does when a parameter
> > is supposed to be exactly some number.
> >
> >         Mike
> >
> > --
> > | Michael Sadd                          | Cornell Univerisity        |
> > | Department of Physics and             | Ithaca, NY 14850           |
> > | Lab of Atomic and Solid State Physics | www.msc.cornell.edu/~sadd/ |
> 
> Ok, so even though I printed out the variable and it said '5', and
> yes I have seen when perl prints 5.000000000001, its not really 5.
> How would I do the comparison?

Have you considered doing the following?

	use integer;  # for integer math (not float)

Be sure to read doc about scope of this directive!

-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: Thu, 27 Feb 1997 22:17:40 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: UCE, spam, Andreessen (was: Re: Newsflash...)
Message-Id: <49m5f5.r71.ln@localhost>


[ besides posting here in comp.lang.perl.misc, I've also sent
  it by email to the spammers below:

  pnetwork@sbexpos.com
  postmaster@real.com
  root@real.com
]


pnetwork@sbexpos.com (pnetwork@sbexpos.com) wrote:
: Newsflash:  Marc Andreessen and Rob Glaser to deliver keynotes at the
              ^^^^^^^^^^^^^^^
: RealMedia Conference 


Will he puleease tell us how we can spam, harvest email addresses
and send Unsolicited Commercial Email just like you do?


: "The RealMedia Conference offers ...

 ... us uncouth and moneygrabbing promoters an opportunity to try out 
our Usenet spamming software."

We already had an opportunity to try out our email address harvesting
program so that we could send out a bunch of UCE too.

Ain't this a truly great opportunity?


**************************
**************************

Here's my real question:

I got an UCE from these jokers last week. Now that I see they are
spamming c.l.p.m (real spam, I've seen it posted seperately to at
least one other newsgroup), my suspicion that they harvested my
email address from c.l.p.m has been reenforced.

Anybody else here get stuff from these jokers?


I sent a complaint to the UCE sender and to postmaster@real.com, but
got no reply...

**************************
**************************


We now return to a continuation of the parody...


: how to utilize this technology to create extraordinary applications and...
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ... piss off thousands of people at a time.


: content," said Rob Glaser, chairman and CEO, Progressive Networks.

Well, at least Rob is content...


: "RealMedia gives developers the freedom to ...

 ... be the targets of machine-run marketing.


: gives end users the opportunity to experience multiple...

 ... contacts from us.


: This is your last chance to register for the RealMedia Conference!  

sh... shoot. I'm gonna miss it  ;-(


: The registration fee is $695 and covers access to all keynote speeches,
                   ^^^^^^^^^^^

This is a _great_ deal. If we actually had to pay for advertising
over the Internet based on the traffic volume we used, it would cost
much more...


: Last Chance! 

 ... to line our pockets!


: Space is limited

'cause people with any 'net ethics at all are now obliged to
boycott you...


: To register for the conference, call 1-800-EAT-SHIT, or register at...

 ... the gates of Hell.



: What:   marketing _targets_ pay for distribution, not the marketers!
: Where:  right here on c.l.p.m, and coming soon to an email box near you.
: When:	  whenever _we_ want to.


: 		or call 800-765-3705  (US) or 415-372-6705 (Int'l)
                        ^^^^^^^^^^^^

Hmmmm. I wonder if they pay for that based on how much it gets used?


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 28 Feb 1997 04:25:13 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Win95 can't always do this! ( Was: Re: Perl on Windows 95)
Message-Id: <5f5mn9$8u@fridge-nf0.shore.net>

Ed Boren (boren@tngms1.mro1.dec.com) wrote:

: I've had this problem in perl win32 (5.001m) when running under Netscape
: Fasttrack Server 2.0 for Windows 95 (it seems to work in NT 4.0). It
: seems to fail when doing a gethostbyname. If run from the command line
                             ^^^^^^^^^^^^^
Exactly.  It was broken in NTPerl PL 110, but fixed in 5.003_07.

--
Nathan V. Patwardhan
nvp@shore.net
"What is your favorite color?
Blue ... I mean yellow ... aieeeee!
	--From the Holy Grail"


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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

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