[16701] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4113 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 00:05:42 2000

Date: Wed, 23 Aug 2000 21:05:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967089918-v9-i4113@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 23 Aug 2000     Volume: 9 Number: 4113

Today's topics:
    Re: @_ as array (Keith Calvert Ivey)
        A Proposal for BaseLib module (was Re: Modifying @INC.. <hasant@trabas.com>
    Re: Associative arrays (Martien Verbruggen)
    Re: Associative arrays (Martien Verbruggen)
    Re: Creating new file and substituting data (Keith Calvert Ivey)
    Re: Direct screen access (Abigail)
    Re: Direct screen access (Abigail)
    Re: Flipflop matching <uri@sysarch.com>
    Re: Forking in WinNT (Abigail)
    Re: Generalized "User Database"? (Martien Verbruggen)
    Re: help with simple regexp - does my head in (Keith Calvert Ivey)
    Re: help with simple regexp - does my head in (Martien Verbruggen)
        help!! <lucas@cplhk.com>
    Re: how can I optimize a tied hash for speed (Abigail)
    Re: how to generate unreadable from readable perl code (David H. Adler)
    Re: how to generate unreadable from readable perl code (Abigail)
    Re: how to generate unreadable from readable perl code (Abigail)
        How to Include a Perl script in a Perl script <ksmith@firesnacks.com>
    Re: How to Include a Perl script in a Perl script <tony_curtis32@yahoo.com>
    Re: How to Include a Perl script in a Perl script <tina@streetmail.com>
    Re: How to Include a Perl script in a Perl script <mischief@motion.thispartfake.net>
    Re: How to Include a Perl script in a Perl script <dale@emmons.dontspamme.com>
    Re: How to Include a Perl script in a Perl script (Abigail)
    Re: How to split mailheaders (Keith Calvert Ivey)
    Re: Just another silly post. (brian d foy)
    Re: Just another silly post. <reljr_2@yahoo.com>
    Re: Just another silly post. <reljr_2@yahoo.com>
    Re: Just another silly post. (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Aug 2000 02:27:25 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: @_ as array
Message-Id: <39ab8746.8692493@news.newsguy.com>

"Amir E. Aharoni" <amir_e_a@netvision.net.il> wrote:

>$_ and @_ are _completely different_ variables; just as $keanu and @keanu
>are completely different variables; the $ and @ characters are inseparable
>parts of variables' names.

Well, not inseparable, since (as we're discussing in this
thread) $keanu[0] is an element in @keanu and is not related to
$keanu (as long as we're not playing with typeglobs).

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 24 Aug 2000 03:26:02 GMT
From: Hasanuddin Tamir <hasant@trabas.com>
To: bandung-pm-list@happyfunball.pm.org
Subject: A Proposal for BaseLib module (was Re: Modifying @INC...)
Message-Id: <8o24jp$973$1@nnrp1.deja.com>

In article <sq8n506bt91153@corp.supernews.com>,
  "Chris Stith" <mischief@motion.thispartfake.net> wrote:
>
> "Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> wrote in message
> news:39a41d62@news.victoria.tc.ca...
> > hasant@trabas.com wrote:
> > : The Problem
> >
> > : Determine a non-standard module path dynamically
> > : in the scripts.
> >
> > Can you not define the PERL5LIB environment variable before hand?
>
> I might even suggest putting a small config file in the
> application's base directory, which lists where the
> modules to be included reside. Read it in once, reuse it
> thoughout any part of the code that needs it. This could
> be done for the base directory, too, for that matter, in case you need
to
> find data files or whatever based on that.

Then how do you define the full path to that config file? As I
suppose it must be read by every script.


regards,
san


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 24 Aug 2000 01:29:41 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Associative arrays
Message-Id: <slrn8q8uje.ma.mgjv@verbruggen.comdyn.com.au>

On Wed, 23 Aug 2000 14:00:08 GMT,
	Philip Garrett <philipg@atl.mediaone.net> wrote:
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message
> news:slrn8q78b6.5ap.mgjv@martien.heliotrope.home...
> > On Wed, 23 Aug 2000 10:30:58 +0100,
> > Alex Buell <alex.buell@tahallah.clara.co.uk> wrote:
> > > I was playing with associative arrays like so:
> > >
> > > %fields = ( "Member ID" => 0, "Forename" => 1, "Surname" = >2 );
> [snip]
> > > print $fields{0); # I want to print "Member ID" but it doesn't!
> >
> > Because they are hashes, or associative arrays. The elements of these
> > things do not have an index. They're fundamentally unordered, and you
> > should not expect any order.
> 
> I think you misunderstood the OP.  He thinks it should return "Member ID"
> because it's associated with "0", not because it's the first element in the
> list.

You are probably right, and that's why the rest of my post talked
about that. However, the question was ambiguous enough to eleiminate
this possibility right at the start.

I don't have ESP, so I have to try to cover as many of the
interpretations I can think of. :)

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.   | make a better idiot.
NSW, Australia                  | 


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

Date: Thu, 24 Aug 2000 01:37:39 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Associative arrays
Message-Id: <slrn8q8v2c.ma.mgjv@verbruggen.comdyn.com.au>

On Wed, 23 Aug 2000 18:30:54 GMT,
	Mark <mtaylorlrim@my-deja.com> wrote:
> In article <slrn8q7e5q.5ap.mgjv@martien.heliotrope.home>,
>   mgjv@tradingpost.com.au wrote:
> > [please, in the future, put your reply after the suitably trimmed text
> > you reply to]
> >
> Well pardon the hell out of me, Mr Moderator

My, my. We have got thin skin, don't we?

> > [reorder post to respect the natural arrow of time]
> >
> Sorry, I think my time is more valuable than using it to please you. I
> have already spent too much time...

My time, and many other people's time, is too valuable to scroll up
and down to try to figure out what you are replying to.

It is certainly too valuable to point out that your post was off the
point, so that people who can't see that for themselves don't start
trying things out with your code, wasting _their_ time.

Because I care about quality of information that comes out of this
group, I do spend that time, now and again.

> Does this meet with your specifications?

I did not specify anything. The OP did. You didn't read it. You lose.
If you can't live with the fact that this gets pointed out to you,
don't post.

Usenet tradition also specifies rules for posting to newsgroups, and
replying to posts. Follow them, or live wit the fact that people will
point out to you that you're not following them. And many times it
gets brought to your attention in ways that would have penetrated your
thin skin very roughly. You are using this group, so live by its
rules. 

Do you visit restaurants, and fart loudly and demonstrably while your
eating? And do you insist that the effort in containing your sphincter
muscle are too valuable to stop it when someone asks?  Instead you'd
rather have everyone else have to deal with the fact that you are
making a nuisance of yourself.

Martien

PS. Oh, before I forget, *plonk*, so it won't matter to me anymore.
-- 
Martien Verbruggen              | 
Interactive Media Division      | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd.   | but mean your mother.
NSW, Australia                  | 


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

Date: Thu, 24 Aug 2000 03:13:25 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Creating new file and substituting data
Message-Id: <39ae91b1.11360137@news.newsguy.com>

Ulrich Ackermann <uackermann@orga.com> wrote:

>my first try would lead in thefollowing direction:
>1. Read the file with the names: 
>           open NAMES, "file_with_names.txt";
>           my @names = <NAMES>;

            chomp @names; # remove newlines

>2. After setting $/ to undef I would slurp in the complete template
>file, presumed it isn't too big:
>           undef $/;
>           open TEMPLATE, "template_file.txt";
>           my $text = <TEMPLATE>;
>3. Replace the %%XXX%% n a for(each) loop with the name and write it
>into a new file
>           for (@names) {
>               $text =~ s/%%XXX%%/$_/g;  # Maybe \%\%XXX\%\%

That only works the first time through the loop, since after
that $text no longer contains '%%XXX%%'.  You need to make a
copy of $text.

It's not necessary to backslash % -- it's not special in regular
expressions, and hashes (as opposed to hash elements) don't
interpolate.

>               open OUT, ">$_.txt";
>               print OUT $text;
>               close OUT;
>           }

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: 24 Aug 2000 02:23:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Direct screen access
Message-Id: <slrn8q91nd.tj3.abigail@alexandra.foad.org>

Chris Denman (chris@inta.net.uk) wrote on MMDXLVIII September MCMXCIII in
<URL:news:8ntttl$19hl$1@news2.vas-net.net>:
&& Is it possible to change the video adapter mode to, say, 320X200X256 ?

Perhaps. But that highly depends on your system. What if you run your
program on a headless box?

&& I know the screen address is at a000 and is 64K in size (in 256 colour
&& mode).

Goodie. But that isn't very portable, is it?

&& The reason being, is I would love to write a simple game in Perl (and have
&& done so years ago in C).

You might want to write an XS program to write directly to certain memory
addresses.


Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: 24 Aug 2000 02:26:38 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Direct screen access
Message-Id: <slrn8q91tj.tj3.abigail@alexandra.foad.org>

Chris Denman (chris@inta.net.uk) wrote on MMDXLVIII September MCMXCIII in
<URL:news:8nu1im$1b22$1@news2.vas-net.net>:
?? Jonathan,
?? 
?? Please excuse my ignorance, could you please tell me what a XS component is?

Please read the manual to answer that question. "man perl" will list
several manpages dealing with XS.

?? I have tried to set a variable as an address to hex 0a000 and wrote a
?? charater to that address, but perl came back with errors, saying that this
?? area of memory has forbiden access.

Eh, what exactly did you do? 

?? Does this mean that even if I could change the screen mode, I will still not
?? be able to write to this address?

Right. Perl does not let you directly access memory by address. Perl
is a high level language. If you want to interface with your system in
a low level way, you need to use a low level language, like C, and use
XS or SWIG to interface Perl with the low level language.

?? Thanks again.

Please refrain from posting Jeopardy style.



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: Thu, 24 Aug 2000 01:10:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Flipflop matching
Message-Id: <x71yzftqfd.fsf@home.sysarch.com>

>>>>> "p" == philhibbs  <philhibbs@my-deja.com> writes:

  >> ...  :-)

  p> Oh, I see, the ellpisis. Viewing the message on deja.com, it looks like
  p> his carets are pointing to the es of "matches".

when people use ^^^ to mark something, they assume a fixed width
font. most normal mail and newsreaders use fixed width for that
reason. but with a web based reader who knows what it will look like.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 24 Aug 2000 02:29:15 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Forking in WinNT
Message-Id: <slrn8q922g.tj3.abigail@alexandra.foad.org>

Jeff Susanj (jeffrey.l.susanj@boeing.com) wrote on MMDXLVIII September
MCMXCIII in <URL:news:FzpBu6.93t@news.boeing.com>:
)) 
)) Windows NT does not support fork.

But Perl 5.6.0 on Windows NT supports fork().



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: Thu, 24 Aug 2000 01:41:57 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Generalized "User Database"?
Message-Id: <slrn8q8vad.ma.mgjv@verbruggen.comdyn.com.au>

On Wed, 23 Aug 2000 09:36:00 -0500,
	Matt Kruse <mkruse@netexpress.net> wrote:
> Martien Verbruggen <mgjv@tradingpost.com.au> wrote
> > sounds like /etc/passwd with some extended GCOS information.
> 
> Well, since /etc/passwd is just a flat file containing information, I
> suppose so :)
> 
> > Alternatively, use a combination of DBI, DBD::CSV, or another file based
> > DBI driver. Use the crypt builtin to do password hashing stuff.
> 
> Yup, I know how to accomplish the end task. But I was asking if anyone had
> already done the job of building it, creating methods to update the
> "database", handle file locking, etc.
> 
> > > I thought this would be common! :)
> > Very common.
> 
> Then why can't I find existing code to do it? :)

Maybe I misunderstood. You wanted only the backend code, right?

DBI and DBD::CVS will give you that. To encrypt the password, use the
internal crypt function. You will still have to write the schema and
code to access it, but that's front-end code in my view. It becomes a
matter of using SQL to do the things you said you wanted to do.

I don't know of anything that is built on top of the modules that
would give you that stuff, but it's not that hard to write it...

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | That's not a lie, it's a
Commercial Dynamics Pty. Ltd.   | terminological inexactitude.
NSW, Australia                  | 


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

Date: Thu, 24 Aug 2000 00:43:48 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: help with simple regexp - does my head in
Message-Id: <39a56e10.2237419@news.newsguy.com>

Ren Maddox <ren.maddox@tivoli.com> wrote:
>abigail@foad.org (Abigail) writes:

>>     Benchmark: running -1, 1, each for at least 10 CPU seconds...
>>             -1:  9 wallclock secs (10.62 usr + -0.03 sys = 10.59 CPU)
>>                  @ 445933.52/s (n=4722436)
>>              1: 14 wallclock secs (10.52 usr +  0.00 sys = 10.52 CPU)
>>                  @ 529952.57/s (n=5575101) 
>
>Um... It doesn't seem like negative values for the number of
>iterations is doing what you think.  It looks like it causes each case
>(individually) to run for at least (in this case) 10 seconds.  But if
>you look at the values of n, they are substantially different.  So the
>cases are not being run the same number of times.

Um, I don't think Abigail's thinking what you think she's
thinking.

    (1 s)/445933.52 - (1 s)/529952.57 = roughly 355 ns

just as Abigail said.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 24 Aug 2000 02:13:12 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: help with simple regexp - does my head in
Message-Id: <slrn8q9151.ma.mgjv@verbruggen.comdyn.com.au>

On 23 Aug 2000 15:43:17 -0500,
	Ren Maddox <ren.maddox@tivoli.com> wrote:
> abigail@foad.org (Abigail) writes:
> 
> > Well, yeah, but the difference is insignificant. 
[snip]
> >     Benchmark: running -1, 1, each for at least 10 CPU seconds...
> >             -1:  9 wallclock secs (10.62 usr + -0.03 sys = 10.59 CPU)
> >                  @ 445933.52/s (n=4722436)
                       ^^^^^^^^^^^
> >              1: 14 wallclock secs (10.52 usr +  0.00 sys = 10.52 CPU)
> >                  @ 529952.57/s (n=5575101)
                       ^^^^^^^^^^^
> Um... It doesn't seem like negative values for the number of
> iterations is doing what you think.  It looks like it causes each case

I doubt that Abigail doesn't know what it means. I could be wrong, but
I doubt that as well. Maybe you are incorrect in assuming that Abigail
thought what you think she thought. Maybe I am incorrect in assuming
that Abigail knew what I think she knew. But again, I doubt that.

> (individually) to run for at least (in this case) 10 seconds.  But if
> you look at the values of n, they are substantially different.  So the
> cases are not being run the same number of times.

I think Abigail was probably comparing the two underlined numbers, and
they are significantly different.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If at first you don't succeed,
Commercial Dynamics Pty. Ltd.   | destroy all evidence that you tried.
NSW, Australia                  | 


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

Date: Thu, 24 Aug 2000 11:21:05 +0800
From: "Lucas Tsoi" <lucas@cplhk.com>
Subject: help!!
Message-Id: <8o244a$s011@imsp212.netvigator.com>

Hi all,

I got a question about interpolation, I found the programm
always go error because the non-Englsih codes have invliad
characters.
------------------------------------------------------------
print qq~
    $a 's Chinese is ( chinese codes here )
    $b 's Japannese is ( japanese codes here )
    $c 's  Korean is ( korea codes here )
~;


In know I could do what I want if I single quote the non-Engligh
text, but is that the only way?
any more convenient one?
-----------------------------------------------------------
print qq~
    $a 's Chinese is
~;

print '( chinese codes here )';

print qq~
$b 's Japannese is
~;

print '( japanese codes here )';

print qq~
    $c 's  Korean is
~;

print '( korea codes here )
';









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

Date: 24 Aug 2000 03:31:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: how can I optimize a tied hash for speed
Message-Id: <slrn8q95ng.tj3.abigail@alexandra.foad.org>

Ilmari Karonen (iltzu@sci.invalid) wrote on MMDXLIX September MCMXCIII in
<URL:news:967050016.2136@itz.pp.sci.fi>:
`` 
`` I had to see that to believe it, but it seems you're right.  If one
`` can use each() in list context to get both the key and the value, it
`` isn't more than a few percent slower, though:
`` 
`` #!/usr/bin/perl -w
`` use strict;
`` use Benchmark;
`` 
`` use vars qw(%hash);
`` %hash = map rand() => 1 .. 2048;
`` 
`` timethese 1<<(shift || 0),
``   { keys => 'for my $key (keys %hash) { my $val = $hash{$key}; }',
``     each => 'while (my ($key, $val) = each %hash) { }',
``   };
`` 
`` __END__
`` Benchmark: timing 4096 iterations of each, keys...
``       each: 40 wallclock secs (36.17 usr +  0.00 sys = 36.17 CPU)
``       keys: 38 wallclock secs (34.75 usr +  0.00 sys = 34.75 CPU)
`` 
`` This is perl, version 5.005_03 built for i386-linux


That is not a reasonable benchmark. The drawback of using 'keys %hash'
is the (possible) large list it generates, and hence the allocation of
memory to store that list in. But, you pay that price once, the other
4095 times, you are reusing the allocated memory.

Benchmarking is an art form. And you need to know when you can use it.


Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: 24 Aug 2000 03:26:00 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: how to generate unreadable from readable perl code
Message-Id: <slrn8q95e8.h7b.dha@panix6.panix.com>

On 24 Aug 2000 00:11:23 GMT, Eli the Bearded <elijah@workspot.net> wrote:
>I've used regexps like:
>
>	s X (some regexp that includes lots of ! \# \$ \@ \% / , )
>	  X &replacestring($1) Xxes;
>

Indeed.  I was just thinking of you, in fact, while reading through
the new edition of the camel, which indicates that you can no longer
do this... unless I misread.  :-(

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Sometimes these hairstyles are exaggerated beyond the laws of physics
	  - Unknown narrator speaking about Anime


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

Date: 24 Aug 2000 03:44:43 GMT
From: abigail@foad.org (Abigail)
Subject: Re: how to generate unreadable from readable perl code
Message-Id: <slrn8q96g0.tj3.abigail@alexandra.foad.org>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDXLIX September
MCMXCIII in <URL:news:slrn8q7hot.5ap.mgjv@martien.heliotrope.home>:
[] 
[] Seriously, there are good reasons to avoid / sometimes, particularly
[] when you're working  with a regex that contains one itself. However,
[] choosing a separator that is one of the abovementioned characters, or as
[] low visibility, like ',' is silly. What's wrong with '#' (apart from it
[] breaking simple-minded code parsers)? What's wrong with '!'? What's
[] wrong with m[REGEXP] or m{REGEXP}? All of those provide very readable
[] alternatives that don't obscure what you're doing. And using anything
[] else than m// when not needed is just deliberate obfuscation (unless you
[] prefer m[] or m{}).
[] 
[] The regexp that makes the very limited set of m//, m!!, m[] not
[] sufficient to escape the leaning toothpick syndrome is rare enough to
[] put in an occasional backwhack.


Well, ! has the drawback it's used in regex tokens. (?!...) for instance.
[] is also special in regexes, and while they can nest, it doesn't always
make it more readable. Same for {}. I do use {} myself often though, although
I'm not always happy with the results.

As for '#', one of the simple minded code parsers that trips over it is
Perl. You can't have a space between the 'm' or 's' and the '#', lest
Perl thinks it's a comment. And besides that, '#' is just too much black;
it draws the eye away from what's important: the regex.

As for low visibility, I sometimes use . as the delimiter. You can't use
it if you want to use . in the regex, but I find it's low visibility a
_feature_. It makes the regex stand out more. Furthermore, . is next to /
on my keyboard, and doesn't require a shift. I often use it in my editor.



Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


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

Date: 24 Aug 2000 03:48:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: how to generate unreadable from readable perl code
Message-Id: <slrn8q96n5.tj3.abigail@alexandra.foad.org>

Eli the Bearded (elijah@workspot.net) wrote on MMDL September MCMXCIII in
<URL:news:eli$0008232011@qz.little-neck.ny.us>:
$$ 
$$ But there are some other cases that will screw over parsers.
$$ I've used regexps like:
$$ 
$$ 	s X (some regexp that includes lots of ! \# \$ \@ \% / , )
$$ 	  X &replacestring($1) Xxes;
$$ 
$$ in real code. And control characters (unless considered whitespace)
$$ do work as delimiters. I once used ^A for a security through
$$ obscurity concern.


One should be aware that use of alphanumerics as delimiters is an 
undocumented relic from the past, that might go away unanounced.

But it's a neat feature.



Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


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

Date: Thu, 24 Aug 2000 01:06:43 GMT
From: "Keith Smith" <ksmith@firesnacks.com>
Subject: How to Include a Perl script in a Perl script
Message-Id: <Dy_o5.25048$eR5.757311@news1.rdc1.on.wave.home.com>

HI:

I am looking for something akin to C's #include "header.h".

What would be the PERL equivalent?

Keith




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

Date: 23 Aug 2000 20:33:15 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: How to Include a Perl script in a Perl script
Message-Id: <874s4bo338.fsf@limey.hpcc.uh.edu>

>> On Thu, 24 Aug 2000 01:06:43 GMT,
>> "Keith Smith" <ksmith@firesnacks.com> said:

> HI: I am looking for something akin to C's #include
> "header.h".

> What would be the PERL equivalent?

depends on what you want to do.  Care to elucidate...?

t
-- 
"I'm not easily impressed.  Wow!  A blue car!"
                                               Homer Simpson


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

Date: 24 Aug 2000 01:33:34 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: How to Include a Perl script in a Perl script
Message-Id: <8o1u1e$9r2k3$1@ID-24002.news.cis.dfn.de>

hi,
Keith Smith <ksmith@firesnacks.com> wrote:

> I am looking for something akin to C's #include "header.h".

I don't know much about C, but I guess you're
looking for use(), require() or maybe do().

type perldoc -f use
or perldoc perlmod
to learn more about that

tina


-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Wed, 23 Aug 2000 20:37:57 -0500
From: "Chris Stith" <mischief@motion.thispartfake.net>
Subject: Re: How to Include a Perl script in a Perl script
Message-Id: <sq8v3irdt91157@corp.supernews.com>


"Keith Smith" <ksmith@firesnacks.com> wrote in message
news:Dy_o5.25048$eR5.757311@news1.rdc1.on.wave.home.com...
> HI:
>
> I am looking for something akin to C's #include "header.h".
>
> What would be the PERL equivalent?

require    or     use

Chris Stith -- "The Dark Lord of the Stith"
Motion Internet
mischief@motion.net   mr_mischief1@hotmail.com





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

Date: Wed, 23 Aug 2000 20:56:56 -0500
From: "Dale Emmons" <dale@emmons.dontspamme.com>
Subject: Re: How to Include a Perl script in a Perl script
Message-Id: <sq8vtogt9171@corp.supernews.com>

require "something.pl";

"Keith Smith" <ksmith@firesnacks.com> wrote in message
news:Dy_o5.25048$eR5.757311@news1.rdc1.on.wave.home.com...
> HI:
>
> I am looking for something akin to C's #include "header.h".
>
> What would be the PERL equivalent?
>
> Keith
>
>




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

Date: 24 Aug 2000 03:49:55 GMT
From: abigail@foad.org (Abigail)
Subject: Re: How to Include a Perl script in a Perl script
Message-Id: <slrn8q96po.tj3.abigail@alexandra.foad.org>

Keith Smith (ksmith@firesnacks.com) wrote on MMDL September MCMXCIII in
<URL:news:Dy_o5.25048$eR5.757311@news1.rdc1.on.wave.home.com>:
:: HI:
:: 
:: I am looking for something akin to C's #include "header.h".
:: 
:: What would be the PERL equivalent?


It's Perl, not PERL.

And you could use #include if you wish. Just run it with the -P flag.

But if you're looking for a more Perlish form of requiring and using
code in other files, consult the manual.



Abigail
-- 
 :;$:=~s:
-:;another Perl Hacker
 :;chop
$:;$:=~y
 :;::d;print+Just.
$:;


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

Date: Thu, 24 Aug 2000 02:42:51 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: How to split mailheaders
Message-Id: <39ac8ae3.9618319@news.newsguy.com>

Kjetil Skotheim <kjetilskotheim@iname.com> wrote:

>@header = split(/\n/,$header);             #wrong, obviously
>@header = split(/.+(?!\n\S|$)/s,$header);  #failed, dont know why

I believe you're trying for something like this:

    my @header = split /\n(?=\S|$)/, $header;

>Example of mail header:
>
>(First part should be the first line, second part should be line two,
>three and four, since they three and four starts with space).
>$header=<<END;

That should be

    $header = <<'END';

unless you want to backslash @ throughout the here-doc.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Wed, 23 Aug 2000 21:31:11 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Just another silly post.
Message-Id: <brian-ya02408000R2308002131110001@news.panix.com>

In article <39A46159.ECE3174@yahoo.com>, Policy Man <reljr_2@yahoo.com> posted:

> I have a challenge for you. Create perl code according to these
> requirements:
> 
> In a Unix/Linux OS return a list of the names of all the files,
> directories, sub directories, sub sub directories, sub sub ... sub
> directories, etc. of an arbitrarily given list of directories or files
> (called @given) with the directory name of each directory listing
> given last. Do not include . or .. in the returned list.

> -- external programs of any kind.

well, you have to interact with the file system at some point,
so does that count as a program?  and, if it doesn't, then i'm
allowed to do:

      eval ( <> )

and that pretty much takes care of all of the restrictions
given appropriate input.

> Why do it? The same reason one might climb a mountain -- because we can.

"we"?  let's see your solution.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Wed, 23 Aug 2000 21:28:42 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A48859.B8FA1697@yahoo.com>

brian d foy wrote:

> In article <39A46159.ECE3174@yahoo.com>, Policy Man <reljr_2@yahoo.com> posted:
>
> > I have a challenge for you. Create perl code according to these
> > requirements:
> >
> > In a Unix/Linux OS return a list of the names of all the files,
> > directories, sub directories, sub sub directories, sub sub ... sub
> > directories, etc. of an arbitrarily given list of directories or files
> > (called @given) with the directory name of each directory listing
> > given last. Do not include . or .. in the returned list.
>
> > -- external programs of any kind.
>

Ahhh... its not easy wording things so precisly that no confusion
can exist. Yes, the file system, yea even the OS is a program, but
let's be charitable and assume that the basic systems underlying
the OS and file system are in fact available. If not, then perl
itself would not function.

>
> well, you have to interact with the file system at some point,
> so does that count as a program?  and, if it doesn't, then i'm
> allowed to do:
>
>       eval ( <> )
>
> and that pretty much takes care of all of the restrictions
> given appropriate input.

@given = glob "/tmp";
print join "\n",

eval (<>)  ;

apparently produces nothing. I'm uncertain what you were attempting here. Please
clarify. (remember, I do admit to being an idiot -- I may be overlooking the
obvious!)

>
> > Why do it? The same reason one might climb a mountain -- because we can.
>
> "we"?  let's see your solution.

In due time.



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

Date: Wed, 23 Aug 2000 21:29:54 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A488A2.548C4090@yahoo.com>

Larry Rosler wrote:

>
> Your challenge might be more suitable for the Fun With Perl list,
> fwp@technofile.org

You may be right, but let's see what good old usenet can produce first.



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

Date: 24 Aug 2000 02:45:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Just another silly post.
Message-Id: <slrn8q930n.tj3.abigail@alexandra.foad.org>

Larry Rosler (lr@hpl.hp.com) wrote on MMDL September MCMXCIII in
<URL:news:MPG.140e112c7fb2144798acd2@nntp.hpl.hp.com>:
|| In article <39A46159.ECE3174@yahoo.com> on Wed, 23 Aug 2000 18:42:17 -
|| 0500, Policy Man <reljr_2@yahoo.com> says...
|| > 
|| > I have a challenge for you. Create perl code according to these
|| > requirements:
|| 
|| Your challenge might be more suitable for the Fun With Perl list, 
|| fwp@technofile.org


Nah. Halfway the list of arbitrary restrictions, I hit 'n' key with
the thought 'this is no fun'.

Oh, btw, there's a trivial way around most of the restrictions. Code
the thing in whatever way you want. Turn the code into a string. Replace
all characters with octal escapes. Eval it. (And if down the list it's
mentioned you can't use "eval", there's always s///e and s///ee).


Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4113
**************************************


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