[17000] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4412 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 23 11:05:22 2000

Date: Sat, 23 Sep 2000 08:05:07 -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: <969721506-v9-i4412@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 23 Sep 2000     Volume: 9 Number: 4412

Today's topics:
    Re: "not in string" - how to do it? <ren.maddox@tivoli.com>
    Re: - For this type of use (see msg), should I favor Pe (Clay Irving)
    Re: - For this type of use (see msg), should I favor Pe (Tony L. Svanstrom)
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
    Re: Bad http request? (Tony L. Svanstrom)
    Re: best way to compare $var against <DATA> <ren.maddox@tivoli.com>
    Re: Editing a linked file <ren.maddox@tivoli.com>
    Re: Extra ^M in text file <flavell@mail.cern.ch>
        HTML to Text converter <tom@xor.cc>
    Re: Inserting one page inside another <flavell@mail.cern.ch>
    Re: Levels of Perl Programmer <temp1@williamc.com>
    Re: Levels of Perl Programmer <glynFOOdwr@FSCKdeleteEmeD.co.uk>
        Locking files across CGI script invocations: advice sou <ter@my-deja.com>
        PERL Script in a backgroung <ales.romaniuk@zag.si>
    Re: PERL Script in a backgroung <schelling@bluewin.ch>
    Re: Pure perl encrypt/decryption? <godoy@conectiva.com>
    Re: Simple one? How do I escape the '(" in a string? <ren.maddox@tivoli.com>
    Re: Simple one? How do I escape the '(" in a string? <ren.maddox@tivoli.com>
    Re: Simple one? How do I escape the '(" in a string? <ren.maddox@tivoli.com>
        there must be an easier way to do this <wedeking@msa.attmil.ne.jp>
    Re: Time Zone conversion <godoy@conectiva.com>
    Re: Time Zone conversion <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 22 Sep 2000 21:14:39 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: "not in string" - how to do it?
Message-Id: <m3itrnc0s0.fsf@dhcp11-177.support.tivoli.com>

Ren Maddox <ren.maddox@tivoli.com> writes:

> "Kurt Schmidt" <fpuzvqgxcrnpu@tgr.arg> writes:
> 
> > Let's say that I have arbitrary strings like
> > 
> > aklklsdjjf
> > ssdalkfj
> > srwokgfl
> > jkljsdpitl;
> > skkdddk
> > dlkliujgmn
> > klksddffd
> > 
> > and so on
> > I want to match all strings EXCEPT those that have one or more d in it.
> 
> I would probably reverse the match and then reverse the surrounding
> logic, with something like:
> 
> print unless /d.*d/s;   # s-modifier for any embedded newlines
> 
> But if you really want to match the other way, you could use:
> 
> print if /^[^d]*d?[^d]*$/;

Oops... somehow I misread the requirements as "two or more" instead of
"one or more".

My amended answers are (naturally):

print unless /d/;

or

print if /^[^d]*$/;

though I have trouble imagining why the second would ever be used...

-- 
Ren Maddox
ren@tivoli.com


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

Date: 23 Sep 2000 12:46:18 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <slrn8sp9gq.sid.clay@panix3.panix.com>

On Fri, 22 Sep 2000 23:25:30 -0400, Jon <vemba72@hotmail.com> wrote:

>I am launching a new site and I have the option of having all my file
>splicing and parsing (templates and whatnot) done either via Perl (.cgi) or
>PHP (.phtml)  That will be 90% of the use of the script... assemble
>templates + raw files, breaking files down into multiple "click here for
>page 2/3/etc" pages... etc...
>
>ASP is not an option, I'm on UNIX.
>
>I keep hearing different stories about which of the two (Perl vs CGI)
>performs better on large loads (you'd think I was talking about a laundry
>detergent wouldn't you?)

"Perl vs. CGI" is like saying "Tools vs. a blueprint of a house".

>All my links will be drawn up one way or another... so which way should I be
>investing my time in (I'll be hiring someone to do the script)?
>
>Perl or PHP3?

Which answer do you think you'll get in a Perl newsgroup?

>PS: The server admin told me he had to shut down several sites earlier this
>year because of Perl scripts... too many hits, and every hit ran the
>template-grabbing CGI.  He said sites that get less hits but use Perl tax
>the server more than sites that get more hits but use PHP... somehow, PHP
>opens and closes fewer files (that's how it was explained to me) so he's
>strongly pushing for PHP.  Is this all just BS?

Sounds like BS.

-- 
Clay Irving <clay@panix.com>
Natural abilities are like natural plants that need pruning by study. 
- Francis Bacon 


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

Date: Sat, 23 Sep 2000 15:16:29 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: - For this type of use (see msg), should I favor Perl or PHP3?
Message-Id: <1ehf3oo.1nqe36k1wupcbgN%tony@svanstrom.com>

Clay Irving <clay@panix.com> wrote:

> On Fri, 22 Sep 2000 23:25:30 -0400, Jon <vemba72@hotmail.com> wrote:

> >PS: The server admin told me he had to shut down several sites earlier
> >this year because of Perl scripts... too many hits, and every hit ran the
> >template-grabbing CGI.  He said sites that get less hits but use Perl tax
> >the server more than sites that get more hits but use PHP... somehow, PHP
> >opens and closes fewer files (that's how it was explained to me) so he's
> >strongly pushing for PHP.  Is this all just BS?
> 
> Sounds like BS.

Not really, with CGI you start a new process with each script, that
doesn't happen with PHP. [*]


     /Tony
[*] A little to simplified, but true enough.
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Sat, 23 Sep 2000 10:22:15 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage969704645.16326@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

For an alternative way to get answers, check out the Perlfaq website.

    http://www.perlfaq.com/

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Sat, 23 Sep 2000 12:15:39 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Bad http request?
Message-Id: <1ehev7x.19bug0rcv6taeN%tony@svanstrom.com>

<aap@gmx.net> wrote:

> Just sending some http-request and getting a page in ASCII back is
> enough.
> But is doesn't work. The server I get connected with responds:

> This is the trivial c-code that I use:

A CGI-question that you could answer yourself if you read the RFC and
coding in C... Exactly why did you post that to comp.lang.perl.misc?


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: 22 Sep 2000 23:07:38 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: best way to compare $var against <DATA>
Message-Id: <m34s37bvjp.fsf@dhcp11-177.support.tivoli.com>

Gorbeast <gorbeast@SPAMSUCKS.subduction.org> writes:

> Hello,
> 
> I have a script I am working on and theres a part I haven't figured out
> yet.  If anybody can help me that would be wonderful.  At one point, my
> script should take a variable which is supplied by the user,
> $users_newsgroup, and I want it to run against against <DATA>, (which is
> a list of newgroups), and return a warning to the user if their
> $users_newsgroup does not find a match in <DATA>.  How can I do this?  

{
  my $found;
  while(<DATA>) {
    next unless /$users_newsgroup/;  # or $_ eq $users_newsgroup
    $found++ and last;
  }
  warn "$users_newsgroup not found\n" unless $found;
}


This has the added benefit that it will stop processing DATA as soon
as a match is found.

You can avoid the extra variable via something like:

$users_newsgroup = "four";
while(<DATA>) {
  /$users_newsgroup/
    or eof DATA ? warn "$users_newsgroup not found\n" : next;
  last;
}


-- 
Ren Maddox
ren@tivoli.com


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

Date: 22 Sep 2000 22:37:38 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Editing a linked file
Message-Id: <m37l83bwxp.fsf@dhcp11-177.support.tivoli.com>

Geoff Soper <g.soper@soundhouse.co.uk> writes:

> In the route of our web server (Apache) is a linked file which controls
> our e-mail aliasing. As part of a Perl script to administer user details a
> new alias file is written each time it is run. Unfortunately this seems to
> break the link.

Nothing to do with Perl...

It sounds like the file needs to be a symbolic link instead of a hard
link.  The editor is probably moving the file to a backup and creating
a new file in its place.  The linked file is still linked to the
original file.  A symbolic link would always point to the file of a
given name, so would not be affected by such changes.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Sat, 23 Sep 2000 12:48:57 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Extra ^M in text file
Message-Id: <Pine.GHP.4.21.0009231243190.7026-100000@hpplus03.cern.ch>

On Sat, 23 Sep 2000, Ian Marsh stood Usenet on its head and blurted
out:

> The ^M appears because DOS based Operating systems including WIndows
> 3.1/95/98/NT etc. use a pair of control characters in text files to show
> newline.

Do we have wade through yet another string of hand-rolled answers to
this FAQ every time it comes up, looking for fresh misconceptions that
might mislead others?  (Aside from the misconception that there is a
valid newsgroup called comp.lang.perl, that is).

> Since it only
> processes the CR, the LF is considered text and is displayed as ^M, the
> CON response to ascii(0D).  You have to specify only a CR when
> terminating a line and not rely on Windows OS services to do this.

Rubbish.  Go back into lurk mode until you get a better grasp of your
material.

Fortunately your upside-down fullquoting style will have set off the
alarm bells for anyone who has a clue about usenet.

perldoc perlport has a constructive discussion.  I don't propose to
repeat it here.



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

Date: Sat, 23 Sep 2000 08:04:46 PDT
From: Tom Geldner <tom@xor.cc>
Subject: HTML to Text converter
Message-Id: <VA.00000088.01e113e2@xor.cc>

I'm looking for something in Perl that will convert HTML to 
straight Text (ASCII). Basically, I want to use it to strip HTML 
out of incoming e-mails on my server. I've searched most of the 
Perl archives I know about without success. I found one module 
listed but the ftp link was dead.

Anyone?? Thanks!

Tom of XOR
http://xor.cc for cyber clothez.



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

Date: Sat, 23 Sep 2000 12:39:00 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Inserting one page inside another
Message-Id: <Pine.GHP.4.21.0009231231550.7026-100000@hpplus03.cern.ch>

On Sat, 23 Sep 2000, Tim Richardson wrote:

> > ^^ Hi everyone. What I want to do is insert one page into another.

> > Fine, but what does that have to do with Perl?

> I think it's a fair question.

Yes, but not in a Perl language group, and we're just about to see
why.

> What's a portable version of Unix's cat?

Not helpful, since the rules of HTML mean that if the inserted page is
a valid HTML document, then the result of inserting it unmodified into
another is not valid.  As I say, and as Abigail said, this has nothing
to do with Perl.  You'd do well to pay attention to Abigail's advice,
even if it does tend to get offered in a somewhat cryptic fashion.

f'ups prophylactically set.  When the original poster has worked out
_what_ they need to do, then _how_ to do it in Perl is trivial, but at
least they would then have a Perl-related question.

Don't forget that this can be a security exposure.  Check the WWW
Security FAQ for details.




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

Date: Sat, 23 Sep 2000 10:52:33 GMT
From: PropART <temp1@williamc.com>
Subject: Re: Levels of Perl Programmer
Message-Id: <39CC89F5.1892D411@williamc.com>

Sid Malhotra wrote:
> 
> I am looking for an article (probably written by Tom Christiansen) on
> the levels of a perl programmer.  I don't quite remember what exactly it
> was but it listed the levels of a perl programmer and it's symptoms

I saved this when I was learning Perl... Hope the line endings aren't
screwed up.

****

Subject: Re: Who is Just another Perl hacker?
Date: 1 May 1999 09:09:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Organization: Perl Consulting and Training
Newsgroups: comp.lang.perl.misc

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

In comp.lang.perl.misc,
    cederstrom@kolumbus.REMOVE_THIS.fi writes:
:But when do I become Just another Perl hacker? Who are they?

                +------------------------------+
                | Seven Levels of Perl Mastery |
                +------------------------------+

Novice

  1. Thinks CGI and Perl are interchangeable terms.
  2. Still thinks Perl looks like bad C code viewed over a noisy modem.
  3. Is insecure about the concept of dollar signs.
  4. Thinks Perl should be more like sh or tcl.
  5. Has heard of the ``Unix mindset'', but hopes it's a treatable
     condition.
  6. Can't figure out how to read input from the keyboard.
  7. Thinks regular expressions are somebody cursing.
  8. Wonders why no one can give him a straight answer about whether
Perl is
     compiled or interpreted.

Initiate

  1. Has begun to learn about $_ -- and doesn't like it a bit.
  2. Thinks -w flag is a waste of time.
  3. Thinks Perl should be more like C++ or Java.
  4. Is still trying to figure why Perl has two different kinds of
arrays.
  5. Knows how to use perlbug, but sends in bogus bug reports.
  6. Has been bitten by implicit context conversions, but hasn't caught
on
     yet.
  7. Can't keep == separate from eq, and thinks that + should
concatenate
     strings.

User

  1. Thinks Perl is just for text processing.
  2. Uses the Perl debugger.
  3. Has used other people's modules.
  4. Wonders what an object is.
  5. Knows their way around CPAN.
  6. Knows the difference between local and my.
  7. Uses <DATA>.
  8. Is still trying to figure what references are for.
  9. Thinks Perl should be more like scheme or eiffel.
 10. Submits real bug reports with perlbug.

Expert

  1. Write JAPHs to impress their friends and annoy their coworkers.
  2. Begins all programs with use strict.
  3. Thinks Perl should just be Perl.
  4. Has taken enough advantage of cryptocontext to annoy others.
  5. Knows how to create records and objects with hash refs.
  6. Uses syscall to get at undocumented operating system calls.
  7. Curses the flexibility of the Perl object system.
  8. Uses /e in substitutes.
  9. Has begun to wonder what typeglobs are for.
 10. Has written their own modules in Perl.
 11. Begins to look at all data in terms of regular expressions.
 12. Understands why regexes can't match nested data.
 13. Rewrites minor utilities in Perl.

Hacker

  1. Writes games in Perl.
  2. Has written extension modules in C.
  3. Uses AUTOLOAD and closures in curious ways.
  4. Appreciates the aethetics of the Schwartzian Transform.
  5. Delights in the flexibility of the Perl object system.
  6. Has written their own pod2XXX translator.
  7. Understands the output from Perl -Dflags.
  8. Accesses the Perl symbol table directly.
  9. Submits bug reports with working patches.
 10. Edits files using a special Perl-embedded version of vi or emacs.
 11. Has contributed modules, manpages, and tools to the standard Perl
     distribution.

Guru

  1. Can answer any Perl question instantly.
  2. Can write anything in Perl -- and does.
  3. Takes advantage of undocumented language features.
  4. Writes code that gives even Larry pause.
  5. Implements opaque objects and compiled regexes using closures.
  6. Can read and understand the output of the perl-to-C compiler.
  7. Embeds Perl interpreters in larger applications.
  8. Has written their own -d:debugger module.
  9. Used object-oriented programming before it existed.
 10. Is debating taking their turn with the patch pumpkin.

Wizard

  1. Is on a first-name basis with Larry's wife.
  2. Has written or rewritten major areas in the Perl compiler or
     interpreter.
  3. Is thinking about rewriting the regex engine, the memory allocator,
or
     the garbage collector.
  4. Doesn't write games in Perl, because they realize that Perl itself
is
     the game.

--
Real programmers can write assembly code in any language.   :-)
                --Larry Wall in  <8571@jpl-devvax.JPL.NASA.GOV>


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

Date: Sat, 23 Sep 2000 12:13:54 +0100
From: "Glyndwr" <glynFOOdwr@FSCKdeleteEmeD.co.uk>
Subject: Re: Levels of Perl Programmer
Message-Id: <Ud0z5.5154$6b2.90735@news6-win.server.ntlworld.com>

"PropART" <temp1@williamc.com> wrote in message
news:39CC89F5.1892D411@williamc.com...
> Expert

I qualify for 9 of the points at this level. Excellent.

--
                                           -=G=-
print join " ",reverse split /\s+/,'hacker. Perl another Just',"\n";
Web: http://www.fscked.co.uk                             ICQ: 66545073




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

Date: Sat, 23 Sep 2000 11:17:13 GMT
From: Tim Richardson <ter@my-deja.com>
Subject: Locking files across CGI script invocations: advice sought.
Message-Id: <8qi3fi$hpj$1@nnrp1.deja.com>

I'm interested in advice about how to lock simple database files across
invocations of a CGI script. The scenario: First the user selects some
data to edit (they choose a key to a record in a db_file database). They
submit their record selection, and the script runs and returns a form
with the data ready for editing.
Then the user modifies the data in their browser, and submits it.

What are some light-weight strategies to use to lock the database in
this case? I've thought of passing back a CRC of the database via a
hidden form field. When the form is resubmitted, the crc of the database
file is checked again, and if it doesn't match there is a potential
version conflict.

We could also lock the database by giving each session some identifier,
and recording in another database which session holds the lock, but then
we must worry about timeouts and so on. Is there a module for this?
I think there is probably no good way of doing this and keeping life
simple, so I would be interested in what compromises have proved to be
useful.

regards,

Tim

--
Tim Richardson
(search string: qweeblebeast)


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


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

Date: Sat, 23 Sep 2000 14:09:02 +0200
From: Marvin <ales.romaniuk@zag.si>
Subject: PERL Script in a backgroung
Message-Id: <MPG.1436bbc7c6db8e69989691@news.siol.net>

Hi !

I have a perlscript, which I want to run in a background on UNIX system
(now I have a cronjob to run script every minute).
The script is checking various systems over the network and it takes 
more than a minute, so after a while a have several instances of them in 
a memory.
If I try to run
# myscript.pl &

the script is immediately stopped. Is there any argument it must be 
passed to perl interpreter ?

Thanks


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

Date: Sat, 23 Sep 2000 16:08:07 +0200
From: Barna <schelling@bluewin.ch>
Subject: Re: PERL Script in a backgroung
Message-Id: <39CCB947.FB1079FF@bluewin.ch>

use "# exec myscript.pl &"


Marvin schrieb:

> Hi !
>
> I have a perlscript, which I want to run in a background on UNIX system
> (now I have a cronjob to run script every minute).
> The script is checking various systems over the network and it takes
> more than a minute, so after a while a have several instances of them in
> a memory.
> If I try to run
> # myscript.pl &
>
> the script is immediately stopped. Is there any argument it must be
> passed to perl interpreter ?
>
> Thanks



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

Date: 22 Sep 2000 18:04:54 -0300
From: Jorge Godoy <godoy@conectiva.com>
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <kp66no6suh.fsf@dagon.conectiva>

>>>>> On 22 Sep 2000 13:57:33 GMT, abigail@foad.org (Abigail) said:

    A> Bart Lateur (bart.lateur@skynet.be) wrote on MMDLXXIX September MCMXCIII
    A> in <URL:news:lp2mssom4j93rmhfcn7r6a1p23eh3t33ps@4ax.com>:
    A> || 
    A> || You still have to SUID that binary.


    A> Not a problem if `su' is available.


Even less troubly if 'sudo' can be used. ;-) 


See you,
-- 
Godoy. <godoy@conectiva.com>

Departamento de Publicações       Conectiva S.A.
Publishing Department             Conectiva Inc.


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

Date: 22 Sep 2000 21:21:55 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Simple one? How do I escape the '(" in a string?
Message-Id: <m3g0mrc0fw.fsf@dhcp11-177.support.tivoli.com>

Bob Walton <bwalton@rochester.rr.com> writes:

> Robert Chalmers wrote:
> > 
> > print (DB "\(\n");
> > 
> > $ perl -w beta.pl
> > print (...) interpreted as function at beta.pl line 92.
[snip]
> want to print to open filehandle DB, use:
> 
>     print DB "\)\n";

Further, the ")" doesn't need to be escaped:

print DB ")\n";

-- 
Ren Maddox
ren@tivoli.com


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

Date: 22 Sep 2000 22:13:12 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Simple one? How do I escape the '(" in a string?
Message-Id: <m3d7hvby2f.fsf@dhcp11-177.support.tivoli.com>

Ren Maddox <ren.maddox@tivoli.com> writes:

> Bob Walton <bwalton@rochester.rr.com> writes:
> 
> > Robert Chalmers wrote:
> > > 
> > > print (DB "\(\n");
> > > 
> > > $ perl -w beta.pl
> > > print (...) interpreted as function at beta.pl line 92.
> [snip]
> > want to print to open filehandle DB, use:
> > 
> >     print DB "\)\n";
> 
> Further, the ")" doesn't need to be escaped:
> 
> print DB ")\n";

Or even the "("... (silly me)

print DB "(\n";

-- 
Ren Maddox
ren@tivoli.com


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

Date: 22 Sep 2000 22:34:34 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Simple one? How do I escape the '(" in a string?
Message-Id: <m3aeczbx2t.fsf@dhcp11-177.support.tivoli.com>

"Robert Chalmers" <robert@chalmers.com.au> writes:

> I found one way around it.
> 
> print (DB "\70 \n");   Which is \70 = octal 70 = (
> 
> print (DB "\(\n"); simply doesnt work.
> 
> It's actually the opening quote of a set of brackets that are closed further
> down.
> print (DB "\)\n");  works fine by the way - the bracket is facing the other
> way..

Me thinks that there is more to this problem than you are telling us.
For one thing, it does work, as Abigail already pointed out.  For
another, \70 == octal 70 == decimal 56 == ord "8" (not ord "(").  ord
"(" is octal 50.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Sat, 23 Sep 2000 21:47:00 +0900
From: "Dan and Shelly" <wedeking@msa.attmil.ne.jp>
Subject: there must be an easier way to do this
Message-Id: <8qi8db$j2n$1@newsflood.tokyo.att.ne.jp>

I wrote the below script and it seems to work as I intended it to.  But
looking at it I wonder what I could have done to avoid using so many
variables.  Does anyone know of an easier way to do the same thing that the
script below does?

# list of variables:
#
# $_ - perl's default variable in a while loop for each line in succession
#   from the first line of text to the last.
#   gets reset to the next line down by the while loop
#
# $paragraphLine - $_ is assigned to $paragraphLine if it is a line that
#   should be added to the $paragraph
#   gets reset to the next $_ down by the while loop
#
# $paragraph = collects up the lines of one paragraph
#   gets reset to "" at end of each new paragraph
#
# $endOfPara - used to determine when to start the next paragraph
#   gets reset to 'false' at end of each paragraph
#
# @paras - list of paragraphs - used to sort and get rid of duplicate
paragraphs
#
# $para - used as a temporary variable to step through @paras list and again
#  to step through @uniqParas
#
# $i - incremented by one for each $para in @paras to check for duplicates
#
# $nextPara - compared to $para, if different, para is added to @uniqParas
#
# @uniqParas - this is the list of paragraphs that gets checked for errors
#
# $errors - keeps a count for each paragraph of the number of errors found
#
# $errorMsgs - collects up all the error messages for each paragraph
#
# $paraCount - prints out the number of the paragraph being checked
#


# first, print out html header, then collect lines into paragraphs

print "<html>
<head>
<title>Dan's paragraphs</title>
</head>
<body>
<pre>\n";


open(PARAGRAPHS,"paragraphs.txt") or
 die "can't open paragraphs.txt\n";

while(<PARAGRAPHS>) {

  if ($_ =~ /\S+/ && # if the line is not blank
      $_ !~ /^bad line/ # and if it's not a bad line
     ) { # some lines are blank or bad and don't get added to the paragraph
          $paragraphLine = $_; # step through lines of paragraphs.txt
       } else { $paragraphLine = "" }

  if ("$paragraphLine" =~ /^00/) {
    $endOfPara = 'true';
    $paragraphLine = "";
  } else { $endOfPara = 'false' }

  if ($endOfPara eq 'false') { # keep adding lines if your not at the end

    $paragraph = "$paragraph" . "$paragraphLine"; # until a full paragraph
keep adding lines

  } elsif ("$endOfPara" eq 'true') { # builds up list of paragraphs in
@paras

   if ("$paragraph" ne "") {
    push(@paras,$paragraph);
    $paragraph = "";
    $endOfPara = 'false';
   } # end of if paragraph ne ""
   } # end of elsif endofpara eq true

} # end of while PARAGRAPHS, now
  # we're done looking in file paragraphs.txt and list
  # @paras should contain all the paragraphs from the file

# second, sort the paragraphs and get
# rid of duplicate paragraphs

@paras = sort @paras; # sorts the paragraphs in @paras alphabetically

foreach $para (@paras) { # look through @paras to get rid of duplicates
  $i = $i + 1; # increment counter
  $nextPara = "$paras[$i]"; # since the first paragraphs is $paras[0]...
  if ("$nextPara" ne "$para") {
   push(@uniqParas,$para);
  }
} # now @uniqParas should not have any duplicates


# third, check each paragraph for errors, print out each paragraph
# and each paragraphs errors
# keep a count of paragraphs and corrected paragraphs

foreach $para (@uniqParas) { # check unique paragraphs for errors

  if ("$para" =~ /(error)/) { # found an error
 $theError = "$1";

    $para =~ s/$theError/<u>$theError<\/u>/g; # underlines the error
    $errors++;
    $errorMsgs = "$errorMsgs\n$errors.  found an error\n";

  }
  $paraCount++; # increments count of paragraphs checked
  print "Paragraph number $paraCount\n\n";
  print "$para\n";
  print "$errorMsgs\n";
  $errors = ""; # reset error count for next paragraph
  $errorMsgs = ""; # reset error messages for next paragraph
} # end of checking @uniqParas for errors

# print the end of the html file:

print "</pre>
</body>
</html>\n";

# end of program




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

Date: 23 Sep 2000 09:27:57 -0300
From: Jorge Godoy <godoy@conectiva.com>
Subject: Re: Time Zone conversion
Message-Id: <kp8zsjqomq.fsf@dagon.casa>

>>>>> On Fri, 22 Sep 2000 19:12:32 -0600, "Michael Love" <noone@nospam.com> said:

    ML> I'm trying to find a way to convert a time from one timezone into a time for
    ML> another timezone while compensating for daylight savings time. The basic
    ML> conversion is easy, but with so many countries that use dst having different
    ML> rules for when it starts and ends, it is rapidly becoming too complex for
    ML> what I want to do with it.

    ML> Is there a module that will do this? I've checked out Time::Zone and a
    ML> couple of others, but they don't do the dst compensation part.

Maybe if you break your problem into small pieces it might get
easy... Suggestion (I'm inventing the names, don't waste your time
after this 'module'):

Time::Compare->ToUTC($date);
Time::Compare->FromUTC($date);
Time::Compare->CheckDST($country);

You may, then, convert time from any country (checking if it is in DST
with the later method) to UTC and then convert from UTC to the other
time, doing the compensation with another call to the CheckDST
method. 

This way you would have to bother with how's your CheckDST method,
since this is the slowest part (the other two are already implemented
in other modules, I think). 


See you,
-- 
Godoy. <godoy@conectiva.com>

Departamento de Publicações       Conectiva S.A.
Publishing Department             Conectiva Inc.


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

Date: Sat, 23 Sep 2000 15:13:17 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Time Zone conversion
Message-Id: <Pine.GHP.4.21.0009231434380.7026-100000@hpplus03.cern.ch>

On Fri, 22 Sep 2000, Michael Love wrote:

> I'm trying to find a way to convert a time from one timezone into a time for
> another timezone while compensating for daylight savings time.

The locale support should know the answers to this.  On some OSes it's
just a matter of setting the TZ environment to the appropriate value
before querying the local time; I think on others there's more work to
be done.

I just cobbled this demonstration together (apologies to fans of good
Perl style):

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

sub printlt {
  my @lt = localtime;
  print "$lt[2]:$lt[1]:$lt[0]\n";
  return;
  }

printlt;

$ENV{'TZ'} = 'MEZ-1MESZ';
printlt;

$ENV{'TZ'} = 'GMT0';
printlt;

###

In the UK today (i.e a short time ago), this returned the answers:

13:42:17
14:42:17
12:42:17

representing the default timezone (BST = UTC+1), the European
summer time (UTC+2) and the GMT (=UTC) time.

(This works for example on Digital Unix or on Linux RH6.1; it 
didn't work in ActivePerl 518 on Windows.)

To take a trivial example, I routinely run my web servers by setting
TZ=GMT0 before starting them, so that all their time stamps, logs etc
are kept in UTC instead of in local time, and there's no 1-hour glitch
in the logs at the changeovers.

As I say, however, depending on your underlying support (OS, POSIX
wherever this really is), you may have to do more work than this to
really convince localtime() to use your choice of timezone.  Perhaps
if someone knows a more portable way to access this functionality
(without actually having to tangle with one's own independent source
of timezone information over and above what's in the OS/libraries
already) they'd share it.  perldoc perlport helpfully warns us what
NOT to do (i.e what I showed above ;-) but does not offer any positive
counsel.

ttfn



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

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


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