[6484] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 108 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 13 11:17:16 1997

Date: Thu, 13 Mar 97 08:00:39 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 13 Mar 1997     Volume: 8 Number: 108

Today's topics:
     Re: "my" all vars in eval() ?? (Andrew M. Langmead)
     Re: Am I hosed? (Can't compile modules) (I R A Aggie)
     Re: Basic I/O and 'if vs unless' questions <rra@cs.stanford.edu>
     Re: Elegant way to strip spaces off the ^ and $ of a va <rra@cs.stanford.edu>
     Re: Elegant way to strip spaces off the ^ and $ of a va (Dave Thomas)
     Re: exec & nohup <roderick@argon.org>
     Re: Field Separators <flavell@mail.cern.ch>
     File path separators (Johannes Baagoe)
     Re: File path separators (Johannes Baagoe)
     Re: getting system date on NT? <flg@vhojd.skovde.se>
     Re: help with printing to a socket (Rachel Polanskis)
     Hiding input in msdos perl <x741056@tiuk.ti.com>
     Re: how do i read "man page" of a module on a PC? lvirden@cas.org
     Re: how do i read "man page" of a module on a PC? (Bob Wilkinson)
     how to delete last line in .txt.file (Tom Boeken)
     Re: how to delete last line in .txt.file (Honza Pazdziora)
     Re: how to delete last line in .txt.file <tchrist@mox.perl.com>
     Re: how to delete last line in .txt.file <tchrist@mox.perl.com>
     How to strip newlines from string <skbohler@ix.netcom.com>
     Re: How to strip newlines from string <tchrist@mox.perl.com>
     Re: html embedding <rra@cs.stanford.edu>
     irc bots in perl <metalhead@mhv.net>
     Re: Looking for non-Unix Perl book (John Goerzen)
     Re: MacPerl5 (Chris Nandor)
     Mail an attatchment with Perl (Cheng Tyh Lin)
     Re: Numeric function (Honza Pazdziora)
     Re: Numeric function <tchrist@mox.perl.com>
     Re: Numeric function (Lack Mr G M)
     Re: password entries <dehon_olivier@jpmorgan.com>
     Re: Perl FAQ part 8 of 0..9: System Interaction [Period <roderick@argon.org>
     Perl for WIN32 Perl 1.001m and 1.003 version sure enoug <JeanPhilippe.Amiel@alcatel.titn.fr>
     Question regarding File::Copy (Fairey Simon)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 13 Mar 1997 14:20:56 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: "my" all vars in eval() ??
Message-Id: <E6zJuw.B29@world.std.com>

Matt Kruse <mkruse@shamu.netexpress.net> writes:

>Let's say I want to get a perl expression from the user and execute it.  
>But I don't want to have any variables in the eval() run into my own.  
>What's the best way to do this?

Use the Safe.pm module that comes with the perl distribution. A Safe
compartment has its own package (namespace) and prevents code from
refering to to other Packages.

-- 
Andrew Langmead


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

Date: Wed, 12 Mar 1997 17:57:35 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Am I hosed? (Can't compile modules)
Message-Id: <fl_aggie-ya02408000R1203971757350001@news.fsu.edu>

In article <3326f837.0@news.together.net>, webmaster@metacraft.com (Ross
Carlson) wrote:

+ As a result, I have no compiler! (ARGH)
 
+ Lately I have been trying to make use of some of the 
+ perl modules on CPAN, and it seems that they need to
+ be compiled. Am I hosed?

'fraid so.

+ Anyway, the SGI is an Indy, running IRIX 5.3, and my 
+ perl interpreter is versino 5.001. Some kind soul on this
+ newsgroup sent me that binary a few months ago.

One of the SGI guys (Scott Henry, I think) has put together an
'inst'able perl package. You can download it off the net, but
I'm not sure were.

It's also on the SGI Freeware CD, which AFAIK is freely distributable
pre-compiled freeware packages. Hmmm...I've looked at that CD, and
I could have sworn there was a gcc package...yep, gcc and a fairly
complete line of GNUware.

But I don't know if they're compatible with your system, tho.

James

-- 
Consulting Minster for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 13 Mar 1997 07:13:35 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: chris.starkey@3dlabs.com (Chris Starkey)
Subject: Re: Basic I/O and 'if vs unless' questions
Message-Id: <qumlo7rrfj4.fsf@cyclone.stanford.edu>

[ Posted and mailed. ]

Chris Starkey <chris.starkey@3dlabs.com> writes:

> My first question is: why does the unless statement work, when I had
> 'if (system ("ping $name 2")) it didn't execute the 'rsh' section?

>                 unless (system ("ping $name 2")) {
>                         system ("rsh $name uname -a");
>                         }

Because, due to a design decision made eons ago, Unix commands return 0 if
they succeed and non-zero on failure.  The C library call system()
preserves this behavior, which is then preserved by Perl.  So system() in
Perl will return 0 (false) if the command succeeded and non-zero (true) if
it failed.

> My second question is: why when I run the script file and redirect the
> STDOUT to a file (ie ./my_script > my_script.out) isn't the "Checking
> $name" printed to the file?

Whenever you're getting things printing from multiple sources (for
example, your script printing to STDOUT as well as programs called via
system() printing to STDOUT), make sure to unbuffer STDOUT or things will
show up in the wrong order.  Try adding:

	$| = 1;

to the beginning of your program and see if that solves the problem.

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: 13 Mar 1997 07:08:45 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: greg@bic.mni.mcgill.ca (Greg Ward)
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <qumpvx3rfr6.fsf@cyclone.stanford.edu>

Greg Ward <greg@bic.mni.mcgill.ca> writes:

> How about this:

> $variable =~ s/^\s*//;
> $variable =~ s/\s*$//;

Use + instead of * for a (very) slight speed increase (no need to replace
the null string).

> I've always been slightly irked that you can't do this in one pass, but
> it's still pretty darn simple and elegant.

You can do it in one pass.  It's just slow.

	$variable =~ s/^\s+(.*?)\s+$/$1/;

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: 13 Mar 1997 14:28:33 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Elegant way to strip spaces off the ^ and $ of a variable containing a sentence.
Message-Id: <slrn5ig3i8.tjv.dave@fast.thomases.com>

On 13 Mar 1997 05:03:07 GMT, Tom Christiansen wrote:

> In comp.lang.perl.misc, abigail@ny.fnx.com writes:
>
> :map {s/^\s+//; s/\s+$//;} $variable;
>
> No, that's a bad way.  You ignored the return value of the
> function.

No, its just _another_ way.

Maybe its the stress of getting 5.004 out, but the general level of
tolerance and politeness in this group seems to have taken a nose dive
recently.

Come on, folks - this group used to be one of the most supportive and
positive on the net. Lets not sour it with pedantry.

Dave




-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 13 Mar 1997 09:56:11 -0500
From: Roderick Schertler <roderick@argon.org>
To: Greg Sinclair <gjsincla@tddcae99.fnts.com>
Subject: Re: exec & nohup
Message-Id: <pz7mjbu9pm.fsf@eeyore.ibcinc.com>

On Wed, 12 Mar 1997 09:27:22 -0600, Greg Sinclair <gjsincla@tddcae99.fnts.com> said:
> 
> does exec work like 'nohup' in that the executed process/program will
> continue running even if the terminal or session is closed?

Nope.

> i am seeing this behaviour, but have not seen any documentation
> describing this type of a situation.

Try to pare your code down to the smallest self-contained test case
which will still give you this behavior, then post that test case.  Let
us know how the terminal session is being closed, and what sort of
session it is (telnet, rlogin, directly connected serial line, ssh,
 ...).

At the very least show us the original code and tell us the operating
system and version of perl that you're using.

-- 
Roderick Schertler
roderick@argon.org


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

Date: Thu, 13 Mar 1997 13:43:35 GMT
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Field Separators
Message-Id: <Pine.HPP.3.95a.970313144251.16770E-100000@hpplus05.cern.ch>

On 12 Mar 1997, Tom Christiansen wrote:

> :Because $\ is the output record seperator.  $/ is the input seperator,
> :aliased to $INPUT_RECORD_SEPERATOR when you "use English;".
> 
> Um, no it's not.  It's aliased to $INPUT_RECORD_SEPARATOR in English,

Right - that was a perity error.




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

Date: Thu, 13 Mar 1997 13:34:33 +0100
From: jbaagoe@planete.net (Johannes Baagoe)
Subject: File path separators
Message-Id: <19970313133433740408@mar1-03.planete.net>

>From File::Basename.pm, and the Camel book (2nd. ed) p. 437:

> You are guaranteed that if you concatenate path, name, and suffix together
> in that order, the result will be identical to the input file
> specification.
> 
> EXAMPLES
> 
> Using UNIX file syntax:
> 
>     ($base,$path,$type) = fileparse('/virgil/aeneid/draft.book7', 
>                                   '\.book\d+');
> 
> would yield
> 
>     $base eq 'draft'
>     $path eq '/virgil/aeneid',
>     $tail eq '.book7'

In this were the case, concatenating $path, $base and $tail would yield
'/virgil/aeneiddraft.book7'. As it happens, 
-- 
Johannes
                Nous aurons iti loin dans la prospiriti
                Lorsque peu auront trop, et aucun pas assez
                                N. F. S. Grundtvig, 1783-1872


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

Date: Thu, 13 Mar 1997 15:47:16 +0100
From: jbaagoe@planete.net (Johannes Baagoe)
Subject: Re: File path separators
Message-Id: <199703131547161214833@mar1-03.planete.net>

Johannes Baagoe <jbaagoe@planete.net> wrote:

> From File::Basename.pm, and the Camel book (2nd. ed) p. 437:
> 
> > You are guaranteed that if you concatenate path, name, and suffix together
> > in that order, the result will be identical to the input file
> > specification.
> > 
> > EXAMPLES
> > 
> > Using UNIX file syntax:
> > 
> >     ($base,$path,$type) = fileparse('/virgil/aeneid/draft.book7', 
> >                                   '\.book\d+');
> > 
> > would yield
> > 
> >     $base eq 'draft'
> >     $path eq '/virgil/aeneid',
> >     $tail eq '.book7'
> 
> In this were the case, concatenating $path, $base and $tail would yield
> '/virgil/aeneiddraft.book7'. As it happens, 

Oops, sorry - I went out to lunch, and somebody else used my computer
and posted my unfinished message.

Anyway:

Unless I miss something, $path should be '/virgil/aeneid/', with a
trailing slash. The comments in the source gets it right, the "official"
documentation is wrong.

But that mistake makes me wonder whether there are any clear rules for
directory paths - do they or don't they end with a separator? on
Unix-like systems? MS-DOS? MacOs? VMS? OS2? etc.

Further: Is there a standard, portable way to concatenate a directory
path and a filename to get a full path? We need this whenever we want to
open a file we found with a readdir whithout chdir-ing, and while most
sources I have seen simply say someting like $path = "$dir/$file", this
is 1. Unix-dependent, 2. wrong if $dir already contains a trailing
slash.

Would it be a good idea to include a routine that does this in
File::Basename? I could attempt to write one for the architectures
already provided for (Unix, MS-DOS, MacOS and VMS) by inspecting the
existing source and assuming it is right, but I have no way to test on
VMS. Is it worth the trouble? Has somebody else already done it?

-- 
Johannes



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

Date: Thu, 13 Mar 1997 08:23:58 +0100
From: Fredrik Lindberg <flg@vhojd.skovde.se>
To: cwyatt@cris.com
Subject: Re: getting system date on NT?
Message-Id: <3327AB8E.1906@vhojd.skovde.se>

Chuck Wyatt wrote:
> I'm familiar with how one might assign the system date to a variable
> when programming Perl on a UNIX system.
> 
> eg:
> $date= `/bin/date "+%D %r"`;
> 
> However, it isn't clear to me how to do this in a Windows NT
> environment.

You dont need to execute an external process to obtain the date
and time in Perl. Try this for any system:

#!/usr/bin/perl
#
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =
      localtime(time);

printf("Date is %02d-%02d-%02d and time is %02d:%02d:%02d\n",
        $year, $mon+1, $mday, $hour, $min, $sec);

# Note $mon+1  ^^^^^
__END__

Check out time and localtime in the perlfunc man pages!

Hope this helps

/Fredrik


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

Date: 12 Mar 1997 11:31:26 GMT
From: rachel@virago.org.au (Rachel Polanskis)
Subject: Re: help with printing to a socket
Message-Id: <5g646e$jpp@janis.virago.org.au>

In article <5g3u5r$rkl@fridge-nf0.shore.net>,
	nvp@shore.net (Nathan V. Patwardhan) writes:
> Nathan V. Patwardhan (nvp@shore.net) wrote:
>: Rachel Polanskis (rachel@virago.org.au) wrote:
> 
>: : When I run my script below, on port 7 (echo) I expected it
>: : to return whatever I print out.
> 
>: Are you root?  
> 
> OOPS.  Sorry to follow-up on my own posting, but the reason I asked if
> you were root is because I wondered info you had also written a server
> that was attempting to run on port 7, and thus would be a problem.  
> 
> Sorry for the lunacy.  I'm going to get my first cup of coffee - now :-)
Sounds good.  I have to have decaf now, but the effect is the same...

I don't normally followup to my own posts, but I thought it
best to share my solution with the rest of the group...

My problem seemed to be not calling select() first then 
setting autoflush on the FD.

Here's the fix:

 ..
socket (SOCK, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
connect (SOCK, $paddr) or die "connect: $!";

# select the socket FD and autoflush it.
select (SOCK); $| = 1;

# print to the socket
print SOCK "lots of garbage to the echo port\n";

# do my while loop - read the output of the socket

while (<SOCK>) {

print "$_\n";

}

close (SOCK) or die "close: $!";

# Select the output FD

select (STDOUT);

print "This is now standard output again\n";

 ..

The moral seems to be,
use select() and then autoflush before printing to the socket.

Oh well, it seems to work for me now!

Why was this not documunted in the Camel?
All the examples refer to *reading* from a socket, none
show a simple *write* to the socket...

rachel 


                 defghijklmnopqrstuvwxyz:  What? No ABC?
--
Rachel Polanskis                 Kingswood, Greater Western Sydney, Australia 
grove@zeta.org.au                http://www.zeta.org.au/~grove/grove.html
r.polanskis@nepean.uws.edu.au    http://www.nepean.uws.edu.au/ccd/
                Witty comment revoked due to funding cuts


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

Date: Thu, 13 Mar 1997 12:36:02 +0000
From: Phillip Summers <x741056@tiuk.ti.com>
Subject: Hiding input in msdos perl
Message-Id: <3327F4B2.65BC@tiuk.ti.com>

Hi,

I want to take input from the command line (in Msdos perl) but not
have it displayed.  i.e. to get a password.  Is there any way to
do this?

Thanks in Advance

Phil Summers


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

Date: 13 Mar 1997 10:24:28 GMT
From: lvirden@cas.org
Subject: Re: how do i read "man page" of a module on a PC?
Message-Id: <5g8kks$csp@srv13s4.cas.org>


:brz@hotmail.com wrote:
:: i saw people say read "perldoc LWP::Simple.pm" but
:: i don't have this perldoc in my win32 perl5.003 build
:: 303.

You should contact whomever is working on developing the win32
build environment and mention that perldoc should be something that's
given a high priority since perl seems to depend on it quite heavily.
-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: Thu, 13 Mar 1997 15:06:06 -0500
From: b.wilkinson@NOSPAM.pindar.co.uk (Bob Wilkinson)
Subject: Re: how do i read "man page" of a module on a PC?
Message-Id: <b.wilkinson-1303971506060001@ip57-york.pindar.co.uk>

In article <5g8kks$csp@srv13s4.cas.org>, lvirden@cas.org wrote:

> :brz@hotmail.com wrote:
> :: i saw people say read "perldoc LWP::Simple.pm" but
> :: i don't have this perldoc in my win32 perl5.003 build
> :: 303.
> 
> You should contact whomever is working on developing the win32
> build environment and mention that perldoc should be something that's
> given a high priority since perl seems to depend on it quite heavily.
> -- 

Failing that (I presume you'd like to read this info. soon), take a text editor
to the module.pm file, since the documentation is generally stored with the
source code. Search for a line starting with "=pod" - the documentation should
start there.

Note that this is a pragmatic, rather than elegant, solution.

Bob

-- 
All is flux, nothing is still; nothing endures but change
- Heraclitus


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

Date: Thu, 13 Mar 1997 10:07:47 GMT
From: boeken@rdc.nl (Tom Boeken)
Subject: how to delete last line in .txt.file
Message-Id: <3327ced1.1757084@news.demon.nl>

Can someone point out to me how to delete the last line in a plain
text file from a Perl-script?

thanks!

Tom


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

Date: Thu, 13 Mar 1997 11:03:49 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: how to delete last line in .txt.file
Message-Id: <adelton.858251029@aisa.fi.muni.cz>

boeken@rdc.nl (Tom Boeken) writes:

> Can someone point out to me how to delete the last line in a plain
> text file from a Perl-script?

$a = '';
while (<>)
	{ print $a; $a = $_; }

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 13 Mar 1997 14:46:20 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: how to delete last line in .txt.file
Message-Id: <5g93vs$ai9$4@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    boeken@rdc.nl (Tom Boeken) writes:
:Can someone point out to me how to delete the last line in a plain
:text file from a Perl-script?

>From section 5 of the (new) Perl FAQ:

=head2 How do I change one line in a file/delete a line in a file/insert
       a line in the middle of a file/append to the beginning of a file?

    Although humans have an easy time thinking of a text file as being a
    sequence of lines that operates much like a stack of playing cards --
    or punch cards -- computers usually see the text file as a sequence
    of bytes.  In general, there's no direct way for Perl to seek to a
    particular line of a file, insert text into a file, or remove text
    from a file.

    (There are exceptions in special circumstances.  Replacing a sequence
    of bytes with another sequence of the same length is one.  Another is
    using the C<$DB_RECNO> array bindings as documented in L<DB_File>.
    Yet another is manipulating files with all lines the same length.)
	
    The general solution is to create a temporary copy of the text file with
    the changes you want, then copy that over the original.

	$old = $file;
	$new = "$file.tmp.$$";
	$bak = "$file.bak";
	
	open(OLD, "< $old")         or die "can't open $old: $!";
	open(NEW, "> $new")         or die "can't open $new: $!";
	
	# Correct typos, preserving case
	while (<OLD>) {
	    s/\b(p)earl\b/${1}erl/i;
	    (print NEW $_)          or die "can't write to $new: $!";
	}
	
	close(OLD)                  or die "can't close $old: $!";
	close(NEW)                  or die "can't close $new: $!";
	
	rename($old, $bak)          or die "can't rename $old to $bak: $!";
	rename($new, $old)          or die "can't rename $new to $old: $!";

    Perl can do this sort of thing for you automatically with the C<-i>
    command-line switch or the closely-related C<$^I> variable (see
    L<perlrun> for more details).  Note that C<-i> may require a suffix
    on some non-Unix systems; see the platform-specific documentation
    that came with your port.

	# Renumber a series of tests from the command line
	perl -pi -e 's/(^\s+test\s+)\d+/ $1 . ++$count /e' t/op/taint.t  

	# form a script 
	local($^I, @ARGV) = ('.bak', glob("*.c"));
	while (<>) {
	    if ($. == 1) {
		print "This line should appear at the top of each file\n";
	    }
	    s/\b(p)earl\b/${1}erl/i;        # Correct typos, preserving case
	    print; 
	    close ARGV if eof;              # Reset $.
	}

    If you need to seek to an arbitrary line of a file that changes
    infrequently, you could build up an index of byte positions of where
    the line ends are in the file.  If the file is large, an index of
    every tenth or hundredth line end would allow you to seek and read
    fairly efficiently.  If the file is sorted, try the look.pl library
    (part of the standard perl distribution).
	
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    If I allowed "next $label" then I'd also have to allow "goto $label",
    and I don't think you really want that...  :-) 
            --Larry Wall in <1991Mar11.230002.27271@jpl-devvax.jpl.nasa.gov>


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

Date: 13 Mar 1997 14:53:03 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: how to delete last line in .txt.file
Message-Id: <5g94cf$c57$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    boeken@rdc.nl (Tom Boeken) writes:
:Can someone point out to me how to delete the last line in a plain
:text file from a Perl-script?

It occurs to me that despite the FAQ's answer, there is one way that
in this unique case you could do it:

    #!/usr/bin/perl
    # eatlast -- tchrist@perl.com
    # remove last line in a file without copy or temp

    $errors = 0;
    foreach $file (@ARGV) { 
	unless ( open (FH, "+< $file") ) {
	    $errors++;
	    warn "$0: can't open $file for update: $!\n";
	    next;
	} 
	while ( <FH> ) { 
	    $addr = tell(FH) unless eof(FH);
	} 
	truncate(FH, $addr)	  || die "can't shorten $file: $!":
	close(FH)		  || die "can't close $file: $!";
    }
    exit($errors);

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

Yield to Temptation ... it may not pass your way again.
                --Lazarus Long, "Time Enough for Love"


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

Date: 13 Mar 1997 13:41:48 GMT
From: "Stephen K. Bohler" <skbohler@ix.netcom.com>
Subject: How to strip newlines from string
Message-Id: <01bc2fb4$295fe360$24e42ac2@steve>

I imagine this is a basic question, but my trials have not been successful.

I'm trying to take a string which contains characters and some interspersed
newline characters, and just convert the newlines to a space.

I'm trying:
$string =~ tr/\n/ /

When I look at the output in the file, the string looks a bit garbled. If I
'vi' the file, I see a '^M' where I just want a space.  So, it seems this
isn't working.

If someone could give me (what I assume is a simple answer to an
experienced Perlophile), I would be grateful.

Thanks in advance. 
---------------------------------------------
Stephen Bohler
Oxford
United Kingdom


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

Date: 13 Mar 1997 14:57:34 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to strip newlines from string
Message-Id: <5g94ku$c57$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    "Stephen K. Bohler" <skbohler@ix.netcom.com> writes:
:I imagine this is a basic question, but my trials have not been successful.
:
:I'm trying to take a string which contains characters and some interspersed
:newline characters, and just convert the newlines to a space.
:
:I'm trying:
:$string =~ tr/\n/ /
:
:When I look at the output in the file, the string looks a bit garbled. If I
:'vi' the file, I see a '^M' where I just want a space.  So, it seems this
:isn't working.
:
:If someone could give me (what I assume is a simple answer to an
:experienced Perlophile), I would be grateful.

Newline may or may not be a ^M.

On Unix: 

   If you input a ^J, it echos as ^M^J, and a ^J goes in your file.
   If you input a ^M, it echos as ^M^J, and a ^J goes in your file.
   If you output a ^J, it comes out as ^M^J.
   If you output a ^M, it comes out as ^M.

   In any event, \n should suffice.

On WinDOS and VMS:

   If you input a ^M, it echos as ^M^J, and a ^M^J goes in your file.

I don't know the rest of the cases.  But it's a C library thing.
I would suggest using s/[\n\r]/ /g instead, although with my luck
this will break on Macs.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
In general, if you think something isn't in Perl, try it out, because it
usually is.  :-)
        --Larry Wall in <1991Jul31.174523.9447@netlabs.com>


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

Date: 13 Mar 1997 07:16:46 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: Brian Lorraine <lorraine@ait.nrl.navy.mil>
Subject: Re: html embedding
Message-Id: <qumhgifrfdt.fsf@cyclone.stanford.edu>

[ Posted and mailed. ]

Brian Lorraine <lorraine@ait.nrl.navy.mil> writes:

> Is there a way (without server side includes) that I can stick the
> output of that one script into where the XXX in this html document is?

No, unless you can write the entire page as a CGI script (in which case
you have full control over it).  This is precisely the problem for which
server-side includes were invented.

Note that this is not a Perl question and the answer is the same for any
CGI programming language, so your question should have been directed to
comp.infosystems.www.authoring.cgi instead.

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: Wed, 12 Mar 1997 09:46:10 -0800
From: James Esler <metalhead@mhv.net>
Subject: irc bots in perl
Message-Id: <3326EBE2.CC@mhv.net>

I'm writing to ask if it's possible to write irc scripts and bots in
perl.  If so, where would I find more information on this?


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

Date: 11 Mar 1997 12:17:27 GMT
From: jgoerzen@complete.org (John Goerzen)
Subject: Re: Looking for non-Unix Perl book
Message-Id: <slrn5iajan.fuu.jgoerzen@complete.org>

On Sat, 08 Mar 1997 21:45:53 +0100, Thomas Buehner <buehner@pfaffenhofen.netsurf.de> wrote:
>As a non-Unix person, it took me an hour to find the Perl command for 
>deleting a file: No reference to delete, erase, remove, etc. in the 
>index of any Perl book I looked at. Too many hits on a search through 
>the HTML docs. Only when I asked a Unix crack, he suggested unlink.

 ...

> - extensive descriptions (as opposed to "unlink: delete list of files."

What else needs to be said?  Isn't it obvious what that means?

And besides, I know that C on DOS/Windows calls it unlink just like C on
Unix does (at least Borland C does it that way).  It's not like it's a
surprise that it's named unlink or anything...

-- 
John Goerzen          | Running Debian GNU/Linux (www.debian.org)
Custom Programming    | 
jgoerzen@complete.org | 


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

Date: Thu, 13 Mar 1997 09:42:25 -0500
From: pudge@pobox.com (Chris Nandor)
Subject: Re: MacPerl5
Message-Id: <pudge-ya02408000R1303970942250001@news.idt.net>

In article <3326B773.4066@ix.heise.de>, Juergen Seeger <js@ix.heise.de> wrote:

#Is anyone here who is using MacPerl?

Every day ... might I suggest the MacPerl mailing list?  Look up the
MacPerl home page on Yahoo or any of the many Perl resources.

#================================================================
A burp is not an answer.

   --Bart Simpson

Chris Nandor                                      pudge@pobox.com
PGP Key 1024/B76E72AD                           http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6


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

Date: 13 Mar 1997 01:20:32 GMT
From: a00lcj00@elc012.nchc.gov.tw (Cheng Tyh Lin)
Subject: Mail an attatchment with Perl
Message-Id: <5g7kp0$ijd@cyrene.nchc.gov.tw>

How can I do that by using attatchment to mail a non-ascii code's document?
Or is there any mail size limit that I must cut them by myself?
Please reply to my mail add. Thankx


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

Date: Thu, 13 Mar 1997 08:37:05 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Numeric function
Message-Id: <adelton.858242225@aisa.fi.muni.cz>

Martin Lvnnar <martin.lonnar@edt.ericsson.se> writes:

> Hello!
> 
> Is there a function in perl to check if a scalar variable is numerical
> only. It should work something like this:
> $number = 1234;
> numeric($number);
> # This should render TRUE
> 
> $number = 12B4;
> numeric($number);
> # This should render FALSE
> 
> # It's to be used like this
> if (!numeric($number)){
>     print...
> }

There is not wuch a function built-in, but you can fix yourself one
with sub. In the fourth chapter of new perl FAQ there is a section
How do I determine whether a scalar is a number/whole/integer/float?
so you can choose.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 13 Mar 1997 14:38:52 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Numeric function
Message-Id: <5g93hs$ai9$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    martin.lonnar@edt.ericsson.se writes:
:Is there a function in perl to check if a scalar variable is numerical
:only. 

>From the FAQ:

    =head2 How do I determine whether a scalar is a number/whole/integer/float?

    Assuming that you don't care about IEEE notations like "NaN" or
    "Infinity", you probably just want to use a regular expression.

       warn "has nondigits"        if     /\D/;
       warn "not a whole number"   unless /^\d+$/;
       warn "not an integer"       unless /^[+-]?\d+$/
       warn "not a decimal number" unless /^[+-]?\d+\.?\d*$/
       warn "not a C float"
	   unless /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/;

    Or you could check out
    http://www.perl.com/CPAN/modules/by-module/String/String-Scanf-1.1.tar.gz
    instead.  The POSIX module (part of the standard Perl distribution)
    provides the C<strtol> and C<strtod> for converting strings to double
    and longs, respectively.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "Have the appropriate amount of fun." --Larry Wall


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

Date: 13 Mar 1997 14:51:34 GMT
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: Numeric function
Message-Id: <5g949m$pvl@ukwsv3.ggr.co.uk>

In article <5g93hs$ai9$2@csnews.cs.colorado.edu>, Tom Christiansen <tchrist@mox.perl.com> writes:
|>  [courtesy cc of this posting sent to cited author via email]
|> 
|> In comp.lang.perl.misc, 
|>     martin.lonnar@edt.ericsson.se writes:
|> :Is there a function in perl to check if a scalar variable is numerical
|> :only. 
|> 
|> From the FAQ:

   Then surely it is wrong?

|>        warn "not a decimal number" unless /^[+-]?\d+\.?\d*$/
                                                    ^^^
   Surely  should be \d*?  (The question mark is English punctuaion, not
a perl regexp marker - and that "English" does not  refer  to  the  perl
module!). 

   -.2 (and +.2) should surely be treated as decimal numbers?



-- 
----------- Gordon Lack ----------------- gml4410@ggr.co.uk  ------------
The contents of this message *may* reflect my personal opinion.  They are
*not* intended to reflect those of my employer, or anyone else.


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

Date: 13 Mar 1997 13:09:45 +0100
From: Olivier Dehon <dehon_olivier@jpmorgan.com>
Subject: Re: password entries
Message-Id: <njz7mjcouwm.fsf@jpmorgan.com>

"David Benn" <dbenn@vision.net.au> writes:

> 
> Apart from reading the master password file directly, are there functions
> such as
> getpwent() which will read the master password file rather than the
> world-readable
> password file? If not, I'll just do the former. I'm running BSDi BTW.
> 

getpwent is a built-in perl function, have a look at the perlfunc manpage
to see its interface.

Hope this helps.
Olivier Dehon


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

Date: 13 Mar 1997 10:26:13 -0500
From: Roderick Schertler <roderick@argon.org>
To: Stefan Monnier <monnier@cs.yale.edu>
Subject: Re: Perl FAQ part 8 of 0..9: System Interaction [Periodic Posting]
Message-Id: <pz4tefu9a8.fsf@eeyore.ibcinc.com>

On 12 Mar 1997 13:35:39 -0500, Stefan Monnier <monnier@cs.yale.edu> said:
> 
> [...] but if I set my PERL5LIB to /usr/local/lib/perl5, only
> /usr/local/lib/perl5 and /usr/local/lib/perl5/auto are searched for
> .so files, [...]

This is fixed in the 5.004 beta.  Specifying /foo via either $PERL5?LIB
or -I adds /foo/arch/version, /foo/arch and /foo to @INC.

-- 
Roderick Schertler
roderick@argon.org


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

Date: Thu, 13 Mar 1997 15:45:14 +0100
From: jean-philippe amiel <JeanPhilippe.Amiel@alcatel.titn.fr>
Subject: Perl for WIN32 Perl 1.001m and 1.003 version sure enough ?
Message-Id: <332812FA.41C67EA6@alcatel.titn.fr>

Can some one explain to me if those version are sure enough to be used
in a commercial software application, of if there are too many bugs ??
 
Thank-You very much.

-- 
*---------------------------------------*
Jean Philippe AMIEL

Alcatel Telecom * Alcatel TITN Answare
190 rue Claude-Nicolas Ledoux - BP 83000
13793 AIX EN PROVENCE Cedex 3 - FRANCE

Phone: (33) 4 42 39 38 07 
Fax:   (33) 4 42 39 39 59
*---------------------------------------*


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

Date: Thu, 13 Mar 1997 09:46:00 -0000
From: S.Fairey@datasci.co.uk (Fairey Simon)
Subject: Question regarding File::Copy
Message-Id: <cGBapDataScienceslDATASCIEXCH01000611EA@farnnt15.datasci.co.uk>

Hi,

I am not sure whether this is the correct behaviour but
when I use 'copy' it does not appear to preserve the
file permissions and I have to do a 'chmod' afterwards.
It appears to be using my current 'umask' value.

I am running Perl 5.003 on AIX 3.2.5.

Thanks

Simon



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


------------------------------
End of Perl-Users Digest V8 Issue 108
*************************************

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