[11778] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5378 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 14 04:08:00 1999

Date: Wed, 14 Apr 99 01:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 14 Apr 1999     Volume: 8 Number: 5378

Today's topics:
        accessing an array of subroutine references <ronald_f@my-dejanews.com>
    Re: Another dumb question (Larry Rosler)
        CGI.pm and cookie <donnywi@yahoo.com>
    Re: CGI.pm and cookie (Tim Herzog)
    Re: Convert two newlines to \n<p> <rick.delaney@home.com>
    Re: Creating an empty file. <s.filipowicz@orades.nl>
    Re: FAQ 1.1: What is Perl? (John Stanley)
        FAQ 1.2: Who supports Perl?  Who develops it?  Why is i <perlfaq-suggestions@perl.com>
        Format markaw2091@my-dejanews.com
        Format markaw2091@my-dejanews.com
        Is there a limit to the size of an RE? gaj@austaxprac.com.au
        like print <<...; load a variable? <bluesrift@aol.com>
    Re: like print <<...; load a variable? <ebohlman@netcom.com>
        need to modify 'discus' scripts/config files <perl-listed@parv-et-ceteraFreeHolyCow.com>
    Re: need to modify 'discus' scripts/config files <perl-listed@parv-et-ceteraFreeHolyCow.com>
    Re: pattern matching (Larry Rosler)
    Re: Problem with my & local declarations (Mike Mckinney)
    Re: Problem with my & local declarations (Mike Mckinney)
    Re: Problem with my & local declarations (Mike Mckinney)
    Re: Problem with my & local declarations (Mike Mckinney)
    Re: Problem with my & local declarations <uri@home.sysarch.com>
    Re: Q: Convert two newlines to \n<p> <rick.delaney@home.com>
    Re: Q: Convert two newlines to \n<p> <rick.delaney@home.com>
    Re: Q: Hash tables!!! (Sam Holden)
        reference to an *existing* sub <ronald_f@my-dejanews.com>
    Re: reference to an *existing* sub <ebohlman@netcom.com>
    Re: reference to an *existing* sub <nospam.reiersol@onlinel.no>
        removing ^M, ^B and other wierd chars <kal@valistech.com>
    Re: removing ^M, ^B and other wierd chars (Larry Rosler)
        Running a non CGI program through a weblink e_broyles@yahoo.com
    Re: Running a non CGI program through a weblink (Sam Holden)
    Re: start script at foreign server (Sam Holden)
        Telnet-Client with Net::Telnet stuckenbrock1@my-dejanews.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 14 Apr 1999 06:57:47 GMT
From: Ronny <ronald_f@my-dejanews.com>
Subject: accessing an array of subroutine references
Message-Id: <7f1e99$ise$1@nnrp1.dejanews.com>

I have an array of sub references, like this:

  @subs=(sub {do_this()}, sub {do_that()});

Given an index $i, I would like to execute the subroutine at $subs[$i]. I
tried

  $result=&$subs[$i]();

but got two error messages:

Can't use subscript on subroutine entry at srt line 3, near "0]"
(Did you mean $ or @ instead of &?)
syntax error at srt line 3, near "]("

Introducing an auxiliary scalar makes it work:

$subref=$subs[0];
$x=&$subref();

But I am still wondering if I can write this without the introduction of a
temporary variable. My impression was that the error messages are a
consequence of the Perl parsing rules, but I did not find a better way
of writing it.

Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/

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


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

Date: Tue, 13 Apr 1999 23:35:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Another dumb question
Message-Id: <MPG.117dd7018fa50d149898a8@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <1883@thanatos.win-uk.net> on Tue, 13 Apr 1999 23:34:51 GMT, 
Paul Burridge <osiris@thanatos.win-uk.net> says...
> Am having problems with v.5 of the perl compiler. When running the
> compiler on a target source file, it appears to do *something* and
> spews out a load of info as it compiles and links as one would
> expect. No error messages generated during this, either. However,
> when I come to look for an executable file that I expect the
> program to have created, there's nothing; no .exe, no .obj, no
> .mak, nothing but the original source code file. Having run "find
> <filename.exe>" (using the usual Windows command) through the
> entire HD. and still no executable found, I'm wondering what's
> going wrong. Any ideas? I'm running a PC with Windows 98, BTW.

The perl compiler does not produce an executable file.  It compiles the 
program into an internal representation that it then executes (unless 
there were fatal errors during the compilation).  It is not clear from 
your description of the behavior whether the compilation phase completed 
successfully and execution began.

Try a very simple source file first, something like:

#!/usr/local/bin/perl -w
use strict;

print "Hello, world!\n";

Execute it by typing, at the DOS command prompt,

  perl myprog.txt

If that works, simplify your real source file and pepper it with print 
statements to see where it fails (assuming the compilation is 
successful).

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 13 Apr 1999 23:34:28 -0500
From: Donny Widjaja <donnywi@yahoo.com>
Subject: CGI.pm and cookie
Message-Id: <37141AD4.F68BD807@yahoo.com>

Hi,

I need to write a cgi program in PERL that write a cookie.  I know that
the newest CGI.pm has Cookie.pm.  I have downloaded the newest CGI.pm,
but I can't install it because there is an older version of CGI.pm in
the root directory.  I am running a FreeBSD virtual server.
Does anybody know how to write a cookie by using CGI.pm ver 2.36?  Or
where can I get more information on writing a cookie by using CGI.pm or
other module if not too complicated?

Thank you.


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

Date: Wed, 14 Apr 1999 02:58:56 -0500
From: therzog@knotech.com (Tim Herzog)
Subject: Re: CGI.pm and cookie
Message-Id: <therzog-1404990258560001@therzog-host105.dsl.visi.com>

In article <37141AD4.F68BD807@yahoo.com>, Donny Widjaja
<donnywi@yahoo.com> wrote:

>Hi,
>
>I need to write a cgi program in PERL that write a cookie.  I know that
>the newest CGI.pm has Cookie.pm.  I have downloaded the newest CGI.pm,
>but I can't install it because there is an older version of CGI.pm in
>the root directory.  I am running a FreeBSD virtual server.
>Does anybody know how to write a cookie by using CGI.pm ver 2.36?  Or
>where can I get more information on writing a cookie by using CGI.pm or
>other module if not too complicated?


I'm no CGI expert and I've never used CGI.pm, but I know that cookies are
not terribly hard to do, even w/o a module.  Check out:

http://www.netscape.com/newsref/std/cookie_spec.html

-- 
Tim Herzog


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

Date: Wed, 14 Apr 1999 04:18:21 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Convert two newlines to \n<p>
Message-Id: <37141900.C726C5F9@home.com>

[posted & mailed]

Michael Villeneuve wrote:
> 
> You will not get two consecutive newline (\n) characters 
> in a single record.
[snip]
> 
> (I'm not sure what the
> undef $/;
> does. )

It allows you to get two consecutive newlines in a single record.  In
fact, the whole file.

>  If I'm way off base, don't flame me.  I'm just trying to give my two 
> cents.

We'll take the money, but if flaming is something that frightens you,
you might want to do some simple research before posting.  It would not
take very long to find out what 'undef $/' does.

perldoc perlvar

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 14 Apr 1999 09:41:27 +0200
From: Steven Filipowicz <s.filipowicz@orades.nl>
Subject: Re: Creating an empty file.
Message-Id: <371446A7.B173F7CD@orades.nl>



Steve Linberg wrote:

> This works on my system:
> 
> open (FOO, '>bar.txt') or die "Can't open: $!";
> print FOO "blah!\n";
> close FOO or die "Can't close: $!";
> 
> Not sure what your difficulty is.

I'm not sure either!
I gues I thought it would be a lot more then this!

Well thanks everyone for the help! I think I can continue with my
program now!


Thanks again!


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

Date: 14 Apr 1999 04:59:48 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: FAQ 1.1: What is Perl?
Message-Id: <7f17c4$d6k$1@news.NERO.NET>

In article <371409aa@cs.colorado.edu>,
Tom Christiansen  <perlfaq-suggestions@perl.com> wrote:
>(This excerpt from perlfaq1 - General Questions About Perl 

Instead of splitting the FAQs up into little pieces and stuffing them
onto the net in dribs and drabs, can you please just post the updated
FAQs whole? It is so much more convenient to have them in the original
nine parts and not have to try to repack them. It saves a lot of space
from duplicated headers and allows them to be archived and available
upon request instead of mailed around the world in tiny bits.



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

Date: 13 Apr 1999 23:51:16 -0700
From: Tom Christiansen <perlfaq-suggestions@perl.com>
Subject: FAQ 1.2: Who supports Perl?  Who develops it?  Why is it free?  
Message-Id: <37142cd4@cs.colorado.edu>

(This excerpt from perlfaq1 - General Questions About Perl 
    ($Revision: 1.21 $, $Date: 1999/01/26 09:55:05 $)
part of the standard set of documentation included with every 
valid Perl distribution, like the one on your system.
See also http://language.perl.com/newdocs/pod/perlfaq1.html
if your negligent system adminstrator has been remiss in his duties.)

  Who supports Perl?  Who develops it?  Why is it free?

    The original culture of the pre-populist Internet and the deeply-
    held beliefs of Perl's author, Larry Wall, gave rise to the free
    and open distribution policy of perl. Perl is supported by its
    users. The core, the standard Perl library, the optional modules,
    and the documentation you're reading now were all written by
    volunteers. See the personal note at the end of the README file in
    the perl source distribution for more details. See the perlhist
    manpage (new as of 5.005) for Perl's milestone releases.

    In particular, the core development team (known as the Perl
    Porters) are a rag-tag band of highly altruistic individuals
    committed to producing better software for free than you could hope
    to purchase for money. You may snoop on pending developments via
    nntp://news.perl.com/perl.porters-gw/ and the Deja News archive at
    http://www.dejanews.com/ using the perl.porters-gw newsgroup, or
    you can subscribe to the mailing list by sending perl5-porters-
    request@perl.org a subscription request.

    While the GNU project includes Perl in its distributions, there's
    no such thing as "GNU Perl". Perl is not produced nor maintained by
    the Free Software Foundation. Perl's licensing terms are also more
    open than GNU software's tend to be.

    You can get commercial support of Perl if you wish, although for
    most users the informal support will more than suffice. See the
    answer to "Where can I buy a commercial version of perl?" for more
    information.

-- 
    I know it's weird, but it does make it easier to write poetry in perl.    :-)
                    --Larry Wall in <7865@jpl-devvax.JPL.NASA.GOV>


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

Date: Wed, 14 Apr 1999 07:22:11 GMT
From: markaw2091@my-dejanews.com
Subject: Format
Message-Id: <7f1fmu$kti$1@nnrp1.dejanews.com>

Hi there,

I am havng a problem wih the "format" function". Here is a snippet of my code:

format frm_Report =
@<<	@<<<<<<<<<        ^*
$counter,	lc($&),	$descrip

What I am looking to achieve is:

1        file1.pl        This is my description. As you can
                         now see there is a new line/carriage
                         return and as such I want the paragraph
                         to be formated like this.
2        file2.pl        This is the second entry. No LF/CR.
3        file3.pl        This is the 3rd line. Again, no LF/CR.

Instead I am getting:

1        file1.pl        This is my description. As you can now
                         see there is a new line/carriage return
                         and as such I want the paragraph to be
                         formated like this.
2        file2.pl        This is the second entry. No LF/CR.
3        file3.pl        This is the 3rd line. Again, no LF/CR.

I was under the impression that using the ^* would ensure the layout was
continuous. Any advice greatly welcomed at mawilliams@walsh-international.com
or maw@markaw.demon.co.uk. BTW, I am using perl on win32.

Regards,




-MAW-

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


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

Date: Wed, 14 Apr 1999 07:23:52 GMT
From: markaw2091@my-dejanews.com
Subject: Format
Message-Id: <7f1fq3$l3o$1@nnrp1.dejanews.com>

Hi there,

I am havng a problem wih the "format" function". Here is a snippet of my code:

format frm_Report =
@<<	@<<<<<<<<<        ^*
$counter,	lc($&),	$descrip

What I am looking to achieve is:

1        file1.pl        This is my description. As you can
                         now see there is a new line/carriage
                         return and as such I want the paragraph
                         to be formated like this.
2        file2.pl        This is the second entry. No LF/CR.
3        file3.pl        This is the 3rd line. Again, no LF/CR.

Instead I am getting:

1        file1.pl        This is my description. As you can now
see there is a new line feed/carriage return and as such I want the
formatting to remain within the column.
2        file2.pl        This is the second entry. No LF/CR.
3        file3.pl        This is the 3rd line. Again, no LF/CR.

I was under the impression that using the ^* would ensure the layout was
continuous. Any advice greatly welcomed at mawilliams@walsh-international.com
or maw@markaw.demon.co.uk. BTW, I am using perl on win32.

Regards,




-MAW-

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


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

Date: Wed, 14 Apr 1999 05:33:27 GMT
From: gaj@austaxprac.com.au
Subject: Is there a limit to the size of an RE?
Message-Id: <7f19b7$f40$1@nnrp1.dejanews.com>

Using 5.005_02. Compiled an RE which is the join of phrases/words in a
dictionary, sorted in reverse length order. It's 75K long and won't match
some of the smaller words at the end. If I chop the RE down to 3K the RE
matches the previously ignored words. Could the compiled RE be falling over
somewhere?

The code is like this:

$big = join('|', @sorted_phrases);

$big = '\b('.$big.')\b';

$re = qr/$big/;

while($text =~ m/$re/gc) {
  print "$1\n";
}


Any help greatly appreciated.

Gary Ashton-Jones

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


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

Date: Wed, 14 Apr 1999 05:46:57 GMT
From: "Rob Bell" <bluesrift@aol.com>
Subject: like print <<...; load a variable?
Message-Id: <lZVQ2.2100$fH2.925@c01read04.service.talkway.com>

As a beginner my understanding is that when using the following 
method of printing one does not need to escape quotes or special 
characters.  Is there a way to load a variable similarly and thus 
similarly avoid escaping?

print <<"TOHERE";
 ...
TOHERE

Thank You!
Rob Bell
--
Posted via Talkway - http://www.talkway.com
Surf Usenet at home, on the road, and by email -- always at Talkway.



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

Date: Wed, 14 Apr 1999 06:01:03 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: like print <<...; load a variable?
Message-Id: <ebohlmanFA60pr.n2r@netcom.com>

Rob Bell <bluesrift@aol.com> wrote:
: As a beginner my understanding is that when using the following 
: method of printing one does not need to escape quotes or special 
: characters.  Is there a way to load a variable similarly and thus 
: similarly avoid escaping?

: print <<"TOHERE";
: ...
: TOHERE

Of course.  Beginners often think that "here-doc" quoting is somehow 
magically tied to the print operator, but it isn't.  A here-doc can be 
used anywhere a literal string can, including a simple assignment:

my $string=<<TOHERE;
He said "you can't get there from here."
She replied "I'm going to say this with unbalanced quotes.
TOHERE

The perldata (man page | HTML document | POD file) that came with your 
Perl distribution has a good discussion of here-docs.



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

Date: Wed, 14 Apr 1999 01:38:22 -0400
From: parv <perl-listed@parv-et-ceteraFreeHolyCow.com>
Subject: need to modify 'discus' scripts/config files
Message-Id: <371429CE.DB7DE13F@parv-et-ceteraFreeHolyCow.com>

  has anybody tried to modify the 'discus' (a threaded/linear www
discussion board) scripts & configuration files? most of the
modification will involve to make the dynamically generated html to
conform to html 4 & css as closely as possible. 

 of course, i could sit for few hours, and do it myself...but, then,
being lazy is one of three virtues of a perl programmer. don't you just
want to just love larry!

 - parv


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

Date: Wed, 14 Apr 1999 01:41:14 -0400
From: parv <perl-listed@parv-et-ceteraFreeHolyCow.com>
Subject: Re: need to modify 'discus' scripts/config files
Message-Id: <37142A7A.6E648FE9@parv-et-ceteraFreeHolyCow.com>

it's a shame that i said...
> don't you just want to just love larry!

 ...should have said: don't you just love larry!

 -parv


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

Date: Tue, 13 Apr 1999 22:59:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pattern matching
Message-Id: <MPG.117dce9fc488d6b89898a7@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <3713E146.4475E6FE@valinor.cargill.com> on Tue, 13 Apr 1999 
19:28:54 -0500, Jim Bostwick <jbostwic@valinor.cargill.com> says...

Quoted text moved to the top so we can see what you're responding to.

> bing-du@tamu.edu wrote:
> > How to judge if a variable is composed of digits only?
> 
> "There's more than one way to do it. (also more than shown here)..."

Yes, indeed there is.  Let's see if you have given *any* of them...

> $var = (your input);
> 
> if ($var =~ /^\d+$/) {
>     # it's all digits
>     # begin-string, one-or-more digits, end-string
>     # change '+' to '*' for zero-or-more digits
> }

Well, that matches "0\n", which is *not* 'digits only', is it?  (/$/ is 
not end-string if the string ends in "\n".)  This would work, though:  
/^\d+(?!\n)$/  but a better solution is given below.

> if ($var =~  /![0..9]+/ {
>     # it's got something else in it
>     # string contains something NOT in [0..9] set
> }

Well, that matches "abc!0..9xyz", which is *not* 'digits only', is it?  
For the character class, you must mean [0-9] which is equivalent to \d.  
I can't fathom the rest.

> if ($var eq int($var)) {
>     # string == number - wierd! (even for me)
>     # how many conversions does this do anyway? ;-)
> }

Well, that doesn't match "00", which *is* 'digits only', isn't it?
  
> if ($var == ($var+0)) {
>     # DON'T do this!!
>     # it'll return a false positive long as $var begins with a digit!
> }

Well, that matches "+0.0e-1", which is *not* 'digits only', is it?  (The 
'-w' flag would deal with your other concern.)

> Seriously, the first above is one good method. Later methods are sort of
> because it's been a long day.

None of them is a good method.  A good method has already been posted:

    !/\D/ # match unless (!) any character is a non-digit (\D)

One might debate whether the null string "" that matches this is 'digits 
only', though.  One could say, for example,

    length && !/\D/

or

    /./ && !/\D/

> Try reading 'perldoc perlre', for lots more ways to do it...

Good advice for anyone.  Take it.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 14 Apr 1999 04:46:59 GMT
From: mike@mike.local.net (Mike Mckinney)
Subject: Re: Problem with my & local declarations
Message-Id: <slrn7h87bf.233.mike@mike.local.net>

Eric The Read <emschwar@rmi.net> wrote:
>If "use strict;" is complaining, the solution is to fix your code, not
>disable the warnings.  For very specific cases, you can disable its
>warnings, but you should only do that if you're very certain what you're
>doing really is correct.

Great point. Disabling "use strict;" was only a temporary measure, until I
could figure out what might work, or ask in this newsgroup. If I wasn't
worried about not using strict, I wouldn't have bothered the newsgroup with a
post. I know the code I posted probably made at least a few users in this
newsgroup wince looking at it, but I'm just getting started, and at least for
now, Perl baby talk is about all I need. That of course doesn't mean I don't
care how it looks or reads, so any pointers on writing more readable code are
always appreciated.

>In case it wasn't clear before: you're defining a variable local to that
>block.  When the block is exited, the variable is no more.  If you want
>a variable to be visible throughout a block (subroutines are blocks),
>then you should declare them (with "my", generally) at the beginning of
>that block.

Yes, that fixed it very nicely. Now I see the sense in declaring all variables
at the start, instead of sprinkling declarations throughout my program.

>Unfortunately, it wasn't obvious from your code, and it seemed to me that 
>if you had been using -w and "use strict;", then you'd have found it
>already.

About as far as I got after seeing the error messages was to then try local,
instead of my, and then to use neither, temporarily. The code I posted was
after I had changed a lot of things around in the past 2 days, trying to
figure out just how it might work right.

>> I read all the applicable docs I could find on both, just in case I wasn't
>> clearly understanding the material in Learning Perl, and the docs seem to 
>> agree.
>
>Agree on what?

Reading Learning Perl, and then reading through all the applicable docs I
could find only seemed to support my opinion that the variable should be in
scope throughout, as long as it was in the same function. I see now that if I
had declared it outside the subroutines, at the very beginning of the function
it would have worked fine. I'm glad the users in this newsgroup took the time
to point out to me just how it is supposed to work.


Thanks to all.

-- 
mikemck@austin.rr.com



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

Date: Wed, 14 Apr 1999 04:49:42 GMT
From: mike@mike.local.net (Mike Mckinney)
Subject: Re: Problem with my & local declarations
Message-Id: <slrn7h87gi.233.mike@mike.local.net>

Tad McClellan <tadmc@metronet.com> wrote:

>   Do not think of the extent of scope in terms of functions.
>   
>   Think instead in terms of blocks (or files if not in a block).
>
>   Subroutines do have a block, but so do lots of other
>   constructs such as while and if.
>
>   You can even have a bare block, which would also limit scope.

Yes, I've learned an important point on this, or at least I think I have.
declaring $title inside the outermost block, but outside any inner blocks
seems to work perfectly.

-- 
mikemck@austin.rr.com



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

Date: Wed, 14 Apr 1999 04:53:45 GMT
From: mike@mike.local.net (Mike Mckinney)
Subject: Re: Problem with my & local declarations
Message-Id: <slrn7h87o5.233.mike@mike.local.net>

David Cassell <cassell@mail.cor.epa.gov> wrote:

>Right.  Solution: declare $title *outside* the START block.  Whenever
>I have a problem with -w or 'use strict;' I fight my way to a solution,
>rather than tell myself "Oh what the heck, it won't hurt to say 
>'no strict vars;' for a while..."
>I hope this helps,
>David

Yes, it helped immensely. I'm sure this will save me a lot of frustration down
the road. What's funny is that I felt so sure I knew exactly how it should
work, for two whole days. I just got it in my head that it was one way, and
didn't see much else.

Thanks.

-- 
mikemck@austin.rr.com



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

Date: Wed, 14 Apr 1999 04:55:11 GMT
From: mike@mike.local.net (Mike Mckinney)
Subject: Re: Problem with my & local declarations
Message-Id: <slrn7h87qr.233.mike@mike.local.net>

Uri Guttman <uri@home.sysarch.com> wrote:

>regardless of the scoping problem, declaring perl vars in expressions
>like below is very ugly IMO. i don't even declaring like them in for
>loops but that is much better than this.
>
>  >> chomp( my $author = <STDIN> );

I had thought that was the accepted way of doing it. A good bit of the code
that I've looked at uses that syntax.
How would you do it ?

-- 
mikemck@austin.rr.com



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

Date: 14 Apr 1999 01:18:47 -0400
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: Problem with my & local declarations
Message-Id: <x7n20bok3s.fsf@home.sysarch.com>

>>>>> "MM" == Mike Mckinney <mike@mike.local.net> writes:

  MM> Uri Guttman <uri@home.sysarch.com> wrote:
  >> regardless of the scoping problem, declaring perl vars in expressions
  >> like below is very ugly IMO. i don't even declaring like them in for
  >> loops but that is much better than this.
  >> 
  >> >> chomp( my $author = <STDIN> );

  MM> I had thought that was the accepted way of doing it. A good bit of
  MM> the code that I've looked at uses that syntax.  How would you do
  MM> it ?

i don't know what code you have been looking at but i have never seen a
my declaration inside an expression like that. i have seen many
assignments with my (which i don't do either), but not like yoru code.

i like to do just my statements at the top of the block. call it my
addiction to c style declares, but i just like it there. and i never do
anything but declare them (except for @_ assignments) just like i did in
c. my view is that declares are separate lines from assignments. the my
tends to gets lost in the text of expressions IMO.

so i would have coded it like this:

my( $author, $foo, $bar ) ;

chomp( $author = <STDIN> ) ;

    ...


just my style,

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Wed, 14 Apr 1999 04:05:27 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Q: Convert two newlines to \n<p>
Message-Id: <3714160D.88399A8B@home.com>

[posted & mailed]

Mike Collins wrote:
> 
> Trying to match two newlines to produce one newline and a paragraph
> tag <p>.
> 
> The code shown and many, many variations all fail.
> 
> undef $/;
> while (<TXTFILE>){
>     s/\n\n/\n<p>/sg; #Not even close!
>     print;
> }

Works for me, assuming TXTFILE refers to an open file.  Maybe you want a
little more that what you're telling us.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 14 Apr 1999 04:06:50 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Q: Convert two newlines to \n<p>
Message-Id: <37141660.FEC1659E@home.com>

[posted & mailed]

Tim Herzog wrote:
> 
> undef'ing the globals doesn't work very well.

Why not?  TMTOWTDI.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 14 Apr 1999 04:02:28 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Q: Hash tables!!!
Message-Id: <slrn7h84qk.94h.sholden@pgrad.cs.usyd.edu.au>

David Cassell <cassell@mail.cor.epa.gov> wrote:
>Sam Holden wrote:
>> 
>> Even if perl did free the memory, there is a chance that it wouldn't be
>> returned to the OS anyway. Depending on your OS of course (and your libc
>> I guess).
>
>Of the OS'es with which I have some familiarity, I can't think of one
>off
>the top of my head that will work this way.  Your program can free
>memory
>that it can then use again, but that memory does not get reclaimed by
>the
>OS until your program exits.  And not necessarily then either, with at
>least one OS I can think of, which doesn't need to be mentioned by
>name.  
>:-)

Isn't that what I said? OK I said 'chance' I should have said 
'high chance'. I new that if I said it won't be returned to the
OS someone would provide a counter-example of an OS that isn't
broken (matched with a libc that isn't broken)... 

Oops, I think I may be flamed for that... Did I just call a few
Unix like OSs 'broken'... ;)


-- 
Sam

I would like to tell you that Perl is simple in its complexity. But some
people won't understand that. So pretend I didn't say that, unless you
do.   --Larry Wall


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

Date: Wed, 14 Apr 1999 07:02:48 GMT
From: Ronny <ronald_f@my-dejanews.com>
Subject: reference to an *existing* sub
Message-Id: <7f1eik$ivv$1@nnrp1.dejanews.com>

Hi,

does anyone know if there is a way to create a reference to an existing
subroutine?

Example:
  sub A {};
  sub B {};
  $ref = $some_condition ? \A : \B; # syntactically incorrect!!

The best solution I found was this:
  $ref = $some_condition ? (sub { A(@_) }) : (sub { B(@_) });

The introduction of an additional layer of anonymous subs looks unnecessary.
Is there a better way to write this?

Ronald
--
Ronald Fischer <ronald_f@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/

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


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

Date: Wed, 14 Apr 1999 07:39:16 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: reference to an *existing* sub
Message-Id: <ebohlmanFA659G.47s@netcom.com>

Ronny <ronald_f@my-dejanews.com> wrote:
: does anyone know if there is a way to create a reference to an existing
: subroutine?

: Example:
:   sub A {};
:   sub B {};
:   $ref = $some_condition ? \A : \B; # syntactically incorrect!!

: The best solution I found was this:
:   $ref = $some_condition ? (sub { A(@_) }) : (sub { B(@_) });

: The introduction of an additional layer of anonymous subs looks unnecessary.
: Is there a better way to write this?

Yep:

$ref=$some_condition? \&A: \&B;

Just as a reference to an existing scalar is \$scalar, to an existing 
array is \@array and to an existing hash is \%hash, a reference to an 
existing sub is \&sub.



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

Date: Wed, 14 Apr 1999 09:41:53 +0200
From: "Dagfinn Reiersxl" <nospam.reiersol@onlinel.no>
Subject: Re: reference to an *existing* sub
Message-Id: <3FXQ2.32$y75.288@news1.online.no>

The way to create a reference to an existing subroutine is

$ref = \&A;

See "Programming Perl", page 246.




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

Date: Tue, 13 Apr 1999 21:05:08 -0700
From: "kal@valistech.com" <kal@valistech.com>
Subject: removing ^M, ^B and other wierd chars
Message-Id: <371413F3.F59FC92D@valistech.com>

If I ftp'd text files (in ascii mode) that contain the above characters,
how do I get rid of them?
what regex would clean them off.
thanks
Kal.



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

Date: Tue, 13 Apr 1999 23:59:31 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: removing ^M, ^B and other wierd chars
Message-Id: <MPG.117ddcab5f7d9c319898a9@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <371413F3.F59FC92D@valistech.com> on Tue, 13 Apr 1999 
21:05:08 -0700, kal@valistech.com <kal@valistech.com> says...
> If I ftp'd text files (in ascii mode) that contain the above characters,
> how do I get rid of them?
> what regex would clean them off.

regex solution (suboptimal performance):  s/[\cM\cB]//g

translate solution (much faster):         tr/\cM\cB//d

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 14 Apr 1999 05:32:55 GMT
From: e_broyles@yahoo.com
Subject: Running a non CGI program through a weblink
Message-Id: <7f19a8$f3t$1@nnrp1.dejanews.com>

I am attempting to run a Perl program by weblink.  It is not a cgi and I do
not want or need to have output back to the browser.  The program should
actually write to local files on the server machine.  I get a 500 Server
Error when I tried to invoke it using the following html:

<html>
<head>
<title>sample page </title>
</head>
<body>

<a href="http://link to my perl script.pl">Click to Invoke Test Script</a>

</body>

</html>

When I hit the link it followed it and displayed the error.

I also tried to put a little cgi so that when it followed the link it would
return some html.  That stopped the error but my program did not run.  Here is
the code i tried to run:

#!D:\perl\bin\perl
use Win32::Process;

print <<END_of_Multiline_Text;
Content-type: text/html

<HTML>
<Head>
<Title>Test</Title>
</Head>

<Body>
<H1>Just some random text</H1>
</Body>
</HTML>

END_of_Multiline_Text

Win32::Process::Create($Process,
                 'd:\perl\bin\perl',
                 'perl local_address_of_My_perl_script',
                 0,
                 DETACHED_PROCESS,
                 ".");

Any suggestions on making this work?  I am unable to invoke my script on the
server except through the web(no shell account).  The server is running
Windows NT.  I have run my script on my PC and it does work so the problem
seems to lie in the invocation.

If I could get the invocation to start another process of perl running the
program and return a basic page to the browser, that would be fantastic.

Thanks

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


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

Date: 14 Apr 1999 07:36:57 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Running a non CGI program through a weblink
Message-Id: <slrn7h8hcp.it3.sholden@pgrad.cs.usyd.edu.au>

On Wed, 14 Apr 1999 05:32:55 GMT, e_broyles@yahoo.com wrote:
>I am attempting to run a Perl program by weblink.  It is not a cgi and I do
>not want or need to have output back to the browser.  The program should
>actually write to local files on the server machine.  I get a 500 Server
>Error when I tried to invoke it using the following html:
>
><html>
><head>
><title>sample page </title>
></head>
><body>
>
><a href="http://link to my perl script.pl">Click to Invoke Test Script</a>
>
></body>
>
></html>
>
>When I hit the link it followed it and displayed the error.

Maybe you should look up what a '500 Servewr Error' means.

Did your program actually run? Most probably.
Did it generate valid output for a CGI script? Probably not.
If it's output isn't valid might that cause an error? Probably so.
If the web server doesn't sees the output as an error might it
kill the process? Possibly, would depend on the web server.

-- 
Sam

The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
	--Larry Wall


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

Date: 14 Apr 1999 07:22:33 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: start script at foreign server
Message-Id: <slrn7h8ghp.it3.sholden@pgrad.cs.usyd.edu.au>

 Markus Pscheidt <pscheidt@writeme.com> wrote:
>
>is there a way that a perl script can start another script on another
>server which has root privileges?

Perl can do it the same way any other language that can use a network
connection can do it.

-- 
Sam

 "... the whole documentation is not unreasonably transportable in a
 student's briefcase." - John Lions describing UNIX 6th Edition
 "This has since been fixed in recent versions." - Kernighan & Pike


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

Date: Wed, 14 Apr 1999 06:34:51 GMT
From: stuckenbrock1@my-dejanews.com
Subject: Telnet-Client with Net::Telnet
Message-Id: <7f1cub$hsr$1@nnrp1.dejanews.com>

Hello,

I tried to code a little telnet-client with Net::Telnet, but I had a problem:
If I send a command with the cmd function the first time, I get the output
back as normal. But the more commands I enter, the more often I have to press
the enter key before the commands results appear on the screen. The prompt
appears everytime I press enter. If I close the connection, and open it
again, the first command works correctly again but then it lacks again. It
would really be nice if someone could help me. Heres the interesting part of
the code:

$command="hostname";
print  "Connected to ",$telnet->cmd($command)
       ,"$prompt";

while ($command ne "exit") {
   $command = <STDIN>;
   print  $telnet->cmd(String => $command)
          ,"$prompt";
   ########################################
   #The next three lines is what I want to prevent   #
   ########################################
   $telnet->close;
   $telnet->open($hostname);
   $telnet->login($username, $password);
}

What could that be?

Thank you very much
Soeren

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


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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