[17548] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4968 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 26 14:05:51 2000

Date: Sun, 26 Nov 2000 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975265509-v9-i4968@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 26 Nov 2000     Volume: 9 Number: 4968

Today's topics:
        ActivePerl ppm help again <wstsoi@hongkong.com>
    Re: ActivePerl ppm help again <bwalton@rochester.rr.com>
        ActivePerl ppm help <wstsoi@hongkong.com>
    Re: Can't install modules in ActiveStates v5.6.0 for Wi <carvdawg@patriot.net>
    Re: Can't install modules in ActiveStates v5.6.0 for Wi <graham@letsgouk.com>
    Re: Can't install modules in ActiveStates v5.6.0 for Wi <jeff@vpservices.com>
    Re: Checking if file exists (filename contains a wildca <iltzu@sci.invalid>
        Chron Job/Automate deletion of records <markh@argolink.net>
        How do i replace the spaces? <poohba@io.com>
    Re: How do i replace the spaces? <jeff@vpservices.com>
    Re: How to find what is between n'th and the next tab? <MiGuenther@lucent.com>
        how to recieve the search result from google.com? <jingzx@sinaman.com>
    Re: how to recieve the search result from google.com? <carvdawg@patriot.net>
    Re: identifying $_ as variable or constant <bernie@fantasyfarm.com>
    Re: identifying $_ as variable or constant (Eric Smith)
    Re: identifying $_ as variable or constant (Tad McClellan)
    Re: identifying $_ as variable or constant <uri@sysarch.com>
    Re: Perl and Win98 (Joe Smith)
    Re: PERL PROGRAMMER Wanted (David H. Adler)
    Re: reading IP and MAC addresses with Win::Registry mod <perin@panix.com>
    Re: reading IP and MAC addresses with Win::Registry mod <carvdawg@patriot.net>
    Re: Removing carriage returns from cgi (Tad McClellan)
    Re: Secure vs. unsecure server (Tad McClellan)
        setuid/setgid with perl? <lehmann@cnm.de>
    Re: Sort runtime 5.005 vs 5.004 <jpl@research.att.com>
    Re: TK for Win32? <carvdawg@patriot.net>
    Re: What's the use of the Filter Module <nobody@nowhere.com>
    Re: What's the use of the Filter Module <joe+usenet@sunstarsys.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 26 Nov 2000 19:06:57 +0800
From: "Lucas Gump" <wstsoi@hongkong.com>
Subject: ActivePerl ppm help again
Message-Id: <8vqqra$h891@imsp212.netvigator.com>

Hi all,

I just wanted to upgrade my AactivePerl from 5.22 to the
newest 6.20, so I uninstall the old one and install the new one.

The installation seemed ok but I found ActivePerl did not
add itself into env. path, because I could not lauch my perl
scripts liked 'perl script.pl' or even 'perl -v', it is so weird, is that
I missed something problem of that version of activeperl?

If anybody know where I was going wrong, please tell me, thanks.

Thanks




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

Date: Sun, 26 Nov 2000 18:18:22 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: ActivePerl ppm help again
Message-Id: <3A21549D.D463BE78@rochester.rr.com>

Lucas Gump wrote:
 ...
> I just wanted to upgrade my AactivePerl from 5.22 to the
> newest 6.20, so I uninstall the old one and install the new one.
> 
> The installation seemed ok but I found ActivePerl did not
> add itself into env. path, because I could not lauch my perl
> scripts liked 'perl script.pl' or even 'perl -v', it is so weird, is that
> I missed something problem of that version of activeperl?
> 
> If anybody know where I was going wrong, please tell me, thanks.
 ...
You don't say what your OS is.  If it is Windoze 95, it could be because
you are out of environment space.  In that case, increase your
environment space and try again.  Otherwise, just add c:\perl\bin (or
wherever you installed the executable) to your path and see if it works
then.  Or try running Perl by specifying its full path.  If you don't
know how to do that stuff, read up on Windoze or try a Windoze
newsgroup.
-- 
Bob Walton


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

Date: Sun, 26 Nov 2000 19:06:00 +0800
From: "Lucas Gump" <wstsoi@hongkong.com>
Subject: ActivePerl ppm help
Message-Id: <8vqqpg$h6h1@imsp212.netvigator.com>

Hi all,

I just wanted to upgrade my AactivePerl from 5.22 to the
newest 6.20, so I uninstall the old one and install the new one.

The installation seemed ok but I found ActivePerl did not
add itself into env. path, because I could not lauch my perl
scripts liked 'perl script.pl' or even 'perl -v', it is so weird, is that
I missed something problem of that version of activeperl?

If anybody know where I was going wrong, please tell me, thanks.

Thanks




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

Date: Sun, 26 Nov 2000 07:23:39 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: Can't install modules in ActiveStates v5.6.0 for Win32
Message-Id: <3A2100CB.F092ABFD@patriot.net>

What modules are you trying to install via 'make' that you can't get from
the ActiveState repository using 'ppm'?

Graham Stow wrote:

> When trying to install a module and running 'Makefile.pl', I get a 'Bad
> command or file name' 'Unable to find a perl 5 (by these names:
> C\Perl\bin\Perl.exe miniperl perl perl5 perl5.6.0, in these dirs:
> C:\WINDOWS\COMMAND C:\PERL\BIN C:\Perl\bin)
>
> I'm running ActiveState's perl v5.6.0 for Win32-x86, Binary build 616,
> installed in C:\Perl
>
> Anyone any ideas?
> --
> Graham Stow

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Sun, 26 Nov 2000 13:36:51 +0000
From: Graham Stow <graham@letsgouk.com>
Subject: Re: Can't install modules in ActiveStates v5.6.0 for Win32
Message-Id: <0$wfTDAzHRI6EwkS@letsgouk.com>


>What modules are you trying to install via 'make' that you can't get from
>the ActiveState repository using 'ppm'?

Your dead right. I was simply unaware of the ActiveState repository and
'ppm'
-- 
Graham Stow


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

Date: Sun, 26 Nov 2000 10:20:19 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Can't install modules in ActiveStates v5.6.0 for Win32
Message-Id: <3A215463.79AA0685@vpservices.com>

Graham Stow wrote:
> 
> In article <3A204577.E970300D@vpservices.com>, Jeff Zucker
> <jeff@vpservices.com> writes
> >Graham Stow wrote:
> >>
> >> When trying to install a module and running 'Makefile.pl', I get a 'Bad
> >> command or file name' 'Unable to find a perl 5 (by these names:
> >> C\Perl\bin\Perl.exe miniperl perl perl5 perl5.6.0, in these dirs:
> >> C:\WINDOWS\COMMAND C:\PERL\BIN C:\Perl\bin)
> >>
> >> I'm running ActiveState's perl v5.6.0 for Win32-x86, Binary build 616,
> >> installed in C:\Perl
> >
> >Build 616 has a serious bug that causes that error message.  Upgrade and
> >the problem will go away.
> >
> I'm not at all sure you're right there. 

Well, you are mistaken.  That is a bug and upgrading will make it go
away.

> Rob from Aussie has emailed me
> pointing out that I should be retrieving and installing ActiveState
> modules (http://www.activestate.com/PPMpackages/5.6/, as opposed to
> those obtained from CPAN) using PPM (Perl Package Manager). When I do
> that, everything is hunky-dory!

Certainly ppm is the way to go for modules that have a ppd prepared for
them.  Certainly you should use it when you can.  I assumed you would
know that since it is promeninetly mentioned in the basic documentation
for ActivePerl.

But there are many many modules that do not have a ppd and can not be
installed using ppm.  Those modules can be installed (depending on their
requirements) either with just nmake or with some version of make and a
C++ compiler *if* one is not using  a defective build of ActiveState. 
The error message you showed is a documented bug in earlier ActiveState
builds and prevents any use of make or its relatives.  That bug will go
away if one upgrades the version of ActiveState.  It is also related to
other bugs in the build so there are other reasons to upgrade.  Just
because you found a way around the particular problem that brought that
bug to your attention does not mean that the bug has disappeared or that
it will not bite you in some other form later.

-- 
Jeff


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

Date: 26 Nov 2000 14:33:57 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Checking if file exists (filename contains a wildcard)
Message-Id: <975248618.22108@itz.pp.sci.fi>

In article <8vqja3$4tf$1@nntp1.ba.best.com>, Joe Smith wrote:
>
>	$wildcard = "*.txt";
>	foreach $file (glob $wildcard) {
>	  print "The file '$file' exists\n" if -e $file;
>	}

I would rather expect the filenames returned by glob() to be those of
existing files, so testing their existence seems a bit redundant.. :-)

(Before anyone says the file might've just been deleted, I'd like to
point out that it might just as well be deleted right after the test.)

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



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

Date: Sun, 26 Nov 2000 09:27:53 -0600
From: Mark Henderson <markh@argolink.net>
Subject: Chron Job/Automate deletion of records
Message-Id: <3A212BF9.191E865C@argolink.net>

Greetings:

I have created a mSQL database and I use Perl to manage it.  I am
wondering where I might find examples of scripts that automatically run
at a certain time and delete records from a database. I'm assuming there

needs to be some chron job set up on the server for the script to run at

a certain time.  I only have FTP access to my cgi-bin, so I don't even
know if this is possible.  Any suggestions are greatly appreciated.
Please feel free to email me OL too.  mark@sitesolver1.com

Thanks,

Mark



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

Date: Sun, 26 Nov 2000 18:28:10 GMT
From: Poohba <poohba@io.com>
Subject: How do i replace the spaces?
Message-Id: <3A2156C5.A72ADA5E@io.com>

I am trying to replace the spaces in a filename with "_".  How do I do
this?  Presently I have

#!/usr/bin/perl -w

$dir = "./";

 opendir MYDIR,"$dir";
 @images = grep {/./} readdir MYDIR;
 @images = sort{$a cmp $b} @images;
 closedir MYDIR;

foreach $file (@images) {
  ($story) = split(/\n/, $file);
  $story =~ s/\s/_/;
  if($story =~ /cgi/i) {
     next;
  }
  if($story !~ /txt/i) {
    $story = "$story.txt";
  }
  print "$story\n";
  system"cp $story $story.bak";
}




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

Date: Sun, 26 Nov 2000 10:55:15 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: How do i replace the spaces?
Message-Id: <3A215C93.7457650E@vpservices.com>

Poohba wrote:
> 
> I am trying to replace the spaces in a filename with "_".  How do I do
> this?  Presently I have
> 
> #!/usr/bin/perl -w

No "use strict".  You also do not have any error checking.  You should
at least print out the error and the $! error message for each and every
call that does something with a file or directory in your script.

>  @images = grep {/./} readdir MYDIR;

That is a rather strange grep expression since the only files it
excludes are files that don't have a name.  (a dot matches any
character, not a period, if you mean a period, put \. but is that really
what you want, all files that have a period in them somewhere?)

> foreach $file (@images) {
>   ($story) = split(/\n/, $file);

You might want to think about what you were trying to accomplish with
that line.

>   $story =~ s/\s/_/;

Here's the one you asked about, and it is fine except that you will need
a "g" on the end if you want it to replace all spaces rather than just
the first space it encounters.

>   if($story !~ /txt/i) {

If that is supposed to find if the file has a .txt extension, it should
be /\.txt$/.

>     $story = "$story.txt";
>   }
>   print "$story\n";
>   system"cp $story $story.bak";
> }

Those lines probably do not do what you expect since you have added the
extension ".txt" to your variable but you have not renamed the file to
have that extension so when you try to copy a file with that extension,
it won't find the file.  

-- 
Jeff


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

Date: Sun, 26 Nov 2000 13:39:06 +0100
From: "Michael Guenther" <MiGuenther@lucent.com>
Subject: Re: How to find what is between n'th and the next tab?
Message-Id: <8vr07n$o7p@nntpb.cb.lucent.com>


Tad McClellan wrote in message ...
>Michael Guenther <MiGuenther@lucent.com> wrote:
>
>>Try
>
>
>Can't. It won't compile.
>
>
>>print $result."

>
>
>Can't find string terminator '"' anywhere before EOF at ./temp line 17.



Sorry coppy and past problem  this line should be

print $result."\n";

I think you gys know this



Sorry Michael




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

Date: Sun, 26 Nov 2000 10:29:03 +0800
From: jin zengxiang <jingzx@sinaman.com>
Subject: how to recieve the search result from google.com?
Message-Id: <3A20756F.417C1B51@sinaman.com>

Hi,there:
I want to develop a personal search engine by perl .It should:
1,send a request to the http://www.google.com
2,recieve the search result in google.com so I can do something else .
I know perl must can do it ,but don't know how to do it ,
would you pls teach me how to solve this problem?
thanks

Regards
Alan



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

Date: Sun, 26 Nov 2000 09:54:20 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: how to recieve the search result from google.com?
Message-Id: <3A21241C.8AEA2317@patriot.net>

See the response I sent to this question in comp.lang.perl.modules

jin zengxiang wrote:

> Hi,there:
> I want to develop a personal search engine by perl .It should:
> 1,send a request to the http://www.google.com
> 2,recieve the search result in google.com so I can do something else .
> I know perl must can do it ,but don't know how to do it ,
> would you pls teach me how to solve this problem?
> thanks
>
> Regards
> Alan

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Sun, 26 Nov 2000 08:35:08 -0500
From: Bernie Cosell <bernie@fantasyfarm.com>
Subject: Re: identifying $_ as variable or constant
Message-Id: <25422tojof265hd3ev62l7icphoi1umvro@news.supernews.net>

mgjv@tradingpost.com.au (Martien Verbruggen) wrote:

} On 26 Nov 2000 01:00:29 GMT,
} 	Eric Smith <eric@fruitcom.com> wrote:
} > say: $var='something';
} > In a loop, how can I determine whether the value in $_ is $var or the
} > constant 'something'?
} 
} What you are asking doesn't make sense. The value stored in $_ is either
} the string "something" or it isn't. The value stored in $var is either
} the string "something" or it isn't. The value of the constant expression
} 'something' is always the string "something".
} 
} The value in $_ has no memory of where it came from. It either is
} "something" or it isn't.

I thought that wasn't true -- I thought that Perl preserved lvalue-ness and
so it *DID* remember where $_ came from, and so these are quite different:
     for (@a)
     {  $_ = 4 ; }
and
     for (1,2,3)
     {  $_ = 4 ; }

And so for example:
@a=("something") ;
     for (@a)
     { ... 
     for ("something")
     { ...
won't be _quite_ the same at all..  I don't know how you could tell which
you had, though, until you try to assign to $_ and either get an error or
not.

  /Bernie\
-- 
Bernie Cosell                     Fantasy Farm Fibers
bernie@fantasyfarm.com            Pearisburg, VA
    -->  Too many people, too few sheep  <--          


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

Date: 26 Nov 2000 16:26:27 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: Re: identifying $_ as variable or constant
Message-Id: <slrn922edf.hff.eric@plum.fruitcom.com>

Collective response to the responses to my original posting.
As requested $verbose=9.

The routine below accepts a file identification string as the first
arg and then indiscriminately takes alternate args as labels and
values respectively.  This, however, is inappropriate if I want to say go:
logit('logfiletag','Here is the results array',@array);

So clearly I am looking to determine if the $_ is 'somthing like this'
or rather $this_kind_of_thing.  I have learnt not to ask "is this
possible" but rather "how" in clpm - maybe this case is an exception?

This is the implementation:

#|Method: logit
#|Description: Automated logging method with dynamic filehandle creation
#|Parameters: $filehandle and an @_ of key value pairs
#|Usage:
#|$r='rertrr';
#|$t=4523423;
#|$y="ert$r";
#|logit(exception,"This var",$r,'That var',$t,"another var",$y)
#|

sub logit {
  my $filename = shift;
  local *FH;
  $path=">>/home/eric/www/hotsms/log_";
  if ($filename=~/stdout/i){
    *FH=*STDOUT;
  }else{
  open (FH,   "$path.$filename") || die "cannot open /home/eric/log_$filename $!
";
  }
  open GLOBAL, $globalfh       || die "cannot open $globalfh $!";
  for (@_){
    if (not $i){
  print FH qq|$_
|;
  print GLOBAL qq|$_
|;
    $i++;
    }else{
      $uc=$_;
      #$uc=uc $_;
  print FH qq|* $uc *
|;
  print GLOBAL qq|* $uc *
|;
      undef $i;
    }
  }
  close FH;
  close GLOBAL;
}


Joe Smith posted
 > In article <slrn920o5c.hff.eric@plum.fruitcom.com>,
 > Eric Smith <ericnntp@fruitcom.com> wrote:
 > >say: $var='something';
 > >In a loop, how can I determine whether the value in $_ is $var or the
 > >constant 'something'?
 > 
 > Are you talking about this:
 >   $var = 'something';
 >   $_ = 'something';	# Copy of a string constant
 >   $_ = $var;		# Copy of a string variable
 >   *_ = *var;		# Alias to a string variable
 >   *_ = \$var;		#	"	"
 >   *_ = \'something';	# Alias to a string constant
 >   foreach $_ ($var, 'something') { # Alias to var then alias to constant
 >     $_ .= "foo";	# Attempt to modify string constant 2nd time thru
 >   }
 > 
 > If that is the topic, can you tell us why you want to do that?
 > 	-Joe
 > 
 > --
 > See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Sun, 26 Nov 2000 11:38:26 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: identifying $_ as variable or constant
Message-Id: <slrn922f42.an8.tadmc@magna.metronet.com>


[ Please put your comments *following* the quoted text that
  you are commenting on.

  Please do not quote entire articles. Quote just enough to
  establish the context for your comments.

  Please do not quote .signatures.

  Please visit      news.announce.newusers.

  Thanks.

  Jeopardectomy performed.
]

Eric Smith <eric@fruitcom.com> wrote:
>Joe Smith posted
> > In article <slrn920o5c.hff.eric@plum.fruitcom.com>,
> > Eric Smith <ericnntp@fruitcom.com> wrote:
> > >say: $var='something';
> > >In a loop, how can I determine whether the value in $_ is $var or the
> > >constant 'something'?
> > 
> > Are you talking about this:

[snip]

> > If that is the topic, can you tell us why you want to do that?


>Collective response to the responses to my original posting.
>As requested $verbose=9.
>
>The routine below accepts a file identification string as the first
>arg and then indiscriminately takes alternate args as labels and
>values respectively.  This, however, is inappropriate if I want to say go:
>logit('logfiletag','Here is the results array',@array);


Why is that inappropriate?

The second arg is always what you seem to be calling a "label", right?

Why is the constant string 'Here is the results array' an
"inappropriate" label?

Maybe you need to tell us what "label" means to you.


>So clearly I am looking to determine if the $_ is 'somthing like this'
                                                    ^^^^^^^^^^^^^^^^^^

The correct term for that is "constant".

(you appear to already know that, judging from your Subject,
 but let's be explicit to help all the other readers of this
 thread.
)


>or rather $this_kind_of_thing.  
           ^^^^^^^^^^^^^^^^^^^


The correct term for that is "lvalue" (left-value because it
can appear on the left of an assignment. That is, an lvalue
is something that can be modified).


>I have learnt not to ask "is this
>possible" but rather "how" in clpm - maybe this case is an exception?


Ahh. I think I finally see what you are asking. Let me recast
it to something people will understand, then maybe someone
can answer it  :-)


   How can you tell if a subroutine argument is an lvalue or not?


I dunno how you do that (apart from eval()).

That's a good question.

I await an enlightening followup...



But in the meantime, I have some comments about your code below.


>This is the implementation:

>sub logit {
>  my $filename = shift;
>  local *FH;
>  $path=">>/home/eric/www/hotsms/log_";
                                     ^
                                     ^
>  if ($filename=~/stdout/i){
>    *FH=*STDOUT;
>  }else{
>  open (FH,   "$path.$filename") || die "cannot open /home/eric/log_$filename $!
                     ^
                     ^

You are going to end up with "_." (underscore followed by dot)
in your pathname. Is that what you wanted to do?

If so, then your diagnostic message does not correctly report the
name it was trying to open (you left the dot out of that name).

You probably wanted either "$path$filename" or $path.$filename 
(no quotes) instead.



>  open GLOBAL, $globalfh       || die "cannot open $globalfh $!";


That isn't going to work correctly.

Review the precedence of ||  (at the top of perlop.pod, including
the first few paragraphs in the "Terms and List Operators (Leftward)"
section).

Then either use "or" instead of "||", or put parens around open()'s
argument list. You got it right for the first open(), but not for
this second one.


>  for (@_){
>    if (not $i){


Where did $i come from?

Is it a global variable? (that would be Bad, in general).


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


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

Date: Sun, 26 Nov 2000 17:52:50 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: identifying $_ as variable or constant
Message-Id: <x7snoeboy6.fsf@home.sysarch.com>

>>>>> "ES" == Eric Smith <eric@fruitcom.com> writes:

  ES> The routine below accepts a file identification string as the
  ES> first arg and then indiscriminately takes alternate args as labels
  ES> and values respectively.  This, however, is inappropriate if I
  ES> want to say go: logit('logfiletag','Here is the results
  ES> array',@array);

so pass @array as a ref \@array and deal with it separately.

  ES> So clearly I am looking to determine if the $_ is 'somthing like
  ES> this' or rather $this_kind_of_thing.  I have learnt not to ask "is
  ES> this possible" but rather "how" in clpm - maybe this case is an
  ES> exception?

or we can ask why? i still don't see any reason for you to know if a
value was a constant or a variable. all you seem to do is log it but
there is some very odd code here as well. i will comment on it in general.

  ES> #|Usage:
  ES> #|$r='rertrr';
  ES> #|$t=4523423;
  ES> #|$y="ert$r";
  ES> #|logit(exception,"This var",$r,'That var',$t,"another var",$y)
  ES> #|

  ES> sub logit {
  ES>   my $filename = shift;
  ES>   local *FH;
  ES>   $path=">>/home/eric/www/hotsms/log_";
  ES>   if ($filename=~/stdout/i){

put some white space in your code. this is unreadable. 


  ES>     *FH=*STDOUT;
  ES>   }else{

cuddled elses are considered poor style. and 2 char indents are also
poor style IMO. a quick glance doesn't show me the blocking at all.

  ES>   open (FH, "$path.$filename") || die "cannot open
                   ^^^^^^^^^^^^^^^

do you really want a . in the path or do you want to concatenate $path
and $filename (which the quotes are doing anyway)?

  ES>   /home/eric/log_$filename $!

that path doesn't match the one you open. use the same string in the
open and the error message. best to take the path and file name and make
a new var out of them.

	$base_path = '/home/eric/www/hotsms/log_' ;

	$path = "$base_path$filename" ;

	open (FH, ">>$path") || die "cannot open $path $!" ;





  ES>   }
  ES>   open GLOBAL, $globalfh       || die "cannot open $globalfh $!";

i assume $globalfh is defined elsewhere, but GLOBAL should be localized
for safety too.

  ES>   for (@_){
  ES>     if (not $i){

unless is usually better than if/not. and all you are doing is
alternating between these 2 states. there are other ways which are much
simpler. a simple destructive scan of @_ is very easy and removes the
need for the state:

	while( my( $label, $val ) = splice( @_, 0, 2 ) ) {

		print FH "$label\n* \U$val *\n" ;
		print GLOBAL "$label\n* \U$val *\n" ;
	}

i am not sure if you want to uppercase the value but i did it with \U in
the quoted strings.

in fact i would build a new var with the print text and print that twice
as it makes changing the log format easier and cleaner.

		my $log_text = "$label\n* \U$val *\n" ;
		print FH $log_text ;
		print GLOBAL $log_text ;

done.

  ES>   print FH qq|$_
  ES> |;
  ES>   print GLOBAL qq|$_
  ES> |;

why are you using qq here? it gains you nothing but confusion. all you
are doing is adding a newline so use quotes normally:

	print FH "$_\n" ;

  ES>     $i++;
  ES>     }else{
  ES>       $uc=$_;
  ES>       #$uc=uc $_;
  ES>   print FH qq|* $uc *
  ES> |;
  ES>   print GLOBAL qq|* $uc *
  ES> |;
  ES>       undef $i;

bad. if you really want a state var, just assign 0 to it. undef as a
function is not a good thing to use. it does much more than you need.

and nowhere do i see the need to know if a value was a constant string
or a variable. explain your need for this further in clear english. your
code doesn't reflect that desire at all.


and jeopardy posting is not cool here. put your reply AFTER the quoted
post.

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: 26 Nov 2000 11:10:25 GMT
From: inwap@best.com (Joe Smith)
Subject: Re: Perl and Win98
Message-Id: <8vqr31$fhl$1@nntp1.ba.best.com>

In article <8vchmf$chf$1@nnrp1.deja.com>,  <shawnroske@my-deja.com> wrote:
>i agree with dtbaker,

I prefer the freebie from www.sambar.com

> however, if you really want to use pws:
>http://www.discusware.com/support/resources/windows/perl-pws.html

That's good.  It has a little more detail than the on-line docs:
  Start -> Programs -> ActivePerl -> Online Documentation
  file:///C|/Perl/html/faq/Windows/ActivePerl-Winfaq6.html

	-Joe

--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: 26 Nov 2000 16:35:06 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: PERL PROGRAMMER Wanted
Message-Id: <slrn922etq.7rv.dha@panix6.panix.com>

On Thu, 23 Nov 2000 19:25:10 -0500, Mike Thacker wrote:
>
>PERL programmer wanted to maintain existing code modules.

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

There is a Perl Jobs Announce list that may be more helpful to you.  See
<http://www.pm.org/mailing_lists.shtml> for details.

>President
>Simply the Best, Inc.

I think this is less and less true every time I see it... :-|

yours for a better usenet,

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"Perl Porters, Inc. today announced the release of version .006 of
their popular Perl5 compiler suite, codenamed `Rabid Rat'."
	- Nathan Torkington on p5p (this was a *joke*)


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

Date: 26 Nov 2000 09:54:49 -0500
From: Lewis Perin <perin@panix.com>
Subject: Re: reading IP and MAC addresses with Win::Registry module regexp?
Message-Id: <pc7y9y6ss06.fsf@panix2.panix.com>

jens <jensluetzen@yahoo.de> writes:

> Dear all,
> 
> I am trying to extract the IP addresses from WinNT compters by means of
> perl (Win32::Registry-module). I did already succeed to search the
> registry to return into a file all those values that match the pattern
> d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}. Unfortunately, there are also values
> in the respective subkeys that are equal or greater to 255 (thus
> submasks or other stuff..). I tried all kinds of things to get rid of
> those already (like loading the scalar into an array and splitting it..)
> but none of my efforts were successful.. Is there a way to solve the
> problem with regular expressions? More and more I am thinking I might
> have the wrong strategy since I also have to extract the MAC-addresses
> of the machines.. maybe there is another way?

Your problem isn't really a regex issue; in fact it has nothing to do
with Perl.  In Perl or any other language, if you need to grab IP
addresses and MAC addresses reliably on a Win32 OS, hunting through
the Registry won't do it.  I would suggest reading up on using SNMP in
Microsoft OSes; there's a fair amount of info available on the Net.

/Lew
-- 
Lew Perin / perin@mail.med.cornell.edu / perin@acm.org
www.panix.com/~perin/


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

Date: Sun, 26 Nov 2000 11:06:08 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: reading IP and MAC addresses with Win::Registry module regexp?
Message-Id: <3A2134F0.6C662E69@patriot.net>



> Your problem isn't really a regex issue; in fact it has nothing to do
> with Perl.  In Perl or any other language, if you need to grab IP
> addresses and MAC addresses reliably on a Win32 OS, hunting through
> the Registry won't do it.  I would suggest reading up on using SNMP in
> Microsoft OSes; there's a fair amount of info available on the Net.

Lew is correct...it's not a regex issue.  The IP address is kept in one
(generally) location in
the Registry...you don't have to search the entire Registry w/ a regex to find
it:

HKLM\SYSTEM\CurrentControlSet\Services\<devicename>\Parameters\Tcpip\IPAddress

You can get the MAC address by calling the server or workstation transports
via the Win32::Lanman
module.  Note:  This can also be done via a null session.

Using the Win32::Registry (I prefer Win32::TieRegistry) and Win32::Lanman
modules, you don't have to
install SNMP on your systems, and the collection mechanism is completely
agentless...

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Sun, 26 Nov 2000 08:51:21 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Removing carriage returns from cgi
Message-Id: <slrn9225ap.9v6.tadmc@magna.metronet.com>

Joe Smith <inwap@best.com> wrote:

>If you're running a Win32 perl and reading a Win32 file, chomp removes
                                                          ^^^^^^^^^^^^^
>both the ^M and ^J ("\r\n").  
      ^^^^^^

I don't use Win32 perl, but I might run into someone who does,
so let me ask this then:

   So $/ defaults to "\r\n" on the Win32 port of perl?


I thought the carriage return was handled by the (internal
to the win32 port of perl) I/O routines, not by chomp() and $/.


So, which is it?


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


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

Date: Sun, 26 Nov 2000 08:22:20 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Secure vs. unsecure server
Message-Id: <slrn9223kc.9v6.tadmc@magna.metronet.com>

hokiebear <ayambema@adelphia.net> wrote:

>it generates an error. 


So what did it say?

(that is a rhetorical question because your problem is very
 likely off-topic on this newsgroup.
)

Messages help the helpers help you. That is what they are for.
You should include them when asking for help.


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


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

Date: Sun, 26 Nov 2000 19:33:18 +0100
From: Marten Lehmann <lehmann@cnm.de>
Subject: setuid/setgid with perl?
Message-Id: <3A21576E.3CF72C65@cnm.de>

Hello,

I'm looking for a solution to use the standard system functions setuid
and setgid as known from C and C++. The functions themselves with the
same name doesn't exist in perl, but possibly they do under a different
name or as part of a module? Or am I restricted to C and C++ to use
setuid/setgid?

Sincerely yours
Marten Lehmann


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

Date: Sun, 26 Nov 2000 15:56:02 GMT
From: "John P. Linderman" <jpl@research.att.com>
Subject: Re: Sort runtime 5.005 vs 5.004
Message-Id: <3A213291.7D8BC66@research.att.com>

elmo@iii.org.tw wrote:

> I know that there are some qsort implementations which are
> inefficient under certain situation, but there are others
> that solve these problems.  One of the better qsort implementations
> I'm aware of is the one in *BSD:
>
> ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/src/lib/libc/stdlib/qsort.c
>
> For comparison-based sort, due to my limited knowledge, I can
> hardly believe there's faster sort than quicksort in terms of
> real world performance.  Is there a freely available merge
> sort implementation so that I can test it?
>
> Thanks in advance.
>
> Chih-Cherng Chin
> elmo@iii.org.tw

I'm familiar with the original Bentley/Mcilroy qsort,
and it is, indeed, one of the best I know of.  Somebody
has ``improved'' on that version here.  As a result,
if you run the following C test program, which
generates inputs of the form

reverse (0 .. ($n/2 -1 )), $n/2, reverse(($n/2 +1) .. ($n-1))

for $n increasing powers of 2.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <math.h>

static long Compares = 0;

static int
compare(const void *a, const void *b)
{
    Compares++;
    return( *(int*)a - *(int*)b );
}

int
main(int argc)
{
    size_t n, i, j;
    int *np, *ip;

    for (j=n=1; j<18; j++) {
        n += n;
        if (!(np = (int *) malloc(n * sizeof(int)))) {
            fprintf(stderr, "Out of space going after %d\n", n);
            exit(2);
        }
        ip = np;
        i = n / 2; while (i) *ip++ = --i;
        *ip++ = n / 2;
        i = n; while (--i > n/2) *ip++ = i;
        qsort((void *) np, n, sizeof(int), compare);
        free(np);
        fprintf(stderr, "%3d %8u: %10ld %.0f\n", j, n, Compares,
                                n * log(n) / log(2));
    }
    return (0);
}

you can observe the following results, with column 2 showing
array size and column 3 the number of comparisons.

  1        2:          1 2
  2        4:          4 8
  3        8:         28 24
  4       16:        104 64
  5       32:        380 160
  6       64:       1446 384
  7      128:       5616 896
  8      256:      22138 2048
  9      512:      87940 4608
 10     1024:     350606 10240
 11     2048:    1400216 22528
 12     4096:    5596578 49152
 13     8192:   22377900 106496
 14    16384:   89494966 229376
 15    32768:  357946816 491520
 16    65536: 1431721418 1048576

Ah, the sweet smell of another sort going quadratic.
We'll get to that overheating reactor as soon as the
sort completes.  Oops.

This (unacceptable) behavior can be fixed by removing
the ill-advised ``swap_cnt optimization'', not there in
the original Bentley/Mcilroy code.

*Every* (pure) quicksort implementation goes
quadratic on *some* input.  The question is, will
somebody stumble across that input?  Can you
*prove* they won't?  Sure, you can do ``introspective''
implementations that switch to another algorithm
if it looks like things are going quad.  But why not
just use a simple algorithm that can *provably, never*
go quadratic?

To bring this discussion back to the Perl domain,
merge sort is coming to Perl because it has average
*and worst case* performance that is  O(N log N),
it is stable, and it is relatively simple.   It tends to be
*less* efficient than qsort, particularly on machines
with small memory caches, but only slightly so.
Perhaps Perl 6 will support multiple sort implementations,
selectable by the user.    -- jpl





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

Date: Sun, 26 Nov 2000 07:22:34 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: TK for Win32?
Message-Id: <3A21008A.8A109D9B@patriot.net>

It's just you...

ppm install Tk

GOGAR wrote:

> Is it just me or isn't the Tk module available for Win32?
> and if so, isn't there an alternative?
>
> Gogar

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Sun, 26 Nov 2000 14:23:15 GMT
From: "Nobody" <nobody@nowhere.com>
Subject: Re: What's the use of the Filter Module
Message-Id: <n19U5.18467$ws2.1918238@news3.cableinet.net>

"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrn920q0m.imr.mgjv@martien.heliotrope.home...
> On Sat, 25 Nov 2000 23:33:55 GMT,
> Stephen Hall <sjhall@hallnet.co.uk> wrote:
> > Hi,
> > I have been looking for a way to hide the source of  perl script for
months
>
> Perl FAQ, section 3
>
>        How can I hide the source for my Perl program?
>
> If you have read it, then I wonder why you went through all the
> trouble. If you haven't, then I suggest you do it now.
>
> You don't give us the reasons WHY you want to 'hide' your code, but the
> FAQ mentiones a few.
>
> Martien
> --
> Martien Verbruggen              |
> Interactive Media Division      | Make it idiot proof and someone will
> Commercial Dynamics Pty. Ltd.   | make a better idiot.
> NSW, Australia                  |



I have read FAQ 3 and tried all three suggestions but like I said it can't
be that easy to crack a filter script or there would be no point.

The only other thing I can think or is changing the variable names but
that's hardly secure as a quick find and replace could almost reverse that.

I want to hide the source because I run intranets in a few companies and
manage them by dialing in. I don't want people in those companies to be able
to fiddle with or steal the source.

Stephen Hall.




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

Date: 26 Nov 2000 09:33:26 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: What's the use of the Filter Module
Message-Id: <m34s0uby6h.fsf@mumonkan.sunstarsys.com>

"Nobody" <nobody@nowhere.com> writes:

> I want to hide the source because I run intranets in a few companies and
> manage them by dialing in. I don't want people in those companies to be able
> to fiddle with or steal the source.

Why not just tell these companies:

   "Please don't steal my code- it belongs to me."

Since you are managing their intranets for them, obviously they have 
extended some measure of trust to you, right?  Why not just treat 
them with the same level respect you ask of them?

-- 
Joe Schaefer


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

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


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