[17261] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4683 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 21 11:05:31 2000

Date: Sat, 21 Oct 2000 08:05:09 -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: <972140708-v9-i4683@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 21 Oct 2000     Volume: 9 Number: 4683

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
    Re: Boolean query to Perl regexp match conversion (Tom Christiansen)
    Re: Dynamic Regex building? <mrh@panix.com>
    Re: EOF character in middle of file? <flavell@mail.cern.ch>
    Re: EOF character in middle of file? (Martien Verbruggen)
    Re: How to turn '<br><br>' or '<br><br><br>' into '<br> (Al)
    Re: How to turn '<br><br>' or '<br><br><br>' into '<br> (Martien Verbruggen)
        Looking for source of function to read/write config fil <eldy@ifrance.com>
    Re: Looking for source of function to read/write config (Clay Irving)
        Perl 5.005 or 5.6? <marc@fearby.com>
        Problem getting hostname (Burt Lewis)
    Re: Problem getting hostname (Martien Verbruggen)
        Removing line breaks from a string - HELP! <andy@andyuk.net>
    Re: Removing line breaks from a string - HELP! <mtaylorlrim@my-deja.com>
    Re: Removing line breaks from a string - HELP! (Clay Irving)
    Re: Rijndael in Perl (Rob Warnock)
        Simple Query Function Help Please! jxavier@jxavier.vservers.com
    Re: Simple Query Function Help Please! (Gwyn Judd)
    Re: Simple Query Function Help Please! (Clay Irving)
    Re: SSI and Perl <david.scally@scallynet.co.uk>
        Syndicator Script NEED SERIOUS HELP ! <pj.dewerk@colorguard.org>
    Re: Upload binary file problem! <cheesy@upb.de>
        xcopy a directory tree <jvm@ysabel.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 21 Oct 2000 10:22:05 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage972123846.12112@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: 21 Oct 2000 07:54:47 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Boolean query to Perl regexp match conversion
Message-Id: <39f1a027@cs.colorado.edu>

[A CC of this public Usenet posting was also mailed to the to the
cited author.]

In article <39F02F35.2D659F34@ocegr.fr>,
Stephane Barizien  <sba@ocegr.fr> wrote:
>Hi all,
>I'm looking for a way to convert a "search engine style" boolean query
>like
>
>(foo OR bar) AND blah* AND kernel
>
>into a (set of) equivalent Perl regexp matching operation(s) (assuming
>the entire text to run the query against is in a single
>multiline-thus-with-embedded-newlines Perl $str)
>
>Any clue?

Although there are complex solutions, such as somehow converting
that into

    (?sm)(?=.*foo|bar)(?=.*blah)(?.*kernel)

No one has to date suggested the simplest solution of all.  It's
sort of an Occam's Razor approach, one often favored by Larry, so
we'll call it Larry's Razor.  Just use Perl as the input.  In short,
just require that

    (foo OR bar) AND blah* AND kernel

be typed in with slashes as quote delimiters, yielding 

    (/foo/ or /bar/) and /blah*/ and /kernel/

which you are then free to compile as is.  Benefits of this approach
are many and strong, so you should not automatically disregard it.

Here are just a few.

You don't have to devise your own quoting and meta-quoting syntax,
then educate your users as to how to employ it.  You do not have
to do any tricky parsing involving checking for legality of the
pattern or the connectives and parethesization; in fact, you do
know parsing whatsoever, which considering that this is the hard
part, should be an incredibly welcome relief.  You can rely upon
Perl to do all the hard work, which is as it should be.

I don't pretend to be ignorant of other issues, but I think you'll
find that even despite them, this solution is so incredibly powerful
and startlingly simple as to merit serious consideration, both here
and in many other places.

--tom


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

Date: 21 Oct 2000 15:03:45 GMT
From: Michael Hoffman <mrh@panix.com>
Subject: Re: Dynamic Regex building?
Message-Id: <8ssb8h$8e1$1@news.panix.com>


You know, while searching for an answer on this forum, I noticed that people
don't seem to like you.  Now I know why!  You yell at people for not providing
enough information, so when I do, you yell at me for providing too much.  You
cant' have it both ways.

As to your "answer", did you even bother to read the end of the post?  
Obviously not, or else you would have seen the following:
> Lets say I want to add 3 new fields between the 2nd and 3rd field.
> $orig = ^([^\|]*)\|([^\|]*)\|([^\|]*)\|$
> $repl = $1|$2||||$3|
>
> Given Data like:  Hi|Hello|Howdy|
> I am returned:    $1|$2||||$3|

I believe that is what your "print" statement would provide, no?

Michael Hoffman




In <39F0CD93.144D3AAF@stomp.stomp.tokyo> article, Godzilla! mentioned that:
: Michael Hoffman wrote:

: (snipped 3,591,274 lines of unrelated comments and code)

:>    $in=~ s/$orig/$repl/;      # SOMETHING WRONG HERE!!  BUT WHAT???

: Why don't you print each of those variables before
: your substitution and find out what is wrong?

: print " IN: $in\n ORIG: $orig\n REPL: $repl\n\n";

: Of course this code snippet is extremely complex
: and difficult to understand. Nonetheless, I am
: certain you will figure out how to use this code.

: Godzilla!


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

Date: Sat, 21 Oct 2000 15:06:19 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: EOF character in middle of file?
Message-Id: <Pine.GHP.4.21.0010211457190.10068-100000@hpplus03.cern.ch>

On Sat, 21 Oct 2000 erion3457@my-deja.com wrote:

> I assumed that, since we're reading the file in binary mode, the input
> record separator would be "\015\012" [to match the actual physical
> contents of the file]. 

The point of a binary file is that it has no semantics as regards
record structure, and it would (speaking in general terms) be abnormal
to want to read it in a record-oriented fashion.  If you want to read
text records then (other things being equal) text mode would be the
appropriate way of doing it.

Sometimes it may be appropriate to treat a record-structured file in
binary mode, but then it's up to you to know what you're doing, and
express it clearly in your code. Leaving it to Perl to take care of
something that isn't well-defined and hoping it will DWIM is asking
too much, IMHO.

> If it were, chomp should take off the "\015\012" and it doesn't.  A
> pointer to some documentation that would explain where my thinking
> process has gone wrong would be most appreciated.

perldoc perlport is at least a starting point for this kind of issue.

Keep in mind that there are basically two different classes of
problem: 1 - writing portable code that will run on any platform and
read records that are native to that platform, and 2 - writing code
that will run on a specific platform but can also handle records that
come from any (other) platform.  For bonus points, write code that can
do both (there's some ideas in CGI.pm for example).

good luck



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

Date: Sun, 22 Oct 2000 00:46:23 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: EOF character in middle of file?
Message-Id: <slrn8v37hf.fji.mgjv@martien.heliotrope.home>

On Sat, 21 Oct 2000 15:06:19 +0200,
	Alan J. Flavell <flavell@mail.cern.ch> wrote:
> On Sat, 21 Oct 2000 erion3457@my-deja.com wrote:
> 
> > I assumed that, since we're reading the file in binary mode, the input
> > record separator would be "\015\012" [to match the actual physical
> > contents of the file]. 
> 
> The point of a binary file is that it has no semantics as regards
> record structure, and it would (speaking in general terms) be abnormal
> to want to read it in a record-oriented fashion.  If you want to read
> text records then (other things being equal) text mode would be the
> appropriate way of doing it.

I don't think you mean it to sound quite as strict as you make it sound.
I have quite some code (mainly C) that writes and reads binary files
based on record structures. It is true that binary files have no
_inherent_ record structure, like a text file does have, but that does
not preclude the programmer from organising a binary file based on
records. Of course, normally those records would be of fixed length, but
even that isn't necessary. One could write a length specifier in the
file before a record of variable length.

But yes, and I think this is what you meant to say, the programmer is
totally responsible for making a binary file structured. A text file is
structured by nature, albeit only loosely.

> problem: 1 - writing portable code that will run on any platform and
> read records that are native to that platform, and 2 - writing code
> that will run on a specific platform but can also handle records that
> come from any (other) platform.  For bonus points, write code that can
> do both (there's some ideas in CGI.pm for example).

Many open data formats do the same, both in text and binary. XML is a
good example of a text based format, and PNG one of a binary
transportable format. 

I know that you know all this. I just wanted to add my 2 cents.

Martien

PS. Text formats are ALWAYS preferable. ALWAYS. Unless you know why you
need a binary format.
-- 
Martien Verbruggen              | 
Interactive Media Division      | System Administration is a dirty
Commercial Dynamics Pty. Ltd.   | job, but someone said I have to do
NSW, Australia                  | it.


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

Date: Sat, 21 Oct 2000 13:27:49 GMT
From: nospamapgraham@ispchannel.com--- (Al)
Subject: Re: How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
Message-Id: <39f198c7.209315921@news.ispchannel.com>

On Fri, 20 Oct 2000 02:33:22 +0100, James Taylor
<james@NOSPAM.demon.co.uk> wrote:

>In article <MPG.145a58264869091898982d@localhost>, jason
><URL:mailto:elephant@squirrelgroup.com> wrote:
>> lynton@iname.com wrote ..
>> >How to turn '<br><br>' or '<br><br><br>' into '<br>'  ?
>> >
>> >s/(<br>)+/<br>/gs; won't work
>> 
>> yes it does (although it should be added that both the
>> 'g' and 's' modifiers are not required
>
>Perhaps he just needs to include the possibility of whitespace
>between each <br> tag. He might also wish to cope with
>attributes of the <br> tag. For example:
>
>    s/(<br[^>]*>\s*)+/<br>/;

And, to throw another wrench in the works, in proper XHTML the break
is written thusly: <br />

-Al-





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

Date: Sun, 22 Oct 2000 01:14:27 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How to turn '<br><br>' or '<br><br><br>' into '<br>' ?
Message-Id: <slrn8v3963.fji.mgjv@martien.heliotrope.home>

On Sat, 21 Oct 2000 13:27:49 GMT,
	Al <nospamapgraham@ispchannel.com---> wrote:
> On Fri, 20 Oct 2000 02:33:22 +0100, James Taylor
> <james@NOSPAM.demon.co.uk> wrote:
> 
> >In article <MPG.145a58264869091898982d@localhost>, jason
> ><URL:mailto:elephant@squirrelgroup.com> wrote:
> >> lynton@iname.com wrote ..
> >> >How to turn '<br><br>' or '<br><br><br>' into '<br>'  ?
> >> >
> >> >s/(<br>)+/<br>/gs; won't work
> >> 
> >> yes it does (although it should be added that both the
> >> 'g' and 's' modifiers are not required
> >
> >Perhaps he just needs to include the possibility of whitespace
> >between each <br> tag. He might also wish to cope with
> >attributes of the <br> tag. For example:
> >
> >    s/(<br[^>]*>\s*)+/<br>/;
> 
> And, to throw another wrench in the works, in proper XHTML the break
> is written thusly: <br />

To summarise, hopefully finally:

If you don't mind the format of the remaining <br>, this will preserve
the last in a sequence, and it will preserve any trailing whitespace. It
is case-insensitive, and takes into account that a br can contain
attributes, and can either be written as <br> or <br/> 

s#(?:<br[^>]*>\s*)+(?=<br[^>]*>)##ig;

I do not take the equally valid XML notation of <br></br> into
account, since I don't know whether it's part of XHTML. If it is, add a
/? in the two appropriate places.

If you do care about the format of the remaining one, do:

#(?:<br[^>]*>\s*)*(?:<br[^>]*>)#<br/>#ig;

(Note the * instead of the +. We also will replace single instances of
<br>)

If you don't care about whitespace following the last matched <br> you
can simplify this to:

s#(?:<br[^>]*>\s*)+#<br/>#ig;

neither of these will preserve attributes of any of the breaks. This can
result in unwanted behaviour (think of clear attributes that get lost),
but is impossible to prevent with a simple-minded approach like this. If
you want to keep the same behaviour of the combined <br> tags (apart
from the multiple line breaks it introduces) you will need to write a
real parser, and collate the combined attributes into one <br>.

And we haven't even talked about the fact that you cannot parse HTML
with regular expressions :)

Now, let's hope I didn't forget anything.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd.   | Then things get worse.
NSW, Australia                  | 


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

Date: Sat, 21 Oct 2000 16:49:48 +0200
From: "Eldy" <eldy@ifrance.com>
Subject: Looking for source of function to read/write config files
Message-Id: <8ssad3$3in$1@wanadoo.fr>

I'm looking for the source of a function to read/write parameters in a
config file,
just like GetProfileString/WriteProfileSting in C++.
I want this function to have only 2 or 3 parameters:
Name of variable
Value

This is to enhance AWStats perl log file analyzer.
http://perso.wanadoo.fr/l.destailleur/awstats.html

Thanks to who can avoid me writing such function.

Laurent Destailleur.





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

Date: 21 Oct 2000 15:03:38 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Looking for source of function to read/write config files
Message-Id: <slrn8v3c29.vb.clay@panix2.panix.com>

On Sat, 21 Oct 2000 16:49:48 +0200, Eldy <eldy@ifrance.com> wrote:

>I'm looking for the source of a function to read/write parameters in a
>config file,
>just like GetProfileString/WriteProfileSting in C++.
>I want this function to have only 2 or 3 parameters:
>Name of variable
>Value
>
>This is to enhance AWStats perl log file analyzer.
>http://perso.wanadoo.fr/l.destailleur/awstats.html
>
>Thanks to who can avoid me writing such function.

Something like:

  ConfigFile.pm

The POD is found at:

  http://www.biostat.wisc.edu/~annis/creations/ConfigFile.pm.html

Homepage is:

  http://www.biostat.wisc.edu/~annis/creations/ConfigFile.html

-- 
Clay Irving <clay@panix.com>
Everything has a boolean value, if you stand far enough away from it. 
- Galena Alyson Canada 


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

Date: Sun, 22 Oct 2000 01:15:12 +1000
From: Marc Fearby <marc@fearby.com>
Subject: Perl 5.005 or 5.6?
Message-Id: <39F1B300.2E61F2EF@fearby.com>

What is the main benefit of upgrading to 5.6? I've heard a few people
saying that 5.6 is pretty buggy. My personal experience with 5.6 is that
half of the modules I want to use aren't available for it.

Should I stick with 5.005 (on Windows: ActivePerl 522) or upgrade to
5.6 and just deal with all the problems?

The Perl re-write that's supposed to be going on - will that be Perl 6?
If so, would it be better to wait for that instead?


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

Date: Sat, 21 Oct 2000 10:28:36 GMT
From: burt@ici.net (Burt Lewis)
Subject: Problem getting hostname
Message-Id: <odeI5.69236$tn.1356935@typhoon.ne.mediaone.net>

This use to work great until my ISP changed their operating system and probably 
took out dns reverse lookups or whatever they did.

Now this returns only the IP.

I also can't retreive: HTTP_REFERER

They use the latest apache with a solaris operating system.

Appreciate any ideas on how I can get the user hostname now.



@numbers = split(/\./, $ENV{'REMOTE_ADDR'}); # make 4-element array out of IP
     $ip_number = pack("C4", @numbers);           # mangle
     ($i) = (gethostbyaddr($ip_number, 3))[0];    # and look up

print MAINLOG "Host: $ENV{'REMOTE_HOST'}\n";
print MAINLOG "Addr: $ENV{'REMOTE_ADDR'}\n";
print MAINLOG "Actual: $i\n";

Burt Lewis
burt@ici.net



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

Date: Sun, 22 Oct 2000 00:57:43 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Problem getting hostname
Message-Id: <slrn8v386n.fji.mgjv@martien.heliotrope.home>

On Sat, 21 Oct 2000 10:28:36 GMT,
	Burt Lewis <burt@ici.net> wrote:

> This use to work great until my ISP changed their operating system and
> probably took out dns reverse lookups or whatever they did.
> 
> Now this returns only the IP.

'this'? what?

> I also can't retreive: HTTP_REFERER

Talk to your ISP about why HTTP_REFERER isn't set. I don't know why you
want it anyway, but it should be a fairly standard thing. The server
should just pass on whatever the browser says, whether that's a lie or
not. if it isn't set, there is nothing in Perl that you can do to get
it.

> They use the latest apache with a solaris operating system.

Apache, by default, should set that environment variable. If it doesn't,
they've fiddled with the config. Ask them about it.

> Appreciate any ideas on how I can get the user hostname now.

Just hostname, you mean, right?

> @numbers = split(/\./, $ENV{'REMOTE_ADDR'}); # make 4-element array out of IP
>      $ip_number = pack("C4", @numbers);           # mangle
>      ($i) = (gethostbyaddr($ip_number, 3))[0];    # and look up

The documentation describes a better way to do this. But it should
basically be right. I haven't used pack/unpack for inet addresses for
yonks.

> print MAINLOG "Host: $ENV{'REMOTE_HOST'}\n";
> print MAINLOG "Addr: $ENV{'REMOTE_ADDR'}\n";
> print MAINLOG "Actual: $i\n";

Ask your ISP to turn Reverse lookups back on, if you really MUST have
the host names. it is more efficient to do it in the web server than in
individual CGI programs. If they don't want to do it, and you are still
certain you absolutely NEED hostnames, use gethostby*, as you already
seem to know.

# perldoc -f gethostbyaddr

use Socket;
$iaddr = inet_aton($ENV{REMOTE_ADDR});
$name  = gethostbyaddr($iaddr, AF_INET);

Don't hardcode constants like AF_INET.

Be aware that there are severe performance penalties to pay for reverse
hostname lookups, which is why every single web server that I know of
has it switched off. It may very well be that your ISP has done
something to stop this from working, but I don't know.

You really should talk to your ISP about this. They could get very upset
when they find out that you're loading their DNS servers with this, when
they specifically switched it off.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.   | enough features yet.
NSW, Australia                  | 


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

Date: Sat, 21 Oct 2000 15:11:24 +0100
From: "AndyUK" <andy@andyuk.net>
Subject: Removing line breaks from a string - HELP!
Message-Id: <dlhI5.2297$Ms3.120581@stones>

How to i remove a line break from a string and replace it with a <br> tag?

I have tried several things like:

$mystring=~s/\n/<br>/g;

but this doesn't work.
Is /n the new line character what i am looking for? Or is it to do with
ASCII characters or something?


Thanks,

Andy




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

Date: Sat, 21 Oct 2000 14:32:59 GMT
From: Mark <mtaylorlrim@my-deja.com>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <8ss9er$6m3$1@nnrp1.deja.com>

Have you tried..

$mystring =~ s/\n/\<BR\>/g;


Just a thought...someone else will probably give you something better.

Mark



In article <dlhI5.2297$Ms3.120581@stones>,
  "AndyUK" <andy@andyuk.net> wrote:
> How to i remove a line break from a string and replace it with a <br>
tag?
>
> I have tried several things like:
>
> $mystring=~s/\n/<br>/g;
>
> but this doesn't work.
> Is /n the new line character what i am looking for? Or is it to do
with
> ASCII characters or something?
>
> Thanks,
>
> Andy
>
>

--
Please reply to this newsgroup as my Deja mail
is used as a spam catcher only!


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


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

Date: 21 Oct 2000 14:43:03 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <slrn8v3arn.smc.clay@panix2.panix.com>

On Sat, 21 Oct 2000 15:11:24 +0100, AndyUK <andy@andyuk.net> wrote:

>How to i remove a line break from a string and replace it with a <br> tag?
>
>I have tried several things like:
>
>$mystring=~s/\n/<br>/g;
>
>but this doesn't work.

Yes it does:

  #!/usr/bin/perl -w
  
  $mystring = "It works fine...\n";
  
  print "$mystring";
  
  $mystring=~s/\n/<br>/g;
  
  print "$mystring";

Result:

  It works fine...
  It works fine...<br>

-- 
Clay Irving <clay@panix.com>
Politics is the entertainment branch of industry. 
- Frank Zappa 


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

Date: 21 Oct 2000 09:12:19 GMT
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Subject: Re: Rijndael in Perl
Message-Id: <8srmlj$a1g3$1@fido.engr.sgi.com>

Runu Knips  <runu.knips@gmx.de> wrote:
+---------------
| > attacker looks at what's "left behind" (tempfiles, diskswapping...).
| 
| Is it actually possible with Windows or Linux to get memory which isn't
| swappable ? As an ordinary user process, or as a administrator process ?
+---------------

Most Unixes -- e.g., Linux, FreeBSD, SGI's Irix, many others -- have
"mlock(2)" or "mpin(2)" or "plock(2) or something similar [Irix has
all three!]:

  NAME
     mlock, munlock - lock or unlock pages in memory

  SYNOPSIS
     #include <sys/types.h>
     #include <sys/mman.h>

     int mlock(const void *addr, size_t len);
     int munlock(const void *addr, size_t len);

  DESCRIPTION
     mlock locks the pages associated with the address range (addr, addr +
     len) into memory.  The super-user can lock as many pages as it wishes,
     other users are limited to a per process maximum {PLOCK_MAX}.
     ...

Dunno 'bout Windows, though...


-Rob

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
Network Engineering		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043


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

Date: Sat, 21 Oct 2000 11:04:30 GMT
From: jxavier@jxavier.vservers.com
Subject: Simple Query Function Help Please!
Message-Id: <39f17831.65026352@news.lightrealm.com>

Still new to perl so trying to find out what I did wrong here,  am
just trying to do a simple query that only takes Y or y for an answer.

Here's my screw up:


{
$quest = &query("Would you like to continue?",Y)
}
if ($quest=yY)   {
	&newsubroutine
} else {
print "! 400 Stopping Here\n";
}


Can someone Please tell me where I messed up on this??


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

Date: Sat, 21 Oct 2000 12:02:26 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Simple Query Function Help Please!
Message-Id: <slrn8v31ee.jia.tjla@thislove.dyndns.org>

I was shocked! How could jxavier@jxavier.vservers.com
<jxavier@jxavier.vservers.com> say such a terrible thing:
>Still new to perl so trying to find out what I did wrong here,  am
>just trying to do a simple query that only takes Y or y for an answer.

I take it, you mean to query the user in some way, to which they will
respond with either a 'Y' or a 'y'?

>Here's my screw up:
>
>{
>$quest = &query("Would you like to continue?",Y)
                                              ^^^
>}

hmmm. What's that 'Y' thing out there all on it's lonesome? Is that
supposed to be some sort of default return value for the query string?
If so then you really need to put it in quotes:

$quest = &query('Would you like to continue?','Y');

Note that in this case you are alright using single quotes (') as
opposed to double quotes (").

>if ($quest=yY)   {

ick. This is totally wrong :). I suggest this:

if (lc $query eq 'y') {

The 'lc' bit lowercases it's input. You then compare it to the literal
'y' with the 'eq' operator. What you have done is assigned $quest the
value 'yY' (assuming this code compiles at all, see later).

>	&newsubroutine
>} else {
>print "! 400 Stopping Here\n";
>}

Something that is very much recommended if you are going to post here is
the following two things:

#!/usr/bin/perl -w

The '-w' here will enable all compiler warnings, which is a good thing.

Then on the second line:

use strict;

This will tighten up the compiler and restrict you from using certain
dangerous constructs, such as the bareword you used up there in the if
statement and in the function call. It will also require you to declare
all your variables, which you can generally do using:

my $quest;

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I came to MIT to get an education for myself and a diploma for my mother.


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

Date: 21 Oct 2000 12:37:51 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Simple Query Function Help Please!
Message-Id: <slrn8v33gv.ft5.clay@panix2.panix.com>

On Sat, 21 Oct 2000 11:04:30 GMT, jxavier@jxavier.vservers.com 
<jxavier@jxavier.vservers.com> wrote:

>Still new to perl so trying to find out what I did wrong here,  am
>just trying to do a simple query that only takes Y or y for an answer.
>
>Here's my screw up:
>
>
>{
>$quest = &query("Would you like to continue?",Y)
>}

You forgot to terminate the line, and why do you have the line above enclosed 
in {}?

Assuming your query subroutine does the Right Thing(tm) -- which by the way,
it doesn't look correct because you are passing the subroutine two parameters,
"Would you like to continue?" and Y -- Here is a problem:

>if ($quest=yY)   {

Obviously, you didn't enable warning with:

  #!/usr/local/bin/perl -w

If you did, and you had a bit of code like this:

  #!/usr/local/bin/perl -w
  
  $quest = "N";
  
  if ($quest=Y) {
     print "This always works!\n";
  }

You would find the result to be:

  Found = in conditional, should be == at ./foo.pl line 5.
  This always works!

It always works because you assigned Y to $quest and the assignment returns
true. Correct code would be:

  #!/usr/local/bin/perl -w

  $quest = "N";

  if ($quest eq "Y") {
     print "This always works!\n";
  }

You must use the "eq" equality operator to compare strings. The "==" 
equality operator is used to compare numbers.

>	&newsubroutine

You forgot to terminate the line.

>} else {
>print "! 400 Stopping Here\n";
>}


-- 
Clay Irving <clay@panix.com>
PROVIDENTIAL, adj. Unexpectedly and conspicuously beneficial to the person
so describing it. 
- Ambrose Bierce 


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

Date: Sat, 21 Oct 2000 13:51:51 +0100
From: "David Scally" <david.scally@scallynet.co.uk>
Subject: Re: SSI and Perl
Message-Id: <8ss3mq$l9j$1@gxsn.com>

mmm, I see what you mean about just printing it in Perl, but it doesn't
work:
 print qq| <include virtual="header.inc"> |;

Isn't there some sort of script that processes SSI into a Perl subroutine???

Scall




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

Date: Sat, 21 Oct 2000 12:31:50 GMT
From: "Peter Jan de Werk - CGN" <pj.dewerk@colorguard.org>
Subject: Syndicator Script NEED SERIOUS HELP !
Message-Id: <W0gI5.276$iF1.3617@typhoon.bart.nl>


> Hey,
>
> Who knows of a (free) syndicator script to let my sites visitors place my
> content on their site ? Who can help ?
>
> Peter
>
> --
> Color Guard Nederland
> www.colorguard.org
>
> WGI European Regional
> www.wgieurope.org
>
>
>
>
>
>
>
>
>




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

Date: Sat, 21 Oct 2000 14:56:58 +0200
From: "Bjoern Kaiser" <cheesy@upb.de>
Subject: Re: Upload binary file problem!
Message-Id: <8ss3s2$v2d$03$1@news.t-online.com>

I've got a similar Problem.
This is the script:

use Net::FTP;
 $user="User";
 $pass="something";
 $ftp="ftp.tripod.com";
       $conn = new Net::FTP($ftp);
       $conn->login($user, $pass);
       $conn->put("index.html");
       $conn->type(binary);
       $conn->put("picture.jpg"); # the file ist about 80 kb, but he stops
after 1kb ?????? WHY ?????
       $conn->close();
       $conn->quit();


"Drew Simonis" <dsimonis@fiderus.com> schrieb im Newsbeitrag
news:39F0915B.644F97BF@fiderus.com...
> Aleksey Agafonov wrote:
> >
> > Dear sirs!
> > I have a small problem with binary file upload from html form in web
server.
> > Russian web-server Appach decode my binary file as text. My binary file
> > uploaded but not right. I read the FAQ but nothing understand. And FAQ
> > example not work also! Please help me. Send my mail on
> > Aleksey.Agafonov@mtu-net.ru
> > Thank you!
>
> Have you told the script that the file is binary?




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

Date: Sat, 21 Oct 2000 16:26:15 +0200
From: Jan van Mansum <jvm@ysabel.net>
Subject: xcopy a directory tree
Message-Id: <39F1A787.460FB15C@y.com>

Hello group,

I want to copy a whole directory tree from a given base directory
downward. Is there a function in some standard module that will do that
for me? Or is it even a language feature? If neither of these, can
someone tell me how I create a directory with Perl (on the Win32
platform)?

Thanks for an answer to any of the above questions.

Regards,

Jan van Mansum



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

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


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