[19348] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1543 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 16 18:11:03 2001

Date: Thu, 16 Aug 2001 15:10:14 -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: <997999814-v10-i1543@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 16 Aug 2001     Volume: 10 Number: 1543

Today's topics:
    Re: OT: Why is there so much white space in perl docume (Tad McClellan)
    Re: OT: Why is there so much white space in perl docume <miscellaneousemail@yahoo.com>
    Re: Passing single reference into a sub assigning @_ in <miscellaneousemail@yahoo.com>
    Re: Passing single reference into a sub assigning @_ in <Tassilo.Parseval@post.rwth-aachen.de>
    Re: Passing single reference into a sub assigning @_ in (Tad McClellan)
    Re: Passing single reference into a sub assigning @_ in <mjcarman@home.com>
        Perl hidden text, password prompt. <hlg@socrates.berkeley.edu>
    Re: Perl hidden text, password prompt. <ilya@martynov.org>
    Re: Perl hidden text, password prompt. <rsherman@ce.gatech.edu>
    Re: perldoc is like Greek to a beginner?? <uri@sysarch.com>
    Re: perldoc is like Greek to a beginner?? (Tad McClellan)
    Re: pipe STDERR <gnarinn@hotmail.com>
    Re: pipe STDERR (Tad McClellan)
    Re: regexp gurus - help (B Puli)
    Re: SQL (MySQL) Windows <gnarinn@hotmail.com>
    Re: Text::Wrap/ANSI proplem <mjcarman@home.com>
        Using 'require' and variables <sleddog@komatik.org>
    Re: Using a fake name on this newsgroup and in places l (Abigail)
    Re: Using a fake name on this newsgroup and in places l <miscellaneousemail@yahoo.com>
    Re: Verifying users against NT domain? (Jeff Walker)
    Re: What's the Problem locating Files? <Tassilo.Parseval@post.rwth-aachen.de>
        Will Perl report on variables no longer used?? <miscellaneousemail@yahoo.com>
    Re: Will Perl report on variables no longer used?? <ilya@martynov.org>
    Re: Will Perl report on variables no longer used?? <cberry@cinenet.net>
    Re: Will Perl report on variables no longer used?? <tsee@gmx.net>
    Re: Will Perl report on variables no longer used?? <tsee@gmx.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 16 Aug 2001 14:58:23 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: OT: Why is there so much white space in perl documentation??
Message-Id: <slrn9no5uf.5sq.tadmc@tadmc26.august.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
>In article <m3lmkk2ciw.fsf@dhcp9-161.support.tivoli.com>, Ren Maddox at 
>ren@tivoli.com says...


>I guess 
>I had just been making the point that Windows does not have native 
>utilities to do as much as UNIX folks have at their disposal.  


Unix was designed for programmers.

Windows was designed for consumers.

Which would you expect to be more popular among programmers?

We (here in comp.lang.*, ie. "programmers") are not in the
target audience that Windows was designed for.

Not at all surprising that it easier to program on Unix,
it was designed to be easy to program. (because it was
programmers doing the designing, and they were designing
"for themselves")


>Which 
>makes reading perldoc's at the command line a bit easier and more 
>practical on UNIX I think.  


That sounds like an excuse we hear often here. I doubt you would
use it that way, but I see it happen all the time.

   I can't do a word search for "frobitz" in all the *pods on 
   my M$ system, so can someone look that up for me?



You _have_ to read the docs (either 'cause you want to post, or
just because you gotta get past this problem so you can
satisfy your boss and get a paycheck).

It does not matter if it is easy or hard, you still have to do it.

A poor choice of tools on your part does not constitute an
emergency on the community's part.


Again, not directed at you, just at lots of folks that use
the same tool you happen to use, and who post here ungraciously.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 16 Aug 2001 21:44:05 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: OT: Why is there so much white space in perl documentation??
Message-Id: <MPG.15e5eca4b5e6069a98976a@news.edmonton.telusplanet.net>

In article <slrn9no5uf.5sq.tadmc@tadmc26.august.net>, Tad McClellan at 
tadmc@augustmail.com says...

> Unix was designed for programmers.
> 
> Windows was designed for consumers.
> 

Good points Tad.  I agree.  

> Not at all surprising that it easier to program on Unix,
> it was designed to be easy to program. (because it was
> programmers doing the designing, and they were designing
> "for themselves")

Windows sucks as far as a good programming platform.  I have to reboot my 
computer (was Windows 95, now Windows 98) a minimum of 3 or 4 times a day 
because of this or that memory violation or who knows what.  I used to 
have to reboot double that before I got a memory booster.  Programs 
freeze up, I get blue screens of death.  You name it.  Admittedly I am 
stretching Windows by doing all I do on it but still.  I am constantly 
having to pre-empt Windows and figure out how I am going to make sure 
everything is saved, etc. in case Windows crashes again.  Knowing that 
Windows WILL crash again is always in the back of my mind.   

I tried Linux once and after installing it about 30 times and then trying 
to work in it I realized that my productivity would crawl to an almost 
full stop for a while I learned how to use it. Something I couldn't 
afford at the time. 

Someday when I have more time (right!) I will definitely go back to 
Linux.  For now I guess it's just one of those wishes that I wish would 
come true.  Instantly and easily without any or little work on my part 
=:).  Kinda like Windows does it (super big sarcastic grin). 

> That sounds like an excuse we hear often here. I doubt you would
> use it that way, but I see it happen all the time.

No I certainly would not use the poor tool that Windows is as an excuse 
for not trying to look things up myself but I'll tell you what.  It's 
frustrating sometimes to work on Windows.  I mean just today I was trying 
to install the DBD::CSV module.  It took me about an hour to an hour and 
a half just to figure out where to get it, how to use the ActiveState PPM 
installation utility, to look up the DBD docs, to search for some example 
uses, and so forth.  My productivity as usual came to an absolute crawl 
trying to find this or that.  It's really frustrating sometimes because I 
will be hot on the trail of some neat Perl code and swish I end up 
falling into the quicksand of trying to find some little, itty, bitty, 
piece of information that takes me an hour or more to find.  

My biggest need as a beginning Perl programmer is to establish some kind 
of system for finding the info that I need when I need it.  I spend 
probably twice if not three times as much time trying to find things and 
to answer my own questions than I do writing Perl code.  It's ridiculous 
but I got to do it. Though I am aiming to do it better without taking so 
much time at it. 

>    I can't do a word search for "frobitz" in all the *pods on 
>    my M$ system, so can someone look that up for me?

Right with you on this one Tad though I would definitely spend some time 
showing newbies how to look things up for themselves.  As you and others 
have done for me.  But look things up for someone who can do it 
themselves if given the knowledge of how to fish for knowledge?  Not 
likely.  Who's got the time for that?  (Unless they are my parents-in-
law, brother, or sister =:).

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Thu, 16 Aug 2001 18:10:27 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Passing single reference into a sub assigning @_ into a hash??
Message-Id: <MPG.15e5b9d2185ab4c0989766@news.edmonton.telusplanet.net>

In article <3B7C07DE.B4187FBD@guideguide.com>, Jasper McCrea at 
jasper@guideguide.com says...

> Why push it into a hash? Why not just:
> 
> my ($io_handle) = (@_, *STDOUT);

Works beautifully.  Thanks Jasper.  I've never seen that construct 
though.  Can someone explain the statement above to me?

Is it something like....

Assign the @_ array values into $io_handle.  If @_ is empty then assign 
*STDOUT.  

Can someone also point me to some perldoc that might expand on this some?  

Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: Thu, 16 Aug 2001 20:25:54 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Passing single reference into a sub assigning @_ into a hash??
Message-Id: <3B7C1032.5060104@post.rwth-aachen.de>

Carlos C. Gonzalez wrote:
> In article <3B7C07DE.B4187FBD@guideguide.com>, Jasper McCrea at 
> jasper@guideguide.com says...
> 
> 
>>Why push it into a hash? Why not just:
>>
>>my ($io_handle) = (@_, *STDOUT);
>>
> 
> Works beautifully.  Thanks Jasper.  I've never seen that construct 
> though.  Can someone explain the statement above to me?

It goes along with the Perl-logic how lists are handled. Consider:

@a = qw(a b c);
@b = qw(d e f);
@c = (@a, @b);
print @c;
__END__
abcdef

This should make clear what happens in the example that you wanted 
explained:

($io_handle) forces list-context (otherwise it would hold the number of 
elements in the list of the right side). It is a list-slice consisting 
of only the first element of the right list. If @_ is empty, then 
'*STDOUT' becomes the only element of the right-side list and thus gets 
assigned to $io_handle.


> Is it something like....
> 
> Assign the @_ array values into $io_handle.  If @_ is empty then assign 
> *STDOUT.  

Yes. But there is no if-magic going on behind the scenes as I tried to 
explain.

> Can someone also point me to some perldoc that might expand on this some?  

Probably perldata is the manpage you are looking for, particularly the 
'List value constructors' section.

Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Thu, 16 Aug 2001 15:27:01 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Passing single reference into a sub assigning @_ into a hash??
Message-Id: <slrn9no7k5.5sq.tadmc@tadmc26.august.net>

Carlos C. Gonzalez <miscellaneousemail@yahoo.com> wrote:
>
>I am trying to create a sub that will accept an IO handle and printf to 
>it.  If the IO handle is not specified I want the sub to print to STDOUT 
>by deault. 


>sub print_contents
>{
>  my %args = (
>    IO_HANDLE => *STDOUT,
>	@_);


>I called it by either ...
>
>print_contents(\*STDOUT);


   print_contents( 'IO_HANDLE', \*STDOUT);
#                     key         value


The value of $args{IO_HANDLE} in print_contents will be overwritten
when there are args as above.


>print_contents();
>
>%file_hash is a global hash filled with key, value pairs of data.


Please consider providing some input data. Saying it Perl is more
precise that natural language anyway:

my %file_hash = (
   'jack@ardvark.com' => 'Jack,20010812,18:34,Canada,Stony Plain,Yes',
   'linda@ant.com'    => 'Linda,20010812,18:34,France,Paris,Yes',
);


That wouldn't have been very hard.

Then we would be able to actually run your code instead of only
doing a "bench analysis" of it.


>print_contents is working just fine except for one thing.  Perl warns me 
>that I am trying to pass a single value, namely \*STDOUT, to the sub and 
>that I am initializing %args to a single value when I do that.  When I 
>don't pass in an IO handle, no problem.  


When you assign a list to a hash, the list better be alternating
key/value pairs. If it isn't, you get warned about it.


>Should I heed the warning?  


You should *always* heed warnings.


>Is there a danger in not doing so?  


Yes. If it was totally benign why would someone take the time
to code up a warning about it :-)


>Is there 
>a way to rewrite something in print_contents so as to avoid what 
>generates the warning?


Others have shown that. I've shown how to change the _calling_
of print_contents so as to avoid generating the warning.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 16 Aug 2001 15:56:42 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Passing single reference into a sub assigning @_ into a hash??
Message-Id: <3B7C338A.B5C8128A@home.com>

"Carlos C. Gonzalez" wrote:
> 
> In article <3B7C07DE.B4187FBD@guideguide.com>, Jasper McCrea at
> jasper@guideguide.com says...
> 
> > Why push it into a hash? Why not just:
> >
> > my ($io_handle) = (@_, *STDOUT);
> 
> I've never seen that construct [...] Can someone explain 
> the statement above to me?
> 
> Is it something like....
> 
> Assign the @_ array values into $io_handle. If @_ is empty then
> assign *STDOUT.

Close. This construct copies one list (@_, *STDOUT) to another list
($io_handle) element for element. So if @_ contains anything, its first 
element will be copied to $io_handle. (After which everything else is
ignored since the left side contains only one element.) If @_ is empty
it will flatten down to nothing and the right hand side reduces to
(*STDOUT). In that case, *STDOUT is copied to $io_handle.

> Can someone also point me to some perldoc that might expand on this
> some?

See the perldata manpage, down in the section about lists.

-mjc


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

Date: Thu, 16 Aug 2001 11:59:32 -0700
From: Helene Grossman <hlg@socrates.berkeley.edu>
Subject: Perl hidden text, password prompt.
Message-Id: <3B7C1814.23FEA1DF@socrates.berkeley.edu>

I am writing a Perl script that will handle entry into a filesystem that
prompts the user for login and password.

How do I make it such that on the password prompt, the user's input is
not displayed on the screen, like in all the telnet and SSH
implementations I have ever seen?

Thanks, Antonio.



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

Date: 16 Aug 2001 23:04:54 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Perl hidden text, password prompt.
Message-Id: <87ae0zsu5l.fsf@abra.ru>


HG> I am writing a Perl script that will handle entry into a filesystem that
HG> prompts the user for login and password.

HG> How do I make it such that on the password prompt, the user's input is
HG> not displayed on the screen, like in all the telnet and SSH
HG> implementations I have ever seen?

use Term::ReadKey.

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Thu, 16 Aug 2001 15:05:41 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: Perl hidden text, password prompt.
Message-Id: <3B7B9AF5.C8F79563@ce.gatech.edu>

Helene Grossman wrote:
> 
> I am writing a Perl script that will handle entry into a filesystem that
> prompts the user for login and password.
> 
> How do I make it such that on the password prompt, the user's input is
> not displayed on the screen, like in all the telnet and SSH
> implementations I have ever seen?
> 
> Thanks, Antonio.

http://search.cpan.org/search?dist=TermReadKey

-- 
robert sherman
css, cee
georgia institute of technology
atlanta, ga, usa


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

Date: Thu, 16 Aug 2001 18:38:30 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <x7ae0zkfyw.fsf@home.sysarch.com>

>>>>> "YO" == Yves Orton <demerphq@hotmail.com> writes:

  YO> Cheers Abigial

  YO> ps (Have you ever thought of writing a book or article on your
  YO> JAPHs?  I for one would buy/read it from top to bottom....)

she has done talks on them at the last two YAPC::NA conferences.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs  --------------------------  http://jobs.perl.org


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

Date: Thu, 16 Aug 2001 14:46:49 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: perldoc is like Greek to a beginner??
Message-Id: <slrn9no58p.5sq.tadmc@tadmc26.august.net>

Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "YO" == Yves Orton <demerphq@hotmail.com> writes:
>
>  YO> Cheers Abigial
>
>  YO> ps (Have you ever thought of writing a book or article on your
>  YO> JAPHs?  I for one would buy/read it from top to bottom....)
>
>she has done talks on them at the last two YAPC::NA conferences.


My favorite quote from YAPC 19100 was from Abigail:

   Creating a JAPH is simple. All you need is an idea, then
   you work out the details.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 16 Aug 2001 18:12:37 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: pipe STDERR
Message-Id: <997985557.7682049642317.gnarinn@hotmail.com>

In article <3B7B8076.BBE2676C@sxb.bsf.alcatel.fr>,
Philippe PERRIN  <philippe.perrin@sxb.bsf.alcatel.fr> wrote:
>
>Is there any Perl solution to force a FILEHANDLE to be non-bufferized ?
>

perldoc -f select

gnari


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

Date: Thu, 16 Aug 2001 15:34:34 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: pipe STDERR
Message-Id: <slrn9no82a.5sq.tadmc@tadmc26.august.net>

gnari <gnarinn@hotmail.com> wrote:
>In article <3B7B8076.BBE2676C@sxb.bsf.alcatel.fr>,
>Philippe PERRIN  <philippe.perrin@sxb.bsf.alcatel.fr> wrote:
>>
>>Is there any Perl solution to force a FILEHANDLE to be non-bufferized ?


No, but the $| special variable might be good enough for your purposes:

   perldoc perlvar


>perldoc -f select


select() does not affect buffering. It affects what the "currently
selected filehandle" is. You may need to use select() to get
autoflushing enabled though.


$| does not disable buffering, though it may appear to. It just
causes the buffer to be flushed more often than usual.

$| does not disable buffering.

$| enables autoflush.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 16 Aug 2001 13:33:38 -0700
From: bpuli@hotmail.com (B Puli)
Subject: Re: regexp gurus - help
Message-Id: <42ec637b.0108161233.2eb2225f@posting.google.com>

Thanks for your quick and useful reply. The regexp that you provided
works in identifying the required comment.

I also found that the simple /\*/ .. /\// works in identifying
comments.

I have a related question though. Both these methods work only if the
comment occurs only once in the file. ( I have another use for this
regexp).

I am reading the entire file by undef'ing $/. What do i need to do for
applying this regexp multiple times in the same file. reading in by
paragraphs does not work because there might or might not be newlines
betwen comments.

any pointers appreciated.

thanks

bp

"Kurt Stephens" <vze2r2j8@verizon.net> wrote in message news:<VLge7.1718$cf.385956@typhoon2.gnilink.net>...
> 
> Consider the usual idiom for stripping C comments:
> 
> [Begin code]
> 
> my $comment_re = qr'
>     /\*             # Start comment
> 
>     (?:             # Match group
>         [^*]        #   anything but *
>     |               # or
>         \*          #   *
>         (?!/)       #   not followed by /
>     )*              # zero or more times
> 
>     \*/             # End Comment
> 'x;
> 
> $code =~ s/$comment_re//;
> 
> [End code]
> 
> Or, if you prefer...
> 
> $code =~ s/\/\*(?:[^*]|\*(?!\/))*\*\///sg;
> 
> 
> Note that the cluster (?:[^*]|\*(?!\/))* matches the text inside the
> comment.  To match only RCS comments, we can set up the regex to match the
> following:
> 
> Start comment
>     Comment text
>     RCS text
>     More comment text
> End comment
> 
> For a simple solution, we can match any comments that contain the text
> '$Log:'.  For a more robust solution, we can restrict the RCS text match to
> a line starting with optional whitespace, $Log:, any text excluding '$',
> followed by '$'.  We need the multiline 'm' modifier so that ^ will match
> after newlines within the text.
> 
> The following code should do the trick:
> 
> [Begin code]
> 
> my $rcs_re = qr'
>     /\*             # Start comment
> 
>     (?:             # Match group
>         [^*]        #   anything but *
>     |               # or
>         \*          #   *
>         (?!/)       #   not followed by /
>     )*              # zero or more times
> 
>     ^               # Start RCS line
>     [ \t]*          # optional whitespace
>     \$Log:          # literal $Log:
>     [^$\n]+         # anything but $, newline
>     \$              # literal $
> 
>     (?:             # Match group
>         [^*]        #   anything but *
>     |               # or
>         \*          #   *
>         (?!/)       #   not followed by /
>     )*              # zero or more times
> 
>     \*/             # End Comment
> 'mx;
> 
> $code =~ s/$rcs_re//g;
> 
> [End code]
> 
> HTH,
> 
> Kurt Stephens


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

Date: Thu, 16 Aug 2001 18:37:12 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: SQL (MySQL) Windows
Message-Id: <997987032.00073551107198.gnarinn@hotmail.com>

In article <997955061.25473.0.nnrp-01.d4f094e4@news.demon.co.uk>,
Paul Fortescue <paul@net366.com> wrote:
>I think I'm being a donkey. I have installed MySQL on Win2K, and downloaded
>the modules DBI and DBD which I have put into the /perl/lib directory
>

just to be sure:
by this, i hope you mean that you did one of
  a) download and install with cpan
  b) download and install with activestates package manager
  c) downloaded the archives, unpacked them,and did the 
        perl Makefile.PL
        make
        make test
        make install

or did you do something else?

the 'put into the /perl/lib directory' sounds a bit suspicious

gnari


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

Date: Thu, 16 Aug 2001 15:29:19 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Text::Wrap/ANSI proplem
Message-Id: <3B7C2D1F.BB0170E5@home.com>

Philip Taylor wrote:
> 
>   I've got some text which needs to be wrapped at 50 columns, and
> Text::Wrap does this fine.
> 
> However, there is a problem when the text contains ANSI codes
>
> When displayed, the ANSI codes don't take up any space [...]
> but Text::Wrap doesn't know this and counts the ANSI codes
> as displayed characters
>
> Is there an easy way to make Text::Wrap ignore the codes when
> calculating the wrapping, but still include them in the printed
> output?

Give this a try. (Tested with your example, but may have undiscovered
bugs.)

#!/usr/bin/perl -w
use strict;
use Text::Wrap;

$Text::Wrap::columns = 50;

my $text = "\e[31mThis line of text should appear in the colour
red\e[0m.\n";

print my_wrap($text);

sub my_wrap {
    my $msg = shift;

    my @escape = ($msg =~ /(\e\[\d+m)/g);
    my @location;

    foreach (@escape) {
        my $idx = index($msg, $_, 0);   # find
        push(@location, $idx);          # remember
        substr($msg, $idx, length, ''); # remove
    }
    
    # wrap without escapes
    my $line = wrap('', '', $msg);

    # replace -- must do this in reverse order!!!
    foreach my $n (reverse 0 .. $#escape) {
        substr($line, $location[$n], 0, $escape[$n]);
    }
    return $line;
}


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

Date: Thu, 16 Aug 2001 20:11:22 GMT
From: Doug Robbins <sleddog@komatik.org>
Subject: Using 'require' and variables
Message-Id: <MPG.15e6081f20ff20429896a5@news1.ns.sympatico.ca>

I have a set of perl script that (hopefully, someday) will work 
together as a CGI application.

There are a series of configuration variables that all scripts use. I 
want to place these variables in a separate 'config' file and then 
'require' that file at the top of each script. But how do I do this, 
and at the same time pre-declare variables (in accordance with 'use 
strict')?

Here is a basic example of what I mean:

---config.cgi contains config variables shared by scripts---
$basepath = "/some/path";
$baseURL = "http://somewhere.com";
[...other variables]
---end config.cgi---

---myscript.cgi---
#/usr/bin/perl
require "config.cgi";
open(IN,"$basepath/data.dat") or die("Couldn't open data.dat: $!");
[... do things]
---end myscript.cgi---

The above works okay. But to 'use strict', $basepath needs to be pre-
declared. But where?

Regardless whether I declare 'my $basepath' in config.cgi or in 
myscript.cgi, it return with a null value and the script dies, "no such 
file...". 

I've spent hours with perldoc and more hours with web seaches, but I 
just can't get my head around this. Sorry if it's a newbie FAQ. Any 
tips appreciated.
 
-- 
Doug Robbins


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

Date: 16 Aug 2001 21:09:43 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Using a fake name on this newsgroup and in places like perlmonks??
Message-Id: <slrn9nodl9.ksf.abigail@alexandra.xs4all.nl>

Carlos C. Gonzalez (miscellaneousemail@yahoo.com) wrote on MMCMVI
September MCMXCIII in <URL:news:MPG.15e396a698e576af989748@news.edmonton.telusplanet.net>:
<> Hi everyone,
<> 
<> I've been looking around at www.perlmonks.org and noticed that everyone 
<> there goes by fake names such as reptile, ChemBoy, and others.  Sometimes 
<> I see some usenet messages from others that way too.  I've even gotten 
<> some usenet messages that have real sounding names only to learn later 
<> when the authors email me that they are called by some other name.
<> 
<> Maybe I am being naive about the Internet or something but I was 
<> wondering why people use fake names so much?  Especially when discussing 
<> something as acceptable as Perl?  
<> 
<> I could understand it if say one was the President and wanted to remain 
<> anonymous in order to be able to speak freely without having the press 
<> blow everything out of proportion but for the average Perl programmer is 
<> there a reason to hide one's identity?  
<> 
<> I don't know.  I am asking sincerely.  Maybe I am missing something and 
<> should start hiding my real name too but it would seem that using a fake 
<> name would open the door for me to not be accountable for what I say 
<> (since it wouldn't be me saying it sort of thing).  
<> 
<> Any thoughts on this?


You may claim that you are "Carlos C. Gonzalez" but that doesn't mean
anything. Perhaps it is your name, perhaps it isn't. Does it matter?
A name is just something used to identify something - what is the real
difference between using a name that was partly inherited, partly given
by your parents, and using a name that you picked yourself?

But tell me, why does a "Carlos C. Gonzalez" use
"miscellaneousemail@yahoo.com" as email address? That is *also* a 
fake name with no relation to your real name.

Also note that using "fake" names is much, much older than the internet.
Authors, actors, artists and other public figures have used choosen names
for a long time. You didn't think that "John Wayne" was born with that
name, did you?



Abigail
-- 
   my $qr =  qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/;
      $qr =~  s/$qr//g;
print $qr, "\n";


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

Date: Thu, 16 Aug 2001 22:01:30 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: Using a fake name on this newsgroup and in places like perlmonks??
Message-Id: <MPG.15e5f07e9030b7b898976b@news.edmonton.telusplanet.net>

In article <slrn9nodl9.ksf.abigail@alexandra.xs4all.nl>, Abigail at 
abigail@foad.org says...

> You may claim that you are "Carlos C. Gonzalez" but that doesn't mean
> anything. Perhaps it is your name, perhaps it isn't. Does it matter?
> A name is just something used to identify something - what is the real
> difference between using a name that was partly inherited, partly given
> by your parents, and using a name that you picked yourself?

There is really is no difference Abigail as long as you are known by that 
name.  The real you that is.  Your name is who you are.  As the real me I 
am of the belief that one should not hesitate to use their real name.  
Unless there is a very real and practical reason to do otherwise.  Of 
course this is just my personal opinion.  I was just surprised to see so 
many fake names at perl monks. 

> But tell me, why does a "Carlos C. Gonzalez" use
> "miscellaneousemail@yahoo.com" as email address? That is *also* a 
> fake name with no relation to your real name.

My email address is most certainl related to my real name Abigail.  My 
real name of Carlos C. Gonzalez is associated with that email address.  
It is not fake at all.  The reason I use that email address is to catch 
all the email that does not fall within any of my other email addresses.  
I also use it to protect my other email addresses from a deluge of spam.  
If miscellaneousemail@yahoo.com gets too much I can just create another 
one.  It is a practical thing and in no way an attempt to hide myself.  
Yahoo even has information on where I live as part of their terms of 
service to use Yahoo email.  

> Also note that using "fake" names is much, much older than the internet.
> Authors, actors, artists and other public figures have used choosen names
> for a long time. 

Agreed but where is the practical reason why so many programmers use fake 
names Abigail?  I can understand an author's reasons.  Or an actors, 
artist, or other public figure but it's hard for me to understand a Perl 
programmer using a fake name.  I mean we are not discussing top secret 
stuff or anything and most of us will never run for public office.  Nor 
is someone very likely to quote our Perl code statements and 
explanations against us.

Again all this is just my opinion Abigail.  I just thought there might be 
some reason I was not aware of when I started this thread.  A reason that 
might lead me to use a fake name too.  So far all I have seen is that it 
is a matter of personal preference on the part of programmers in general 
and as such I think I will keep using my real name. 

Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: 16 Aug 2001 15:02:26 -0700
From: jwalker@compaq.com (Jeff Walker)
Subject: Re: Verifying users against NT domain?
Message-Id: <3962a9b2.0108161402.2187e124@posting.google.com>

Ilya Martynov <ilya@martynov.org> wrote in message news:<87hevawkze.fsf@abra.ru>...
> B> Hi,
> B> I am running a fairly large perl app on a beowulf cluster using RH 6.2. 
> B> Currently, users are verified against a local database before they can
> B> use the system, and this works fine as there were not too many users to
> B> maintain.
> 
> B> Now however, there is a need to verify ALL in-house users to use the
> B> system (a nice sign of its popularity :).  The company is a windoze shop
> B> however, and we are trying to figure out how to verify users directly
> B> against the NT domain.  I took a look at the Win32 modules, but they are
> B> only ( I think ) for windows machines.
> 
> B> Does anyone have any suggestions on modules, documentation or code to
> B> verify users in the NT domain from a unix box?
> 
> Authen::Smb?
> 
> Disclaimer: I have never used this module.

I've used Win32::Authenticate::AuthenticateUser and it works great...

AuthenticateUser( "$domain", "$user", "$pwd" )

 ...but I've only done it on a Win2K server.  Worth a shot, tho.

While we're here, I have my own question:

I can authenticate users, and direct a user to his/her home directory, but
I'd like to lock down the directories so only a particular domain user
has privs to the directory.  How do I send the authorization in the HTTP
header?  I only really have conrol over the response header; the request
that contains the authorization is generated at the browser.  Any ideas?

Jeff


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

Date: Thu, 16 Aug 2001 20:06:38 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: What's the Problem locating Files?
Message-Id: <3B7C0BAE.9050307@post.rwth-aachen.de>

John P wrote:
> Hi there All
> 
> I am distributing scripts which have the line.
> use Digest::MD5 qw (md5_base64);

[snipped redundancies]

Listen, this is now the third time you pose this very question while 
your first coming-up with it has already been answered. You run into the 
risk of falling into some people's killfiles if you intend to ask that 
another five or so times.

Tassilo



-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Thu, 16 Aug 2001 18:17:34 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Will Perl report on variables no longer used??
Message-Id: <MPG.15e5bc5d15a60f92989768@news.edmonton.telusplanet.net>

Hi everyone,

Occasionally I find myself redoing a sub and in the process I neglect to 
remove some my variables that are no longer needed.  I forget about them 
and they stay there taking up name space. Unwanted and unneeded. 

Is there some command line switch for Perl or other technique that will 
report on a variable not being used?  That will return a warning to that 
effect?

In other languages like Delphi the compiler reports on these kinds of 
things so that you can clean up your code of useless variables.  

Thanks.

---
Carlos 
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are 
welcomed to visit and take a look, trying to subscribe will only be a 
frustration for you as your data will not be saved at this time.


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

Date: 16 Aug 2001 22:32:55 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <87lmkjsvmw.fsf@abra.ru>


CCG> Hi everyone,
CCG> Occasionally I find myself redoing a sub and in the process I neglect to 
CCG> remove some my variables that are no longer needed.  I forget about them 
CCG> and they stay there taking up name space. Unwanted and unneeded. 

CCG> Is there some command line switch for Perl or other technique that will 
CCG> report on a variable not being used?  That will return a warning to that 
CCG> effect?

CCG> In other languages like Delphi the compiler reports on these kinds of 
CCG> things so that you can clean up your code of useless variables.  

I belive if you run your scripts as 'perl -w' or your script has 'use
warnings' (works in new Perls) it will be reported as warning:

    Name ""%s::%s"" used only once: possible typo

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Thu, 16 Aug 2001 18:41:14 -0000
From: Craig Berry <cberry@cinenet.net>
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <Xns90FF76E37C09Fcberrycinenetnet1@207.126.101.92>

Ilya Martynov <ilya@martynov.org> wrote in news:87lmkjsvmw.fsf@abra.ru:

> I belive if you run your scripts as 'perl -w' or your script has 'use
> warnings' (works in new Perls) it will be reported as warning:
> 
>     Name ""%s::%s"" used only once: possible typo

This works on globals, but not on lexicals.

  sub foo {
    my $bar;
    1;
  }

produces no warning about $bar.

-- 
Craig Berry <http://www.cinenet.net/~cberry/>
"That which is now known, was once only imagined." - William Blake



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

Date: Thu, 16 Aug 2001 20:35:13 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <9lh5jj$ev2$04$1@news.t-online.com>

"Carlos C. Gonzalez" <miscellaneousemail@yahoo.com> schrieb im Newsbeitrag
news:MPG.15e5bc5d15a60f92989768@news.edmonton.telusplanet.net...
> Hi everyone,
>
> Occasionally I find myself redoing a sub and in the process I neglect to
> remove some my variables that are no longer needed.  I forget about them
> and they stay there taking up name space. Unwanted and unneeded.
>
> Is there some command line switch for Perl or other technique that will
> report on a variable not being used?  That will return a warning to that
> effect?
>
> In other languages like Delphi the compiler reports on these kinds of
> things so that you can clean up your code of useless variables.
>
> Thanks.

If you use strict and warnings like you should, Perl will warn you if you
use a var only once. It won't warn you if a var isn't used for a certain ...
dunno... maybe a certain amount of commands. It just doesn't warn you.

If you declare your vars with 'my' in your subs (and you definetly should),
the vars will go out of scope when the program exits the sub. Perl's garbage
collector will take care of deleting them. As you should keep subs and
blocks in general as short as possible, you should not run into a lot of
vars that are wasting namespace.

If, however, you are using a lot of global vars, you're screwed. They're not
going to go out of scope. In C, you'd just kill them manually (you have to),
but as I never thought about doing so in Perl, I'm not quite sure if $foo =
undef; actually *deletes* the var from namespace. I doubt it, but correct me
if I'm wrong.

Hope I could help.

Steffen Müller




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

Date: Thu, 16 Aug 2001 21:11:34 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <9lh5mm$f5n$04$1@news.t-online.com>


"Craig Berry" <cberry@cinenet.net> schrieb im Newsbeitrag
news:Xns90FF76E37C09Fcberrycinenetnet1@207.126.101.92...
> Ilya Martynov <ilya@martynov.org> wrote in news:87lmkjsvmw.fsf@abra.ru:
>
> > I belive if you run your scripts as 'perl -w' or your script has 'use
> > warnings' (works in new Perls) it will be reported as warning:
> >
> >     Name ""%s::%s"" used only once: possible typo
>
> This works on globals, but not on lexicals.
>
>   sub foo {
>     my $bar;
>     1;
>   }
>
> produces no warning about $bar.
>


Isn't bar destroyed when the sub exits? Hasn't Perl got a GC?

Steffen




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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1543
***************************************


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