[21728] in Perl-Users-Digest
Perl-Users Digest, Issue: 3932 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 8 06:05:53 2002
Date: Tue, 8 Oct 2002 03:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 8 Oct 2002 Volume: 10 Number: 3932
Today's topics:
[NewBie] Using libraries without installing on Web <david.hawley@acm.org>
Re: [NewBie] Using libraries without installing on Web <nospam@nospam.com>
array question (Mary Wong)
Re: array question <nospam@nospam.com>
Re: array question <krahnj@acm.org>
Re: array question <usenet@tinita.de>
Re: array question <bart.lateur@pandora.be>
Re: Convert Perl script to C program (and Why was this (Helgi Briem)
eMail Relay Server with testing features (NiCC)
Re: eMail Relay Server with testing features <bernard.el-hagin@DODGE_THISlido-tech.net>
Forking woes <morganm@qualcomm.com>
Re: Forking woes <nospam@nospam.com>
Re: Forking woes <nospam@nospam.com>
Re: Help me understand *foo = \... <nospam-abuse@ilyaz.org>
Re: ithreads, perl 5.8 and shared objects <nospam-abuse@ilyaz.org>
Re: ithreads, perl 5.8 and shared objects <uri@stemsystems.com>
Re: mod_perl startup.pl and require <nospam@nospam.com>
Re: newb here learning Perl <johannes.fuernkranz@t-online.de>
Re: One line to Segfault Perl <nospam-abuse@ilyaz.org>
Problem configuring perl-5.8.0 <laguest@nospam.abyss2.demon.co.uk>
Re: Script to Change Filename <nospam-abuse@ilyaz.org>
Split a string (Dmitry)
Re: Split a string <dav.1@bigfoot.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 8 Oct 2002 13:49:35 +0900
From: "Sojourneer" <david.hawley@acm.org>
Subject: [NewBie] Using libraries without installing on Web
Message-Id: <antoq9$kf2$1@newsflood.tokyo.att.ne.jp>
Hi all.
I want to run some Perl scripts on a shared Web host. The hosting provider
I'm talking to does not allow installation of modules, so only the standard
ActivePerl5 modules are supported. Unfortunately I need modules, that
though are registered and available from repositories, aren't in the
standard install.
Question 1: Can I work around this?
Question 2: Does anyone know of Windows-based hosting services that are more
flexible, while supporting ASP and MSXML?
Thanks loads in advance.
------------------------------
Date: Mon, 7 Oct 2002 22:41:22 -0700
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: [NewBie] Using libraries without installing on Web
Message-Id: <3da26f7a_2@nopics.sjc>
"Sojourneer" <david.hawley@acm.org> wrote in message
news:antoq9$kf2$1@newsflood.tokyo.att.ne.jp...
> Hi all.
>
> I want to run some Perl scripts on a shared Web host. The hosting
provider
> I'm talking to does not allow installation of modules, so only the
standard
> ActivePerl5 modules are supported. Unfortunately I need modules, that
> though are registered and available from repositories, aren't in the
> standard install.
>
> Question 1: Can I work around this?
Yes.
use lib "path_to_module";
ex: use lib "/usr/local/foo/Foo";
> Question 2: Does anyone know of Windows-based hosting services that are
more
> flexible, while supporting ASP and MSXML?
> Thanks loads in advance.
>
>
>
>
>
>
------------------------------
Date: 7 Oct 2002 22:48:55 -0700
From: mary_wong1232002@yahoo.com (Mary Wong)
Subject: array question
Message-Id: <5b85cd30.0210072148.3d9c170b@posting.google.com>
Hello,
Anyone can tell me what's wrong in this program?
or how to fix it. THANK
#!/usr/bin/perl -w
@fruits=('apple', 'orange', 'banana');
print("\n3 fruits:@fruits\n");
print("\nEnter an index number between 0 and 2 to delete fruit from the list:
");
while(($index=<STDIN>) !~ /\d/ || $index < 0 || $index > 2)
{
print("\nIllegal input\n");
print("Please enter an index number between 0 and 2 again: ");
}
delete $fruits[$index];
print "@fruits\n";
$ lb2
3 fruits:apple orange banana
Enter an index number between 0 and 2 to delete fruit from the list: 8
Illegal input
Please enter an index number between 0 and 2 again: d
Illegal input
Please enter an index number between 0 and 2 again: 0
Use of uninitialized value in join or string at lb2 line 14, <STDIN> line 3.
orange banana
$
------------------------------
Date: Mon, 7 Oct 2002 23:20:25 -0700
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: array question
Message-Id: <3da278a1$1_4@nopics.sjc>
"Mary Wong" <mary_wong1232002@yahoo.com> wrote in message
news:5b85cd30.0210072148.3d9c170b@posting.google.com...
> Hello,
>
> Anyone can tell me what's wrong in this program?
> or how to fix it. THANK
[snipped]
Mary,
deleting an element from the beginning or middle of an array doesn't
actually "delete" it. The element coresponding to the position will be set
to the uninitialized state, hence, the error message. If you test for the
existence of the element with "exists", you'll get a false return even
though the array hasn't shrunk at all unless the deleted element happens to
be at the end of the array. For your script. simply use "splice" to
completely remove the element off the array.
splice @fruits, $index, 1;
print @fruits, "\n";
------------------------------
Date: Tue, 08 Oct 2002 06:29:37 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: array question
Message-Id: <3DA27B3F.EE221936@acm.org>
Mary Wong wrote:
>
> Anyone can tell me what's wrong in this program?
> or how to fix it. THANK
>
> #!/usr/bin/perl -w
>
> @fruits=('apple', 'orange', 'banana');
> print("\n3 fruits:@fruits\n");
>
> print("\nEnter an index number between 0 and 2 to delete fruit from the list:
> ");
> while(($index=<STDIN>) !~ /\d/ || $index < 0 || $index > 2)
> {
> print("\nIllegal input\n");
> print("Please enter an index number between 0 and 2 again: ");
> }
>
> delete $fruits[$index];
This is the same as $fruits[$index] = undef; To remove the array
element use:
splice @fruits, $index, 1;
> print "@fruits\n";
John
--
use Perl;
program
fulfillment
------------------------------
Date: 8 Oct 2002 08:01:25 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: array question
Message-Id: <anu3cl$h700t$2@fu-berlin.de>
John W. Krahn <krahnj@acm.org> wrote:
>>
>> delete $fruits[$index];
> This is the same as $fruits[$index] = undef;
actually, it's different:
$ perl -wle'
@a = qw(a b c);
$a[0] = undef;
print exists $a[0] ? 1 : 0;
delete $a[0];
print exists $a[0] ? 1 : 0;'
1
0
regards, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Tue, 08 Oct 2002 09:49:46 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: array question
Message-Id: <mda5qu4hqjue0if65jomijf99f7367s56b@4ax.com>
Tina Mueller wrote:
>>> delete $fruits[$index];
>
>> This is the same as $fruits[$index] = undef;
>
>actually, it's different:
>$ perl -wle'
>@a = qw(a b c);
>$a[0] = undef;
>print exists $a[0] ? 1 : 0;
>delete $a[0];
>print exists $a[0] ? 1 : 0;'
>1
>0
That's a historical difference, intended for the use of pseudo-hashes.
Now that those are on the way out, this difference is not much more than
a fait divers.
--
Bart.
------------------------------
Date: Tue, 08 Oct 2002 09:12:26 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <3da2a0f5.2508339852@news.cis.dfn.de>
On Mon, 07 Oct 2002 18:28:36 GMT, "MrFFrreeddoo"
<mapSoN.S.S@oderF> wrote:
>"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
>news:Pine.LNX.4.40.0210071851000.10879-100000@lxplus075.cern.ch...
>> On Oct 7, -F-r-e-d-o- inscribed on the eternal scroll:
>>
>> > But sigh, I am obviously just wasting my time,
>>
>> The time you're wasting isn't only your own, while we struggle to
>> find the common factor to put into the killfile recipe.
>
>Thats not my problem. ^
No, you have far more serious problems than that Manfred,
Manny, Fredo, whatever you want to call yourself.
>LOL how predictable of you folk. Got no balls to ACTUALLY
>address the issue,
Everybody has long forgotten what the issue was. We are
going mad from having an annoying whining toddler throwing
tantrums in our newgroup.
Go away, NOW!
--
Regards, Helgi Briem
helgi AT decode DOT is
A: Top posting
Q: What is the most irritating thing on Usenet?
- "Gordon" on apihna
------------------------------
Date: 8 Oct 2002 02:27:47 -0700
From: mail@dominicneumann.de (NiCC)
Subject: eMail Relay Server with testing features
Message-Id: <887ed4b5.0210080127.79127d78@posting.google.com>
hi.
i want to write an email relay server with gets all the mail message.
then it must test the to, cc and bcc fields for some words and put a
log message to a file if something was found.
independent from the result of the test all mails must be forwarded
unchanged to the real mail server.
how can i realize this??
thanks
------------------------------
Date: Tue, 8 Oct 2002 09:30:34 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: eMail Relay Server with testing features
Message-Id: <slrnaq59ag.7v3.bernard.el-hagin@gdndev25.lido-tech>
In article <887ed4b5.0210080127.79127d78@posting.google.com>, NiCC
wrote:
> hi.
> i want to write an email relay server with gets all the mail message.
> then it must test the to, cc and bcc fields for some words and put a
> log message to a file if something was found.
> independent from the result of the test all mails must be forwarded
> unchanged to the real mail server.
>
> how can i realize this??
http://www.procmail.org
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Mon, 7 Oct 2002 23:28:27 -0700
From: "Mark Morgan" <morganm@qualcomm.com>
Subject: Forking woes
Message-Id: <anttuc$lb$1@coset.qualcomm.com>
Hi all,
Hoping someone can offer some insight here. :) I have a perl script I've
written whos job it is to do some work, fork a child (daemon) and then exit.
This seems to work great in most circumstances. I had some initial issues
with closing out file descriptors which gave me woes early on, but I've
worked those out now. I've now tested the script using perl, C-system calls
and C-exec calls, and all work well and return properly.
So here's the issue. We run a third-party solution also written in C,
which also makes system calls. When setting up this program to call my perl
script, however, it hangs and waits for the child process to return.
Obviously since the child is a daemon, it never returns, and thus the call
never returns in the third party software. Obviously bad behaviour.
Obviously, I don't have the vendor's code to look at to see exactly how
they're calling exec/wait. Has anyone ever seen similar behaviour, or does
someone more knowledgable in the ways of exec/wait have some insight to
offer? I'd like to be able to reproduce the error myself, but my meagre
attempts at using a simple exec/wait always work fine. I'm thinking the
vendor must be specifying some sort of flag which is telling wait() to wait
for all grandchildren to return.. any ideas?
Thanks,
- Mark
------------------------------
Date: Mon, 7 Oct 2002 23:39:29 -0700
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: Forking woes
Message-Id: <3da27d19$1_5@nopics.sjc>
"Mark Morgan" <morganm@qualcomm.com> wrote in message
news:anttuc$lb$1@coset.qualcomm.com...
> Hi all,
>
> Hoping someone can offer some insight here. :) I have a perl script
I've
> written whos job it is to do some work, fork a child (daemon) and then
exit.
> This seems to work great in most circumstances. I had some initial issues
> with closing out file descriptors which gave me woes early on, but I've
> worked those out now. I've now tested the script using perl, C-system
calls
> and C-exec calls, and all work well and return properly.
>
> So here's the issue. We run a third-party solution also written in C,
> which also makes system calls. When setting up this program to call my
perl
> script, however, it hangs and waits for the child process to return.
> Obviously since the child is a daemon, it never returns, and thus the call
> never returns in the third party software. Obviously bad behaviour.
>
> Obviously, I don't have the vendor's code to look at to see exactly how
> they're calling exec/wait. Has anyone ever seen similar behaviour, or
does
> someone more knowledgable in the ways of exec/wait have some insight to
> offer? I'd like to be able to reproduce the error myself, but my meagre
> attempts at using a simple exec/wait always work fine. I'm thinking the
> vendor must be specifying some sort of flag which is telling wait() to
wait
> for all grandchildren to return.. any ideas?
>
> Thanks,
> - Mark
>
>
Umm...that's interesting. Why don't you detach the deamon by changing its
sid? Make it an independent session by calling setsid or some similar
function, just to see if the same behavior reoccur.
------------------------------
Date: Mon, 7 Oct 2002 23:43:41 -0700
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: Forking woes
Message-Id: <3da27e15$1_2@nopics.sjc>
"Tan Nguyen" <nospam@nospam.com> wrote in message
news:3da27d19$1_5@nopics.sjc...
> Umm...that's interesting. Why don't you detach the deamon by changing its
> sid? Make it an independent session by calling setsid or some similar
> function, just to see if the same behavior reoccur.
Well, I assume you run your stuff on *nices. I don't know if Windows
implements some sort of a equivalent function. Since MS claims that Windows
is POSIX compatible, I assume they have it too.
use POSIX qw(setsid);
------------------------------
Date: Tue, 8 Oct 2002 05:50:11 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Help me understand *foo = \...
Message-Id: <antrmj$ndo$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Da Witch
<heather710101@yahoo.com>], who wrote in article <ansjet$o23$1@reader1.panix.com>:
> I've read all the relevant parts in the Camel book (I think), but I'm
> still very confused by Perl expressions such as:
>
> *xyz = [1, 2, 3];
You have every right to be. Basically: people wanted some new
functionality from the interpreter, and wanted to achieve it without
inventing new keywords. So they looked for a syntax which did not
make sense before, and made the interpreter make the wanted action
when it saw the syntax.
Which did not make the syntax have any sense... This is extremely
ugly hack; IIRC, nowadays it should have been written as
*xyz{ARRAY} = [1,2,3];
[Other people explained the difference w.r.t. our(), which has a
similar consequences in the lexical settings.]
Ilya
------------------------------
Date: Tue, 8 Oct 2002 05:40:24 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <antr48$n72$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Rocco Caputo
<troc@netrus.net>], who wrote in article <slrnapvo65.8ma.troc@eyrie.homenet>:
> I must disagree with you here. A properly designed events library
> will integrate itself with other event loops without the need for
> strange select() hacks. As Uri mentioned, POE includes such a
> library.
Oh, get real! There is *absolutely* no way to marry several event
loops which use different IPC mechanisms - unless your OS supports
waiting on both kinds of events. Try to wait on a semaphore *or* on
file-being-readable (without using the threads). Even using the
threads this requires ugly hacks. (I did it for Tk event loop on OS/2
- which can wait on GUI events together with select(). Ugly...)
> POE's library presents an abstract interface to events. It supports a
> number of concrete event loops through the use of bridge classes [1].
> These bridges replace POE's default select() code entirely with other
> event loops, making select() hacks moot.
Now suppose two modules - which do not know about each other - try to
subclass select(). How would they do it?
Ilya
------------------------------
Date: Tue, 08 Oct 2002 05:57:45 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <x7n0ppxyjr.fsf@mail.sysarch.com>
>>>>> "IZ" == Ilya Zakharevich <nospam-abuse@ilyaz.org> writes:
IZ> [A complimentary Cc of this posting was sent to
IZ> Rocco Caputo
IZ> <troc@netrus.net>], who wrote in article <slrnapvo65.8ma.troc@eyrie.homenet>:
>> I must disagree with you here. A properly designed events library
>> will integrate itself with other event loops without the need for
>> strange select() hacks. As Uri mentioned, POE includes such a
>> library.
IZ> Oh, get real! There is *absolutely* no way to marry several event
IZ> loops which use different IPC mechanisms - unless your OS supports
IZ> waiting on both kinds of events. Try to wait on a semaphore *or* on
IZ> file-being-readable (without using the threads). Even using the
IZ> threads this requires ugly hacks. (I did it for Tk event loop on OS/2
IZ> - which can wait on GUI events together with select(). Ugly...)
that isn't what he is saying. poe can piggyback on several other
existing event loop systems (e.g. tk) and not use its own one. there is
no need to merge two complete event loop systems. his words above could
be construed that way but he didn't mean it that way.
>> POE's library presents an abstract interface to events. It supports a
>> number of concrete event loops through the use of bridge classes [1].
>> These bridges replace POE's default select() code entirely with other
>> event loops, making select() hacks moot.
IZ> Now suppose two modules - which do not know about each other - try to
IZ> subclass select(). How would they do it?
again, that is not relevant. only one module should ever do the core
select calls. poe can choose which one does it which is what
matters. then it supplies a wrapper for poe to use that event loop and
all poe compatible modules should work fine. if some external module
does its own event loop then it won't integrate well. that is why you
don't write hardwired event loops. one reason LWP::Parallel sucks IMO is
that its event loop is jammed into its code. and that event loop is
specific to that module and not usable by other modules. LWP itself
should have been written with event loops in mind (a callback i/o API
which would work with regular or event loop i/o) so it would port to
event loops but it wasn't.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 7 Oct 2002 23:07:05 -0700
From: "Tan Nguyen" <nospam@nospam.com>
Subject: Re: mod_perl startup.pl and require
Message-Id: <3da27581$1_4@nopics.sjc>
"Ken" <angel@xev.net> wrote in message
news:fafcc419.0210071654.2adc908@posting.google.com...
> I am currently using mod_perl. I use a startup.pl script to preload
> all my needed modules. Most of them I load with use(). However, there
> are some modules that I need to create when Apache is started. The
> files don't exist until Apache is started. (Just bare with me.) I
> create the modules in startup.pl. Therefore, I can't use the use()
> statement. If I try, the modules are loaded before they exist.
>
> Ok, here is my question:
> Will loading modules with require() preload them into memory like the use
statement does?
Yes and No.
Say, we have a module "Foo" with an exported function "bar". When you
"require Foo", you load Foo into memory but you don't import "bar". When you
"use Foo", you load Foo into memory and import "bar" into your current
namespace at compile time.
use Foo;
is equivalent to
BEGIN { require Foo; import Foo }
so you can call bar like this:
bar "Good day, mate";
require Foo;
and you try
bar "Good day, mate";
you'll hear errors screaming at you.
Of course, you can get around like this:
Foo::bar "Good day, mate";
>Are there any reasons I shouldn't load modules with require() in this way?
If you'd like "use" to take care of the import step, use it. I'd like to
"use" modules as it's the norm these days and at least saves you 4
characters of typing compared to "require". You can always "require" modules
with "use" by quoting importing nothing into the namespace like this
use Foo qw();
------------------------------
Date: Tue, 08 Oct 2002 11:16:02 +0200
From: =?ISO-8859-1?Q?Johannes_F=FCrnkranz?= <johannes.fuernkranz@t-online.de>
Subject: Re: newb here learning Perl
Message-Id: <anu7s0$arm$01$1@news.t-online.com>
John W. Krahn wrote:
>
> news:comp.lang.perl.moderated sends an E-Mail/FAQ thing when you post
> for the first time.
I've tried to post there several times, never received anything.
I tried to register by sending E-mail to the administrators, never
received a reply.
The part I liked most about the welcome-message was:
6. Will I receive a rejection notice if my submission is rejected?
Absolutely. Always. Without fail. Yes. In case this isn't clear:
POSTS ARE NEVER REJECTED SILENTLY.
They sure had me on that one...
Juffi
------------------------------
Date: Tue, 8 Oct 2002 05:42:59 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: One line to Segfault Perl
Message-Id: <antr93$n7l$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Mark Jason Dominus
<mjd@plover.com>], who wrote in article <anmu5c$agk$1@plover.com>:
> >but you have to ask the question wtf execute 'undef tcp'?
>
> Maybe you have to ask that; I don't.
>
> I once reported that Perl dumped core when I gave it a uuencoded file
> as input.
I submitted "test Perl with a random Perl-like program" suite a couple
of years ago. Do not know whether it is run against the new versions
nowadays...
Ilya
------------------------------
Date: Tue, 08 Oct 2002 09:17:14 +0100
From: "Luke A. Guest" <laguest@nospam.abyss2.demon.co.uk>
Subject: Problem configuring perl-5.8.0
Message-Id: <anu4a9$n2$1$830fa7a5@news.demon.co.uk>
Hi,
I'm currently trying to build an LFS system, but keep failing when I try to
configure perl-5.8.0. I have seen this problem before, but I canot remember
how to fix it. Basically, if I follow the commands for configuring
perl-5.8.0 I get a broken makefile:
Make[1]: Leaving directory `/usr/src/perl-5.8.0/x2p'
Now you must run 'make'.
If you compile perl5 on a different machine or from a different object
directory, copy the Policy.sh file from this object directory to the
new one before you run Configure -- this will help you with most of
the policy defaults.
makefile:856: *** missing separator. Stop.
This is a spurious "0" character at the beginning of the line, just before
this stuff:
av$(OBJ_EXT): av.c
av$(OBJ_EXT): av.h
av$(OBJ_EXT): config.h
...
Now, I just configured it in redhat and it doesn't give me this problem.
Now, I'm wondering if I don't have the correct packages installed to get it
to work properly. These are the packages that we install for a basic
(statically linked) system (before we compile our dynamically linked
system):
Bash-2.05a
Binutils-2.13
Bzip2-1.0.2
Diffutils-2.8.1
Fileutils-4.1
Findutils-4.1
Gawk-3.1.1
GCC-3.2
Grep-2.5
Gzip-1.2.4a
Make-3.79.1
Patch-2.5.4
Sed-3.02
Sh-utils-2.0
Tar-1.13
Texinfo-4.2
Textutils-2.1
Util-linux-2.11u
This is the URL for the book that I'm following:
http://www.linuxfromscratch.org/view/cvs/
Thanks in advance,
Luke.
------------------------------
Date: Tue, 8 Oct 2002 05:33:13 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Script to Change Filename
Message-Id: <antqmp$n01$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
JP
<NO_SPAM_pangjoe@rogers.com>], who wrote in article <RW7n9.174125$8b1.150642@news01.bloor.is.net.cable.rogers.com>:
> I am trying to write a shell script to rename files in a sub-directories.
> Here is what I have to do:
>
> 1. Select only those filenames with .dat extension
> 2. The sournce filename must be all numeric but ends with a character
> digital, e.g. 12345a.dat, 234567b.dat
> 3. If it meets the above two criteria, rename the file by inserting a dash
> in between the numerals and character, e.g. 12345a.dat --> 12345-a.dat,
> 234567b.dat -->234567-b.dat
>
> I have trouble filtering the numeric part with variable length. Any
> suggestions?
Given that you you now know what REx to use, run
pfind . -f 'Put-Your-REx-Here'
[correct the quoting to suit your shell]. pfind script (find/grep
with the Perl syntax) is available on my dir on CPAN.
Hope this helps,
Ilya
------------------------------
Date: 7 Oct 2002 23:19:42 -0700
From: Dmitry_Babich@icomverse.com (Dmitry)
Subject: Split a string
Message-Id: <f21990ff.0210072219.6b8295f@posting.google.com>
Hi all
I have a string that should be split to array of lines according to the following:
(1) newline donates end of the current line
(2) each line should be not longer than 5 characters and line can
split a word
E.g. String "abc\n12 45678" (Assume that there is no words longer than 5 characters)
Line[0] = "abc"
Line[1] = "12 "
Line[2] ="45678";
P.S.
The question is not just theoretical.
Consider utility that receives a string and should display it
on the screen with 5 columns. We don't want the utility
to split words, hence thus 2 condition. First condition is obvious.
Thanks
------------------------------
Date: Tue, 8 Oct 2002 10:27:48 +0200
From: "Al" <dav.1@bigfoot.com>
Subject: Re: Split a string
Message-Id: <anu4u4$8f6$1@sunnews.cern.ch>
"Dmitry" <Dmitry_Babich@icomverse.com> wrote in message
news:f21990ff.0210072219.6b8295f@posting.google.com...
> Hi all
>
> I have a string that should be split to array of lines according to the
following:
> (1) newline donates end of the current line
> (2) each line should be not longer than 5 characters and line can
> split a word
>
> E.g. String "abc\n12 45678" (Assume that there is no words longer than 5
characters)
> Line[0] = "abc"
> Line[1] = "12 "
> Line[2] ="45678";
>
> P.S.
> The question is not just theoretical.
> Consider utility that receives a string and should display it
> on the screen with 5 columns. We don't want the utility
> to split words, hence thus 2 condition. First condition is obvious.
>
> Thanks
hi
some thing like this .............sorry probably a long way of doing it but
it might help you
----------------------------------------------------------------------------
-------------------------------------
#!/usr/bin/perl -w
$string="abcdefgdlfsdlfdslkfjdslfjds1234567890\n9847598475947598347";
if($string=~/(\w+)\n/){
spliter($1);
spliter($');
}else{
spliter($string);
}
sub spliter{
$true=1;
$strg=$_[0];
if(length($strg)>5){
$entry=substr($strg,0,5);
$rem=substr($strg,6,);
push @list, $entry;
}else{
push @list, $strg;
}
while ($true){
if(length($rem)>5){
$entry=substr($rem,0,5);
$rem=substr($rem,6,);
push @list, $entry;
}else{
push @list, $rem;
undef $true;
}
}
}
while(<@list>){
print "$_\n";
}
----------------------------------------------------------------------------
----------------------------------------------------------
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 3932
***************************************