[10129] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3722 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 15 18:07:49 1998

Date: Tue, 15 Sep 98 15:00:29 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 15 Sep 1998     Volume: 8 Number: 3722

Today's topics:
    Re: assigning file contents to a string <r28629@email.sps.mot.com>
    Re: Can I foreach multiple arrays? <jdf@pobox.com>
    Re: Can I foreach multiple arrays? (Sean McAfee)
    Re: Can I foreach multiple arrays? (Craig Berry)
    Re: Can I foreach multiple arrays? <dgris@rand.dimensional.com>
    Re: Can I foreach multiple arrays? <tchrist@mox.perl.com>
        Creating users under Win32 <rlaflamm@sscinc.com>
    Re: Creating users under Win32 <eashton@bbnplanet.com>
        Help me with subroutine from "Learning Perl" book sofianb@tc.umn.edu
    Re: Help me with subroutine from "Learning Perl" book <dgris@rand.dimensional.com>
    Re: help with perl reg. expr. (Tad McClellan)
    Re: Help: "cat" command and variable assignment (Sean McAfee)
    Re: Help: "cat" command and variable assignment (Gary L. Burnore)
    Re: how to handle compressed text files (Matt Knecht)
    Re: how to handle compressed text files (Clinton Pierce)
        Need help with PerlScript and Windows Scripting Host (w <mishkin@rational.com>
        output from a file to be used in code trex16@my-dejanews.com
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <borg@imaginary.com>
    Re: Perl & Java - differences and uses (Abigail)
        Perl tutorial <j.s.wijnhout@student.utwente.nl>
    Re: Perl tutorial <eashton@bbnplanet.com>
        Perl Web Editing Tool kazman@my-dejanews.com
        Perl kazman@my-dejanews.com
        Perl kazman@my-dejanews.com
    Re: print statement in perl <tpham@ee.gatech.edu>
    Re: Problem calling executables from Win95 ('General fa (Tye McQueen)
    Re: script: scriptMangle! <eashton@bbnplanet.com>
        Site devoted solely to scripting under Win32 <cwashing@ix.netcom.com>
        Turning off echo in NT <jhill@cis.ohio-state.edu>
        Why my perlgrep cannot compared to grep dizhao@my-dejanews.com
    Re: Why my perlgrep cannot compared to grep <tchrist@mox.perl.com>
        Win32::NetAdmin and WIN95 (RonBo)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Tue, 15 Sep 1998 15:39:58 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: assigning file contents to a string
Message-Id: <35FED09E.3FE59223@email.sps.mot.com>

Jason Holland wrote:
> 
> > file contents in any way.  I just want to store the entire file in a
> > variable, so that I can later refer to the variable in a print statement.
> 
> Try this:
> 
>         open( FILE, "file" );
>         my $content = "" ; foreach ( <FILE> ) { $content .= $_ }
>         close( FILE );
> 

Not a one-liner, but try this:

	open( FH, $filename) or die;
	undef $/;			# default is "\n"
	$whole_file = <FH>;		# whole file here
	close(FH);
	__END__

RTFM:
	perldoc perlvar

-TK


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

Date: 15 Sep 1998 22:28:17 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: jzobel@my-dejanews.com (Joachim Zobel)
Subject: Re: Can I foreach multiple arrays?
Message-Id: <m31zpdi0im.fsf@joshua.panix.com>

jzobel@my-dejanews.com (Joachim Zobel) writes:

> I would like to
> 
> foreach ($foo, $bar) (@foos, Qbars) {} # doesn`t work
> 
> just like I 
> 
> foreach $foo (@foos) {}
> 
> Is there a simple and elegant way?

Yes.

  foreach my $foo (@foos) {
    foreach my $bar (@bars) {

    }
  }

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 15 Sep 1998 20:34:58 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Can I foreach multiple arrays?
Message-Id: <SbAL1.2974$F7.12093945@news.itd.umich.edu>

In article <35fec571.1428841@dilbert.crrrwg.de>,
Joachim Zobel <jzobel@my-dejanews.com> wrote:
>I would like to

>foreach ($foo, $bar) (@foos, Qbars) {} # doesn`t work

>just like I 

>foreach $foo (@foos) {}

>Is there a simple and elegant way?

No, but either of these will do what you want:

for ($i = 0; $i < @foos; $i++) {
	($foo, $bar) = ($foos[$i], $bars[$i]);
	# ...
}

foreach $foobar (map { [$foos[$_],$bars[$_]] } 0..$#foos) {
	($foo, $bar) = @$foobar;
	# ...
}

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: 15 Sep 1998 20:38:47 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Can I foreach multiple arrays?
Message-Id: <6tmj8n$rta$1@marina.cinenet.net>

Jonathan Feinberg (jdf@pobox.com) wrote:
: jzobel@my-dejanews.com (Joachim Zobel) writes:
: 
: > I would like to
: > 
: > foreach ($foo, $bar) (@foos, Qbars) {} # doesn`t work
: > 
: > just like I 
: > 
: > foreach $foo (@foos) {}
: > 
: > Is there a simple and elegant way?
: 
:   foreach my $foo (@foos) {
:     foreach my $bar (@bars) {
: 
:     }
:   }

I think the idea was to pull out element 0 of each array, then element 1,
then element 2, and so forth.  I know of no elegant way to do this, though
setting it up as a for loop is pretty easy:

  die "Array size mismatch" unless @foos == @bars;

  for (my $n = 0; $n < @foos; $n++) {
    my ($foo, $bar) = ($foos[$n], $bars[$n]);
    # Your processing here.
  }

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Tue, 15 Sep 1998 21:07:31 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Can I foreach multiple arrays?
Message-Id: <6tmk64$dgb$1@rand.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

In article <35fec571.1428841@dilbert.crrrwg.de>
jzobel@my-dejanews.com (Joachim Zobel) wrote:

>I would like to
>
>foreach ($foo, $bar) (@foos, Qbars) {} # doesn`t work

Support for multiple iterators is something I would very
much like to see added to the language, but until that
happens this is what I do-

for( map { [ $array1[$_], $array2[$_] ] } 
     0 .. ($#array1 > $#array2 ? $#array1 : $#array2)) {

    my ($foo, $bar) = @$_;
 ...
}

There are several disadvantages to this construct, the greatest
(IMO) being that it is ugly.  While this example isn't too bad,
when $#array1 == 10000000 and $#array2 == 4 you have to go
through all sorts of contortions to avoid the memory overhead
of autovivification.

Or, you can always try a different approach.  If the data in
the two arrays is tightly enough coupled that you need to
iterate over both simultaneously you may be better off storing
the necessary two-element lists in a hash.  If you can be sure
that one array contains no duplicate values you can do this-

@hash{@array1} = @array2;
for(keys(%hash)) {
    my $foo = $_;
    my $bar = $hash{$_};
}

If you can't be sure that this won't create duplicate keys you'll
need to create unique keys and then store a reference to a list-

  $hash{$i++} = [shift @array1, shift @array2] while (defined $array1[0] ||
                                                      defined $array2[0]);

Ummm.. but that destroys the original lists.

  $hash{$i++} = [$array1[$i], $array2[$i]] while (defined $array1[$i] || 
                                                  defined $b[$i]);

Hope this helps.

dgris
-- 
Daniel Grisinger           dgris@perrin.dimensional.com
`Bangladesh.  Because life is too short to run bad code.'
                               Jon Orwant


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

Date: 15 Sep 1998 21:17:01 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Can I foreach multiple arrays?
Message-Id: <6tmlgd$hbp$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, jzobel@my-dejanews.com (Joachim Zobel) writes:
:I would like to
:   foreach ($foo, $bar) (@foos, @bars) {} # doesn't work
:just like I 
:   foreach $foo (@foos) {}
:Is there a simple and elegant way?

Destructively:

    while (($foo, $bar) = (shift @foos, shift @bars)) { } 

Non-destructively, given @foos == @bars:

    @pairs = map { [ $foos[$_], $bars[$_] }  0 .. $#foos;
    while (($foo, $bar) = @{shift @pairs}) { }

That assuming you don't really mean:

    @tmp = (@foos, @bars);
    while (($first, $second) = splice(@tmp, 0, 2)) { }

--tom
-- 
"Whenever you find that you are on the side of the majority, it is time
 to reform."    --Mark Twain


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

Date: Tue, 15 Sep 1998 17:22:32 -0400
From: "bob laflamme" <rlaflamm@sscinc.com>
Subject: Creating users under Win32
Message-Id: <6tmlqs$f47$1@client3.news.psi.net>

I have a script which does some basic administration tasks under NT.
The problem I'm up aginst right now is how to fill in all the fields when I
create a new user. I'm able to get everything except the 'User Profile Path'
set. So far I have been unable to locate a function the let me set it
(AdminMisc or NetAdmin).

Can anybody help?

tia

bob laflamme




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

Date: Tue, 15 Sep 1998 21:47:54 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Creating users under Win32
Message-Id: <35FEDE27.622A9D71@bbnplanet.com>

bob laflamme wrote:

> I have a script which does some basic administration tasks under NT.
> The problem I'm up aginst right now is how to fill in all the fields when I
> create a new user. I'm able to get everything except the 'User Profile Path'
> set. So far I have been unable to locate a function the let me set it
> (AdminMisc or NetAdmin).

This really isn't a Perl question. Why not try 'net user /?'. This will
list all of the options with the 'net user' command which includes
/PROFILEPATH I believe.
Enjoy.

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: Tue, 15 Sep 1998 20:07:23 GMT
From: sofianb@tc.umn.edu
Subject: Help me with subroutine from "Learning Perl" book
Message-Id: <6tmhdq$o3b$1@nnrp1.dejanews.com>

Hello ! My name is Budi Sofian. I am currently reading the first chapter of
"Learning Perl" book (Randal-O'reilly). I couldn't get one of their example,
which included a subroutine, to work. Here's the example :

#!/usr/bin/perl
%words = qw(
	fred		camel
	barney		llama
	betty		alpaca
	wilma		alpaca
);
print "What is your name? ";
$name = <STDIN>;
chomp ($name);
if ($name =~ /^randal\b/i) {
	print "Hello, Randal! How good of you to be here!\n";
} else {
	print "Hello, $name!\n";
	print "What is the secret word? ";
	$guess = <STDIN>;
	chomp ($guess);
	while (! good_word($name,$guess)) {
		print "Wrong, try again. What is the secret word? ";
		$guess = <STDIN>;
		chomp ($guess);
	}
}
sub good_word {
	my($somename,$someguess) = @_;
	$somename =~ s/\W.*//;
	$somename =~ tr/A-Z/a-z/;
	if ($somename eq "randal") {
		return 1;
	} elsif (($words{somename} || "groucho") eq $someguess) {
		return 1;
	} else {
		return 0;
	}
}

When I run the program, I have to enter "groucho" for every person (fred,
barney, betty, and wilma), except "randal". Could you please tell me why it is
not working ? Thanks in advance.

PS: I am using ActivePerl 5.005_2.

Regards, Budi Sofian


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 15 Sep 1998 21:17:11 GMT
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: Help me with subroutine from "Learning Perl" book
Message-Id: <6tmks7$dih$1@rand.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

In article <6tmhdq$o3b$1@nnrp1.dejanews.com>
sofianb@tc.umn.edu wrote:

>	} elsif (($words{somename} || "groucho") eq $someguess) {
                         ^^^^^^^^
Add a $ before somename and it will work fine.

dgris
-- 
Daniel Grisinger           dgris@perrin.dimensional.com
`Bangladesh.  Because life is too short to run bad code.'
                               Jon Orwant


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

Date: Tue, 15 Sep 1998 13:27:40 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help with perl reg. expr.
Message-Id: <sibmt6.fhk.ln@metronet.com>

david@ceres.ca.gov wrote:

: 	I was hoping someone out there has a perl script which can do the
: following with each entry in a flatfile database. Change each pipe
: delimited entry from:

: http://html-resources.com| HTML Resources |10-Sep-1998|cgi/misc|Great place
: for html resources |

: to:
: 1|HTML Resources|http://html-resources.com|10-Sep-1998|cgi/misc|Great place
: for html resources |


-----------------------
#!/usr/bin/perl -w

$num=1;
while (<DATA>) {
   @parts = split /\|/;

   $parts[1] =~ s/^\s+//;  # remove leading/trailing space
   $parts[1] =~ s/\s+$//;

   print $num++, '|';
   print join '|', $parts[1], @parts[0,2..$#parts];
}


__DATA__
http://html-resources.com| HTML Resources |10-Sep-1998|cgi/misc|Great place for html resources |
http://html-resources.com| HTML Resources |10-Sep-1998|cgi/misc|Great place for html resources |
-----------------------


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


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

Date: Tue, 15 Sep 1998 20:25:35 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Help: "cat" command and variable assignment
Message-Id: <33AL1.2970$F7.12089972@news.itd.umich.edu>

In article <6tma96$fvk$1@nnrp1.dejanews.com>,  <avern@hotmail.com> wrote:
>This is a clarification of my earlier post.  Is it possible to write a single
>line in perl that assign the contents of a file to a string variable by
>piping the output of a "cat" command? Does anyone know the correct syntax? 
>I'm looking for something like:

>$entire_file =  " cat path/to/file | ";
>OR
>$entire_file = " `cat path/to/file`";  (note the backticks versus the pipe)

Well, if you "use IO::File" at the top of your script, you could do this:

{ local $/; $file = (new IO::File "/path/to/file", "r")->getline(); }

(If the file can't be opened, the program will die with the message
'Can't call method "getline" without a package or object reference at ...')

If your script doesn't ever want to read from a file one line at a time,
put "undef $/" along with "use IO::File" at the top of the script, and do
this:

$file = (new IO::File "/path/to/file", "r")->getline();

If you wanted to be obfuscatory, you could do this instead:

$file = readline *{ new IO::File "/path/to/file", "r" };

-- 
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
            | K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
            | tv+ b++ DI++ D+ G e++>++++ h- r y+>++**          | umich.edu


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

Date: Tue, 15 Sep 1998 21:09:24 GMT
From: gburnore@databasix.com (Gary L. Burnore)
Subject: Re: Help: "cat" command and variable assignment
Message-Id: <3608d746.4081868@nntpd.databasix.com>

On Tue, 15 Sep 1998 18:05:27 GMT, in article
<6tma96$fvk$1@nnrp1.dejanews.com>, avern@hotmail.com wrote:

>Hi,
>
>This is a clarification of my earlier post.  Is it possible to write a single
>line in perl that assign the contents of a file to a string variable by
>piping the output of a "cat" command? Does anyone know the correct syntax? 
>I'm looking for something like:
>
>$entire_file =  " cat path/to/file | ";


cat /path/to/file | won't work at a prompt and probably won't work in a perl
script.


As others have said, there are ways to do it without the use of cat.
-- 
      I DO NOT WISH TO RECEIVE EMAIL IN REGARD TO USENET POSTS
---------------------------------------------------------------------------
                  How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore                       |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
                                      |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DOH!                                  |  ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
                                      |  ][3 3 4 1 4 2  ]3^3 6 9 0 6 9 ][3
Special Sig for perl groups.          |     Official Proof of Purchase
===========================================================================


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

Date: Tue, 15 Sep 1998 19:55:16 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: how to handle compressed text files
Message-Id: <ECzL1.41$Wo6.602012@news2.voicenet.com>

adrs@chemistry.ucsc.edu <adrs@chemistry.ucsc.edu> wrote:
>What is a good way to handle compressed files?  I have several text files
>I'd like to parse, each of which has been compressed with Unix 'compress'
>
>Right now, I'm putting each file into a temporary file with
>
>	system("zcat $file > tempfile")
>
>Then, I open 'tempfile,' work with it, close it, delete it, then repeat.
>
>This doesn't seem to work very well, though.

I'd probably use something like:

open(F, "/usr/local/bin/zcat $file|") || die "$0: fork failed: $!";
# do stuff with F, just like any other filehandle
close F or die "$0: $!";

Even better is to use magic open:

{
    local @ARGV = ( "/usr/local/bin/zcat $file |" );

    while (<>) {
        # Work with the file as you normally would
    }
}

Make sure you localize @ARGV, or you'll lose any command line parameters
(If that matters).  That's why the whole thing is in a naked block.

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 15 Sep 1998 19:57:59 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: adrs@chemistry.ucsc.edu
Subject: Re: how to handle compressed text files
Message-Id: <6tmgs7$cnb7@eccws1.dearborn.ford.com>

In article <6tmej7$7qk@darkstar.ucsc.edu>,
	adrs@chemistry.ucsc.edu writes:
>What is a good way to handle compressed files?  I have several text files
>I'd like to parse, each of which has been compressed with Unix 'compress'
>
>Right now, I'm putting each file into a temporary file with
>
>	system("zcat $file > tempfile")
>
>Then, I open 'tempfile,' work with it, close it, delete it, then repeat.
>
>This doesn't seem to work very well, though.

What's wrong with pipes?

	open(FH, "zcat $file|") || die "Cannot fork for pipe: $!\n";

	@TEXT=<FH>;	# Slurp in the uncompressed data
	
	close(FH) || die "zcat failed: $!\n";


-- 
+------------------------------------------------------------------------+
|  Clinton A. Pierce    |   "If you rush a Miracle Man,   | http://www.  |
|  cpierce1@ford.com    |     you get rotten miracles"    | dcicorp.com/ |
| fubar@ameritech.net   |--Miracle Max, The Princess Bride| ~clintp      |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*



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

Date: Tue, 15 Sep 1998 16:33:32 -0400
From: "Nathaniel Mishkin" <mishkin@rational.com>
Subject: Need help with PerlScript and Windows Scripting Host (wsh)
Message-Id: <6tmiut$6fe$1@usenet.rational.com>

I'm trying to figure out how to get access to the "WScript" object from a
PerlScript script.  (PerlScript is the thing that interfaces Perl with
Microsoft's generic Windows scripting mechanism.)  All the info I can find
on the net and in various docs about PerlScript seems to be in the context
of Web pages.  I'm looking for examples of scripts that are intended to be
invoked by WSCRIPT or CSCRIPT, not IIS.

Thanks.
--
Nat Mishkin
mishkin@rational.com





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

Date: Tue, 15 Sep 1998 21:17:58 GMT
From: trex16@my-dejanews.com
Subject: output from a file to be used in code
Message-Id: <6tmli6$suk$1@nnrp1.dejanews.com>

Hey everyone, I was wondering if someone can help me.  I have a .exe file
that produces a date and a numeric code and displays it onto the screen.  I
would like to generate a short perl program that captures this output and
writes it to a .txt file.  Can someone give me some pointers on how to use
the output of another file for my own file?

Frustrated.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 15 Sep 98 19:55:50 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <905889286.210363@thrush.omix.com>

George Reese <borg@imaginary.com> wrote:
: In comp.lang.java.programmer Abigail <abigail@fnx.com> wrote:
: : George is right in the sense that if you want a true OO environment,
: : suitable for several programmers to work on the same project, Perl is
: : a lousy choice.
:
: And this is a great summary of what I have basically been trying to
: say all along.

        I might be great, except for the fact that it is an opinion
        based on outdated information that is no longer valid.  Perl
        5.005* no longer has any of the encapsulation limitations
        limitations Abigail wrote of.

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Tue, 15 Sep 1998 21:06:29 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <pFAL1.1890$E9.6245803@ptah.visi.com>

In comp.lang.java.programmer Zenin <zenin@bawdycaste.org> wrote:
: George Reese <borg@imaginary.com> wrote:
: : In comp.lang.java.programmer Abigail <abigail@fnx.com> wrote:
: : : George is right in the sense that if you want a true OO environment,
: : : suitable for several programmers to work on the same project, Perl is
: : : a lousy choice.
: :
: : And this is a great summary of what I have basically been trying to
: : say all along.

:         I might be great, except for the fact that it is an opinion
:         based on outdated information that is no longer valid.  Perl
:         5.005* no longer has any of the encapsulation limitations
:         limitations Abigail wrote of.

Those are irrelevant.  The point is that even if perl gets rid of
those encapsulation issues, perl does not enforce a structured
approach to programming--something very essential to large,
multi-developer software engineering projects.

-- 
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie."
			    -Orson Welles


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

Date: 15 Sep 1998 21:37:39 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6tmmn3$fcl$1@client3.news.psi.net>

George Reese (borg@imaginary.com) wrote on MDCCCXLI September MCMXCIII in
<URL: news:2MyL1.1837$E9.6166774@ptah.visi.com>:
++ In comp.lang.java.programmer Abigail <abigail@fnx.com> wrote:
++ : George is right in the sense that if you want a true OO environment,
++ : suitable for several programmers to work on the same project, Perl is
++ : a lousy choice.
++ 
++ And this is a great summary of what I have basically been trying to
++ say all along.


No, not really. You can't obviously not work without an OO environment.
Many others aren't that rigid. Many others don't work in large projects
either.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

Date: Tue, 15 Sep 1998 22:33:06 +0200
From: "Jeroen Wijnhout" <j.s.wijnhout@student.utwente.nl>
Subject: Perl tutorial
Message-Id: <6tmj46$but$1@dinkel.civ.utwente.nl>

Hi,

I am planning to use Perl for writing simple CGI scripts, I need an
introduction in Perl first. I would be pleased if someone could give me a
tutorial for writing CGI scripts in Perl....

thanks in advance,
Jeroen

mail me at:
j.s.wijnhout@student.utwente.nl




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

Date: Tue, 15 Sep 1998 20:59:54 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Perl tutorial
Message-Id: <35FED2E6.D4686F0D@bbnplanet.com>

Jeroen Wijnhout wrote:

> I am planning to use Perl for writing simple CGI scripts, I need an
> introduction in Perl first. I would be pleased if someone could give me a
> tutorial for writing CGI scripts in Perl....

You might try http://language.perl.com/faq/index.html. Enjoy.
 
e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: Tue, 15 Sep 1998 21:27:29 GMT
From: kazman@my-dejanews.com
Subject: Perl Web Editing Tool
Message-Id: <6tmm41$tmm$1@nnrp1.dejanews.com>

I am tryiing to create perl script which edits only a specify part of each
page.  Below is the what I started:

  if ($param{level} == 2) {
    $certf = substr($param{basictext},0,500);
    @words = split(/\s+/,$certf);
    $certf = join(' ',@words[0..$#words-1]);
    $lda = &ora_login('OCIS','mwinter','mwinter1') || &errmsg($ora_errstr);
    open(TEMPOUT,">/usr/local/www/htdocs/webpages/$param{'id'}.dir");
    print TEMPOUT $param{'directory'};
    close(TEMPOUT);

	open (RTIIU, ">>/var/tmp/mosaic/RTIIU");
	print RTIIU $param{'id'};
	print RTIIU "\n";
	close (RTIIU);

    chmod(0777,"/usr/local/www/htdocs/webpages/$param{'id'}.dir");

    open(WEBPAGE,"/usr/local/www/htdocs/$param{directory}/index.html");
    open(NEWPAGE,">/usr/local/www/htdocs/$param{directory}/index.html.tmp");
    $body = 0;

    print NEWPAGE <<EOF;
<HTML>
<HEAD>
<TITLE>$param{companyname}</TITLE>
<META Name="description" Content="$param{certf}">
<META Name="keywords" Content="$param{keywords}">
</HEAD>
<!-- $param{certf} -->

EOF
    while (<WEBPAGE>) {

$HTML = $HTML.$_;

  if ($_ =~ /VALUE=\"\"/i) {  s/VALUE=\"\"/VALUE=\"$param{id}\"/gi;  print
NEWPAGE;  }  if ($_ = /^<.*>/ .. /(<P><IMG
SRC=\"/imagesT/area_of_expertise.gif\" HEIGHT=25 WIDTH=427 ALT=\"Area Of
Expertise Key Words\">)/([^\"]*)/<P><CENTER><A HREF=\"#top\"><IMG
SRC=\"/imagesT/top.gif\")/i { 
s/([^\"]*)=\"\"/([^\"]*)=\"$param{keywords}\"/gi;  print NEWPAGE;  }  elsif
($body == 1) {	print NEWPAGE;	}  elsif ($_ =~ /<BODY/i) {  print NEWPAGE; 
$body = 1;  }  } $_ = $HTML; $true = /^(<HTML>)/ .. /<body .\"(.*)\"/i; $2;

    close(WEBPAGE);
    close(NEWPAGE);

print NEWPAGE <<EOF;
$2
$body
EOF

rename("/usr/local/www/htdocs/$param{directory}/index.html","/usr/local/www/htdo
cs/$param{directory}/index.html-old");

rename("/usr/local/www/htdocs/$param{directory}/index.html.tmp","/usr/local/www/
htdocs/$param{directory}/index.html");
    chmod(0777,"/usr/local/www/htdocs/$param{directory}/index.html");
    &html_header2("Edit successful");
$data2 = &GetFile("/usr/local/www/htdocs/cgi-templates/thanks.html");
print $data2;
&form;
}


The specific part is

<P><IMG SRC="/imagesT/area_of_expertise.gif" HEIGHT=25 WIDTH=427
ALT="Area Of Expertise Key Words">
#
#
#
<P><CENTER><A HREF="#top">
<IMG SRC="/imagesT/top.gif">

# part can be edited and anything else has to be stayed before and after
those images.

I cannot add <!-- --> tag to specify because there are many pages exist.

Please help me.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 15 Sep 1998 21:20:26 GMT
From: kazman@my-dejanews.com
Subject: Perl
Message-Id: <6tmlmr$t11$1@nnrp1.dejanews.com>

I am trying to make script which can edit web pages through web browsers.
But I want the script can edit only a specific part of pages.  For example,
If I want people to edit words between specific images, what can I do?

Below is what I tried to do.

  if ($_ = /^<.*>/ .. /(<P><IMG SRC=\"/imagesT/area_of_expertise.gif\"
HEIGHT=25 WIDTH=427 ALT=\"Area Of Expertise Key
Words\">)/([^\"]*)/<P><CENTER><A HREF=\"#top\"><IMG
SRC=\"/imagesT/top.gif\")/i { 
s/([^\"]*)=\"\"/([^\"]*)=\"$param{keywords}\"/gi;  print NEWPAGE;  } }

I am trying to have a script which edit words between

<P><IMG SRC=\"/imagesT/area_of_expertise.gif\" HEIGHT=25 WIDTH=427 ALT=\"Area
Of Expertise Key Words\">

AND

<P><CENTER><A HREF=\"#top\"><IMG SRC=\"/imagesT/top.gif\">

Everything else before and after images has to stay the same as before.

Please someone help me.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 15 Sep 1998 21:20:25 GMT
From: kazman@my-dejanews.com
Subject: Perl
Message-Id: <6tmlmp$t10$1@nnrp1.dejanews.com>

I am trying to make script which can edit web pages through web browsers.
But I want the script can edit only a specific part of pages.  For example,
If I want people to edit words between specific images, what can I do?

Below is what I tried to do.

  if ($_ = /^<.*>/ .. /(<P><IMG SRC=\"/imagesT/area_of_expertise.gif\"
HEIGHT=25 WIDTH=427 ALT=\"Area Of Expertise Key
Words\">)/([^\"]*)/<P><CENTER><A HREF=\"#top\"><IMG
SRC=\"/imagesT/top.gif\")/i { 
s/([^\"]*)=\"\"/([^\"]*)=\"$param{keywords}\"/gi;  print NEWPAGE;  } }

I am trying to have a script which edit words between

<P><IMG SRC=\"/imagesT/area_of_expertise.gif\" HEIGHT=25 WIDTH=427 ALT=\"Area
Of Expertise Key Words\">

AND

<P><CENTER><A HREF=\"#top\"><IMG SRC=\"/imagesT/top.gif\">

Everything else before and after images has to stay the same as before.

Please someone help me.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Tue, 15 Sep 1998 17:11:24 -0400
From: Tien Pham <tpham@ee.gatech.edu>
Subject: Re: print statement in perl
Message-Id: <35FED7FC.EF0FCA36@ee.gatech.edu>

Hello there,

I got one respond from Jeff Pinyan.  His suggestion is to pre-declare
the
arrays:

>I believe this error is similar to this error:

>eval '@array = qw( foo bar )';
>print "@array\n";

>The reason is, when you assign the typeglob (*cout = func(\@stuff)),
you
>are using the array form (@cout) for the first time in double quotes.
The
>reason Perl barks at you is because it expects the ACTUAL @cout to be
>mentioned somehow before it has any reason to use it in quotes.

>Thus, the code should predeclare @cout, or, in my case:
>@array = ();
>eval '@array = qw ( foo bar )';
>print "@array\n";

However, I found out that this works only when the passed arrays are
one dimensional.  So if I pass 2-dimensional arrays and try to print
them out, I'll get something like this:

----

ARRAY(0xc3450) ARRAY(0xd7dd0)   ARRAY(0xd7dc4) ARRAY(0xd7e48)   aaa

----

which is not desirable.

You can test the following codes to see what I meant:

-----

#!/usr/local/bin/perl

@x = ([1,0,1], [0,1,1]);
@y = ([1,1,1], [1,1,0]);

@sum = ();
@cout = ();

#--Note that @x and @y are 2-dimensional arrays;

(*sum,*cout) = func (\@x,\@y);

print STDOUT "@sum\t@co\taha\n";

sub func {
  local (*x,*y) = @_;
  my ($bit);
  local (@sum,@co);

  @sum = ();
  @co = ();

  #--Do nothing; Just copy to different vars
  #--and return them

  @sum = @x;
  @co = @y;

  print STDOUT "@sum\t@co\taaa\n";
  return (\@sum,\@co);
}
----------

Does anybody know how to fix this (passing and printing 2-dimensional
arrays)?

Again, thank you for your help,

tien pham
tpham@ee.gatech.edu

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

Tien Pham wrote:
Hello there,

>
> I have a question regarding to Perl.
>
> On page 117 of "Programming Perl" by O'Reilly & Associates,
> there is an example (near the bottom of the page) showing
> how to pass arrays using typeglob approach.
> I include the example here for convenience:
>
>      (*a, *b) = func(\@c, \@d);
>      print "@a has more than @b\n";
>      sub func {
>         local (*c, *d) = @_;
>         if (@c > @d) {
>            return (\@c, \@d);
>         }
>         else {
>            return (\@d, \@c);
>         }
>      }
>
> Notice how @a and @b are printed in the print statement in
> the codes above.
>
> I follow pretty much the method shown on that page, but I
> always got error message when I executed my Perl program:
>
>     % In string, @cout now must be written as \@cout at
>       add.prl line 17, near "@sum \t @cout"
>       Execution of add.prl aborted due to compilation errors.
>
> This is my Perl program:
> -----------------------
>
> @x = ([1,0,1], [0,1,1]);
> @y = ([1,1,1], [1,1,0]);
>
> $row = $#x;
> $col = $#{$x[0]};
>
> for $time (0..$row) {
>   (*sum,*cout) = add_arr (\@x,\@y);
>   print "@sum \t @cout \t aaa\n";
> }
>
> sub add_arr {
>   local (*x,*y) = @_;
>   print STDOUT "@x\t@y\tbbb\n";
>
>   return (\@x,\@y);
> }
>
> ------------------------
>
> Basically, it complains that I cannot have @sum or @cout like that
> in the quotation.  According to the book, I can.
>
> If I add another print statement to the program:
>
> ...
> for $time (0..$row) {
>   (*sum,*cout) = add_arr (\@x,\@y);
>
>   print @sum, "\t", @cout, "\t aaa\n";      <---- Added
>   print "@sum \t @cout \t aaa\n";
> }
> ...
>
> Both statements are executed properly!  Without the added
> line, the 2nd print statement will give error message.
>
> Does anybody know what's going on, and how to fix this?
>
> thanks,
>
> tien pham
> tpham@ee.gatech.edu
>
> --
> Plan:
>
> To live
>  To enjoy
>   To appreciate
>    every opportunity and every minute here, in America!
> --------------------------------------

--
Plan:

To live
 To enjoy
  To appreciate
   every opportunity and every minute here, in America!
--------------------------------------





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

Date: 15 Sep 1998 15:58:01 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Problem calling executables from Win95 ('General failiure' on A: when there is no reference to A:)
Message-Id: <6tmkcp$oge@fohnix.metronet.com>

posenj@lancet.co.za writes:
) ;kjgblkjghnlkuy

Okay.  The original post didn't make it to my unworthy news server
so I can't complain.

) On Sun, 09 Aug 1998 02:31:16 GMT, posenj@lancet.co.za wrote:
) >When calling any external program (located on my C: drive) from the
) >script my A: drive is accessed. I get the following message:
) >
) >	General failure reading device  LP!!?
) >	Abort, Retry, Fail?

This is controlled by the SEM_FAILCRITICALERRORS flag of
SetErrorMode().  To use this Win32 API from Perl, get my
forthcoming v0.06 of Win32API::File or get Win32::API and
write your own interface to it.

The value of SetErrorMode() is inherited from the parent
process so how this is set will affect how other programs
behave.

For more information, get the Win32 SDK documentation from
Microsoft (or included with your Win32 C compiler).

Check
    http://www.metronet.com/~tye/alpha/Win32API/
if v0.06 of Win32API::File isn't on your CPAN server when you read
this.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Tue, 15 Sep 1998 21:14:49 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: script: scriptMangle!
Message-Id: <35FED665.3008CAE1@bbnplanet.com>

Craig Berry wrote:
 
> I happen to be in sympathy with your general free software approach.  I
> just wish you'd stop attacking strawmen when criticizing the non-free
> approach(es).

I don't see that as attacking. To make Perl 'unreadable' is almost
blasphemy. Also, to assume that your code is safer by making it cryptic
is certainly a misconception proven to be wrong over years of
cryptographic history, e.g. purple, enigma, etc. You have a choice to
either sell it with a license leaving you legal recourse or give it
away. 'Codae Obscurae' is sort of, well, pointless, unless you are
sending the plans for WWIII encoded in music encoded in Perl. :)  

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: Tue, 15 Sep 1998 16:07:22 -0500
From: "Clarence Washington Jr." <cwashing@ix.netcom.com>
Subject: Site devoted solely to scripting under Win32
Message-Id: <6tmksn$pj3$1@farragut.paranet.com>

Check it out
http://cwashington.netreach.net

Win32 bit scripting, lots of sample scripts, downloads,
reference files, and technical support via an online discussion forum.







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

Date: Tue, 15 Sep 1998 16:17:39 -0400
From: Jim Hill <jhill@cis.ohio-state.edu>
Subject: Turning off echo in NT
Message-Id: <35FECB63.41E7F5D3@cis.ohio-state.edu>

Hello,
    I am writing a client/server app that must verify the user based on
their username and pasword.
I was wondering if anyone knows how to turn off echo under NT(using the
ms-dos window)  when the
user enters his/her password.

Thank You ,
Jim



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

Date: Tue, 15 Sep 1998 19:50:31 GMT
From: dizhao@my-dejanews.com
Subject: Why my perlgrep cannot compared to grep
Message-Id: <6tmge7$mr8$1@nnrp1.dejanews.com>

  I am wondering why a perl like grep is much slower than ordinary grep.
  I use Slackware 2.0.34 and perl 5.0004 and a text file of 381,906
lines(19,505,167 characters). The command is like this:
      time perl -ne ' /date/i;' .all.2 > /tmp/null
   Result:
      8.290u 0.140s 0:08.45 99.7%     0+0k 0+0io 179pf+0w

      time grep -i date .all.2 > /tmp/null
   Result:
      0.360u 0.040s 0:00.39 102.5%    0+0k 0+0io 4839pf+0w

  It seems that the grep is 30 times faster than the perl one. Then I test
the I/O speed of perl like this:  time perl -ne ' print;' .all.2 > /tmp/null 
Result:  1.960u 0.490s 0:02.45 100.0%  0+0k 0+0io 174pf+0w  So it seems the
bottle is not in the I/O but in the regexp match. But why is the perl's
regexp much slower than the grep's? (I have used more complex regexp like
"date[0-9][^0-Z_]" but the conclusion is the same). Can someone give me an
answer? Thanks.  BTW, has somebody try to use the perl library routines
directly?(I mean use gcc to directly link the functions in perl library.)?
Please tell me how.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 15 Sep 1998 21:05:47 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why my perlgrep cannot compared to grep
Message-Id: <6tmkrb$hbp$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, dizhao@my-dejanews.com writes:
:  I am wondering why a perl like grep is much slower than ordinary grep.

The basic reason is the general interpreter loop overhead that you don't
have in grep.

:  I use Slackware 2.0.34 and perl 5.0004 and a text file of 381,906
:lines(19,505,167 characters). The command is like this:
:      time perl -ne ' /date/i;' .all.2 > /tmp/null

Well, you can do better there.  /i is rather slow in Perl.

% time perl -ne '/vt100/i' /etc/termcap 
0.440u 0.000s 

% time perl -ne '/[vt][tT]100/' /etc/termcap 
0.170u 0.010s 

--tom
-- 
"Developing fewer bugs before you ship is how you succeed. This Rule does
not apply to Microsoft." --Rob Pike


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

Date: Tue, 15 Sep 1998 20:38:52 GMT
From: snorjb@wnt.sas.com (RonBo)
Subject: Win32::NetAdmin and WIN95
Message-Id: <35fecff6.26306078@newshost.unx.sas.com>

Does anyone know an alternate way of gettting at User information,
specifically $comment, for a WIN95 client running under NT?  The
Win32::NetAdmin is only compatible with NT clients, and I've not been
able to pull out the comment field for Win95\98 clients. 

Thanks. for any help. 



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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 3722
**************************************

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