[11124] in Perl-Users-Digest
Perl-Users Digest, Issue: 4724 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 22 18:06:36 1999
Date: Fri, 22 Jan 99 15:00:21 -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 Fri, 22 Jan 1999 Volume: 8 Number: 4724
Today's topics:
[OO] Passing instance objects (Scott Roughton)
Re: [Q] regexp or split? How do I prune this string: d2 <ludlow@us.ibm.com>
Re: ancestry of perl features (David Formosa (aka ? the Platypus))
Re: CGI/Perl: passing information to SSI? (Abigail)
debugging under WindowsNT vbatorowicz@mmm.com
Re: First line skip when reading file <Monty.Scroggins@mci.com>
flock and cgi: can it hang? joeltesttutor@my-dejanews.com
Graphing <bruce.d@btinternet.com>
Re: Identify a line <ludlow@us.ibm.com>
Re: Is there an HTML to CGI.pm converter?? (Ben Coleman)
LWP::Simple HELP!!! <bfreedman@esdim.noaa.gov>
Re: LWP::Simple HELP!!! <michael_mongeau@stratus.com>
mSQL problem <rgl34@hotmail.com>
Multidimensional arrays. jambutter@my-dejanews.com
Re: Multidimensional arrays. <ludlow@us.ibm.com>
Re: Newbie Shopping Cart Question birgitt@my-dejanews.com
Perl & IIS problem <drdoctor@u.washington.edu>
Re: Perl editor ? (tony summerfelt)
Re: Perl editor ? dhosek@webley.com
POD to HTML? <chrisl@hamptons.com>
Re: POD to HTML? <michael_mongeau@stratus.com>
Re: POD to HTML? (Mike Stok)
Publisher Looking for co-author <stephanie.wall@coriolis.com>
Re: regular expression help <ludlow@us.ibm.com>
Re: regular expression help (Mike Stok)
Re: regular expression help <bgilbert@sgi.com>
Re: regular expression help (Charles DeRykus)
Re: regular expression help (Greg Bacon)
Re: SWIG with ActiveState? (Jan Dubois)
Re: The Documeantion (was Re: Perl problem :(Offline mo don_hosek@my-dejanews.com
Where can i find the Perl software for Windows-95. <harish_mittal@usa.net>
Re: Y2K? (John Moreno)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Jan 1999 20:42:04 GMT
From: roughton@bnr.ca (Scott Roughton)
Subject: [OO] Passing instance objects
Message-Id: <78anqs$8su@brtph500.us.nortel.com>
Hi,
I have a newbe OO question. Is there a good way to pass an instance object
to another instance object. Say I have a box of jiblets that I want to put
in a bigger box. When I try this, the jiblets in the smaller box are put on
the outside of the container instead of inside it.
The result is that when I pass an instance of $fred to $bigbox, the stuff in
$fred gets tacked on the end of @_ instead of with $fred. Should I be using
references for this?
Anyone have any suggestions?
Thanks in advance
S.
------------------------------
Date: Fri, 22 Jan 1999 15:52:04 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: [Q] regexp or split? How do I prune this string: d20+4 ??
Message-Id: <36A8F304.C7613282@us.ibm.com>
Andreas Gustafsson wrote:
> I'm trying to pluck out just the numbers /after/ 'd6' in this string,
> but I can't do it!
>
> the string: d6+4
>
> my mission is to get the numer after d6 and put it in a new variable.
>
> how do I do it? regexp? split()?
Perl enters the world of role playing.
This (untested) script should give you an idea of how to do it with a
regex. If the string looks like a die roll, as defined by the regex,
then the modifier gets stored to $1.
#!/usr/bin/perl -w
@dice = ('d6+4', 'd20+3', 'd12', 'foo+4');
foreach (@dice) {
m/^ # beginning of string
d # literal 'd'
\d+ # at least one digit
\+{1} # 1 plus sign
(\d+) # capture 1 or more digits to $1
$ # end of string
/x;
if (defined $1) {
print "$_: $1\n";
} else {
print "$_: no match\n";
}
}
perldoc, Learning Perl, Programming Perl, and Mastering Regular
Expressions will all give you great reading for further study.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: 22 Jan 1999 22:18:57 GMT
From: dformosa@zeta.org.au (David Formosa (aka ? the Platypus))
Subject: Re: ancestry of perl features
Message-Id: <slrn7ahuah.pa1.dformosa@godzilla.zeta.org.au>
In article <36a8b024@csnews>, Tom Christiansen wrote:
>
[...]
>:varying lenghth strings (no \0 needed) sh, PL/I
>
>Gosh, no. Think BASIC and awk.
Are this type of strings called "pascal style"?
[...]
> OO set-up (hashes, classes) python
I thourt that perl predates python.
[...tom's list cut...]
Addtions
eval lisp
dynamic scope (via local) lisp
>It's more interesting to figure out what *IS* original,
>unique unto Perl. There are quite a few mysteries yet.
>I'll let you start that list yourself. :-)
die eval used for excptions
tied objects
glob verrables.
--
Please excuse my spelling as I suffer from agraphia. See
http://www.zeta.org.au/~dformosa/Spelling.html to find out more.
How to win arguments on usenet http://www.zeta.org.au/~dformosa/usenet.html
------------------------------
Date: 22 Jan 1999 20:33:01 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: CGI/Perl: passing information to SSI?
Message-Id: <78an9t$j3i$1@client2.news.psi.net>
M. Morgan (mmorgan@gladstone.uoregon.edu) wrote on MCMLXX September
MCMXCIII in <URL:news:788ii3$6r$2@pith.uoregon.edu>:
""
""
"" The SSI appears to be running from a command line on the server, so in that
"" case how do I pass information to a perl script from the command line? Or
"" am I missing it completely? Does anyone have a simple answer to this
"" question?
Read a group about HTTP servers. This isn't a Perl question.
Abigail
--
perl -wleprint -eqq-@{[ -eqw\\\\- -eJust -eanother -ePerl -eHacker -e\\\\-]}-
------------------------------
Date: Fri, 22 Jan 1999 20:44:04 GMT
From: vbatorowicz@mmm.com
Subject: debugging under WindowsNT
Message-Id: <78anuh$g3e$1@nnrp1.dejanews.com>
Hi
When I debug on Windows NT and I am not in the current directory I get the
following message:
E:\bin\New_stuff>
E:\bin\New_stuff>testpo850.bat
Can't locate perl5db.pl in @INC at e:\bin\New_Stuff\testmainarci.pl line 1.
BEGIN failed--compilation aborted at e:\bin\New_Stuff\testmainarci.pl line 1.
Please help.
Thank you in advance
Victor
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 22 Jan 1999 21:39:31 GMT
From: "Monty Scroggins" <Monty.Scroggins@mci.com>
Subject: Re: First line skip when reading file
Message-Id: <ne6q2.193$yi4.4977@news.cwix.com>
Are you sure your array base variable "$[" is set to zero?
This could be a zero-relative/one-relative problem.
put the declaration - $[=0; at the top of your script and see
if it doesnt fix your problem.
Monty
Gary C. New wrote in message <36A8A8FF.FA2A017B@smip.com>...
>I've narrowed my problem down to this:
>
>When trying to use a simple while loop to read in multi. lines from a
>text file the first line of the file is always skipped.
>
># This opens the index.dat file for reading into @temp
> open(INDEX_DAT, "index.dat") || die "Can't open index.dat.\n";
> while (<INDEX_DAT>) {
> @temp = <INDEX_DAT>;
> }
> close(INDEX_DAT);
>
>
># This suggests that the first line del prob is prior to this code
># open(INDEX_TMP, ">index.tmp") || die "Can't open index.tmp.\n";
> foreach $_ (sort @temp) {
> print "$_\n";
> }
># close(INDEX_TMP);
>exit;
>
>My text file (index.dat) looks simular to this:
>Bowden_Jeffrey_T # line 1
>Brimhall_Trent_S # line 2
>
>When I execute it at command line all I get is:
>>Brimhall_Trent_S
>
>Any clues as to why this is happening?
>
>
>Gary
>
>
------------------------------
Date: Fri, 22 Jan 1999 21:55:06 GMT
From: joeltesttutor@my-dejanews.com
Subject: flock and cgi: can it hang?
Message-Id: <78as3k$k5l$1@nnrp1.dejanews.com>
I am setting up a DB_file to store data behind a website.
What happens if a perl script locks a DB_file and then for whatever reason
fails to close the file?
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 22 Jan 1999 22:54:02 -0000
From: "Bruce Davidson" <bruce.d@btinternet.com>
Subject: Graphing
Message-Id: <78avc0$hbm$1@plutonium.btinternet.com>
What would be the best binary module for creating gif charts/graphs on the
fly from a data hash, using Active State perl on w95/PWS.
Thanks
------------------------------
Date: Fri, 22 Jan 1999 15:21:42 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Identify a line
Message-Id: <36A8EBE6.998B3348@us.ibm.com>
Gigatron wrote:
>
> Hello All,
>
> How do I identify a line?
>
> from a text file with many lines?
In a reply to another one of your posts, it was suggested to you that
you either buy "Learning Perl", or read the docs that came with perl.
This was good advice. These questions that you're asking are very
easily answered after just a small amount of effort on your part.
The docs and the FAQ came with perl. They are on your computer. If
they aren't, then you access them from www.perl.com. Become good
friends with the docs and the FAQ. They are very well written.
During the course of your reading, if you run across a passage that
isn't clear, feel free to ask about it. Just be specific, and maybe
give a small piece of your code that isn't working the way you expect it
to.
www.dejanews.com is also an excellent tool for asking newbie questions.
I mean the "power search" tool, not the "post a new message" tool.
Since every newbie question imaginable has already been asked over and
over again, take advantage of that fact. You'll get your answer
quicker, and without the flames that usually accompany "I didn't read
the FAQ, but I'll ask anyway" posts. The power search will let you
limit your search to a single newsgroup, if you wish. Perfect for
researching answers to clpm questions both newbie and otherwise.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Fri, 22 Jan 1999 22:37:48 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Re: Is there an HTML to CGI.pm converter??
Message-Id: <36a8fb01.238234202@news.mindspring.com>
On Fri, 22 Jan 1999 13:59:00 GMT, dturley@pobox.com wrote:
>In article <7885jf$1sl@dgs.dgsys.com>,
> jete@dgs.dgsys.com (Jete Software Inc.) wrote:
>>Is there a converter
>> which will accept a file of HTML code and produce the appropriate
>> calls to CGI.pm routines to produce output which is identical to its
>> HMTL input??
>
>I just answewred this question a couple of weeks ago. Randal Schwartz did
>just this in a column in Web Techniques
>
>http://www.stonehenge.com/merlyn/WebTechniques/col31.listing.txt
Except that that's the wrong listing. You really want
http://www.stonehenge.com/merlyn/WebTechniques/col30.listing.txt
Ben
--
Ben Coleman
Senior Systems Analyst
TermNet Merchant Services, Inc.
Atlanta, GA
------------------------------
Date: Fri, 22 Jan 1999 16:01:23 -0500
From: Bob Freedman <bfreedman@esdim.noaa.gov>
Subject: LWP::Simple HELP!!!
Message-Id: <36A8E723.6F78F67@esdim.noaa.gov>
I am getting errors with code that I simply want to return me a web page
a separated by lines. the code follows along with the command line and
the error:
CODE:
#!/usr/local/bin/perl
use LWP::Simple;
$url = $ARGV[0];
print $url,"\n";
@document = split(/\n/,get($url));
for $document (@document) {
print $_,"\n";
}
COMMAND LINE:
perl -w httptest.pl www.yahoo.com
ERRORS:
Use of uninitialized value at
/usr/local/lib/perl5/site_perl/LWP/Protocol.pm line 107.
Use of uninitialized value at
/usr/local/lib/perl5/site_perl/LWP/Protocol.pm line 82.
Use of uninitialized value at httptest.pl line 7.
------------------------------
Date: Fri, 22 Jan 1999 17:08:48 -0500
From: "Michael Mongeau" <michael_mongeau@stratus.com>
Subject: Re: LWP::Simple HELP!!!
Message-Id: <78assq$6kl@transfer.stratus.com>
Bob Freedman <bfreedman@esdim.noaa.gov> wrote in message
news:36A8E723.6F78F67@esdim.noaa.gov...
>I am getting errors with code that I simply want to return me a web page
>a separated by lines. the code follows along with the command line and
>the error:
>
>CODE:
>#!/usr/local/bin/perl
>
>use LWP::Simple;
>
>$url = $ARGV[0];
>print $url,"\n";
>@document = split(/\n/,get($url));
>for $document (@document) {
> print $_,"\n";
>}
>
>COMMAND LINE:
>perl -w httptest.pl www.yahoo.com
>
I can see two problems. First you need to either pass the full URL on the
command line (http://www.yahoo.com/) or modify the program to add the
protocol header.
$url = "http://" . $url . "/";
The other problem is in your for loop. You specify $document as the loop
variable put then you print out $_. Either change the for statement to
just 'for (@document) ' or change the print statement to 'print
$document,"\n";'
Michael Mongeau
------------------------------
Date: Fri, 22 Jan 1999 14:33:37 -0800
From: "Robert Long" <rgl34@hotmail.com>
Subject: mSQL problem
Message-Id: <78audg$srs@masters0.InterNex.Net>
I hope someone here can help me.
I have a program that uses mSQL on a regular basis. I have had no problems
until lately. On various occasions I get the message that the value for one
of the fields is too long. I have verified that this is not the case, and
that all other values of the fields are correct in type and size. The
strange part is that the update to the database takes, eventhough it reports
this error.
Has anyone run into this problem? If you wish detailed information, please
let me know.
Thanks
Robert
------------------------------
Date: Fri, 22 Jan 1999 21:33:41 GMT
From: jambutter@my-dejanews.com
Subject: Multidimensional arrays.
Message-Id: <78aqrl$io5$1@nnrp1.dejanews.com>
I've got the following code
---------------------------------------------------------
#!/usr/local/bin/perl -w
while(<DATA>)
{
push @arrayoflines, [ split(/,/) ];
}
for $j (0 .. $#arrayoflines)
{
$aref = $arrayoflines[$i];
$n = @$aref - 1;
for $p (0 .. $n)
{
print "element $j $p is $aref->[$p]\n";
}
}
__DATA__
column11,11,column12,12,column13,13
column21,1,column22,22,column23,23
---------------------------------------------------------
Now the output I'm getting is
element 0 0 is column11
element 0 1 is 11
element 0 2 is column12
element 0 3 is 12
element 0 4 is column13
element 0 5 is 13
element 1 0 is column11
element 1 1 is 11
element 1 2 is column12
element 1 3 is 12
element 1 4 is column13
element 1 5 is 13
Whereas, the output I actually want is
element 0 0 is column11
element 0 1 is 11
element 0 2 is column12
element 0 3 is 12
element 0 4 is column13
element 0 5 is 13
element 1 0 is column21
element 1 1 is 21
element 1 2 is column22
element 1 3 is 22
element 1 4 is column23
element 1 5 is 23
What am I doing wrong?
And if I want to work with a multidimensional type struture, is this the best
way to go about doing it? What else could I use?
Any help would be gratefully appreciated.
THANKS.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 22 Jan 1999 15:58:35 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Multidimensional arrays.
Message-Id: <36A8F48B.EB5BBC76@us.ibm.com>
jambutter@my-dejanews.com wrote:
> for $j (0 .. $#arrayoflines)
> {
> $aref = $arrayoflines[$i];
^^^^
$j
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Fri, 22 Jan 1999 21:59:01 GMT
From: birgitt@my-dejanews.com
Subject: Re: Newbie Shopping Cart Question
Message-Id: <78asav$k9r$1@nnrp1.dejanews.com>
In article <36A7AB0D.67E86E93@sinewave.com>,
apoh@sinewave.com wrote:
> I have written a lot of PERL code but all of it pretty simple, mainly
> performing flat file DB operations and maintenance. I'd like to get
> real and interface a shopping cart with a SQL database. I have heard
> there are many shopping cart programs available for free download. Can
> someone recommend one that is a good match with PERL (whether or not I
> have to buy it).
>
> Thanks in advance!!
>
>
http://www.minivend.com
B.Funk
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 22 Jan 1999 13:55:00 -0800
From: "E. Kolve" <drdoctor@u.washington.edu>
Subject: Perl & IIS problem
Message-Id: <36A8F3B4.D5009615@u.washington.edu>
I have installed activestate's perl distribution for NT and I am able to
run your basic "hello world" app, but when I try to run a perl script
that uses the WIN32 module, or any module for that matter, the program
crashes and no output is returned. I re-installed the modules using ppm
to make sure they were there, but that still did not help. Any help
would be appreciated.
thanks,
eric
------------------------------
Date: 22 Jan 1999 15:42:58 -0500
From: tonys@myspleen.kos.net (tony summerfelt)
Subject: Re: Perl editor ?
Message-Id: <36a8e2d2.0@news.kosone.com>
On Fri, 22 Jan 1999 12:35:54 -0500, BELYAKOV_LEN wrote:
> I'm playing with PerlBuilder (from soluctionsoft.com) and while it's
> nice and better than nothing it's got some quirks and behaves annoying
> at times. I'd buy it were it $40, but unfortunately it's $150. Does
> anyone know of another IDE-type editor that's good for using Perl?
http://homepage.dave-world.net/~pete
codemagic is the name of the program. it works with a few languages but the
emphasis is on perl. better yet it's free.
it was in beta last time i checked, but i expect people to forget aobut
perlbuilder (or anything with a $150 price tag) pretty soon after this
program has all it's features in place
--
.t
*-------------------------------------------------------------------------
| origin: ...the vented spleen kingston on (613-544-9332) 1:249/139
|
| `you want a toe? i can get you a toe'
|
| take myspleen out to reply via email
*-------------------------------------
------------------------------
Date: Fri, 22 Jan 1999 21:31:21 GMT
From: dhosek@webley.com
Subject: Re: Perl editor ?
Message-Id: <78aqn9$imr$1@nnrp1.dejanews.com>
In article <36A8B6FA.DE80D6F0@inrange.com>,
BELYAKOV_LEN <len.belyakov@inrange.com> wrote:
> I'm playing with PerlBuilder (from soluctionsoft.com) and while it's
> nice and better than nothing it's got some quirks and behaves annoying
> at times. I'd buy it were it $40, but unfortunately it's $150. Does
> anyone know of another IDE-type editor that's good for using Perl?
I do most of my stuff in emacs. For basic stuff the learning curve is pretty
low and it's capable of doing just about anything, although personally I've
not gotten much more sophisticated than simple keyboard macros.
-dh
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 22 Jan 1999 21:25:01 GMT
From: Chris <chrisl@hamptons.com>
Subject: POD to HTML?
Message-Id: <36A8ECAD.52F2DBD9@hamptons.com>
It seems like an unbelievably obvious step to go from perldoc output to
HTML. So, like, is it?
(I'm new to perl)
- Chris
------------------------------
Date: Fri, 22 Jan 1999 17:11:13 -0500
From: "Michael Mongeau" <michael_mongeau@stratus.com>
Subject: Re: POD to HTML?
Message-Id: <78at1b$6nn@transfer.stratus.com>
Chris <chrisl@hamptons.com> wrote in message
news:36A8ECAD.52F2DBD9@hamptons.com...
>It seems like an unbelievably obvious step to go from perldoc output to
>HTML. So, like, is it?
On Unix: /usr/local/bin/pod2html
On Windows: [PerlHome]\bin\pod2html.bat
Michael Mongeau
------------------------------
Date: Fri, 22 Jan 1999 16:12:38 -0600
From: mike@stok.co.uk (Mike Stok)
Subject: Re: POD to HTML?
Message-Id: <#VTJTRlR#GA.280@news1.texas.rr.com>
In article <36A8ECAD.52F2DBD9@hamptons.com>,
Chris <chrisl@hamptons.com> wrote:
>It seems like an unbelievably obvious step to go from perldoc output to
>HTML. So, like, is it?
>
>(I'm new to perl)
What happens when you try
perldoc pod2html
on your system?
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
| 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Fri, 22 Jan 1999 15:02:21 -0700
From: "Stephanie Wall" <stephanie.wall@coriolis.com>
Subject: Publisher Looking for co-author
Message-Id: <oC6q2.38$U83.1631@news.goodnet.com>
Hello,
I am an acquisitions editor with a computer book publisher and I am looking
for a qualified individual to co-author a book already in development. The
book works with the Perl modules and NT.
Interested persons please contact me by email ASAP.
Thank you,
Stephanie Wall
The Coriolis Group
stephanie.wall@coriolis.com
www.coriolis.com
------------------------------
Date: Fri, 22 Jan 1999 14:13:49 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: regular expression help
Message-Id: <36A8DBFD.7374F33D@us.ibm.com>
josh@sequoiasoft.com wrote:
> I'm trying to chop the .jpg or .gif extensions off a filename, in Perl
> $afile = ($file =~ m:(.*)\\..*:);
> $file is the filename of the picture, eg. Pic1-2.jpg
> This returns an empty string. What am I doing wrong?
For one thing, you are escaping the \ that is supposed to be escaping
the .
Try this instead:
$file =~ m/(.*)\./; # does not modify $file
$afile = $1;
Note that you don't need to use the .* at the end, because it's not
doing anything for you anyway. Also, this will strip any one extension
from a filename. If you really only want to get rid of .jpg or .gif you
could try this:
$file =~ s/\.(jpg|gif)$//; # this modifies $file
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Fri, 22 Jan 1999 14:25:21 -0600
From: mike@stok.co.uk (Mike Stok)
Subject: Re: regular expression help
Message-Id: <uIeUWVkR#GA.188@news1.texas.rr.com>
In article <78aibq$b3h$1@nnrp1.dejanews.com>, <josh@sequoiasoft.com> wrote:
>
>I'm trying to chop the .jpg or .gif extensions off a filename, in Perl
> $afile = ($file =~ m:(.*)\\..*:);
>$file is the filename of the picture, eg. Pic1-2.jpg
>This returns an empty string. What am I doing wrong?
Not reading enough docs?
One way to do it migth be to look at the File::Basename module which might
do what you want, and may seem like overkill.
Do either of these do what you want?
($afile) = $file =~ /(.+)\.[^.]+/;
($afile = $file) =~ s/\.[^.]+$//;
They are two very different beasts, the first does a list assignment of
matched chunks, hence the () around the $afile; the second does an
assignment, and then does a s/// on $afile.
perldoc perlre
and
perldoc perlop
might help you see what's going on.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
| 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Fri, 22 Jan 1999 12:50:47 -0800
From: Ben Gilbert <bgilbert@sgi.com>
Subject: Re: regular expression help
Message-Id: <36A8E4A7.B2994B59@sgi.com>
Although James answered your question you may also want to use
File::Basename. It becomes easy to extract path, name, and suffix from a
given file with the code:
($name,$path,$suffix) = fileparse("lib/File/Basename.pm","\.pm");
Look at perldoc File::Basename for more info. Just goes to show there is
always more than one way to do it. ;)
-Ben
--
Ben Gilbert bgilbert@sgi.com 650.933.8721 (w) 888.502.3126 (p)
Technical Consultant, SGI http://reality.sgi.com/bgilbert/
-----------------------------------------------------------------
This transmogrifier will turn you into anything at all. - Calvin
-----------------------------------------------------------------
------------------------------
Date: Fri, 22 Jan 1999 20:40:47 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: regular expression help
Message-Id: <F5zArz.4G@news.boeing.com>
In article <78aibq$b3h$1@nnrp1.dejanews.com>, <josh@sequoiasoft.com> wrote:
>I'm trying to chop the .jpg or .gif extensions off a filename, in Perl
> $afile = ($file =~ m:(.*)\\..*:);
>$file is the filename of the picture, eg. Pic1-2.jpg
>This returns an empty string. What am I doing wrong?
>
A case of operator error...
You're using the match operator C<m> when you want
the substitute C<s> operator. They're both in perlop:
perldoc perlop and look for discussions beginning:
m/PATTERN/cgimosx
s/PATTERN/REPLACEMENT/egimosx
hth,
--
Charles DeRykus
------------------------------
Date: 22 Jan 1999 20:03:15 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: regular expression help
Message-Id: <78ali3$i5r$1@info.uah.edu>
In article <78aibq$b3h$1@nnrp1.dejanews.com>,
josh@sequoiasoft.com writes:
: I'm trying to chop the .jpg or .gif extensions off a filename, in Perl
: $afile = ($file =~ m:(.*)\\..*:);
: $file is the filename of the picture, eg. Pic1-2.jpg
: This returns an empty string. What am I doing wrong?
Did you check to make sure the match succeeded? Your problem is that
you have an extra backslash (your pattern is looking for a backslash
in the filename). Use something like this:
my($base,$ext);
if ($file =~ /^(.*)\.(.*)$/) {
($base,$ext) = ($1,$2);
}
else {
warn "$0: could not decompose `$file'\n";
}
Hope this helps,
Greg
--
In my opinion MS is a lot better at making money than it is at making good
operating systems.
-- Linus Torvalds
------------------------------
Date: Fri, 22 Jan 1999 21:18:07 +0100
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: SWIG with ActiveState?
Message-Id: <36acda5c.7201395@news3.ibm.net>
[mailed & posted]
Steve Beisner <beisner@acm.org> wrote:
>Is anyone successfully using SWIG with ActiveState
>(5.0 patchlevel 5 subversion 02)?
>
>I can build and install it fine, but I'm getting
>undefined symbols at link time on even the simplest
>examples. From the symbol names, it looks like
>perhaps something has changed name (just a wild
>guess) in perlcore.lib. Missing symbols are
> __imp__PL_stack_sp
> __imp__PL_stace_base
> __imp__PL_markstack_ptr
> __imp__PL_sv_yes
>
>Or maybe there's a .lib file I'm missing? Any help
>appreciated.
I have *no* idea how SWIG works, so this is just wild guessing. But here
goes: ActivePerl is built using the PERL_OBJECT option. That means all the
undefined symbols above are not really exported in that version; they have
become member variables of the CPerlObj object. You have to use the
PERL_OBJECT option for your extension too to link with ActivePerl.
Alternatively you could use the C-API layer (link with PerlCAPI.lib). In
MakeMaker controlled extensions you can force building with C-API by:
perl Makefile.PL CAPI=TRUE
Note that "CAPI=TRUE" *must be* in uppercase!
-Jan
------------------------------
Date: Fri, 22 Jan 1999 21:28:27 GMT
From: don_hosek@my-dejanews.com
Subject: Re: The Documeantion (was Re: Perl problem :(Offline mode...)
Message-Id: <78aqhd$iim$1@nnrp1.dejanews.com>
In article <882R7JAziLq2EwFK@beausys.demon.co.uk>,
Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> In article <slrn7agm54.nt0.sholden@pgrad.cs.usyd.edu.au>, Sam Holden
> <sholden@pgrad.cs.usyd.edu.au> writes
> >I can only dream of the day that people actually learn how to read manuals,
> >and don't get into the habit of asking in newsgroups for everything. Of
course
> >if people keep answering them with more than a reference to the docs then it
> >will never happen...
> I spend half my life reading manuals. I also know that manuals dont
> always tell you what you want to know.
> However, I have to say that I amazed by this attitude. I guess that one
> could, with such reasoning, answer 99.9% of all the questions that come
> up on this newsgroup with the simple (and unhelpful) reply of "Read the
> manual!".
Free software documentation is frequently a bit dicey. The cold hard truth of
the matter is that being a good programmer does not always translate to being
a good documenter. A great deal is assumed about the background of readers
which is not always true.
The FAQ for Perl at www.perl.com is devoid of basic usability features (e.g.,
links to questions and answers from the TOC). I've been rapidly coming up to
speed with Perl 5 the past couple of weeks and I couldn't find answers to
some of the basic questions like how to make two-dimensional arrays & the
like in the FAQ. Trying to figure out which of the big perldoc pages to find
some information in is not intuitive to the newcomer. The CPAN web interface
is also a bit perplexing to the newcomer. A better interface could do a lot
to eliminate many questions which are answered with "the XXX module does
exactly what you need."
In an ideal world, before posting a query to a newsgroup, one should try to
find the information in printed and on-line manuals, including a search for
previous inquiries on dejanews. In practice this doesn't happen.
Personally, I don't think that it takes that much more effort to give an
answer along the lines of:
You can get that sort of functionality using XXX. Try perldoc -f XXX for full
details.
than to be snippy and post something like
rtfm, you stupid twit.
If you're not willing to be helpful, why bother posting a reply?
-dh (who knows more than some, less than many, but is at least willing to help
as best as he is able).
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 22 Jan 1999 14:29:48 -0800
From: "Harish Mittal" <harish_mittal@usa.net>
Subject: Where can i find the Perl software for Windows-95.
Message-Id: <36a9dde9.0@news.hkc.net>
Can anybody please tell me where to find the perl for windows 95.
Thanx in advance.
Harish Mittal
harish_mittal@usa.net
------------------------------
Date: Fri, 22 Jan 1999 17:34:15 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Y2K?
Message-Id: <1dm1fcj.1cwxw3bfbe3m2N@roxboro0-062.dyn.interpath.net>
<dhosek@webley.com> wrote:
> abigail@fnx.com wrote:
> > Tuomas Angervuori (tumppi@icon.fi) wrote
> > || I have a script which compares two dates.
> > || -Clip-
> > || ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
> > || localtime(time);
> > || #if current date is newer than the one mared in data files, update...
> > || if (($year == $year_data) and ($mon >= $mon_data)) {
> > || if ($mday > $mday_data) {
> > || &update;
> > || }
> > || }
> > || if ($year > $year_data) {
> > || &update;
> > || }
> > || -Clip-
> > ||
> > || $year_data, etc, are found from the data files.
> > ||
> > || As you might have noticed, this isn't year 2000 compatible.
>
> > And why isn't it year 2000 compatible?
>
> The fact that the localtime function returns a year in 2-digit format
> confuses a lot of people who assume that this means that it will return 00
> for the year 2000. It will, in fact return 100 for the year 2000. To convert
> a year to 4-digit format (which presumably was the source of the original
> poster's concern), it is adequate to simply add 1900 to the year. On the
> other hand, if you're still using a 32-bit system in the year 2038, Unix date
> functions in general will fail (or at least those that use seconds since
> 1970).
>
> As the year progresses, this will probably become an increasingly frequently
> asked question.
Silly stuff like the above is already a frequently asked/said.
The above code handles the year 2000 just fine, which was Abigail's
point (I believe). Also it's bad enough reading and answering the
explicit misunderstandings people have (at least then they are easily
addressed) without having to deal with the implied -- for all we can
know "Tuomas" thought that when reading in the year from a file it would
always be something like "2000.0000000000001".
--
John Moreno
------------------------------
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 4724
**************************************