[11760] in Perl-Users-Digest
Perl-Users Digest, Issue: 5360 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 12 12:07:38 1999
Date: Mon, 12 Apr 99 09:00:17 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 12 Apr 1999 Volume: 8 Number: 5360
Today's topics:
Re: autoexec.bat and Perl bug? <c4jgurney@my-dejanews.com>
DBI help <david@weaverweb.co.uk>
Re: Hash symbol '%' a stylized what? (Jonathan Stowe)
Re: How to get yesterday date (Larry Rosler)
Re: how to print random words from array on one line (Abigail)
installing libnet on win32 <tgray@smlny.com>
Re: leap year? <droby@copyright.com>
Re: Perl and DDE <jdf@pobox.com>
Problem with Shishir Gundavarams guestbook (velocity)
Re: Problem with Shishir Gundavarams guestbook <jdf@pobox.com>
Re: Q: perl/fork()/system() problem on Solaris 2.6 (Mike Willett LADS LDN X7563)
Reading from file into an array.... <p8e77@keele.ac.uk>
Re: Reading from file into an array.... <jdf@pobox.com>
Re: Removing last space (Larry Rosler)
Re: Resolving shortcuts in Windows 9x (Jonathan Stowe)
Re: SORT BY DATE (Larry Rosler)
sorting a reference by a specific key... mondolumina@my-dejanews.com
Re: Splitting messages (Tom Mornini)
Re: stripping spaces out (Jonathan Stowe)
Re: stripping spaces out (Larry Rosler)
Re: Suit case or backpack (Jonathan Stowe)
wwwboard / umask <robert@filthyswan.demon.co.uk>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Apr 1999 15:05:20 GMT
From: Jeremy Gurney <c4jgurney@my-dejanews.com>
Subject: Re: autoexec.bat and Perl bug?
Message-Id: <7et23a$pp5$1@nnrp1.dejanews.com>
In article <7esvbh$n88$1@nnrp1.dejanews.com>,
lingane@my-dejanews.com wrote:
> I have come across a problem. My autoexec.bat file contains a path name which
> includes a space i.e "c:\program files\whatever"
>
> When I run a perl script that includes a
> dir c:\* \a-o \b \s
>
> it acts as if the options were file names instead of options.
>
> This code works fine, as long as I don't have a line with a space in it in the
> autoexec.bat file.
>
> Any way around this? Is this a perl bug?
>
> Thanks
> Lingane
This is an windows problem - I seem to remember that .bat files are assumed
to be 16 bit by the os and therefore can't contain long filenames. Change
your path to the dos version "c:\progra~1\whatever" and everthing should be
fine.
Generally if you are using .bat files I would suggest changing them to .cmd as
these are assumed to be 32 bit and fulfill the same purpose.
Jeremy Gurney
SAS Programmer | Proteus Molecular Design Ltd.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 12 Apr 1999 17:00:35 +0100
From: David Stringer <david@weaverweb.co.uk>
Subject: DBI help
Message-Id: <C0ddgAAjihE3EwXJ@weaverweb.co.uk>
Help
I have been trying to use DBI with mysql. I installed both with CPAN and
it seemed to go fine.
when I use the connect method i.e...
$dsn = "DBI:mysql:database=test";
$dbh = $dsn->connect($dsn, test, whatsit);
I get..
Can't locate object method "connect" via package
"DBI:mysql:database=test"
I have tried a few variations of syntax and read the FAQ and man pages.
I just cannot find what's wrong.
--
David Stringer
------------------------------
Date: Mon, 12 Apr 1999 15:33:52 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: Hash symbol '%' a stylized what?
Message-Id: <37121213.27517554@news.dircon.co.uk>
On 12 Apr 1999 07:40:16 -0700, gerg@shell1.ncal.verio.com (Greg
Andrews) wrote:
>damian@cs.monash.edu.au (Damian Conway) writes:
>>
>> 4. Perl Institute known as Department of Perl Affairs.
>>
>
>s/Department/Ministry/ perhaps?
>
It depends whether this body will be headed by A Secretary of State
for Perl Affairs or a Minister for Perl Affairs of course ...
/J\
------------------------------
Date: Mon, 12 Apr 1999 07:46:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to get yesterday date
Message-Id: <MPG.117ba711404cef8989894@nntp.hpl.hp.com>
In article <yliub2cgdj.fsf@windlord.stanford.edu> on 12 Apr 1999
02:55:36 -0700, Russ Allbery <rra@stanford.edu >says...
...
> sub yesterday {
> my $now = defined $_[0] ? $_[0] : time;
> my $then = $now - 60 * 60 * 24;
> my $ndst = (localtime $now)[8] > 0;
> my $tdst = (localtime $then)[8] > 0;
> $then - ($tdst - $ndst) * 60 * 60;
> }
Note the comfortable arithmetic use of the numeric value of a Boolean.
According to a recent thread, the only linguistic guarantee is that the
value be TRUE, not 1. But every implementation of perl that I know of
returns 1 in numeric context. I gave up in frustration after failing to
get someone in charge of the Perl docs to agree to make this fact part
of the language specification.
So, pedants of the world, that should be:
my $ndst = (localtime $now)[8] > 0 ? 1 : 0;
my $tdst = (localtime $then)[8] > 0 ? 1 : 0;
Ugh. PLEASE, whoever can, formalize this into the language!
Cross-posted to comp.lang.perl.moderated in the hope that someone there
will acknowledge the issue and deal with it.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 12 Apr 1999 15:31:51 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: how to print random words from array on one line
Message-Id: <7et3l7$1jo$1@client2.news.psi.net>
tzoko1000@my-dejanews.com (tzoko1000@my-dejanews.com) wrote on MMXLIX
September MCMXCIII in <URL:news:7eragj$c8u$1@nnrp1.dejanews.com>:
`` Hello,
`` I'm new to perl and I can't find a solution to a problem for 2
`` days. I bet it's something very easy :)
You are probably very new to Usenet as well. Or you use software that
is badly broken. Your posting had no less than *5* references, yet it
wasn't refering to any other posting.
Please fix your software and/or your posting behaviour.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
------------------------------
Date: Mon, 12 Apr 1999 11:28:18 -0400
From: "Tim Gray" <tgray@smlny.com>
Subject: installing libnet on win32
Message-Id: <XcoQ2.3075$8m5.4234@newsr1.twcny.rr.com>
I am having trouble getting libnet installed in an NT server. I got a copy
of microsoft's nmake.exe from visual studio. When I run
nmake test
it gives me
Net::SMTP: Uknown error at t\smtp.t line 15
and then
NMAKE: fatal error U1077: 'C:\perl\bin\perl.exe' : return code '0xff'
I am using activestate build 514. Thanks.
Tim Gray
------------------------------
Date: Mon, 12 Apr 1999 15:28:28 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: leap year?
Message-Id: <7et3eh$qus$1@nnrp1.dejanews.com>
In article <MPG.117427f099033500989850@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
> In article <7edu93$m7t$1@client2.news.psi.net> on 6 Apr 1999 21:28:03
> GMT, Abigail <abigail@fnx.com> says...
> ...
> > But that requires another module, and hence slows down your program
> > due to extra compilation.
> ...
> > Note that this subroutime might be wrong if called a few microseconds
> > before the new year.
>
> April 1 seems to have come late, this year.
>
I believe I can shed some light on this.
Abigail's post was not actually made on April 6 as cited, but on MMXLIV
September MCMXCIII. Abigail always posts in September MCMXCIII. Being
bereft of April, Abigail is compelled to simply ignore the date convention
restricting foolishness to April 1 (as does most of the world, come to think
of it).
I think this is quite a good idea. Since MCMXCIII was not a leap year, and
anyway, February will never happen again if we don't leave September, this
leap year computation problem is no longer important at all.
This also solves Y2K. And Y10K. Though September might someday overflow.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Apr 1999 10:50:09 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: feketeroland11@my-dejanews.com
Subject: Re: Perl and DDE
Message-Id: <m3emlpki5a.fsf@joshua.panix.com>
feketeroland11@my-dejanews.com writes:
> Hello, I'm Roland from Hungary!
Jonathan from "the States" here.
> I've a problem with Perl. I want to running an application
> (WinFaxPro) from Perl using DDE. But this application do not support
> the OLE interface, just the DDE.
The ActiveState perl does indeed have a compatible version of
Win32::DDE, available using the ppm tool that comes with their
distro. Just
c:\> ppm
> install Win32-DDE
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 12 Apr 1999 15:36:22 GMT
From: kissqfjg@sp.zrz.tu-berlin.de (velocity)
Subject: Problem with Shishir Gundavarams guestbook
Message-Id: <371212d5.14971456@news.zrz.tu-berlin.de>
Hey folks,
I am learning CGI Programming with Shishir Gundavaram's book CGI
Programming in the WWW. Because of that I downloaded all the examples
from ftp.ora.de. I am most interested in the guestbook thats because I
started learning CGI Programming.
But I have some trouble with this guestbook. I am using Windows 95 B,
Perl 5.0 and Apache 1.3.3 to test the scripts at home. I can start
your guestbook with "http://localhost/cgi-bin/guestbook.pl?add" But
when I press the button "Add to guestbook" I get the error:
-----------------------------------------------------------------------------------------------------------------------------------------------
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your
request.
Please contact the server administrator, you@your.address and inform
them of the time the error
occurred, and anything you might have done that may have caused the
error.
Premature end of script headers: c:/apache/cgi-bin/guestbook.pl
Apache/1.3.3 Server at localhost Port 80
-----------------------------------------------------------------------------------------------------------------------------------------------
I modified the first lines of your source code into :
#!c:/perl/bin/perl.exe
$webmaster = "kissqfjg\@sp\.zrz\.tu-berlin\.de";
$method = $ENV{'REQUEST_METHOD'};
$script = $ENV{'SCRIPT_NAME'};
$query = $ENV{'QUERY_STRING'};
$document_root = "C:/Apache/htdocs";
$guest_file = "/guestbook.html";
$full_path = $document_root . $guest_file;
What am I doing wrong ? Do I have to write a "guestbook.html" myself
or does the guestbook.pl create one itself ?
Thanks for help
Henner (Berlin/Germany)
at kissqfjg@sp.zrz.tu-berlin.de
------------------------------
Date: 12 Apr 1999 10:57:03 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: kissqfjg@sp.zrz.tu-berlin.de (velocity)
Subject: Re: Problem with Shishir Gundavarams guestbook
Message-Id: <m3aewdkhts.fsf@joshua.panix.com>
kissqfjg@sp.zrz.tu-berlin.de (velocity) writes:
> I can start your guestbook
It's not *our* guestbook; it's *yours*.
> Internal Server Error
You need to study this document:
http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
> #!c:/perl/bin/perl.exe
> $webmaster = "kissqfjg\@sp\.zrz\.tu-berlin\.de";
> $method = $ENV{'REQUEST_METHOD'};
Oops. You really ought to be using CGI.pm.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 12 Apr 1999 14:54:43 GMT
From: willettm@ml.NOSPAM.com (Mike Willett LADS LDN X7563)
Subject: Re: Q: perl/fork()/system() problem on Solaris 2.6
Message-Id: <7et1fj$83s$1@news.ml.com>
In article <3705372f.0@news.syr.edu>,
asriniva@newstand.syr.edu (Arvind Srinivasan) writes:
>We are in the process of migrating from Solaris2.5.1 to 2.6 and have
>encountered a problem in one of our scripts which uses fork() & system().
>
>It appears that setting $SIG{CHLD} causes the return code from
>system() to be -1. This happens only on Solaris 2.6.
First :System return two pieces of information. The first 8 bits
are the return status of the child process and the second 8 bits
are the result of any signal. The correct code should be
$rc = $status >> 8; # first 8 bits
$signal = $status & 255; # second 8 bits
I think that your problem is with the way in which the status
is collected. By ignoring the child signal the system call can't
collect the child info correctly. Perhaps putting back the
SIGCHLD processing. (Well that works for me).
Personnally, I think ignoring CHLD is a poor idea anyway. You should
always process them at some point even if you do nothing with them.
(Caveat: I have had problems when too many children die in quick
sucession - I beleive thats a Perl problem though).
Mike
>-----
>#!/usr/local/bin/perl
>
>$child = fork();
>
>
># if this line is not commented, then $status = -1 in 2.6
>$SIG{CHLD} = "IGNORE";
>
>if ($child == 0)
>{
> $status = system("echo ChildProcess");
> print "Child status = $status (errno = $!)\n";
> exit;
>}
>sleep(5);
>-----
>
>Perl version: 5.004
>
>On 2.5.1, the output is:
>
>ChildProcess
>Child status = 0 (errno = )
>
>On 2.6, the output is:
>
>ChildProcess
>Child status = -1 (errno = No child processes)
>-----
>
>Patch 105210-19 didn't fix the problem.
>
>Any suggestions to move us forward would be greatly appreciated.
>
>Thanks,
> Arvind
>
------------------------------
Date: Mon, 12 Apr 1999 15:39:58 +0100
From: "Andrew Weller" <p8e77@keele.ac.uk>
Subject: Reading from file into an array....
Message-Id: <7et0k8$ncp$1@cfs2.kis.keele.ac.uk>
Dear All,
I need to write some code in Perl to do the following:
I'm trying to read in a data file which looks like the following:
head -26.27939 43.58512 14.08601 43.43750
head -26.14723 43.68331 14.11775 40.93750
head -28.55041 48.04858 15.52853 50.81250
head -27.17389 46.06922 14.88883
63.93750......etc.....
This data can vary from 1 entry to an infinite amount. I would like to read
the file in and loop through the set until it reaches the end, reading each
entry (as: text, xvalues, yvalues, zvalues, intensity). My current code
looks like this:
-------------------
#! perl -w #Win32 platform
#------------------------------
# Program to read from a file
# Manipulate the data
# And save to a new file
# Author: Andrew Weller
#------------------------------
{
get_filename ();
open (READFILE, $filename) || die "Can't read $filename: $!";
while (<READFILE>) {
chomp;
my ($text, $xvalues, $yvalues, $zvalues, $intensity) = split;
print "$text \t $xvalues \t $yvalues \t $zvalues \t $intensity\n";
}
close (READFILE) || die "Can't close $filename: $!";
}
# Subroutine that returns a file name to be read to / saved to
sub get_filename {
print "Please enter a directory and file to OPEN / SAVE.\n";
print "For example, C:\\MYDOCU~1\\Thesis\\apit1.dat\n\n";
chomp ($filename = <STDIN>);
return $filename;
}
-------------------
Although this works fine - what I'm after is, instead of the values being
printed to screen with the following line:
print "$text \t $xvalues \t $yvalues \t $zvalues \t $intensity\n";
I want the variables to be saved as an array, so that they can be
manipulated later and saved to a new file.
If there is anybody who could help me, please let me know!
Thanks,
Andy
--
Andy Weller
M.Sc. Computing in Earth Sciences
Dept. of Earth Sciences
Keele University
Staffordshire, ST5 5BG, UK
e-mail: p8e77@keele.ac.uk
Tel. (+44) 01782 246883
------------------------------
Date: 12 Apr 1999 11:00:52 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: "Andrew Weller" <p8e77@keele.ac.uk>
Subject: Re: Reading from file into an array....
Message-Id: <m37lrhkhnf.fsf@joshua.panix.com>
"Andrew Weller" <p8e77@keele.ac.uk> writes:
> my ($text, $xvalues, $yvalues, $zvalues, $intensity) = split;
> I want the variables to be saved as an array, so that they can be
> manipulated later and saved to a new file.
So what you want is to create a "list of lists", yes?
In that case your best bet is to settle down with the perllol
document, followed shortly thereafter by perldsc and perlref. If you
haven't yet read perldata, then do that first.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Mon, 12 Apr 1999 08:36:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Removing last space
Message-Id: <MPG.117bb2ea62a38563989896@nntp.hpl.hp.com>
In article <7esujt$mlh$1@nnrp1.dejanews.com> on Mon, 12 Apr 1999
14:05:55 GMT, JoshNarins <joshnarins@my-dejanews.com >says...
> In article <7esqd8$ioe$1@weber.a2000.nl>,
> "Bas van Reek" <basvreek@xs5all.nl> wrote:
> > How do i remove the last space from a variable
> >
> > I do not mean $foo =~ s/ //g; or chop.
> > only the last space(s) if there is one.
> >
> > so "bla bla " needs to become "bla bla"
...
> $line =~ s/\s*$//; # Remove all whitespace at end of line.
>
> If there is no whitespace, the above does what you want (i.e. nothing).
It could 'do nothing' more efficiently if you replaced the star by a
plus, as others have suggested. It also removes a trailing newline,
which is not necessarily what was requested.
All of this is, of course, part of the answer in perlfaq4: "How do I
strip blank space from the beginning/end of a string?"
I would answer the literal question that was actually asked this way:
s/ (?=[^ ]*$)//
This indeed removes the last space from a variable -- only one space,
the last one in the string (but not necessarily a 'trailing' space).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 12 Apr 1999 15:21:29 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: Resolving shortcuts in Windows 9x
Message-Id: <37120c62.26060780@news.dircon.co.uk>
On Mon, 12 Apr 1999 10:30:46 -0400, "Mark Jeweler"
<jewelerm@unforgettable.com> wrote:
>I am a relative newbie to perl, though am fairly familiar with it, having
>worked in Unix for a number of years way back when...
>
>Anyway, my issue is on a Microsoft Windows 9x platform. I can easily open
>and parse regular files, but am having problems with "shortcuts", which
>windows handles as ".LNK" files.
>
>I have tried the "readlink" command, but this does not seem to do what I
>want.
>
>I have a shortcut, which points to another file. I want to be able to
>reference the shortcut, resolve the link to the file it points to, and then
>ultimately, to be able to open and work with the pointed-to file.
>
Would you believe the Win32::Shortcut module available from CPAN ?:
http://www.perl.com/CPAN/modules/by-category/22_Microsoft_Windows_Modules/Win32/Win32Shortcut-0.02.zip
A quick example:
#!perl -w
use strict;
use Win32::Shortcut;
my $LINK=new Win32::Shortcut();
$LINK->Load('p:\NEWEDT~1.lnk');
print "Shortcut to: $LINK->{'Path'} $LINK->{'Arguments'} \n";
open (LINKFILE,$LINK->{'Path'}) || die "Cant open - $!\n";
$LINK->Close();
# etc ...
close(LINKFILE);
/J\
------------------------------
Date: Mon, 12 Apr 1999 08:19:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: SORT BY DATE
Message-Id: <MPG.117baed6bf4bbb46989895@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <3712025F.EE5BA50@tivoli.com> on Mon, 12 Apr 1999 09:25:35 -
0500, John Warner <jwarner@tivoli.com >says...
> Your reply brings up an interesting question for me. How does Perl
> handle dates before 1900? Does it simply return a negative number?
By 'it' I presume you mean the functions gmtime() and localtime().
They don't have to deal with it, because the domain of the function is
the Unix epoch, which starts at Thu Jan 1 00:00:00 1970 UTC
[gmtime(0)]. Negative arguments work on the Unix implementations I have
tested, but ActivePerl fails with an 'uninitialized value' error.
As the gmtime() function seems to clip the largest negative argument to
the integer -(2 ** 31), the earliest value the Unix implementations
return is Fri Dec 13 20:45:52 1901. This is greater than 1900, so your
question is moot.
What a miracle of design!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 12 Apr 1999 14:50:01 GMT
From: mondolumina@my-dejanews.com
Subject: sorting a reference by a specific key...
Message-Id: <7et16m$oqv$1@nnrp1.dejanews.com>
hey folks,
does anyone know if there's a way to sort a reference? i'm using perLDAP to
generate some custom reports and the search results are put into a reference
called $entry. i'd like to sort the results of the reference by
$entry->{cn}[0]. right now i'm just printing them out in a while loop:
while ($entry)
{
print $entry->{cn}[0]." ".$entry->{phone}[0]."etc... \n";
$entry = $conn->nextEntry(); # more reference pointer to next entry
}
obviously i could push the reference into a hash and sort it, but i'm trying
to avoid extra cpu eating steps...
cheers!
-john
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 12 Apr 1999 15:23:16 GMT
From: tmornini@netcom.com (Tom Mornini)
Subject: Re: Splitting messages
Message-Id: <tmorniniFA31Es.GFz@netcom.com>
John (esugs@csv.warwick.ac.uk) wrote:
: I need to write a script in perl (or awk, or shell script) that will take
: the standard input, split it into 160 character lumps, and send each lump
: as a seperate e-mail messgage.
perldoc Text::Wrap
It's part of the standard distribution.
#!/usr/local/bin/perl -w
use strict;
use Text::Wrap qw(wrap $columns);
my $message='This is a very long line that we want to output as multiple short lines. If this were an e-mail message, it would be very nice to shorten it to fit on a pager, for instance. :-)';
$columns=20;
my @lines=wrap('','',$message);
for my $line (@lines) {
print "$line\n";
}
-- Tom Mornini
-- InfoMania
------------------------------
Date: Mon, 12 Apr 1999 15:00:29 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: stripping spaces out
Message-Id: <371208be.25127984@news.dircon.co.uk>
On Mon, 12 Apr 1999 08:15:55 -0500, quinn coldiron
<qcoldiro@unlinfo.unl.edu> wrote:
>I read the perl FAQ, and found a reg exp to strip spaces, but it only
>strips spaces off the beginning and end of a string. I want to strip
>ALL the spaces out of a string. Does anybody have a reg exp that will
>do this?
>
Errr
perlfaq4 has this to remove space from the ends of a string:
$string =~ s/^\s+//;
$string =~ s/\s+$//;
And the perlre manpage says:
In particular the following metacharacters have their standard
egrep-ish meanings:
\ Quote the next metacharacter
^ Match the beginning of the line
. Match any character (except newline)
$ Match the end of the line (or before newline at the end)
| Alternation
() Grouping
[] Character class
So now you know what is causing those regex to do what they do and
thus you know what to remove in order to remove all spaces from a
string.
/J\
------------------------------
Date: Mon, 12 Apr 1999 08:46:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: stripping spaces out
Message-Id: <MPG.117bb525edece804989897@nntp.hpl.hp.com>
[Posted and a courtesy copy sent.]
In article <3711F20B.9F79548E@unlinfo.unl.edu> on Mon, 12 Apr 1999
08:15:55 -0500, quinn coldiron <qcoldiro@unlinfo.unl.edu >says...
> I read the perl FAQ, and found a reg exp to strip spaces, but it only
> strips spaces off the beginning and end of a string. I want to strip
> ALL the spaces out of a string. Does anybody have a reg exp that will
> do this?
Yes, but I won't show it to you (though others already have), because
then you might use it instead of the proper (much more efficient)
solution, which does not use a regular expression at all:
tr/ //d
You will find the 'tr' (translate) operation in perlop. If your
definition of 'spaces' is broader than just the space character,
enumerate them in the left-hand side. ('\s' won't work there.)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 12 Apr 1999 15:30:51 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: Suit case or backpack
Message-Id: <3712107d.27111065@news.dircon.co.uk>
On 12 Apr 1999 14:42:04 GMT, stan@tempest.temple.edu (Stanley Horwitz)
wrote:
>
>Does anyone have any thoughts on this matter? How is train traveling with
>a suit case? I still plan to pack light.
>
I would consult the documentation for the Luggage::Pack module
available from CPAN.
?
/J\
------------------------------
Date: Mon, 12 Apr 1999 16:57:06 +0100
From: "Robert Johnston" <robert@filthyswan.demon.co.uk>
Subject: wwwboard / umask
Message-Id: <923932538.3064.0.nnrp-03.c1ed46a8@news.demon.co.uk>
I'm trying to get WWWboard going on a server run by Demon. I'm having quite
a few problems. When the script executes, it overwrites the file
'wwwboard.html' with an almost blank file. The files in /wwwboard/messages
also aren't readable to visitors.
As per the instructions with WWWboard, I chmoded wwwboard.html, data.txt and
/messages to 777, but I still think there's something screwy with the
permissions. Demon support sent me a vague email directing me to look at a
site covering the perl command umask, which they say can be used to alter
default permissions on the server.
Now I have no experience with perl, so speak slowly! ...but has anyone
encountered a similar problem? Any help appreciated, particularly private
replies.
Rob
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5360
**************************************