[9597] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3191 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 17 20:07:17 1998

Date: Fri, 17 Jul 98 17:00:38 -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           Fri, 17 Jul 1998     Volume: 8 Number: 3191

Today's topics:
    Re: %vHash = $vScalar doesn't work, why? (Mark-Jason Dominus)
    Re: Can a Crontab run perl script <p-fein@uchicago.edu>
    Re: Can a Crontab run perl script (Abigail)
    Re: Changing user from nobody to username (Abigail)
    Re: Correction: Problem with escaped octal chars > 177 (Ronald J Kimball)
    Re: Get char from string (Abigail)
    Re: hash undef problem (Craig Berry)
    Re: hash undef problem (Mark-Jason Dominus)
    Re: Help me on the if-then-else branch (Craig Berry)
    Re: Help me on the if-then-else branch (Craig Berry)
    Re: Help me on the if-then-else branch (Abigail)
    Re: Help me on the if-then-else branch (Abigail)
    Re: I'm baffled.. (and an amateur:) <yong@shell.com>
    Re: I'm baffled.. (and an amateur:) (Ronald J Kimball)
    Re: Java and Perl together? randall_burns@hotmail.com
    Re: Javascript History -1 (Need the Perl equivalent) swhite@accessonline.com
    Re: matching problem (Ronald J Kimball)
        Matching values in a hash Juli@my-dejanews.com
    Re: Mutiple pattern searches (Abigail)
        NewLines in pattern matching bronevetsky@midicorp.com
    Re: NewLines in pattern matching (Larry Rosler)
    Re: NewLines in pattern matching (Craig Berry)
    Re: open (IN, "foo.txt") works, open (IN, "$foo") does  (Troy Denkinger)
    Re: Passing null BSTR pointer with Win32::OLE marc_mims@my-dejanews.com
    Re: Perl Beautifier Home Page (Ronald J Kimball)
        perl question on split <gaheris@best.com>
    Re: Please Help Me! (Matt's Script BB Problem) (Ronald J Kimball)
    Re: Premature End of Script Header problem <mastered@paclink.com>
    Re: Print LoL-tree routine (attached) (Ronald J Kimball)
    Re: Print LoL-tree routine (attached) (Ronald J Kimball)
    Re: Print LoL-tree routine (attached) (Ronald J Kimball)
        prototypes and 'Bizarre copy of ARRAY' <seay@hol.fr>
    Re: regexp help? (Ronald J Kimball)
        shmwrite() and shmread() question (Josh Blackwell)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 17 Jul 1998 19:47:09 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: %vHash = $vScalar doesn't work, why?
Message-Id: <6oonpt$b7b$1@monet.op.net>

In article <6oldgs$av4@bilbo.ShireNet.com>,
Scott Cherkofsky <crusader@bilbo.ShireNet.com> wrote:
>
>I've got a simple problem that's been driving me bonkers.  why doesn't 
>the following code work?

Because a string is not a list.

>	$vSDFGuts = "NAME,Scott,DESC,5ft10inches";
>	%hSDFInfo = $vSDFGuts;
>
>I can't get $hSDFInfo{NAME} to give me back Scott!

Try

	%hSDFInfo = split(/,/ => $vSDFGuts);

That says to carve $vSDFGuts into pieces at every comma, and to make a
list of the resulting pieces, and then to turn that list into a hash.


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

Date: Fri, 17 Jul 1998 22:08:03 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Re: Can a Crontab run perl script
Message-Id: <opgsok0m8qk.fsf@harper.uchicago.edu>

linberg@literacy.upenn.edu (Steve Linberg) writes:

> 
> In article <35AFAB40.6076@ford.com>, whaidri@ford.com wrote:
> 
> > I wrote a perl (actually an oraperl) program. It runs as expected when
> > submitted from the command line. But when I run it from a crontab, it
> > does not work.
> > 
> > Thanks.
> 
> You're welcome!
> 
> Do you have a question?  :)

I'm just guessing here, but it's probably "Why?".

Answer: How should we know?  You didn't tell us anything.  Given that,
I'd say something's not working right.

-- 
Peter A Fein                                           Summering in SF!
Home: 650-571-6476                                   Work: 650-628-2172
p-fein@uchicago.edu                             pfein@us.checkpoint.com
Gilette's Razor: The best a man can get.


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

Date: 17 Jul 1998 23:12:52 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can a Crontab run perl script
Message-Id: <6oolpk$9s4$1@client3.news.psi.net>

Wali Haidri (whaidri@ford.com) wrote on MDCCLXXXI September MCMXCIII in
<URL: news:35AFAB40.6076@ford.com>:
++ I wrote a perl (actually an oraperl) program. It runs as expected when
++ submitted from the command line. But when I run it from a crontab, it
++ does not work.


Pay it more, it's probably on strike.



Abigail
-- 
It might help if you specify "does not work".


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

Date: 17 Jul 1998 23:14:52 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Changing user from nobody to username
Message-Id: <6ooltc$9s4$2@client3.news.psi.net>

dhawker@my-dejanews.com (dhawker@my-dejanews.com) wrote on MDCCLXXXI
September MCMXCIII in <URL: news:6oo7fr$l9m$1@nnrp1.dejanews.com>:
++ The web server is run as "nobody" and emails sent from a web script have
++ nobody@host in the From. Is it possible, in perl, to change the identity to
++ our username? Short of sending ourself an email to be processed by our mail
++ server script which runs as our username.


Maybe. Be more specific.



Abigail
-- 
perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
          print chr 0x$& and q
          qq}*excess********}'


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

Date: Fri, 17 Jul 1998 19:28:59 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Correction: Problem with escaped octal chars > 177
Message-Id: <1dcbrxy.1dss0wamv3c1gN@bay1-252.quincy.ziplink.net>

Joshua Powers <jpowers@cs.oberlin.edu> wrote:

> I have run into an interesting problem...

Please provide a brief code sample which demonstrates this behavior.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 17 Jul 1998 23:15:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Get char from string
Message-Id: <6oolv1$9s4$3@client3.news.psi.net>

bchapman (bchapman@best.com) wrote on MDCCLXXXI September MCMXCIII in
<URL: news:35AF8BBB.EF03907A@best.com>:
++ Say I have a string that is 10 chars long and I want the 4th char of it.
++ 
++ The only way I know how to do that is substr the string down to a 1
++ character string, and then chop that to give me the char.
++ 
++ Is there an easier way to do that?


Yes. Use substr() and forget about chop().


Abigail
-- 
perl -wle '$, = " "; sub AUTOLOAD {($AUTOLOAD =~ /::(.*)/) [0];}
           print+Just (), another (), Perl (), Hacker ();'


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

Date: 17 Jul 1998 22:07:02 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: hash undef problem
Message-Id: <6oohu6$ka1$4@marina.cinenet.net>

Eric Sheng (shenge@ece.ucdavis.edu) wrote:
: 	I am using a hash of hash of hash in my script as follow:
: 
: $all_groups{$group_name}{$element_name}{$element_component} = "xyz";
: 
: what I need to do at one point is "undef" all the data structure under a
: certain $element_name.  

  delete $all_groups{$group_name}{$element_name};

Gets rid of the element in the middle (element name) hash level, and
dereferences the hash it used to have as its (by-reference) value; if that
was the last reference, the bottom hash goes away.

If you instead decide you want the element name still in the hash but with
an empty-hash (by reference) value, do

  $all_groups{$group_name}{$element_name} = {};

: I am doing:
:
: 	undef $all_groups{$group_name}{$element_name}
: 
: but I believe it is not deleting the $element_name itself.

Nope, that just sets the value associated with that element name to undef.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 17 Jul 1998 18:33:52 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: hash undef problem
Message-Id: <6oojgg$at8$1@monet.op.net>

In article <6oofui$7ov$1@mark.ucdavis.edu>,
Eric Sheng  <shenge@ece.ucdavis.edu> wrote:
>what I need to do at one point is "undef" all the data structure under a
>certain $element_name.  I am doing:
>
>	undef $all_groups{$group_name}{$element_name}
>I still see the "Element_name" I "undef" before.  What should I do?

`undef' does not delete an item from a hash.  It makes it undef.
That is not the same.  To delete the item, use `delete'.

Here are three different hashes:

	X =>     1
	Y =>     2


	X =>     1
	Y => undef


	X =>     1


undef  $hash{Y} turns the first hash into the second hash.
delete $hash{Y} turns the first hash into the third  hash.





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

Date: 17 Jul 1998 21:58:42 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help me on the if-then-else branch
Message-Id: <6oohei$ka1$3@marina.cinenet.net>

Jerome O'Neil (joneil@cks.ssd.k12.wa.us) wrote:
: We can knock it down to three like this:
: 
: #!/usr/local/bin/perl -w
: print qq{What is your name?\n};
: chomp($name = <STDIN>);
: ($name =~ /lloyd/i) ? print qq{Hi Lloyd glad yer back!\n} : qq{Hello,
: $name\n};

Little problem with your logic, there.  Probably meant (un-one-lined for
clarity):

  print( ($name =~ /lloyd/) ? 
           qq{Hi Lloyd glad yer back!\n} :
           qq{Hello, $name.\n};

Also notice that your version will take 'lloyd' (case-insensitive)
anywhere in the input string, so 'foolloydbar' gets greeted wrong.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 17 Jul 1998 22:14:25 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Help me on the if-then-else branch
Message-Id: <6ooic1$ka1$5@marina.cinenet.net>

Craig Berry (cberry@cinenet.net) wrote:
: Little problem with your logic, there.  Probably meant (un-one-lined for
: clarity):
: 
:   print( ($name =~ /lloyd/) ? 
:            qq{Hi Lloyd glad yer back!\n} :
:            qq{Hello, $name.\n};
                                ^ )

Close paren before semicolon got nuked by finger slip.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 17 Jul 1998 23:23:44 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help me on the if-then-else branch
Message-Id: <6oome0$9s4$4@client3.news.psi.net>

lloyd (lloyd007@best.com) wrote on MDCCLXXXI September MCMXCIII in
<URL: news:lloyd007-1707980934570001@lloyd007.vip.best.com>:
++ 
++ #!/usr/local/bin/perl -w
++ 
++ print "What is your name?\n";
++ $name = <STDIN>;
++ if ($name eq "lloyd") {
++    print "Hi Lloyd glad to see you back!\n";
++ } else {
++ print "hello, $name\n";
++ }
++ 
++ Why is this happening. I copied this program stright out of that book and
++ it doesn't work. Someone please be kind enough to help.....


You mean the example on page 7? 

I think you forgot to copy line 3 of the program.




Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


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

Date: 17 Jul 1998 23:25:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help me on the if-then-else branch
Message-Id: <6oomha$9s4$5@client3.news.psi.net>

Mark Stang (markstang@ncgroup.com) wrote on MDCCLXXXI September MCMXCIII
in <URL: news:6oo1or$ku8$1@usenet1.interramp.com>:
++ I'm a newbie too, but I think your code should be changed to read
++ 
++ $name = chomp(<STDIN>);


No, I don't think so. Unless he has his name stored in $/, which
is unlikely.



Abigail
-- 
The newline formally known as Abigail


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

Date: Fri, 17 Jul 1998 16:49:10 -0500
From: Yong Huang <yong@shell.com>
Subject: Re: I'm baffled.. (and an amateur:)
Message-Id: <35AFC6D6.1420D916@shell.com>

I posted the msg below.

A CGI script has to go through a lot of debugging as any program does. It's
much easier to insert a print "\$var is now: $var.\n"; into the
individually print'ed lines than into a here doc. Other than debugging, you
really want to insert a lot of if ($foo==$bar) {print "XXX";} else { print
"YYY";} type of blocks in your code. My approach is much easier to
maintain.

Another advantage (I think, haven't tested) is that multiple print'ed lines
guarantee the user sees the result coming in a little by little in a slow
connection if $| is set to 1. But a big print or a here doc prints that at
one shot.

Finally, there're many times you want to do this:

open SQL, "| sqlplus user/passwd" or die: $!;
print SQL "select * from mytab;\n";
print SQL... print SQL........
close SQL

This type of sqlplus can be superseded by using Oraperl etc. But my point
is, if you need this type of print to pipe, I wonder if you can still use a
here doc:

select SQL;
print <<END
select * from mytab;
desc mytab;
END

I didn't test it though.

Yong Huang wrote:

> Contrary to what many people think, single print sometimes does have
> problems. When writing a CGI script, you have to insert dynamic content
> between HTML code. This breaks the first form of your single print
> (print qq{}). That's still acceptable. But if your original code is
> using the here document and you want to insert the dynamic content in
> there, you have to give up on the here document.
>
> Yong Huang



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

Date: Fri, 17 Jul 1998 19:28:52 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: I'm baffled.. (and an amateur:)
Message-Id: <1dcbqzt.5lv9y18xdj5sN@bay1-252.quincy.ziplink.net>

Yong Huang <yong@shell.com> wrote:

> A CGI script has to go through a lot of debugging as any program does. It's
> much easier to insert a print "\$var is now: $var.\n"; into the
> individually print'ed lines than into a here doc. Other than debugging, you
> really want to insert a lot of if ($foo==$bar) {print "XXX";} else { print
> "YYY";} type of blocks in your code. My approach is much easier to
> maintain.

Have you considered using the debugger?

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 17 Jul 1998 23:17:17 GMT
From: randall_burns@hotmail.com
Subject: Re: Java and Perl together?
Message-Id: <6oom1t$dco$1@nnrp1.dejanews.com>

Question: Would it be possible to write a Perl implementation that would
allow Perl to be used for both the front-end and back end  aspects of
web pages?  I get the impression that Java has some threading features
that Perl doesn't(and of course Perl has lots of features that Java
doesn't).  Right now, web programming strikes me as something of a Tower
of Babel   situation with lots of different languages-and no one
language that can do it all.

I've seen some talk on one of the Perl web pages about getting manufacturers
to have add-on modules that allow Perl bytecodes to be use by a browser-
it seems to be that getting Perl working well with the existing browser
standards might be more straightforward. Am I missing something here?


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


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

Date: Fri, 17 Jul 1998 22:56:28 GMT
From: swhite@accessonline.com
Subject: Re: Javascript History -1 (Need the Perl equivalent)
Message-Id: <35afd4f5.1101989@news.sprint.ca>

On 17 Jul 1998 03:45:17 GMT, mgjv@comdyn.com.au (Martien Verbruggen)
wrote:

>In article <35aeafcc.3726642@news.sprint.ca>,
>	swhite@accessonline.com writes:
>> Hi,
>> 
>> How do I read the name of the HTML file that I used to call the perl
>> script?
>
>You don't call a perl script with a HTML file. You can have a link or
>a form submit thingie in HTML, which will cause your browser to
>contact a server with a certain URL. The server will execute a CGI
>process, etc. Outside of the scope of this group.

and the link calls the script. (ya ya ya) I didn't think it was
neccessary to explain every little thing.  Have some insight even if
just a little.   ????
>
>> I need a function like the javascript history -1 that I can call in
>> Perl.
>
>JavaScript, as you mean it, runs in the browser. CGI processes run on
>the server. The server has no access to the client's history. Maybe
>you can try one of the CGI environment variables. Go to a CGI group,
>and ask there. Somewhere in comp.infosystems.www.* there should be at
>least one.

Wrong again?  There was no cgi group under that name.  I found one
anyways.

>You have not asked anything perl specific.

Why not check out Perl 101,  I did and found I could read an
environment variable and get the "calling URL" which happens to be the
html file.

Wow, that wasn't so hard for a newbie like me having come from the C
side of things.

Thanks anyways!!!!!!!!

Steve

>
>Martien
>-- 
>Martien Verbruggen                  | 
>Webmaster www.tradingpost.com.au    | If it isn't broken, it doesn't have
>Commercial Dynamics Pty. Ltd.       | enough features yet.
>NSW, Australia                      | 



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

Date: Fri, 17 Jul 1998 19:28:53 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: matching problem
Message-Id: <1dcbr3n.9zgmclzhp9vmN@bay1-252.quincy.ziplink.net>

Simon Dueckert <dueckert@iis.fhg.de> wrote:

>   ($file,$desc,$url)=(/^(\s)()(\s)$/);  -->probably this looks
> very strange to you

You can say that again!

That matches the beginning of the string, followed by a single
whitespace character, followed by another whitespace character, followed
by the end of the line.

If it matches, $file and $url will each contain a single whitespace
character, and $desc will contain the null string.  [ ()??  Why do you
want to capture nothing? ]

Have you read the perlre documentation?

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 17 Jul 1998 23:34:25 GMT
From: Juli@my-dejanews.com
Subject: Matching values in a hash
Message-Id: <6oon22$ek0$1@nnrp1.dejanews.com>

while (defined ($line = <FILE>) ) {
 	foreach $key (keys %in) {
		if ($key =~ /\bfoo\b/) {
		     if ($in{$key} =~ /$line/ ) {
			    push (@thefile, $line);
		     }
		}
	 }
}
What I am doing here is reading in a file, line by line.
Foreach key that matches foo
If the value matches a line in the file
write line to the array......

The first match works fine,
but I am not able to match the value with anything in the file.
Any help is appreciated.
Juli@my-dejanews.com

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


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

Date: 17 Jul 1998 23:27:35 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Mutiple pattern searches
Message-Id: <6ooml7$9s4$6@client3.news.psi.net>

John Nguyen (RC0705@email.sps.mot.com) wrote on MDCCLXXXI September
MCMXCIII in <URL: news:35AF380A.533C@email.sps.mot.com>:
++ Is there a way of searching a text file using multiple search patterns. 
++ For example, say I want only lines from a text file that does NOT
++ include these three patterns: abc xyz mno


RTFFAQ.


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


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

Date: Fri, 17 Jul 1998 22:58:25 GMT
From: bronevetsky@midicorp.com
Subject: NewLines in pattern matching
Message-Id: <6ookug$bh3$1@nnrp1.dejanews.com>

Can someone tell me of an easy way to pattern match for any character the
same way I could with .*, except that I'd like to be able to include newlines
in the pattern. I can't figure out how to phrase it. Stuff like [\n|.]* or
[\n.]* doesn't work.

Greg Bronevetsky

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


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

Date: Fri, 17 Jul 1998 16:26:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: NewLines in pattern matching
Message-Id: <MPG.10197d66c93e1ebc989726@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6ookug$bh3$1@nnrp1.dejanews.com> on Fri, 17 Jul 1998 22:58:25 
GMT, bronevetsky@midicorp.com <bronevetsky@midicorp.com> says...
> Can someone tell me of an easy way to pattern match for any character the
> same way I could with .*, except that I'd like to be able to include newlines
> in the pattern. I can't figure out how to phrase it. Stuff like [\n|.]* or
> [\n.]* doesn't work.

Easy way:  Add the suffix s to your regex:  /./s;

Harder way (like you were trying):  /(?:.|\n)/;

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 17 Jul 1998 23:22:49 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: NewLines in pattern matching
Message-Id: <6oomc9$ka1$6@marina.cinenet.net>

bronevetsky@midicorp.com wrote:
: Can someone tell me of an easy way to pattern match for any character the
: same way I could with .*, except that I'd like to be able to include newlines
: in the pattern. I can't figure out how to phrase it. Stuff like [\n|.]* or
: [\n.]* doesn't work.

Just use the /s modifier on the match; it does specifically that (makes .
match \n).  So

   /.*/s

will match zero or more any-chars in a row, including newlines.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 17 Jul 1998 22:38:47 GMT
From: troy@whadda.com (Troy Denkinger)
Subject: Re: open (IN, "foo.txt") works, open (IN, "$foo") does not???
Message-Id: <6oojpe$5r$1@hirame.wwa.com>

In article <6ommop$n2d$1@penthesilea.Materna.DE>, Juergen.Puenter@materna.de (J|rgen P|nter) wrote:
>-  $file2 = "complete_path_to.";        #no \n, \t, whitespace... in here
>   $file3 = "file.001";                 #no \n, \t, whitespace... in here
>   $file4 = #choose your method to put together $file2 and $file3#
>   open (FHIN, "$file4") || die "...";
>   $foo = <FHIN>;

This works for me.

#!/perl/bin -w

$file2 = "test.";       
$file3 = "txt";        
$file4 = $file2.$file3;         #works fine, as expected
#$file4 = "$file2$file3";       #works file, as expected

open (FHIN, "c:\\$file4") || die "$!";
$foo = <FHIN>;
print $foo;

Running Win32 5.00402.

Regards,

Troy Denkinger


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

Date: Fri, 17 Jul 1998 21:54:15 GMT
From: marc_mims@my-dejanews.com
To: jan.dubois@ibm.net
Subject: Re: Passing null BSTR pointer with Win32::OLE
Message-Id: <6ooh67$4md$1@nnrp1.dejanews.com>

[courtesy copy sent via e-mail]

In article <35b178f1.3681764@news2.ibm.net>,
  jan.dubois@ibm.net (Jan Dubois) wrote:
> There is no way (that I know of) with the Win32::OLE module to produce a
> VT_BSTR VARIANT containing a NULL pointer. I'm not even sure if that
> would be valid (for the IDispatch interface). Did you trying passing a
> VT_NULL or VT_EMPTY variant to the function (using Win32::OLE::Variant)?
>
> If this all fails, could you send me a (short) example of what you are
> trying to do and/or a pointer to the VSS documentation (I don't use it
> myself, but probably have it somewhere in the Visual Studio stuff).

Jan,

You can find the VisualSourceSafe OLE Automation documentation at:
<http://www.microsoft.com/ssafe/techmat/oleauto.htm>

Here's some perl source that demonstrates the problem:

use Win32::OLE;
use Win32::OLE::Const 'Microsoft Visual SourceSafe Automation';
use Win32::OLE::Variant;

$Win32::OLE::Warn = 3;

$db = Win32::OLE->new('SourceSafe');
$db->Open("\\\\minneola\\data\\sourcesafe\\srcsafe.ini");


$source_item = '$/foo/bar/pickle.src';

$item = $db->VSSItem($source_item);

$var = Variant(VT_BSTR | VT_BYREF, undef);
$item->Get($var);
# $var is 'c:\tmp\sst8.tmp' on return (or a similar temporary name)
# equivalent to C++:
#   BSTR var = "";
#   item->Get(&var);

$var = Variant(VT_BSTR | VT_BYREF, 'c:\dev\perl\src.fil');
$item->Get($var);
# $var is 'c:\dev\perl\src.fil' as advertised

$item->Get('c:\dev\perl\src1.fil');
# works exactly the same as the previous example

$item->Get;
# generates the message: Signal SEGV: Invalid argument
# as does $item->Get(undef);

$item->Get(0);
# generates an "Invalid DOS Path" error

__END__

What I need is the equivalent to the C++ code:
   BSTR var = NULL;
   item->Get(&var);

which would get a local copy to the location specified in the SourceSafe
database -- not a temorary, and not a caller specified location.  This has the
added benefit of creating the entire path for the local copy if it does not
exist, otherwise, the following would be a suitable workaround:

$local = $item->LocalSpec;
$item->Get($local_spec);

If the path doesn't already exist, however, this results in an error (Invalid
DOS Path, if I'm not mistaken).

    -Marc


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


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

Date: Fri, 17 Jul 1998 19:28:54 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl Beautifier Home Page
Message-Id: <1dcbrl6.1nvk5lmi8evshN@bay1-252.quincy.ziplink.net>

Abigail <abigail@fnx.com> wrote:

> ++ Maybe more than 80 chars are also needed when you have variables
> ++ called enormousStudlyCappedName1?
>           1234567890123456789012345
>                    1         2
> 
> Nope. 25 << 80.

I suppose if the script consisted solely of variable names on on lines
by themselves, then Abigail would be right.

Most code involves using variables within more complicated expressions,
however.  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 17 Jul 1998 16:16:42 -0700
From: Todd Hansen <gaheris@best.com>
Subject: perl question on split
Message-Id: <35AFDB59.139F7912@best.com>

I'm receiving some odd rsults on the following piece of code:

if (length($responses[12]) > 0) {
        print STDERR ("checking version...length > 0\n");
        if ($responses[12] =~ /./) {
                print STDERR ("version is . delimited contents =
$responses[12]\n");
                ($version, $junkit) = split(/./, $responses[12], 2);
                print STDERR ("version = $version\n");
                }
        else {
                print STDERR ("version is NOT delimited contents =
$responses[12]\n");
                $version = $responses[12];
                print STDERR ("version = $version\n");
                }
        }
else {
        $version = "0";
        }


The results I'm receiving on this code snippet is as follows:

checking version...length > 0
version is . delimited contents = 11.00
version =
junkit = 1.0

or, alternatively

checking version...length > 0
version is . delimited contents = 2.0
version =
junkit = .0


The results I am looking for should have $version = 11 and $junkit 00 or
$version = 2 and $junkit = 0
As near as I can tell, the problem seems to be with the split(/./,
$responses[12]) part of the statement, specifically, the delimiter.
Does anyone know if using the period as a delimiter is not allowd in
this operation, or identify what else may be wrong with this code?

Anyhelp will be appreciated.

Thanks

Todd C. Hansen
gaheris@best.com

*******************************************************************************

Foster's: It's Australian for Coors!
*******************************************************************************





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

Date: Fri, 17 Jul 1998 19:28:55 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Please Help Me! (Matt's Script BB Problem)
Message-Id: <1dcbrs5.1wyay50o3pz6uN@bay1-252.quincy.ziplink.net>

Steve Linberg <linberg@literacy.upenn.edu> wrote:

> I thought I read somewhere that he was going to update wwwboard to version
> 3.

What, version 3 of Perl?

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 17 Jul 1998 15:15:58 -0700
From: David Hemmer <mastered@paclink.com>
To: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Premature End of Script Header problem
Message-Id: <35AFCD1D.C0CCB56A@paclink.com>



Alan J. Flavell wrote:

> Well, you've missed:
>
> [X] The fault symptoms you've reported here are pretty much the same as
> every other newbie CGI fault report, i.e they do little more than prove
> that you have a problem, but don't contain even one detail that would
> help.  WHAT'S THE SERVER'S ERROR LOG SAY, damnit?
>
> [X] This appears to be a CGI question, not a perl language question,
> so it probably belongs on the CGI group.
>

Here's that exact error message for those actually interested in helping:

[Fri Jul 17 04:25:28 1998] access to
/home/mastered/public_html/cgi-bin/status.cgi failed for p12pm3.paclink.com,
reason: Premature end of script headers
exec of /home/mastered/public_html/cgi-bin/status.cgi failed, reason: Exec
format error (errno = 8)

Im still researching on my own to find the problem but will still entertain
suggestions on how to fix this problem.BTW I can appreciate you taking the
time out of your day to trash the question of someone who is trying to learn
something new on their own(you know who Im talking to -- if this doesn't
pertain to you you can skip the rest of this post).  I also can appreciate the
fact that I maybe left something out and it migt rub you the right way.  But
why are so many contributors of this newsgroup so testy when it comes to
newbies and their questions?  Where the hell do you get off being this way
with someone who is trying to get a hint about what he might be doing wrong
with something he/she is new at?

Every resource I have found suggests this newsgroup as a forum for "getting
ideas and solving problems" while working with the perl language.  No I don't
have the address of every RTFM.doc or PERL FAQ and what I have read so far
either didn't make sense or didn't have what I thought needed to solve this
problem.

AND PLEASE REMEMBER THIS NEXT TIME YOU ANSWER A NEWBIE QUESTION!!!!! Not all
of us were programming gods/godesses when we left the womb -- and I doubt you
were too.  Try to remember you were a newbie once too and probably had
similarly simple or obvious answered questions when you started out -- DON"T
BE A DICK!

Dave Hemmer
'rainman'
mastered@paclink.com




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

Date: Fri, 17 Jul 1998 19:28:58 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Print LoL-tree routine (attached)
Message-Id: <1dcbrwr.1uzv4go1xdtcrzN@bay1-252.quincy.ziplink.net>

Paul <swoboda@uvic.ca> wrote:

> This is a multi-part message in MIME format.
> --------------EEDBCACFE718426561C264E7
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

Darnit, I asked you to cut that out!  Grrr!!

P.S.  :-)

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 17 Jul 1998 19:28:56 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Print LoL-tree routine (attached)
Message-Id: <1dcbruw.asto9x1tbf5fzN@bay1-252.quincy.ziplink.net>

Paul <swoboda@uvic.ca> wrote:

> This is a multi-part message in MIME format.
> --------------E63EC5F334085C5BE9523E02
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

Please don't post multi-part messages..  Just include your script in the
body of the message.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 17 Jul 1998 19:28:57 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Print LoL-tree routine (attached)
Message-Id: <1dcbrvt.1p0al8673wi3qN@bay1-252.quincy.ziplink.net>

Paul <swoboda@uvic.ca> wrote:

> This is a multi-part message in MIME format.
> --------------A66FCACF72CC1AAE64AB08DD
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit

As I said before, please don't do that.  Thanks!

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 17 Jul 1998 23:18:16 +0000
From: Douglas Seay <seay@hol.fr>
Subject: prototypes and 'Bizarre copy of ARRAY'
Message-Id: <35AFDBB8.4F7D17B4@hol.fr>

I have a subroutine

	sub	dummy($\%@)
	{
	my ($scalar, $hashref, @list) = @_;
	...
	}

If I call this

	dummy $my_scalar, %my_hash, @my_list;

I get a 'Bizarre copy of ARRAY in aassign at ./t line 9 (#2)' error, but
when I call the same thing as

	dummy $my_scalar, %my_hash, (@my_list);

it works well.  "perldiag" says that this is an internal error and I
should never see it, but I could trap it if I care to do so.  I'd rather
not use eval {} for this and I find the extra set of parens to be ugly
and misleading.  Is there something here that I'm overlooking?  If so, a
kindly prod to the right direction would be appreciated.  

- doug

PS - Please CC me on any replies.  I can only check news on weekends and
I'd rather not wait a week if I could avoid it.


==={ version }===

~/News> perl -v

This is perl, version 5.004_04 built for i386-linux

Copyright 1987-1997, Larry Wall

Perl may be copied only under the terms of either the Artistic License
or the
GNU General Public License, which may be found in the Perl 5.0 source
kit.

==={ sample code }===

#!/usr/bin/perl -w

use     strict;
use     diagnostics;

sub     dummy($\%@)
{
print "dummy args:", @_, "\n";
my ($scalar, $hashref, @list) = @_;
print "scalar($scalar) hashref($hashref) list:", @list, "\n";
}


$, = " ";

my $scalar = "scalar";
my %hash = ( alpha => 'A', beta => 'B' );
my @list = qw(one two three);

print "list:", @list, "\n";

print "ONE\n";
dummy $scalar, %hash, "ugly", (@list);

print "TWO\n";
dummy $scalar, %hash, "uglier", @list ;


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

Date: Fri, 17 Jul 1998 19:29:00 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: regexp help?
Message-Id: <1dcbs27.2yq45md0avaoN@bay1-252.quincy.ziplink.net>

Yong Huang <yong@shell.com> wrote:

> This is very interesting. My script below manually deals with the commas in
> quotes. They're changed to triple commas as an example.
> 
> #!perl -w
> #I use Perl for Win95. So there's no path after #!. But I want the -w switch.
> 
> open(IN, "file.txt");
> 
> while (<IN>)
>  { #s/\G(".+?),(.+?")/$1,,,$2/g;    #Hope somebody can make this work.
>                                     #I can't.

That's because, by your use of /g and \G, you're requiring each match to
begin where the previous one left off, with one quoted block followed
immediately by the next.  It seems unlikely that your input looks like
this: '"foo,bar""foo,bar""foo,bar"'

Try this instead:
s/\G([^"]*"[^"]*),([^"]*")/$1,,,$2/gx;

> 
>    $lngth = @tmp = split /"/;
> 
>    for ($i=0; $i<$lngth; $i++)
>     { if ($i%2!=0)    #find the string in quotes;
>                       #they're after odd number of " 's
>        { $tmp[$i] =~ s/,/,,,/g;
>        }
>     }
> 
>    print join("",@tmp);
>  }
> 
> close IN;

An alternative way of writing this:

while (<IN>) {

  @tmp = split /"/;

  foreach (@tmp) {
    next if $i ^= 1;
    s/,/,,,/g;
  }

  print join '"', @tmp;
}


None of these solutions deal with backslashed quotes, of course.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 17 Jul 1998 16:25:54 -0700
From: josh@netoutfit.com (Josh Blackwell)
Subject: shmwrite() and shmread() question
Message-Id: <josh-ya02408000R1707981625540001@news.keyway.net>


Was I wrong in thinking shmwrite() and shmread() would return the same
refrence to the object it stores? I am trying to share an open file handle
between to processess and the refrence keeps changing. 

Process 1 shmwrite() set: value=2  reference=SCALAR(0x1eada0) 

Process 1 shmread() got: value=2  reference=SCALAR(0x1a7ad8) 
Process 2 shmread() got: value=2  reference=SCALAR(0xb46d8)

Is this supposed to happen?

-Josh Blackwell <josh@netoutfit.com>


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

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

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