[16117] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3529 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 1 00:10:25 2000

Date: Fri, 30 Jun 2000 21:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <962424614-v9-i3529@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 30 Jun 2000     Volume: 9 Number: 3529

Today's topics:
    Re: Read multiple lines as one (Tad McClellan)
    Re: Read multiple lines as one <makarand_kulkarni@My-Deja.com>
        Spliting things <psychoNOpsSPAM@pcpatches.com.invalid>
    Re: Spliting things <makarand_kulkarni@My-Deja.com>
    Re: Still stuck: "converting rel. HTML paths into abs.  (Randal L. Schwartz)
        symbolic links and $PWD jrigler@Colorado.EDU
    Re: threaded perl for windoze? (jason)
        Typo in Andrew Johnsons book? or Newbie-itis? (Gurujiwan)
    Re: Typo in Andrew Johnsons book? or Newbie-itis? <uri@sysarch.com>
    Re: Typo in Andrew Johnsons book? or Newbie-itis? <bwalton@rochester.rr.com>
        Vector library mnanao@my-deja.com
        web script not executing on NT Server [was: help!!] (jason)
    Re: What is $foo&? <dan@tuatha.sidhe.org>
    Re: What is $foo&? <johnny@johnnyamos.com>
    Re: What is $foo&? (Tad McClellan)
    Re: What is $foo&? <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 30 Jun 2000 17:21:18 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Read multiple lines as one
Message-Id: <slrn8lq3qe.72b.tadmc@magna.metronet.com>

On Fri, 30 Jun 2000 17:43:28 -0400, Gary Pitman <gpitman@nb.net> wrote:

>In a file that contains
>    <VirtualHost xxx.xxx.xxx.xxx:80>
>        ServerName www.foo.com
>        DocumentRoot /home/a/abc/www
>    </VirtualHost>
>i need to extract only the domain name and the username from the path
>("abc" in above example)
>I can get it to work when all the info is on one line but I am having
>trouble remembering or finding how to treat multiple lines as one.
>I am sure the tags will make this simple if i could just remember how to
>do it.


You do not need to "treat multiple lines as one".

You do not need to do anything "special" to pattern
match against a string that happens to contain \n's.

Below, the same code extracts the name from a single
"line", as well as from multiple "lines":

-----------------
#!/usr/bin/perl -w
use strict;

$_ = 'ServerName www.foo.com';
print "ServerName '$1'\n" if /ServerName\s+(\S+)/;

$_ = '<VirtualHost xxx.xxx.xxx.xxx:80>
        ServerName www.foo.com
        DocumentRoot /home/a/abc/www
      </VirtualHost>';
print "ServerName '$1'\n" if /ServerName\s+(\S+)/;
-----------------



Now _getting_ multiple lines to match against may be what
you are having trouble with.

Is that your problem?

Have you read about the $/ variable?

   perldoc perlvar

Maybe

   local $/ = "</VirtualHost>\n";

will help...


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


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

Date: Fri, 30 Jun 2000 15:27:01 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Read multiple lines as one
Message-Id: <395D1EB5.53FC0804@My-Deja.com>

> I can get it to work when all the info is on one line but I am having
> trouble remembering or finding how to treat multiple lines as one.
> I am sure the tags will make this simple if i could just remember how 
undef $/ ( the record separator ).
after you extract the domain and the user name reset $/
--


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

Date: Fri, 30 Jun 2000 17:12:14 -0700
From: psycho <psychoNOpsSPAM@pcpatches.com.invalid>
Subject: Spliting things
Message-Id: <03ac8724.1ef4cdfc@usw-ex0102-016.remarq.com>

ok, I have a ladder script that im running and i want to split
the ranked members by so many so that i can place ads in the
gaps. How would i do this?

1 to 25
<ad>
26-50
<ad>

and so on..

thanks,
 psycho


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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Fri, 30 Jun 2000 18:36:54 -0700
From: Makarand Kulkarni <makarand_kulkarni@My-Deja.com>
Subject: Re: Spliting things
Message-Id: <395D4B36.59062F20@My-Deja.com>

> ok, I have a ladder script that im running and i want to split
what is a ladder script ?


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

Date: 30 Jun 2000 16:04:59 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Still stuck: "converting rel. HTML paths into abs. paths
Message-Id: <m18zvmhisk.fsf@halfdome.holdit.com>

>>>>> "Jan" == Jan Bessels <j.bessels@quicknet.nl> writes:

Jan> I do absolutely believe you. The comp.lang.perl group seems
Jan> however to be quite lively. In the period 4-june-2000 till now
Jan> 637 were posted. Just stating the facts. Have a feeling that the
Jan> admins will not quite believe me when I tell them that
Jan> comp.lang.perl doesn't exist anymore. I believe that even the
Jan> company I work for (large ISP, www.planet.nl) carries
Jan> comp.lang.perl.

So let me "just state the facts".  It's been on the news.admin-posted
"dead group" list for roughly 5 years.  The closest we have to Usenet
overseers have said "it doesn't exist".

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Sat, 01 Jul 2000 01:19:17 GMT
From: jrigler@Colorado.EDU
Subject: symbolic links and $PWD
Message-Id: <8jjgub$6mu$1@nnrp1.deja.com>

Does anyone know a good trick for fooling PERL into inheritting the $PWD
from the shell that starts it (i.e. you know how bash and tcsh will show
the $PWD as the path a user cd'd to, rather than the true path if they
followed a symlink)?  I have a relatively simple script that I want to
run from a directory where I've installed some package...

  /usr/local/package/package-ver.X

In that directory, I have /bin, /lib, /etc, etc. directories.  The
script is designed to create a symbolic link to the appropriate
/usr/local directories.

The problem is that my "/usr/local" is actually a symbolic link to a
shared partition on my file server.

 /usr/local  -->  /misc/usrlocal/local.solaris

 ...where...

 /misc/usrlocal/local.solaris (nfsmount)-->
                                        server:/usrlocal/local.solaris


Instead of the links getting set as...


 /usr/local/bin/executable  -->
 /usr/local/package/package-ver.X/bin/executable


 ...I get...


 /usr/local/bin/executable  -->
 /usrlocal/local.solaris/package/package-ver.X/bin/executable


Which ONLY exists if a person is logged into the file server.  This has
got to be a common problem, but I can't figure out a way around it
reading the Programming PERL book by O'Reilly, and I've tried everything
suggested for using "Use Cwd;" and "Use Cwd 'chdir';".

Thanks for any help!

-EJR


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 01 Jul 2000 03:36:42 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: threaded perl for windoze?
Message-Id: <MPG.13c80488cfe7153c989762@news>

Paul Johnston writes ..
>I'm using perl 5.005_03 built by activestate for an NT box, but they do not
>seem to compile thread support.

thank heavens .. the threading support is still in an experimental stage

>Are there any perl binaries for NT that support threads?  If not, is it
>possible to compile it?  I have cygwin b20 installed which of course
>includes gcc.

download the Perl source (also available from ActiveState - though I'm 
not sure whether the 5.005_03 source is still - so you might have to go 
to CPAN) and start reading all the included READMEs

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sat, 01 Jul 2000 02:26:19 GMT
From: Gorbeast@SPAMSUX.subduction.org (Gurujiwan)
Subject: Typo in Andrew Johnsons book? or Newbie-itis?
Message-Id: <fFc75.23649$_b3.528529@newsread1.prod.itd.earthlink.net>

I've been trying to get a snippet of code to work for me and It just wont.
Is it a typo in this otherwise fine book?

From 'Elements Of Programming In Perl', page 149, section 8.1.3:
------------------------------------------------------------------
my %employees = ( { asmith => { name => 'Anne Smith',
                                age => 35
                                children => ['amanda', 'amy'],
                                beer => ['pale ale',  'lager'],

                              }

                );


print "@{$employees{asmith}{children}}\n";

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


I am working on a script, somewhat similar, in that I want the 'Subject:'
and 'To:' line of an email to be elements of a hash. I am basing it on this 
example, so naturally my code doesn't work either.  But it doesn't complain 
about a compilation/syntax error, I get a SMTP error.  It works fine if I 
use a regular '$variable'.  Can elements of a hash be used for to send an 
mail message from a perl script?  I thought it would work barring any human 
error.

 


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

Date: Sat, 01 Jul 2000 02:54:44 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Typo in Andrew Johnsons book? or Newbie-itis?
Message-Id: <x766qqtv9q.fsf@home.sysarch.com>

>>>>> "G" == Gurujiwan  <Gorbeast@SPAMSUX.subduction.org> writes:

  G> I've been trying to get a snippet of code to work for me and It just wont.
  G> Is it a typo in this otherwise fine book?

  G> my %employees = ( { asmith => { name => 'Anne Smith',
                       ^
where did that character come from? it is not in the book.

  G>                                 age => 35
                                              ^
missing comma there as well.

  G>                                 children => ['amanda', 'amy'],
  G>                                 beer => ['pale ale',  'lager'],
  G>                               }
  G>                 );


you should have mentioned it was a syntax error, and not "it just won't work'

learn to be more careful when typing in code from a book. and triple
check things before you attempt to claim it is a bug in a book (though
they are rife in some books).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 01 Jul 2000 02:53:49 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Typo in Andrew Johnsons book? or Newbie-itis?
Message-Id: <395D5D88.54B84F8A@rochester.rr.com>

Gurujiwan wrote:
> 
> I've been trying to get a snippet of code to work for me and It just wont.
> Is it a typo in this otherwise fine book?
> 
> From 'Elements Of Programming In Perl', page 149, section 8.1.3:
> ------------------------------------------------------------------
> my %employees = ( { asmith => { name => 'Anne Smith',
>                                 age => 35
>                                 children => ['amanda', 'amy'],
>                                 beer => ['pale ale',  'lager'],
> 
>                               }
> 
>                 );
> 
> print "@{$employees{asmith}{children}}\n";

Well, I don't know about the book (I don't have a copy), but you've got
at least two in the above:  The second { is unmatched and should be
removed, and the comma after 35 is missing.  Did you try to compile it? 
With those fixes, it seems to give the results I would expect.

> 
> -------------------------------------------------------------------
> 
> I am working on a script, somewhat similar, in that I want the 'Subject:'
> and 'To:' line of an email to be elements of a hash. I am basing it on this
> example, so naturally my code doesn't work either.  But it doesn't complain
> about a compilation/syntax error, I get a SMTP error.  It works fine if I
> use a regular '$variable'.  Can elements of a hash be used for to send an
> mail message from a perl script?  I thought it would work barring any human
> error.

Well, maybe someone could help you if you told us *which* error --
*exactly* what it says.  It sounds like maybe you are running this as a
CGI script.  Depending on whether or not you are using the CGI module
(you are, I hope), you should be able to set it so errors in your script
will should up on your browser.  Check out the docs of CGI for text like
"fatals_to_browser".

You should be able to use any valid Perl expression in a perl CGI
script.  But not if it won't compile.  Try to run your script offline
first, just to see if it compiles.  If it doesn't, fix it and try again.
-- 
Bob Walton


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

Date: Sat, 01 Jul 2000 02:42:47 GMT
From: mnanao@my-deja.com
Subject: Vector library
Message-Id: <8jjlr4$a2m$1@nnrp1.deja.com>

Does anyone know of a simple library that allows you to manipulate
vectors in perl?  I need vector addition and subtraction in particular.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sat, 01 Jul 2000 03:32:51 GMT
From: elephant@squirrelgroup.com (jason)
Subject: web script not executing on NT Server [was: help!!]
Message-Id: <MPG.13c803a018050f25989761@news>

wckf writes ..
>Ok.. i have a problem running Perl on an NT server.
>i'm using a form script.. and whenever i try to submit the form,
>it always asks me if i want to download the script first.  why is
>it doing that and how can i fix it?
>
>also.. when the form is viewed from any other machine, after the
>submit butten is hit my perl script pops up in a text editor.
>now usually this happens if the first line of the script isn't pointing
>to where perl is located, but it is; "C:\perl".
>any suggestions on either of these two issues is appreciated!

please post more relevant subject lines in future - it dramatically 
increases the likelihood of you receiving useful information

type the following at the command line

  perldoc -q "web programming"

and read the information referred to there

essentially you have not set up whatever web server you're using 
correctly to run these Perl scripts by correctly mapping the filename 
extension that you're using to the Perl interpreter that you have 
installed

more recent versions of ActiveState's Perl do all that for you during 
the installation process .. if you're running an old version of Perl 
then you might want to consider upgrading

  http://www.activestate.com/ActivePerl/

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Fri, 30 Jun 2000 22:17:11 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: What is $foo&?
Message-Id: <H%875.1409$cu1.4926@news1.rdc1.ct.home.com>

Johnny Amos <johnny@johnnyamos.com> wrote:
> I wrote:
>> I've gone through the faqs (specifically perlfaq4, perlfaq7 and the perl
>> cgi faq) but I didn't find an answer.

> I also have Learning Perl, Programming Perl, and the Perl Cookbook, but
> I didn't find anything there either. Am I looking in the wrong place?

You're thinking too hard.

  $foo = "12";
  $bar = "$foo&";

just gives $bar a value of "12&".

					Dan


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

Date: Fri, 30 Jun 2000 22:26:01 GMT
From: Johnny Amos <johnny@johnnyamos.com>
Subject: Re: What is $foo&?
Message-Id: <395D20A8.5F4DB896@johnnyamos.com>

Dan Sugalski wrote:
> You're thinking too hard.
> 
>   $foo = "12";
>   $bar = "$foo&";
> 
> just gives $bar a value of "12&".

oh, duh!

Thanks Dan.

Johnny


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

Date: Fri, 30 Jun 2000 17:28:40 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What is $foo&?
Message-Id: <slrn8lq488.72b.tadmc@magna.metronet.com>

On Fri, 30 Jun 2000 20:50:12 GMT, Johnny Amos <johnny@johnnyamos.com> wrote:

>What does $foo& mean? Here is some context:
>
>$foo = "some string";
>$bar = "$foo&;"


$foo is a variable whose value will be interpolated.

& is a character in the string.

$bar should have a value of "some string&".

What "some string&" "means" depends on what it is used for
(it is application dependent, and we don't know what your
application is).

From Perl's point of view, "some string&" is just a
string with 12 characters in it.


>I've gone through the faqs (specifically perlfaq4, perlfaq7 and the perl
>cgi faq) but I didn't find an answer.


Probably because they are just data.

You seem to be confused on what is "code" and what is "data".

You'll never get anywhere unless you can sort that out...


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


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

Date: Fri, 30 Jun 2000 23:02:39 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: What is $foo&?
Message-Id: <395D2757.E3619150@rochester.rr.com>

Johnny Amos wrote:
> 
> What does $foo& mean? Here is some context:
> 
> $foo = "some string";
> $bar = "$foo&;"
> 
> I've gone through the faqs (specifically perlfaq4, perlfaq7 and the perl
> cgi faq) but I didn't find an answer.
 ...
> Johnny
Try 

   perldoc perlop

, specifically the section on "quote and quote-like operators".  There
you will find that variables in strings quoted with " quotes are
"interpolated" or substituted in in place of the variable name, so $bar
will receive the value 
   
   some string&;

in your example.
-- 
Bob Walton


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 3529
**************************************


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