[18586] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 754 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 24 14:10:47 2001

Date: Tue, 24 Apr 2001 11:10:12 -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: <988135811-v10-i754@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 24 Apr 2001     Volume: 10 Number: 754

Today's topics:
    Re: Help with a script <mk@ticklets.com>
    Re: Help with a script <tward10@jaguar.com>
    Re: Help with a script <uri@sysarch.com>
    Re: Issue with 5.004 to 5.6 upgrade - Use strict now au <rick.delaney@home.com>
        Multi-Line Text Editor <Lyle_Goldman@ibi.com>
    Re: Newbie question: reading variables with CGI <errolbrown@hotmail.com>
    Re: Newbie question: reading variables with CGI nobull@mail.com
    Re: Perl Fehler bei Scriptausführung <webmaster@jt-online.de>
        Problem - PERL mail script sends HTML formating as part <yourguru@whkjcssss.com>
    Re: Problem - PERL mail script sends HTML formating as  <dperham@dperham.eng.tvol.net>
    Re: problem understanding stat function output (Tad McClellan)
    Re: Problems with module PlPRC nobull@mail.com
    Re: RegEx optimization assistance <nospam@newsranger.com>
    Re: RegEx optimization assistance <bart.lateur@skynet.be>
    Re: RegEx optimization assistance (Craig Berry)
    Re: regexp matching with optional part <uri@sysarch.com>
    Re: Where is my script (Anno Siegel)
    Re: Where is my script <martin@djernaes.net>
    Re: Where is my script (Craig Berry)
    Re: Windows Perl for Windows 95 -- Internet Explorer 5  (Charles M. Kozierok)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 24 Apr 2001 16:17:12 +0200
From: "Paul Kersey" <mk@ticklets.com>
Subject: Re: Help with a script
Message-Id: <9c4211$8pp$1@news1.xs4all.nl>

a '500' server error means something is wrong with your server
configuration.

Check the error log of your webserver for details.

Possible errors when working on linux/unix server:
- #!/usr/sbin/perl is not the correct path to perl executable
- your script doesn't have execute rights

Anyway: provide more details....
> Below is the code used, but it keeps returning a '500' server error - but
I
> can't see why.  I have uploaded as ASCII.





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

Date: Tue, 24 Apr 2001 16:01:06 +0100
From: "Trevor Ward" <tward10@jaguar.com>
Subject: Re: Help with a script
Message-Id: <9c44fi$hfu13@eccws12.dearborn.ford.com>

Perhaps it may be permissions.

On unix box set to 755. If not seeif there is a ^m on the end of any of the
lines

These are what normally cause a servor error. If the perl syntax is correct.

Matt Ross <m-a-t-t@m-a-t-t-r-o-s-s.co.uk> wrote in message
news:HHeF6.5837$Ln6.814564@news2-win.server.ntlworld.com...
> Hi,
>
> Would anyone be willing to help with a script I've got to maintain a
mailing
> list?
>
> Below is the code used, but it keeps returning a '500' server error - but
I
> can't see why.  I have uploaded as ASCII.
>
> Thanks,
>
> Matt
> matt@mattross.co.uk
>
> Code:
>
> #!/usr/sbin/perl
>
>
> $buffer = <STDIN>;
> if ($buffer eq "") { $buffer = $ENV{'QUERY_STRING'}; }
> @pairs = split(/\&/, $buffer);
> foreach $pair (@pairs) {
>     ($name, $value) = split(/=/, $pair);
>     $value =~ tr/+/ /;
>     $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>     $FORM{$name} = $value;
> }
>
>
>
>
> sub error {
>
> print "Content-type: text/html\n\n";
> print <<EndHTML;
> <HTML>
> <HEAD>
> <TITLE>[ mr:uk ] - Subscribe</TITLE>
> <LINK REL="stylesheet" HREF="http://www.mattross.co.uk/style.css"
> TYPE="text/css">
> </HEAD>
> <BODY>
> <FONT FACE="Tahoma" SIZE=\"3\"><STRONG>Error</STRONG><BR><HR>
> <FONT FACE="Tahoma" SIZE=\"2\">
> <BR>
> Please enter an email address</H2>
> </BODY>
> </HTML>
>
> EndHTML
> ;
>
> exit;
> }
>
> #
> # End additions.
> #
>
> if ($FORM{'action'} eq "add")
> {
> &error unless $FORM{'address'};
>   open (subscriberlist, ">>subscribers.txt");                # Add the new
> address to the bottom of the list
>   print subscriberlist "$FORM{'address'}\n";
>   close (subscriberlist);
>
>   open (subscriberlist, "<subscribers.txt");                 # Read the
> contents
>   read (subscriberlist, $list, 10000);
>   close (subscriberlist);
>
>   open (SENDMAIL, "|/usr/sbin/sendmail -t");                 # E-mail the
> contents to list owner
>   print SENDMAIL "To: webmaster\@mattross.co.uk ([ mr:uk ] Webmaster)\n";
>   print SENDMAIL "From: webmaster\@mattross.co.uk ([ mr:uk ]
Webmaster)\n";
>   print SENDMAIL "Reply-to: webmaster\@mattross.co.uk ([ mr:uk ]
> Webmaster)\n";
>   print SENDMAIL "Subject: New subscription\n\n";
>   print SENDMAIL "New address: $FORM{'address'}\n\n";
>   print SENDMAIL "Complete list:\n";
>   print SENDMAIL "$list";
>   close (SENDMAIL);
>
> #
> # Matt, edit the message in the email body to what you want.
> #
>
>   open (MAIL, "|/usr/sbin/sendmail -t");      # E-mail confirmation.
>   print MAIL "To: $FORM{'address'}\n";
>   print MAIL "From: webmaster\@mattross.co.uk ([ mr:uk ] Webmaster)\n";
>   print MAIL "Reply-to: webmaster\@mattross.co.uk ([ mr:uk ]
Webmaster)\n";
>   print MAIL "Subject: Welcome to the [ mr:uk ] Mailing List\n\n";
>   print MAIL "Hi there,\n\nThis is just a confirmation email.\n\nIf you
> joined this list in error, or someone added your email address without
your
> permission, use the link below to be removed from the list.\n\n";
>   print MAIL
>
"http://www.mattross.co.uk/cgi-bin/subscribe.pl?action=remove&address=$FORM{
> 'address'}\n\n";
>   print MAIL "Thankyou\n\n";
>   close (MAIL);
>
> #
> # End additions
> #
>
> # Show a confirmation page
>
> print "Content-type: text/html\n\n";
> print <<EndHTML;
> <HTML>
> <HEAD>
> <TITLE>[ mr:uk ] - Subscribe!</TITLE>
> <LINK REL="stylesheet" HREF="http://www.mattross.co.uk/style.css"
> TYPE="text/css">
> </HEAD>
> <BODY>
> <FONT FACE="Tahoma" SIZE=\"3\"><STRONG>Thank you</STRONG><BR><HR>
> <FONT FACE="Tahoma" SIZE=\"2\">
> <BR>
> Your e-mail address, $FORM{'address'}, has been added to the [ mr:uk ]
> subscription list.<BR>
> Please check your mailbox to ensure you receive confirmation.<BR>
> <BR>
> <A HREF="javascript:window.close();">Close Window</A>
>
>
> </BODY>
> </HTML>
>
> EndHTML
> ;
>
> exit;
> }
>
> elsif ($FORM{'action'} eq "remove")
> {
>   open (subscriberlist, "<subscribers.txt");                 # Read the
list
> file and close
>   read (subscriberlist, $buffer, 10000);
>   close (subscriberlist);
>   @list_lines = split (/\n/, $buffer);
>
>   open (subscriberlist, ">subscribers.txt");                 # Open list
> file again, for output
>   foreach $line(@list_lines)
>   {
>     if ($line ne $FORM{'address'})                           # Only
re-write
> the line if it's different
>     {                                                        # from the
one
> to be removed
>       print subscriberlist "$line\n";
>     }
>   }
>   close (subscriberlist);
>
> print "Content-type: text/html\n\n";
> print <<EndHTML;
> <HTML>
> <HEAD>
> <TITLE>[ mr:uk ] - Subscribe!</TITLE>
> <LINK REL="stylesheet" HREF="http://www.mattross.co.uk/style.css"
> TYPE="text/css">
> </HEAD>
> <BODY>
> <FONT SIZE=\"3\"><STRONG>Unsubscribe Confirmation</STRONG><BR><HR>
> <FONT SIZE=\"2\">
> <BR>
> Your e-mail address, $FORM{'address'}, has been removed from the
> subscription list.
> <BR><BR>
> </BODY>
> </HTML>
>
> EndHTML
> ;
>
>   open (SENDMAIL, "|/usr/sbin/sendmail -t");
>   print SENDMAIL "To: Webmaster\@mattross.co.uk ([ mr:uk ] Webmaster\n";
>   print SENDMAIL "From: webmaster\@mattross.co.uk ([ mr:uk ]
Webmaster)\n";
>   print SENDMAIL "Reply-to: webmaster\@mattross.co.uk ([ mr:uk ]
> Webmaster)\n";
>   print SENDMAIL "Subject: Subscription Cancellation\n\n";
>   print SENDMAIL "Address: $FORM{'address'}\n\n";
>   print SENDMAIL "Complete list:\n";
>   print SENDMAIL "$buffer";
>   close (SENDMAIL);
>
> exit;
> }
>
> elsif ($FORM{'action'} eq "concrete")
> {
>   open (subscriberlist, "<subscribers.txt");                 # Read the
list
> file and close
>   read (subscriberlist, $buffer, 10000);
>   close (subscriberlist);
>   @subscribers = split (/\n/, $buffer);
>
>   foreach $subscriber (@subscribers)
>   {
>     open (SENDMAIL, "|/usr/sbin/sendmail -t");
>     print SENDMAIL "To: $subscriber\n";
>     print SENDMAIL "From: webmaster\@mattross.co.uk ([ mr:uk ]
> Webmaster)\n";
>     print SENDMAIL "Reply-to: webmaster\@mattross.co.uk ([ mr:uk ]
> Webmaster)\n";
>     print SENDMAIL "Subject: Website Update Notification\n\n";
>
> # Matt, i've added these 3 lines that takes the message from the form and
> does stuff to it :)
> # I borrowed it from a script i use to email myself so it does work
(crosses
> fingers ;)
>
>     $FORM{'message'} =~ s/\cM\n/<br>\n/g;
>     $message = $FORM{'message'};
>     $message =~ s/<br>//g;
>
>     print SENDMAIL "$message\n\n\n";
>     print SENDMAIL "To unsubscribe from [ mr:uk ] updates, use this
URL:\n";
>     print SENDMAIL
>
"http://www.mattross.co.uk/cgi-bin/subscribe.pl?action=remove&address=$subsc
> riber\n\n";
>     print SENDMAIL "If there are any problems with this service then
contact
> the webmaster by replying to this e-mail.\n";
>     close (SENDMAIL);
>   }
>
> print "Content-type: text/html\n\n";
> print <<EndHTML;
> <HTML>
> <HEAD>
> <TITLE>Confirmation</TITLE>
> <LINK REL="stylesheet" HREF="http://www.mattross.co.uk/style.css"
> TYPE="text/css">
> </HEAD>
> <BODY>
> <FONT SIZE=\"3\"><STRONG>Confirmation</STRONG><BR><HR>
> <FONT SIZE=\"2\">
> <BR>
> The following message has been sent to the subscribers.
> <BR>
> <PRE>$FORM{'message'}</PRE>
> <BR>
> <A HREF=\"http://www.mattross.co.uk/admin\">Return to admin page</A>
> </BODY>
> </HTML>
>
> EndHTML
> ;
>
> exit;
> }
>
> exit;
>
>
>




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

Date: Tue, 24 Apr 2001 16:50:12 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help with a script
Message-Id: <x7itjui6nm.fsf@home.sysarch.com>


you win the worst quoting award of the month. 4 lines of comment before
a jeopardized 270 lines of quote. think about what you just did while
you endure your 5 minute timeout in the corner.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Tue, 24 Apr 2001 13:05:07 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Issue with 5.004 to 5.6 upgrade - Use strict now automatic?
Message-Id: <3AE57D3F.26E984@home.com>

Tuc wrote:
> 
> Abigail wrote:
> 
> >
> > A few points.
> >
> >   -  Although some warnings are mandatory, the "used only once" isn't.
> >      You probably managed to turn it on somehow.
> 
> Yes, I've since found your right.  It turns out it might be something with the
> "Filter" package.

If you're using 5.6.0 and Filter.pm has 'use warnings' in it then a bug
in perl will enable "used only once" warnings in the calling scope.  I
think this was semi-fixed but I don't know if it made it into 5.6.1 or
not.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Tue, 24 Apr 2001 14:42:57 GMT
From: Lyle Goldman <Lyle_Goldman@ibi.com> 
Subject: Multi-Line Text Editor
Message-Id: <RhgF6.3333$QV4.278330@www.newsranger.com>

Hello. Is there a Perl module that allows multi-line console-based text editing
that will work under Microsoft Windows? What I want is something similar to the
Curses packages but will run under Windows. Also, it need to be text-based, so
Tk is no good. Thank you.

- Lyle Goldman




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

Date: Tue, 24 Apr 2001 14:06:05 +0100
From: "errol brown" <errolbrown@hotmail.com>
Subject: Re: Newbie question: reading variables with CGI
Message-Id: <3TeF6.133490$HR6.14896062@nnrp4.clara.net>

> Hmmm..., another charter member of the cplm catfish club? ;-)

Yeah, the group is full of them.  I find it really difficult to believe that
*so many* people can't get sex....

errol




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

Date: 24 Apr 2001 17:54:50 +0100
From: nobull@mail.com
Subject: Re: Newbie question: reading variables with CGI
Message-Id: <u9y9sqkzl1.fsf@wcl-l.bham.ac.uk>

"Super-Simon" <simon@super-simon.com> writes in untrimmed-jeopary
style:

> <nobull@mail.com> wrote in message news:u91yqjo85s.fsf@wcl-l.bham.ac.uk...
> > Unless it is your intension to be insulting then you should quote _in_
> > _context_ only _relevant_ bits of the message to which you are
> > replying.
> >
> > Is it your intension to be insulting?

I'll take that as a "yes".

I really can't understand why people think it is fun or cleaver to
come here and act in such an offensive way.

> > "Super-Simon" <simon@super-simon.com> writes:
> >
> > > "brian d foy" <comdog@panix.com> wrote in message
> > > news:comdog-CFCF7A.11442523042001@news.panix.com...
> > > > use CGI.pm.  it comes with Perl and is documented.
> > > >
> > > I know, but I can't find an example of how to use it...
> >
> > The manuals for Perl modules can be displayed using the "perldoc"
> > command.
>
> I read the perldoc but I didn't understand really what they meant (my
> english is not that good).

Your English seems very good to me.  There is no way I could have
guessed that when you said "find an example" you really meant
"understand the example".  I therefore told you how to find an
example.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 24 Apr 2001 19:32:14 +0200
From: "Jens Thieme" <webmaster@jt-online.de>
Subject: Re: Perl Fehler bei Scriptausführung
Message-Id: <9c4e4k$1bf$05$1@news.t-online.com>


"Michael Döring" <info@rpv.de> schrieb im Newsbeitrag
news:9buunb$e28$1@news.netcologne.de...
> "Tony Curtis" <tony_curtis32@yahoo.com> schrieb:
>  ^^^^^^^^^^^
>
> Würdest Du bitte Deinen korrekten Namen angeben!
> --
> Michael Döring ~~~~~~ Postfach 3143 ~~~~~~ 53831 Troisdorf
> Tel: 02241 978197 ~~~ eMail: info@RPV.de ~~~ ICQ: 12860386
> DAS Newsletterprogramm für Ihre Homepage: www.RPV.de/demo/




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

Date: Tue, 24 Apr 2001 11:27:16 -0400
From: "rthkid" <yourguru@whkjcssss.com>
Subject: Problem - PERL mail script sends HTML formating as part of plain text message
Message-Id: <9c460m$p64$1@sshuraaa-i-1.production.compuserve.com>

I'm trying to have a PERL script email a message with HTML formating.
The problem is that the HTML  is sent as part of the plain text message.
What command will force it to be sent as intended ?

Thanks for any and all help
The Kid  :)




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

Date: 24 Apr 2001 12:37:11 -0400
From: Doug Perham <dperham@dperham.eng.tvol.net>
Subject: Re: Problem - PERL mail script sends HTML formating as part of plain text message
Message-Id: <81oftmw8y0.fsf@wgate.com>

"rthkid" <yourguru@whkjcssss.com> writes:

> I'm trying to have a PERL script email a message with HTML formating.
> The problem is that the HTML  is sent as part of the plain text message.
> What command will force it to be sent as intended ?
> 
> Thanks for any and all help
> The Kid  :)

the default MIME Content-Type of a mail message unless otherwise
indicated is 

Content-Type: text/plain; charset=us-ascii

in order to override this, you'll have to include a MIME mail header that
tells the mail client that the message is html, like

Content-Type: text/html; charset=us-ascii


see rfc 2045 - 2049  which describes MIME

-- 
Doug Perham                                          o{..}o     
dperham@wgate.com                                moo! (oo)___   
WorldGate Communications, Inc.                        (______)\ 
                                                      / \  / \  


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

Date: Tue, 24 Apr 2001 08:16:37 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: problem understanding stat function output
Message-Id: <slrn9earl4.pff.tadmc@tadmc26.august.net>

John Michael <johnm@aiamail.com> wrote:

>I ran this in a perl script.
>($file_mode) = (stat($ENV{'PATH_TRANSLATED'}))[2];
>
>The output was 33188
>According to my books this is the mode & file type.
              ^^^^^^^^

You seem to have skipped the best resource for Perl info and gone
straight to less trustworthy sources. I do not recommend that approach.

You should read the documentation for the functions that you use:

   perldoc -f stat

which answers your question quite handily:

--------------------------
Because the mode contains both the file type and its permissions, you
should mask off the file type portion and (s)printf using a C<"%o">
if you want to see the real permissions.

    $mode = (stat($filename))[2];
    printf "Permissions are %04o\n", $mode & 07777;
--------------------------


>I need just the mode so that I can check it against a value like so.
>
>if ($file_mode eq "0777"}){
                ^^ ^    ^
                ^^ ^    ^

The mode is a number, nothing to be gained by stringifying it..

   $file_mode &= 07777;     # mask off file type info
   if ( $file_mode == 0777 ) {
      warn "You are much too trusting for your own good\n";
      warn "Consider using 0775 permissions for '$ENV{'PATH_TRANSLATED'}'\n";
   }


>How do I get the mode out of this?


By consulting the documentation that came with the software that 
you are using!


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


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

Date: 24 Apr 2001 17:57:37 +0100
From: nobull@mail.com
Subject: Re: Problems with module PlPRC
Message-Id: <u9wv8akzge.fsf@wcl-l.bham.ac.uk>

matthias@jaekle.net writes:
 
> "Mathias-H. Weber" wrote:
> > 
> > I tried to install Bundle::PlRPC. Everything went fine up to "make test"
> > of module "PlRPC-0.2015". The error message is not very valuable ("Use
> > of uninitialized value in concatenation (.)") - the problem is deeper
> > and may have something to do with incorrect usage of Sys::Syslog.

Actually this sounds suspiciously like bug that I found in Sys::Syslog
itself.

> > I have tried hard to find the problem with "make test" but did not
> > succeed. Has anybody used/installed this module recently and give some
> > hints?

> I ignored the error message and made a "make install" and everything was
> working fine.

I found and fixed the error in Sys::Syslog and posted the patch to
bugs.perl.org (BugID 20010308.001).  It is currently still listed as
open which seems odd for a bug with realively high impact and a
trivial fix. 

Interestingly the last time I answered this question here (2001-03-14)
it was asked by yet another Mathias.  What is it about PlRPC that
makes it so attractive to people called Mathias?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 24 Apr 2001 13:40:35 GMT
From: Drew <nospam@newsranger.com>
Subject: Re: RegEx optimization assistance
Message-Id: <nnfF6.3256$QV4.271002@www.newsranger.com>

>John W. Krahn wrote:
>>while ( <DATA> ) {
>>    if ( /\bfree\b/ ) {
>>        my @keys = split " ";
>>        @stats{ @keys } = split " ", <DATA>;
>                                      ^^^^^^
>Oh yeah. Of course. Bugger. In fact, that store-data-into-hash idea is
>very neat.
>	Bart.

Ok, not to be overly annoying, but where can I find further information about
this "store-data-into-hash" idea?  

I've already Benchmark'ed the code I'm going to use (and seen a slight
performance boost using study, btw) but I'd like to understand this method as
well, so I might use it.  Or at least Benchmark it against the current method
(thanks Bart & John).




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

Date: Tue, 24 Apr 2001 14:08:49 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: RegEx optimization assistance
Message-Id: <kq1bet897kujb2ds4he8a20cn5m56iv9ne@4ax.com>

Drew wrote:

>Ok, not to be overly annoying, but where can I find further information about
>this "store-data-into-hash" idea?  

It's an application of hash slices as an LValue. See the docs, perldata.
In practice,

	@hash{qw/FOO BAR/}

is the same as

	($hash{'FOO'}, $hash{'BAR'})

and as said, you can assign to it as well. That's what an LValue is: a
value that can appear on the *L*eft hand side of an assignment:

	@keys = qw/FOO BAR/;
	@hash{@keys} = 1 .. @keys;

This will set $hash{'FOO'} to 1 and $hash{'BAR'} to 2.

I've regularily used this idea myself already, for example for reading
data of one row from a tab delimited text file into a hash, but I
wouldn't have thought of using it for this particular case.

-- 
	Bart.


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

Date: Tue, 24 Apr 2001 17:02:02 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: RegEx optimization assistance
Message-Id: <tebccapccsrm3f@corp.supernews.com>

Drew (nospam@newsranger.com) wrote:
: >John W. Krahn wrote:
: >>while ( <DATA> ) {
: >>    if ( /\bfree\b/ ) {
: >>        my @keys = split " ";
: >>        @stats{ @keys } = split " ", <DATA>;
: >                                      ^^^^^^
: >Oh yeah. Of course. Bugger. In fact, that store-data-into-hash idea is
: >very neat.
: 
: Ok, not to be overly annoying, but where can I find further information about
: this "store-data-into-hash" idea?  

It's pretty simple.  The code looks for the line with 'free' on it; this
will be the column headings, so all of them get stored into the @keys
array.  Then the next line, which is guaranteed to have the corresponding
numeric values in the same columns, is split, with each value being
assigned by key into a hash called %stats using a hash slice.

Very nice.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Tue, 24 Apr 2001 16:46:19 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: regexp matching with optional part
Message-Id: <x7lmoqi6u3.fsf@home.sysarch.com>

>>>>> "RF" == Ronald Fischer <ronald.fischer@deadspam.com> writes:

  RF> Uri Guttman <uri@sysarch.com> writes:
  >> 
  >> s/^x-|-x$//g && $_

  RF> That's it! I never thought about the s/// function here, but of course,
  RF> the solution is simple:

  RF> (s/^x-|-x$//g, length($_) > 0)

better off using && instead of , because if the s/// fails, why test for
length? also the > 0 is not needed in any case.

my version above would work fine except for a string of '0' (or that
with your x- or -x stuff).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 24 Apr 2001 13:10:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Where is my script
Message-Id: <9c3tvn$ojq$1@mamenchi.zrz.TU-Berlin.DE>

According to ( ) | 3 ] <obiwan@mahood.com.eatme_spammers>:

You posted your reply above the quoted text.  Don't do that.

> Your own location is called your present (or current) working directory.  In
> unix, this is reffered to as pwd or cwd.  There is a unix command, cwd,
                                                                     ^^^
ITYM pwd.

> which tells you this when you're in a shell.  There is also an environment
> variable for most shells (PWD) which contains this information.
> 
> A process has an environment, as you do as a user, and a corresponding set

This is slightly misleading.  A process has an environment, period.
This can be an interactive shell (in which case you seem to call it
the user's environment) or another program.  The user doesn't really
have an environment in this sense, neither as a person nor as
an entity in the system.

> of environment variables.  To see your environment variables (in most
> shells), type: env.
> 
> In perl, environment variables are stored in the %ENV hash.  Hopefully you
> can learn from the following:
> 
> #! /usr/local/bin/perl
> 
> foreach $x ( sort keys %ENV ) {
>         print "$x: $ENV{$x}\n";
> }
> 
> print "Here is my PWD: $ENV{'PWD'}\n";

This is not a good way to find the current directory.  Besides being
Unix-centric and not even guaranteed to work there (as you note),
the environment variable contains what it contained when perl started.
(It is updated by the shell, but not by perl.)  If the current directory
has changed since then, the contents of $ENV{ PWD} will be incorrect.

The right way to find the current directory is to use the standard
Cwd module.  It can also change the behavior of Perl's chdir() to
keep $ENV{ PWD} current.

Anno

[jeopardectomy]


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

Date: Tue, 24 Apr 2001 08:08:22 -0700
From: Martin Djernaes <martin@djernaes.net>
Subject: Re: Where is my script
Message-Id: <3AE596E6.61CD4746@djernaes.net>

Hi,

Sorry if I didn't explain myself correctly.

I stand in ~/test

call /usr/local/bin/perl ../perlscript/test.pl

I want to get ~/perlscript/ (or /users/someone/perlscript) from inside
test.pl (without hardcoding).

Maybe FinBin can do it (I have not had time testing it), but I
understood from perldoc that there was a problem. If I would stand in
~/perlscript/ and call /usr/local/bin/perl test.pl it would not get the
correct path - is that correct?

Martin

"( ) | 3 ]" wrote:
> 
> Your own location is called your present (or current) working directory.  In
> unix, this is reffered to as pwd or cwd.  There is a unix command, cwd,
> which tells you this when you're in a shell.  There is also an environment
> variable for most shells (PWD) which contains this information.
> 
> A process has an environment, as you do as a user, and a corresponding set
> of environment variables.  To see your environment variables (in most
> shells), type: env.
> 
> In perl, environment variables are stored in the %ENV hash.  Hopefully you
> can learn from the following:
> 
> #! /usr/local/bin/perl
> 
> foreach $x ( sort keys %ENV ) {
>         print "$x: $ENV{$x}\n";
> }
> 
> print "Here is my PWD: $ENV{'PWD'}\n";
> 
> - ( ) | 3 ][
> 
> Martin Djernaes wrote:
> 
> > Hi,
> >
> > What's the way to find the location of a script (from within the
> > script)?
> >
> > I have a CGI script in /home/someuser/public_html/adir/ called
> > ascript.pl. When ever it's called by Apache I can use '.' for the
> > current dir, which is also the dir of the script, but if I'm in
> > /home/someuser and call /usr/bin/perl public_html/adir/ascript.pl I look
> > that information - how do I find "my own" location?
> >
> > Martin


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

Date: Tue, 24 Apr 2001 17:37:22 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Where is my script
Message-Id: <tebeei8djjhcf9@corp.supernews.com>

Martin Djernaes (martin@djernaes.net) wrote:
: Sorry if I didn't explain myself correctly.
: I stand in ~/test
: call /usr/local/bin/perl ../perlscript/test.pl
: I want to get ~/perlscript/ (or /users/someone/perlscript) from inside
: test.pl (without hardcoding).

And FindBin doesn't work?  (It does precisely that for me.)

: Maybe FinBin can do it (I have not had time testing it),

Wouldn't it have been faster to try it than to post to Usenet and wait for
answers?

: but I
: understood from perldoc that there was a problem. If I would stand in
: ~/perlscript/ and call /usr/local/bin/perl test.pl it would not get the
: correct path - is that correct?

/m/hermosa/usr3/home/cberry > cat fbtest
#!/usr/bin/perl -w

use strict;
use FindBin qw($Bin);

print "Bin is: $Bin\n";
/m/hermosa/usr3/home/cberry > fbtest
Bin is: /m/hermosa/usr3/home/cberry
/m/hermosa/usr3/home/cberry > perl fbtest
Bin is: /m/hermosa/usr3/home/cberry
/m/hermosa/usr3/home/cberry > cd public-html
/m/hermosa/usr3/home/cberry/public-html > ../fbtest
Bin is: /m/hermosa/usr3/home/cberry
/m/hermosa/usr3/home/cberry/public-html > perl ../fbtest
Bin is: /m/hermosa/usr3/home/cberry


-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "When the going gets weird, the weird turn pro."
   |               - Hunter S. Thompson


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

Date: Tue, 24 Apr 2001 13:47:26 GMT
From: ixlu@PCGuide.com (Charles M. Kozierok)
Subject: Re: Windows Perl for Windows 95 -- Internet Explorer 5 required?
Message-Id: <OtfF6.425$Be3.41489@news.shore.net>

In article <jdhaet0rm5cshcmnvueruq1n4sgudkhi94@4ax.com>,
Bart Lateur  <bart.lateur@skynet.be> wrote:
} Charles M. Kozierok wrote:
} 
} >Thanks Bart. I'll give Indigo a try. If you have any tips or pitfalls
} >to help a newbie avoid, please share them. :)
} 
} Avoid spaces in the path to perl's directory. PerlConsole doesn't work
} for me. Instead, one can start (and stop) Apache manually with the start
} menu items, and point your browser to <http://localhost/html/>. There's
} a file missing in the html directory with the name "win32prk.css",
} Netscape doesn't like that; you may even put an empty file of that name
} there. Create a directory called "local_repository" in your root perl
} directory. It's there that the GPM will then put its downloads. The base
} URL for Activestate's repository is
} <http://www.activestate.com/PPMpackages/5.6>. Heh!

Thanks a lot Bart! Much appreciated. (I hate spaces in general,
too much hassle on the command line and some browsers don't like them
in URLs.)

cheers,

-*-
Charles M. Kozierok (mailto:ixl@PCGuide.com)
Webslave, The PC Guide - <http://www.PCGuide.com>
Comprehensive PC Reference, Troubleshooting, Optimization and Buyer's Guides...


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 V10 Issue 754
**************************************


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