[11283] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4883 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 12 16:07:27 1999

Date: Fri, 12 Feb 99 13:01:34 -0800
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, 12 Feb 1999     Volume: 8 Number: 4883

Today's topics:
    Re: Split string <jglascoe@giss.nasa.gov>
    Re: Split string <houghje@itd.ssb.com>
    Re: Split string jjds@para-protect.com
        String Terminator <gala@sonic.net>
    Re: String Terminator <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: String Terminator <ebohlman@netcom.com>
    Re: syntax error I can't find? (Abigail)
    Re: Trouble 'make'ing CPAN Modules! (Question) <david@inxpress.net>
    Re: unique hashnames (Larry Rosler)
    Re: unique hashnames droby@copyright.com
    Re: unique hashnames <ebohlman@netcom.com>
    Re: Win32 perl how to do system(set var= $var) <ebohlman@netcom.com>
    Re: x-perl what's that? <david@inxpress.net>
    Re: x-perl what's that? <jglascoe@giss.nasa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 12 Feb 1999 13:55:38 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Professeur Alfred <ughridk@hotmail.com>
Subject: Re: Split string
Message-Id: <36C4792A.731FC44A@giss.nasa.gov>

[courtesy cc of this posting sent to cited author: Alfred]

Professeur Alfred wrote:
> 
> I'm a novice in Perl programming. I would to know how to split a string on
> the '?' character.
> I tried to do it this statement but it doesn't work:
> ($address,$search) = split (/?/, $variable);

careful!  The question-mark character, "?", is a meta-character in
regular expressions...

try this:
($address,$search) = split /\?/, $variable;

> I think the problem is that Perl interprets the '?' as a wild card and not
> as a character.

right.  So, you backslashify it to signal perl that it's a literal character.

--
	"Djikstra's complaint about goto is that it leads to
	 spaghetti code. Of course, with a little work,
	 spaghetti code can be followed. Spaghetti data on the
	 other hand, requires a much larger amount of work
	 to follow. Spaghetti objects are clearly the highest
	 form so far devised."

	-- Hans Spiller
	   "How to Write Bad Code"
	   http://www.exmsft.com/~hanss/badcode.htm


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

Date: Fri, 12 Feb 1999 14:25:16 -0500
From: Jack Houghton <houghje@itd.ssb.com>
Subject: Re: Split string
Message-Id: <36C4801B.4EAC3777@itd.ssb.com>


--------------A299A96795C9AC7B6B747184
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The ? is a special character which needs to be escaped when you don't want to
use it as a special character. try the following:

( $address, $Search ) = split( /\?/, $Variable );

This should work!

-Jack Houghton-

Professeur Alfred wrote:

> I'm a novice in Perl programming. I would to know how to split a string on
> the '?' character.
> I tried to do it this statement but it doesn't work:
> ($address,$search) = split (/?/, $variable);
>
> the $variable is an URL like: http://domain_name.com/home.htm?vara=x&varb=y
>
> I think the problem is that Perl interprets the '?' as a wild card and not
> as a character.
>
> Thanks for your help!
>
> If you want to answer me by e-mail, retrieve the "bbb" from my address.
> ughridk@bbbhotmail.com



--------------A299A96795C9AC7B6B747184
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
The ? is a special character which needs to be escaped when you don't want
to use it as a special character. try the following:

<P>( $address, $Search ) = split( /\?/, $Variable );

<P>This should work!

<P>-Jack Houghton-

<P>Professeur Alfred wrote:
<BLOCKQUOTE TYPE=CITE>I'm a novice in Perl programming. I would to know
how to split a string on
<BR>the '?' character.
<BR>I tried to do it this statement but it doesn't work:
<BR>($address,$search) = split (/?/, $variable);

<P>the $variable is an URL like: <A HREF="http://domain_name.com/home.htm?vara=x&varb=y">http://domain_name.com/home.htm?vara=x&amp;varb=y</A>

<P>I think the problem is that Perl interprets the '?' as a wild card and
not
<BR>as a character.

<P>Thanks for your help!

<P>If you want to answer me by e-mail, retrieve the "bbb" from my address.
<BR>ughridk@bbbhotmail.com</BLOCKQUOTE>
&nbsp;</HTML>

--------------A299A96795C9AC7B6B747184--



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

Date: Fri, 12 Feb 1999 20:09:43 GMT
From: jjds@para-protect.com
Subject: Re: Split string
Message-Id: <7a21pv$omv$1@nnrp1.dejanews.com>

You are correct the ? is interpreted as a wildcard. You want to split on the
literal value and since ? is a special character you need to put a \ in front
of it.

Instead of
($address,$search) = split (/?/, $variable);

Try
($address,$search) = split (/\?/, $variable);

Good luck,

Jeremiah Sahlberg
Computer Security Engineer
Para-Protect Services, Inc.
jjds@para-protect.com
http://www.para-protect.com



In article <t5_w2.1399$J5.1007@weber.videotron.net>,
  "Professeur Alfred" <ughridk@bbbhotmail.com> wrote:
> I'm a novice in Perl programming. I would to know how to split a string on
> the '?' character.
> I tried to do it this statement but it doesn't work:
> ($address,$search) = split (/?/, $variable);
>
> the $variable is an URL like: http://domain_name.com/home.htm?vara=x&varb=y
>
> I think the problem is that Perl interprets the '?' as a wild card and not
> as a character.
>
> Thanks for your help!
>
> If you want to answer me by e-mail, retrieve the "bbb" from my address.
> ughridk@bbbhotmail.com
>
>

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 12 Feb 1999 11:08:58 -0800
From: "Gala Grant" <gala@sonic.net>
Subject: String Terminator
Message-Id: <7a1u5l$k1m$1@ultra.sonic.net>

I have a script with this in it:

print <<"_END_";
</BODY>
</HTML>
_END_

when I compile the program it says that the string terminator _END_ couldn't
be found before the end of the program.  Obviously it is there, so I figure
it is some other problem with the script.  I seem to remember seeing
something like this once before.  Does anyone have any idea what I am doing
wrong?
Thanks,
Gala Grant




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

Date: 12 Feb 1999 20:39:11 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: String Terminator
Message-Id: <83aeyjqun4.fsf@vcpc.univie.ac.at>

Re: String Terminator, Gala <gala@sonic.net> said:

Gala> I have a script with this in it: print
Gala> <<"_END_"; </BODY> </HTML> _END_

Gala> when I compile the program it says that the
Gala> string terminator _END_ couldn't be found

try it as

    print <<_EOT_;
    ...
    _EOT_


Of course, instead you could always use the HTML
shortcuts in CGI.pm and then not have to worry about
such things:

    print header;
    print start_html("Title");
    print h1("Hello");
    print end_html;

  (perldoc CGI)

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Fri, 12 Feb 1999 19:49:36 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: String Terminator
Message-Id: <ebohlmanF724Eo.8DA@netcom.com>

Gala Grant <gala@sonic.net> wrote:
: I have a script with this in it:

: print <<"_END_";
: </BODY>
: </HTML>
: _END_

: when I compile the program it says that the string terminator _END_ couldn't
: be found before the end of the program.  Obviously it is there, so I figure
: it is some other problem with the script.  I seem to remember seeing
: something like this once before.  Does anyone have any idea what I am doing
: wrong?

You've probably got an extraneous but invisible character on the "_END_" 
line.  One common cause of this is composing a script on a machine that
uses "\r\n" as a line terminator (such as Win32), FTPing the script to a 
machine that uses "\n" as a line terminator (such as Unix), and 
forgetting to set the FTP transfer to "ASCII" mode in order to force line 
terminators to be converted.  The result is that perl on the target 
system sees "_END_\r" instead of just "_END_" and gets confused.




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

Date: Fri, 12 Feb 1999 19:59:30 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: syntax error I can't find?
Message-Id: <CK%w2.2765$rs2.2630404@client.news.psi.net>

John G (cybpunk@geocities.com) wrote on MCMXC September MCMXCIII in
<URL:news:36c346a3.14194921@news.ma.ultranet.com>:
__ I get a syntax error on line 26 near "else if".


Perl ain't C. Curlies are mandatory.




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


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

Date: Fri, 12 Feb 1999 13:01:13 -0600
From: "David M. Lloyd" <david@inxpress.net>
Subject: Re: Trouble 'make'ing CPAN Modules! (Question)
Message-Id: <36C47A79.F3427AC9@inxpress.net>

> Hmmm.  First, did you do "the usual thing" for building Perl modules,
> namely
> 
>   perl Makefile.PL
>   make
>   make test
>   make install

Just out of curiosity, can I just do a copy into my
'/usr/local/lib/perl5' directory after this stuff is installed,
or do I have to reinstall the whole thing?

===========================================================
David M. Lloyd                  mailto:david@inxpress.net

Administrator
Internet Express, Inc.
802 W. Broadway, Suite 0101
Madison, WI. 53713-1866
Voice: (608) 663-5555           http://www.inxpress.net
Fax: (608) 663-1818             mailto:admin@inxpress.net
Data: (608) 663-5551            mailto:support@inxpress.net

===========================================================


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

Date: Fri, 12 Feb 1999 11:09:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: unique hashnames
Message-Id: <MPG.112e1c59c92f5901989a2b@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <36C47D42.100@ic.delcoelect.com> on Fri, 12 Feb 1999 11:13:06 
-0800, Micah G. Cook <mgcook@ic.delcoelect.com> says...
> I was trying to dynamically create hashes:
> 
> $name is going to change each time thru the loop.
> 
> $$name{'status'} = "active" ;
> 
> #this is my problem,
> essentially i created a hash of arrays, but i wanted
> to create several hashes with different names
> one for each name.

Don't do it that way!  'Symbolic references' should be avoided if at all 
possible.

Use a single top-level hash, with $name as the key to a second-level 
hash:

  $hash{$name}{status} = 'active';

This is clean and passes 'use strict;'.  You'll never go back to 
symbolic references again.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 12 Feb 1999 20:06:52 GMT
From: droby@copyright.com
Subject: Re: unique hashnames
Message-Id: <7a21kk$olb$1@nnrp1.dejanews.com>

In article <36C3762C.2D84@ic.delcoelect.com>,
  "Micah G. Cook" <mgcook@ic.delcoelect.com> wrote:
> I am reading in hostnames, each on separate lines in a file.
>
> how do i create a hash with the name of the hostname?
>

You're trying to use the value of one variable as the name of another, which
is actually quite easy to do in Perl, but generally inadvisable.

You really should be building a "hash of hashes" with hostname as one index
instead of building a separate hash for each hostname with the hostname as
variable name.	Study the perlref and perllol manpages to learn how to deal
with these.

And please read Mark-Jason Dominus' excellent note on this topic at
http://www.plover.com/~mjd/perl/varvarname.html to learn why at's a bad idea.

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 12 Feb 1999 19:32:36 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: unique hashnames
Message-Id: <ebohlmanF723MC.7uF@netcom.com>

Micah G. Cook <mgcook@ic.delcoelect.com> wrote:
: I was trying to dynamically create hashes:

: $name is going to change each time thru the loop.

: $$name{'status'} = "active" ;

: #this is my problem,
: essentially i created a hash of arrays, but i wanted
: to create several hashes with different names
: one for each name.

That's what you *want* to do, but what you *need* to do is use a hash 
of hashes so you can say something like $hash{$name}{'status'}='active'.  
Take a look at perllol and perldsc; if you don't understand them, look at 
perldata and perlref first.



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

Date: Fri, 12 Feb 1999 19:27:20 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Win32 perl how to do system(set var= $var)
Message-Id: <ebohlmanF723DK.7Mx@netcom.com>

sirron@mail.mcoe.k12.ca.us wrote:
: I don't know. What I would like to be able to do is set this environment
: variable so that the next perl script in a batch job can use it as input.

As others have pointed out, you can't do this directly.  What you *can* 
do is set an environmental variable ($ENV{name}=value) and then call the 
next script *as a child process of yours* using system() or piped input.  
You can pass environmental changes to your children, but not to your 
siblings.



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

Date: Fri, 12 Feb 1999 13:19:03 -0600
From: "David M. Lloyd" <david@inxpress.net>
Subject: Re: x-perl what's that?
Message-Id: <36C47EA7.8303D88A@inxpress.net>

My guess would be that the script is not set to be 'Executable';
whether NT or UNIX your browser will probably try to download it.

"Steve ." wrote:
> 
> I recently was given a perl program to play with from an outside
> source, and when I pull it up in my browser, Netscape  3 shows it is
> an x-perl app and doesn't know what to do with it.  Any ideas on what
> I need to look for to figure out what to change to avoid this?  If you
> run the program from the command line it just shows:
> 
> Content-type: text/html
> 
> Which is rather normal.  Thanks.
> 
> Steve

-- 
===========================================================
David M. Lloyd                  mailto:david@inxpress.net

Administrator
Internet Express, Inc.
802 W. Broadway, Suite 0101
Madison, WI. 53713-1866
Voice: (608) 663-5555           http://www.inxpress.net
Fax: (608) 663-1818             mailto:admin@inxpress.net
Data: (608) 663-5551            mailto:support@inxpress.net

===========================================================


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

Date: Fri, 12 Feb 1999 14:25:39 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: "Steve ." <syarbrou@nospam.enteract.com>
Subject: Re: x-perl what's that?
Message-Id: <36C48033.CCF7BE84@giss.nasa.gov>

[courtesy cc of this posting sent to cited author: Steve]

"Steve ." wrote:
> 
> I recently was given a perl program to play with from an outside
> source, and when I pull it up in my browser, Netscape  3 shows it is
> an x-perl app and doesn't know what to do with it.  Any ideas on what
> I need to look for to figure out what to change to avoid this?  If you
> run the program from the command line it just shows:

If you click and hold the right mouse button (on the white
square representing the perl program), then you
should see a list of options.  Select "Save link as...".
A new window will pop up.  Select "text" from the pull-down
menu in the new window, and simply click "OK".

-- 
	"I discount everything Djikstra has to say
	because he doesn't actually run his programs"

	--Rob Pike, on Djikstra's belief that bugs in
	  your program are a moral failure to prove your
	  program mathematically correct.


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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