[10301] in Perl-Users-Digest
Perl-Users Digest, Issue: 3894 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 5 15:13:12 1998
Date: Mon, 5 Oct 98 12:05:33 -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, 5 Oct 1998 Volume: 8 Number: 3894
Today's topics:
Re: $/ in 5.005 <Jochen.Stenzel.gp@icn.siemens.de>
Add user script <tytek@yahoo.com>
ANN: Intro/Advanced Perl class, Phila area, Oct 26-30 <joseph@5sigma.com>
Common prefix for an array of strings (Bart Lateur)
Re: DEL in PERL (Abigail)
Re: HELP !!! <jdporter@min.net>
Help with Embedding Perl into multiple instance in diff <victorl@egSoftware.com>
Help with perl code !!!! nguyen.van@imvi.bls.com
Re: HERE Documents and skipping indentation (advanced) (John Klassa)
Re: I want to write an NT service in Perl [SUMMARY] <aspinelli@ismes.it>
memory management teds@intex.com
Re: need a regular expressions expert... (Patrick Timmins)
Re: Passing Variables: $_ vs. @_ <rabell@ti.com>
Re: Passing Variables: $_ vs. @_ <rabell@ti.com>
Re: Passing Variables: $_ vs. @_ <rabell@ti.com>
Re: Passing Variables: $_ vs. @_ <jdporter@min.net>
Re: Passing Variables: $_ vs. @_ <rabell@ti.com>
Re: Passing Variables: $_ vs. @_ <eashton@bbnplanet.com>
Perl and Novell Netware v4 (Michael Congdon)
Re: Perl and Novell Netware v4 <eashton@bbnplanet.com>
Re: read subdirectories <jdporter@min.net>
Re: regex help <r28629@email.sps.mot.com>
Re: regex help droby@copyright.com
Re: Search for forwardslash...how? <matt@whiterabbit.co.uk>
Re: Search for forwardslash...how? <gadget@bc.sympatico.ca>
Re: Search for forwardslash...how? <r28629@email.sps.mot.com>
Re: Search for forwardslash...how? <jdporter@min.net>
Re: send geroge reese (was Re: Call for Participation: (Abigail)
Re: sort question? <matt@whiterabbit.co.uk>
Re: sort question? (Brand Hilton)
Re: Split question - retain the pattern? (Bart Lateur)
Re: Split question - retain the pattern? <jdporter@min.net>
Re: Sys::Syslog problems (Marc Haber)
Re: Sys::Syslog problems (Douglas SEAY)
Win32::EventLog::Read <kyeh@ix.directmedia.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 05 Oct 1998 18:06:53 +0200
From: "Hr. Jochen Stenzel" <Jochen.Stenzel.gp@icn.siemens.de>
Subject: Re: $/ in 5.005
Message-Id: <3618EE9D.B40EAA70@icn.siemens.de>
Hello,
> I still used 5.00501. May be 5.00502 is the better choice - so I will try
> it.
Well, I tried 5.00502, but the behaviour remained. After that, I rebuilt
Perl WITHOUT thread support (which I used both in the previous 5.00501
executable and in my first 5.00502 build). This made the difference. Now the
testscript replies A AND B. In other words, $/ is already known at compile
time.
Unfortunately, I WANT to use threads ...
Jochen
------------------------------
Date: Mon, 5 Oct 1998 14:54:35 -0400
From: "Ty Goolman" <tytek@yahoo.com>
Subject: Add user script
Message-Id: <6vb5i7$d81@nntp1.erinet.com>
I am in search of an add user script. I am running Apache/1.2.6
FrontPage/3.0.3 on a RH Linux server. I would like to automate adding new
users to my server. I would prefer using a Perl script(s).
--
Ty Goolman
Tytek Network Solutions - http://www.tytek.net
Tytek Computers - http://www.tytek.com
Win $$$, Prizes. Get Free Stuff - http://www.winonthe.net
Muscle Car Mania - http://muscle.tytek.net
------------------------------
Date: Mon, 05 Oct 1998 10:27:00 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: ANN: Intro/Advanced Perl class, Phila area, Oct 26-30
Message-Id: <36190154.6C8FAA4B@5sigma.com>
I'll be teaching another "Learning Perl + PROM" class in Moorestown,
New Jersey October 26-30. This is a combination of an introductory
Perl course and some more advanced topics. Students can take both
classes or just one. I will be teaching the class personally.
Admission is open. There is a late registration deadline, but I may
postpone or remove it depending how full the class is. The class
is very reasonably priced ....
See http://www.perltraining.com/schedules.html for more information.
Also, you may want to check back at www.perltraining.com Tuesday
or later, as I am reworking the site, adding additional information,
etc.
-joseph
--
Joseph N. Hall, prop., 5 Sigma Productions mailto:joseph@5sigma.com
Author, Effective Perl Programming . . . . . http://www.effectiveperl.com
Perl Training . . . . . . . . . . . . . . . http://www.perltraining.com
------------------------------
Date: Mon, 05 Oct 1998 12:43:21 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Common prefix for an array of strings
Message-Id: <3618bc9b.2349307@news.ping.be>
Here's a nice puzzle for you. How do you extract a common prefix of a
number of strings? The solution I have doesn't appeal to me. It's much
too like C. There must be better solutions.
Example: I have 3 strings:
@string = ('Fabriqui en Belgique.', 'Fabriqui en France.',
'Fabriqui en Belgique et en France.')
The result I'm looking for, for this example, is "Fabriqui en ".
$commonlength = &min(@string);
$prefixlength = 0;
PREFIXCHAR: while($prefixlength<$commonlength) {
my($char) = substr($ary[0],$prefixlength,1);
my($i);
for($i=1;$i<@string;$i++) {
substr($string[$i],$prefixlength,1) eq $c
or last PREFIXCHAR;
}
} continue { $prefixlength++ }
$prefix = substr($string[0],0,$prefixlength);
sub min {
my($min)= shift;
foreach (@_) {
$min < $_ or $min = $_;
}
return $min;
}
Bart.
------------------------------
Date: 5 Oct 1998 16:38:57 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: DEL in PERL
Message-Id: <6vasn1$6rh$1@client3.news.psi.net>
Computer Guru (computerguru@mailexcite.com) wrote on MDCCCLIX September
MCMXCIII in <URL:news:6v45ta$eof$1@supernews.com>:
++
++ begin 666 Computer Guru Consulting.vcf
You can't be a guru.
*plonk*
Abigail
--
undef$/;$_=<DATA>;s.\n..g,%%=map{$i++=>$_}split//=>"Y|\\<>/,";s,9(..)|8(
.)|7(.),($1||$2?" ":_)x($1||$2||$3||10),xeg,s,.,$%{$&}||$&,xeg,s,(.{54})
,$1\n,xg,print
__DATA__
915749177293018418172817282775821719281841182182258273528372292352721841
182182527381282182192527811745574824811721946259467284729217585748474817
158217181182172847481778227282283584282582718122837221821822817158172812
271827281282581728127118318223823714814182182183082228273582182125813748
251731825812745811721821731825812738248117218825862592025862591970917729
252768328274817781182192518573571581728122718272812182192518418428273582
182125182172923174185273824811721821745938259327381739197292558318328175
857482182181728274817786589227282282715817328118215815715817281227182728
128528408458158172812712822738118438128273582182125862731718258137482581
2738241721718128127382481172191425872586258625852589
------------------------------
Date: Mon, 05 Oct 1998 14:31:37 -0400
From: John Porter <jdporter@min.net>
Subject: Re: HELP !!!
Message-Id: <36191089.E8C63D8C@min.net>
Charles Li wrote:
>
> I'm doing PERL CGI programming. I am not able to use CGI.pm (for some
> reason), how do I pass on the HTML form inputs to the variables in my
> PERL CGI script?
I would much rather help you solve the problem of not being able
to use CGI.pm. It really is the best way to go.
So what are the symptoms? What error message do you get when
you type
perl -MCGI
at your command prompt?
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Mon, 5 Oct 1998 11:24:39 -0700
From: "Victor Lu" <victorl@egSoftware.com>
Subject: Help with Embedding Perl into multiple instance in different threads?
Message-Id: <6vb34f$p1n$1@nntp.or.nw.verio.net>
Has anyone tried to embed perl into multiple threads such that each thread
runs a seperate perl instance. concurrently.
VL
================================================
Victor Lu, Project Manager
WebTrends Corporation. Portland, Oregon
< victorl@webtrends.com>, 503-294-7025 x211
================================================
------------------------------
Date: Mon, 05 Oct 1998 18:08:57 GMT
From: nguyen.van@imvi.bls.com
Subject: Help with perl code !!!!
Message-Id: <6vb1vo$a95$1@nnrp1.dejanews.com>
In article <6v2p2i$aa6$1@nnrp1.dejanews.com>, nguyen.van@imvi.bls.com wrote:
I have a problem with code. I think that it's supposed to work based on my
logical but don't know why the program just stopped at the middle. Following
is my codes.
-----------------------------------------------------------------
----------------------------------------------------------------- #!
/opt/bin/perl -w print "Please enter access files to process: "; while (<>) #
read a list of serires access files from the command line. { chomp $_; # cut
the new line character "\n". @FILES = split (" ", $_); # split spaces
between the files from input and # make the input to be an array. foreach
$file (@FILES) # read one file from input at a time. { print "$file\n" if
(-e $file); # print the output, one file per line print "$file doesn't exist
\n" if (!-e $file);
#The following process can be done by using File:Copy module #Next time,
better use this module next time for speed. #The below code lines are used
to open a file and cp to another.
open (IN, $file) or die "couldn't open $file: $!";
open (OUT, ">>trunc_file") or die "couldn't create trunc_file:
$!";
foreach $each_line (<IN>)
{
print OUT $each_line if ($each_line =~ /crno=/);
}
close (IN) or die "couldn't close $FILE: $!";
close (OUT) or die "couldn't close $trunc_file: $!";
}
} #THE PROGRAM JUST STOPPED RIGHT HERE. IF RUN ONLY THE BELOW CODES, PROGRAM
#WORK WELL. ANYTHING IS WRONG WITH THIS? ANY BETTER SUGESSTIONS.
open (HANDLE_TRUNC, "trunc_file") or die "Couldn't open trunc_file: $!";
open (HANDLE_AOL, ">aol_out") or die "couldn't create aol_out: $!"; open
(HANDLE_MSIE, ">msie_out") or die "couldn't create msie_out: $!"; open
(HANDLE_NETSCAPE, ">netscape_out") or die "couldn't create netscape_out: $!";
foreach (<HANDLE_TRUNC>)
{
printf HANDLE_AOL ("%10s %7s\n" ,$1, $2) if ( $_ =~
/\b(crno=\d{2,})\b.*\b(AOL\s\d\.\d+)\b/);
printf HANDLE_MSIE ("%10s %7s\n" ,$1, $2) if ( $_ =~
/\b(crno=\d{2,})\b.*\b(MSIE\s\d\.\d+)\b.*\b/ and !/(AOL)\s\d\.\d+/);
printf HANDLE_NETSCAPE ("%10s %7s\n" ,$1, $2) if ( $_ =~
/\b(crno=\d{2,})\b.*\b(Mozilla\/\d\.\d+)\b/ and !/(AOL|MSIE)\s\d\.\d+/);
}
close ( HANDLE_TRUNC) or die "couldn't close new_file: $!";
close ( HANDLE_AOL ) or die "couldn't close aol_out: $!";
close ( HANDLE_MSIE ) or die "couldn't close msie_out: $!";
close ( HANDLE_NETSCAPE ) or die "couldn't close netscape_out: $!";
exit;
Thanks
Van Nguyen
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 5 Oct 1998 18:14:33 GMT
From: klassa@aur.alcatel.com (John Klassa)
Subject: Re: HERE Documents and skipping indentation (advanced)
Message-Id: <6vb2a9$lsn$1@aurwww.aur.alcatel.com>
On 04 Oct 1998 16:37:17 +0300, Jari Aalto <jari.aalto@poboxes.com> wrote:
> HERE docs require that you outdent all text, so I was hoping
> to use substitute operator to ignore the leading indentation.
> Would anyone know how to do that.
Check <6k3u68$r1l$2@csnews.cs.colorado.edu>... Tom did a whole article
on this very topic.
--
John Klassa / Alcatel Telecom / Raleigh, NC, USA <><
------------------------------
Date: Mon, 05 Oct 1998 18:23:09 +0200
From: Andrea Spinelli <aspinelli@ismes.it>
To: Andrea Spinelli <aspinelli@ismes.it>
Subject: Re: I want to write an NT service in Perl [SUMMARY]
Message-Id: <3618F26D.C3BC58E6@ismes.it>
Hi,
I am posting to c.l.p.modules because the original post was there and
because
somebody contacted me directly to ask for answers. All I needed was
a suggestion which came from john@neystadt.org , who suggested me
to use SRVANY.EXE. I hear it is in the NT service pack,
but I got it from http://beemail.com/pub/misc/srvany.zip
There is a simple readme.wri file; the essence of which is:
extract SRVANY.EXE to a reasonable directory, let's say C:\BIN
from the dos shell, run
instsrv <your-service> c:\bin\srvany.exe
Now you can fix security from the control panel/services applet.
Now launch
regedit
And go to the key
HKEY_LOCAL_MACHINE\System\Services\CurrentControlSet\<your-service>
now you must add a sub-key called Parameters with Edit/New/Key.
Open it and create the following string values (via Edit/New/String Value)
Application
with value c:\bin\perl\bin\perl.exe
(assuming that is the path of the perl executable)
AppDirectory
(the path where your script must be launched from)
AppParameters
(the name of the script, let's say c:\usr\andrea\script.pl)
Exit regedit, and that's it.
Now you may auto-start the service, stop it, or whatever.
I could have written some lines in Perl to do the above steps, but
since this is a rarely-done operation, it is best performed by hand.
Good luck!
Andrea
------------------------------
Date: Mon, 05 Oct 1998 17:52:35 GMT
From: teds@intex.com
Subject: memory management
Message-Id: <6vb113$84d$1@nnrp1.dejanews.com>
Hi,
I am running Perl 5 on NT4.0.
A "C" function in a Perl module I wrote takes a string as input and outputs a
string. Both are passed as arguments to my function. e.g.,
use test;
$a = "run_this";
#$b will hold the return string
test::run($a,$b);
print $b;
I have 2 questions:
1) How does Perl handle the memory if I allocate the string
in my C function. Do I have to "allocate" $b before I call test::run by doing
something like $b = " ";?
2) My run function checks to see if $b is large enough. If not, it
will reallocated the string. This doesn't seem like it's going to work
calling it via perl. Is there a way to allow this to work?
Thanks,
Ted
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 05 Oct 1998 16:14:53 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: need a regular expressions expert...
Message-Id: <6var9t$tse$1@nnrp1.dejanews.com>
In article <3618C1FE.C5618721@bigfoot.com>,
Roland Giersig <selected.only@bigfoot.com> wrote:
> Patrick Timmins wrote:
> > Why not print on the 'else' side of an if?
>
> Probably because his RE matching framework does not have it.
Why do you say that? The origninal poster certainly never did!
In fact, he cites the 'if' construct he is trying to work with
in his example:
if ( /^[^B]/) {
print $_;
}
He goes on to say:
-----
I know that ordinarily I would write the if statement like "if (!
/^BAD$/)" and I'd be done with it. However, the program that I'm
calling the rexexp functionality with does not have any operator
available to provide negation outside of the expression. This has
proven to be extremely frustrating.
-----
Since he has an 'if' construct, I assume he can have an 'else' block
as well. I don't personally know of anything that allows an 'if' block,
yet doesn't allow an 'else' block (if so, let me know ... I wasn't
aware of it!).
if (/^BAD/) { 1; } else { print; }
is much clearer than
if (/^([^B]|B[^A]|BA[^D])/) { print; }
isn't it?
Patrick Timmins
$monger{Omaha}[0]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 05 Oct 1998 11:27:31 -0500
From: Robert Bell <rabell@ti.com>
Subject: Re: Passing Variables: $_ vs. @_
Message-Id: <3618F373.B84ECBFF@ti.com>
Michal Rutka wrote:
Well, ya caught me.
I reversed the order of the subroutine as listed By Ronald.
############
sub sub {
print $_[0];
print $_[1];
print $_[2];
}
$[ = 1;
@arr = (1,2,3,4,5,6,7);
&sub(@arr);
#############
resulted in 123 as an output.
I guess that I usually don't think about this scoping relevance in Perl, but
I also
tend to place subroutines early in a script.
When I place the subroutine after the $[ assignment, then I get 112.
... as now expected. ;-)
rabell ...
------------------------------
Date: Mon, 05 Oct 1998 12:09:35 -0500
From: Robert Bell <rabell@ti.com>
Subject: Re: Passing Variables: $_ vs. @_
Message-Id: <3618FD4F.9D64FDBC@ti.com>
Robert Bell wrote:
No. This still doesn't make sense. If I simply place the subroutine
declaration after the $[ assignment, this changes the result of the
&sub call which can stay at the end. What is going on here?!?
I have tried the following revised version of the script with
different results for different perl versions.
###########
sub sub {
print $_[0];
print $_[1];
print $_[2];
print "\n";
}
@arr = (1,2,3,4,5,6,7);
&sub(@arr);
$[ = 1;
&sub(@arr);
###########
version 4.0
123
12
version 5.004_01
123
123
# The following has the subroutine defined after the $[
# assignment.
##############
@arr = (1,2,3,4,5,6,7);
&sub(@arr);
$[ = 1;
&sub(@arr);
sub sub {
print $_[0];
print $_[1];
print $_[2];
print "\n";
}
##############
version 4.0
123
12
5.004_01
112
112
In fact now that I think about, what you said is not expected. I
should expect that the print $_[0] after re-assigning $[ = 1 to
produce a null string, just like the version 4.0 Perl is doing.
What am I misunderstanding here?
rabell ...
------------------------------
Date: Mon, 05 Oct 1998 12:14:16 -0500
From: Robert Bell <rabell@ti.com>
Subject: Re: Passing Variables: $_ vs. @_
Message-Id: <3618FE68.A56A599B@ti.com>
Robert Bell wrote:
One more thing.
If I try the following with version 5.004_01
##############
@arr = (1,2,3,4,5,6,7);
&sub(@arr);
$[ = 1;
&sub(@arr);
$[ = 2;
&sub(@arr);
sub sub {
print $_[0];
print $_[1];
print $_[2];
print "\n";
}
##############
I get something similar to what Michal indicated.
171
171
171
While if I use version 4.0, I get what I would expect.
123
12
1
rabell ...
------------------------------
Date: Mon, 05 Oct 1998 13:37:59 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Passing Variables: $_ vs. @_
Message-Id: <361903F7.13C0E9BE@min.net>
Robert Bell wrote:
>
> I guess that I usually don't think about this scoping relevance in
> Perl, but I also tend to place subroutines early in a script.
So maybe that practice isn't such a good idea after all.
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Mon, 05 Oct 1998 12:57:37 -0500
From: Robert Bell <rabell@ti.com>
Subject: Re: Passing Variables: $_ vs. @_
Message-Id: <36190891.CFF6D22B@ti.com>
John Porter wrote:
> Robert Bell wrote:
> >
> > I guess that I usually don't think about this scoping relevance in
> > Perl, but I also tend to place subroutines early in a script.
>
> So maybe that practice isn't such a good idea after all.
>
> --
> John "Many Jars" Porter
> baby mother hospital scissors creature judgment butcher engineer
Are you saying the practice of placing subrountines at the beginning
of a script isn't good (meaning perhaps bad ... BTW, I believe that this
is what you said) or are you saying that you are not sure where
subroutines should be placed by way of saying "maybe".
If there is a preference in general for subroutine placement it would be
good to know to pros/cons.
I like to have them in one place, but I tend to place them at the
beginning of a script ... probably a hold over from C style guides.
rabell ...
------------------------------
Date: Mon, 05 Oct 1998 18:08:03 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Passing Variables: $_ vs. @_
Message-Id: <3619088C.A45986C7@bbnplanet.com>
Robert Bell wrote:
> If there is a preference in general for subroutine placement it would be
> good to know to pros/cons.
I think the point was 'if it ain't werkin' then maybe you need to try
something different'. I don't know that there is a subroutine style per
se, but I personally find that my code has them more towards the bottom.
Making it pretty and readable and sane is a priority as well. Play with
it, see what works for you. Nothing is ever really 'done'.
e.
I turn off the last light and close the door.
Moving toward whatever ancient thing
it is that works the chains
and pulls us so relentless on. -R. Carver-
------------------------------
Date: Mon, 05 Oct 1998 18:04:09 GMT
From: mscongdon@hotmail.com (Michael Congdon)
Subject: Perl and Novell Netware v4
Message-Id: <3619091a.232138519@news.bewellnet.com>
Our company is using a Novell Netware 4.0 server and I'm trying to use
publish our web site using a Perl database script. I'm wondering what
the default ROOT directory is in NetWare.
Also, when do you use "sys:" in the PATH.
------------------------------
Date: Mon, 05 Oct 1998 18:52:03 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Perl and Novell Netware v4
Message-Id: <361912DC.90D02969@bbnplanet.com>
Michael Congdon wrote:
> Our company is using a Novell Netware 4.0 server and I'm trying to use
> publish our web site using a Perl database script. I'm wondering what
> the default ROOT directory is in NetWare.
I'm sure the OS came with a manual.
e.
So the Earth endures, in every petty matter
And in the lives of men, irreversible.
And it seems a relief. To win? To lose?
What for, if the world will forget us anyway. -C. Milosz-
------------------------------
Date: Mon, 05 Oct 1998 14:25:01 -0400
From: John Porter <jdporter@min.net>
Subject: Re: read subdirectories
Message-Id: <36190EFD.4FBF2199@min.net>
aumman@my-dejanews.com wrote:
>
> "Richard Ahier" <richarda@profil-cdi.qc.ca> wrote:
> >
> > I try since a week to make a recursive script who read a directory
> > and all
> > his subdirectories.
> > I just need directories not files.
> > Does somebody have a script to suggest.
>
> try this:
> sub dir_read {
> my ($dir) = shift;
>
> return if ! -d $dir;
> print $dir, "\n";
>
> opendir(DIR, $dir);
> foreach ( readdir(DIR) ) {
> next if /^\./;
> &dir_read($dir . '/' . $_);
> }
> closedir(DIR);
> }
Bad answer.
use File::Find;
my $start_dir = '.'; # or whatever.
find( sub {
if ( -d $File::Find::name ) {
print "$File::Find::name\n"; # found a directory
}
},
$start_dir );
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Mon, 05 Oct 1998 12:42:25 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: regex help
Message-Id: <36190501.7693AB41@email.sps.mot.com>
Randy Jae Weinstein wrote:
>
> Please respond via email, since I don't check this newsgroup often.
> THANKS!
>
Then you shouldn't have posted here. Be responsible about what you did,
please.
------------------------------
Date: Mon, 05 Oct 1998 18:11:43 GMT
From: droby@copyright.com
Subject: Re: regex help
Message-Id: <6vb24v$acq$1@nnrp1.dejanews.com>
In article <6v5b5h$lbf$1@news.nyu.edu>,
rw263@is7.nyu.edu (Randy Jae Weinstein) wrote:
> The below two snippets of code should do the SAME thing, however the
> first works and the later one doesn't. What is wrong with my regex in
> the second?
>
> --- This WORKS: ----------------------------
> if (($a =~ /\//) && ($b =~ /\//)) {
> ($tempA,$junk) = split(/\//,$a);
> ($tempB,$junk) = split(/\//,$b);
> print "($tempA : $tempB)\n";
> }
> --------------------------------------------
>
> --- This DOESN'T: -------------------------
> if (($a =~ /(.*)\//) && ($b =~ /(.*)\//)) {
> print "($1 : $2)\n";
> }
> --------------------------------------------
It's not a regex. It's two regexes, and both set $1. $2 is never set.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 05 Oct 1998 17:19:20 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: Kenneth Hunt <kchunt@mail.hac.com>
Subject: Re: Search for forwardslash...how?
Message-Id: <3618F188.3BF8FA30@whiterabbit.co.uk>
my $pathname="IMUX/C-BAND/COMDEV/0962-12/un012_O.B._Isolation#1.xls";
my (@directories) = split (/\//,$pathname);
my $filename = $directories[-1];
Matt
--
Kenneth Hunt wrote:
>
> I want to split a UNIX pathname at the forward slashs. How can I split
> this line:
>
> IMUX/C-BAND/COMDEV/0962-12/un012_O.B._Isolation#1.xls>
>
> into this line
>
> IMUX C-BAND COMDEV 0962-12 un012_O.B._Isolation#1.xls
>
> Bare in mind that the path has all kinds of characters in it, but I only
> want to split at the forward slash. How do I do that?
> --
>
> ------------------------------------------------------
> Kenneth Hunt
> SC S12 V321 Rm. C233
> office: 364-7755 pager: 715-0600
> ------------------------------------------------------
--
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons
------------------------------
Date: Mon, 05 Oct 1998 10:21:49 -0700
From: Fred Richards <gadget@bc.sympatico.ca>
To: Kenneth Hunt <kchunt@mail.hac.com>
Subject: Re: Search for forwardslash...how?
Message-Id: <3619002D.CD4F1C26@bc.sympatico.ca>
<HTML>
Kenneth Hunt wrote:
<BLOCKQUOTE TYPE=CITE>I want to split a UNIX pathname at the forward slashs.
How can I split
<BR>this line:
<P> IMUX/C-BAND/COMDEV/0962-12/un012_O.B._Isolation#1.xls>
<P>into this line
<P> IMUX C-BAND COMDEV 0962-12
un012_O.B._Isolation#1.xls
<P>Bare in mind that the path has all kinds of characters in it, but I
only
<BR>want to split at the forward slash. How do I do that?
<BR>--
<P>------------------------------------------------------
<BR>Kenneth Hunt
<BR>SC S12 V321 Rm. C233
<BR>office: 364-7755 pager:
715-0600
<BR>------------------------------------------------------</BLOCKQUOTE>
You could try:
<BR>
<HR WIDTH="100%">
<BR>$line = "IMUX/C-BAND/COMDEV/0962-12/un012_O.B._Isolation#1.xls>";
<P><FONT COLOR="#3333FF">$line =~ tr/\// /;
# Translate '/' to ' '</FONT>
<P>print $line;
<BR>
<HR WIDTH="100%">
<BR>Hope this helps
<P>Fred Richards
<BR>The Gadget Guy</HTML>
------------------------------
Date: Mon, 05 Oct 1998 12:47:45 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: Search for forwardslash...how?
Message-Id: <36190641.FB5DEE22@email.sps.mot.com>
Matt Pryor wrote:
>
> my $pathname="IMUX/C-BAND/COMDEV/0962-12/un012_O.B._Isolation#1.xls";
> my (@directories) = split (/\//,$pathname);
> my $filename = $directories[-1];
>
OR , if you just need the filename:
my $filename = (split (/\//,$pathname))[-1];
------------------------------
Date: Mon, 05 Oct 1998 14:27:29 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Search for forwardslash...how?
Message-Id: <36190F91.EA002409@min.net>
Kenneth Hunt wrote:
>
> I want to split a UNIX pathname at the forward slashs. How can I split
> this line:
>
> IMUX/C-BAND/COMDEV/0962-12/un012_O.B._Isolation#1.xls>
>
> into this line
>
> IMUX C-BAND COMDEV 0962-12 un012_O.B._Isolation#1.xls
split m#/#;
If you just want to replace the slashes with spaces,
s#/# #g;
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: 5 Oct 1998 16:06:01 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: send geroge reese (was Re: Call for Participation: Python Conference)
Message-Id: <6vaqp9$532$1@client3.news.psi.net>
Zenin (zenin@bawdycaste.org) wrote on MDCCCLIX September MCMXCIII in
<URL:news:907376089.474707@thrush.omix.com>:
++ Abigail <abigail@fnx.com> wrote:
++ : Jonathan Biggar (jon@floorboard.com) wrote on MDCCCLVIII September
++ : MCMXCIII in <URL:news:361435F6.702C6EDD@floorboard.com>:
++ : ++
++ : ++ Not to brag :-), but I am partly to blame for Perl 5, by pushing Larry
++ : ++ to add the OO stuff.
++ :
++ : So, it's you who I need to club over his head because of the ugly
++ : mess Perl OO is? ;)
++ :
++ : Luckely, there's a cleaner way: closures. With (multiple) inheritance and
++ : autoloading.
++
++ Luckely, there's a cleaner way: upgrade to 5.005+. With core
++ support for private fields, compile time field name checks, and
++ real exception object support.
It remains a hack on a hack.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Mon, 05 Oct 1998 17:26:03 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: gkassyou@newbridge.com
Subject: Re: sort question?
Message-Id: <3618F31B.D460C177@whiterabbit.co.uk>
Advanced sorting is covered exhaustively in Learning Perl, Programming
Perl, and in the man pages.
This depends on how you want the list sorted, however. You didn't make
it clear in your question.
If you want to sort according to the alphabetical order of the last
character, and by number if the letters are equal, then something like
this will do the trick:
@list = qw (
9012354500G
9034988988F
9012354500G
9030940934E
);
@list = sort bylastletter @list;
sub bylastletter {
return ((substr($a,-1,1)) cmp (substr($b,-1,1)) || ($a <=> $b));
}
foreach (@list) {
print "$_\n";
}
George Kassyousef wrote:
>
> How can I sort a value which is made up of integers and characters?
>
> Ex. 9012354500G
> 9034988988F
> 9012354500G
> 9030940934E
>
> after sort:
> 9030940934E
> 9034988988F
> 9012354500G
> 9012354500G
>
>
> Thx.
>
> ------------------------------------------------------------------------
>
> George Kassyousef <gkassyou@newbridge.com>
> Software Engineer
> Newbridge Networks
>
> George Kassyousef
> Software Engineer <gkassyou@newbridge.com>
> Newbridge Networks
> Work: 599-3600 x1630
> Netscape Conference Address
> Netscape Conference DLS Server
> Additional Information:
> Last Name Kassyousef
> First Name George
> Version 2.1
--
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons
------------------------------
Date: 5 Oct 1998 16:57:12 GMT
From: bhilton@tsg.adc.com (Brand Hilton)
Subject: Re: sort question?
Message-Id: <6vatp9$7p14@mercury.adc.com>
In article <3618E64F.365D40F1@newbridge.com>,
George Kassyousef <gkassyou@newbridge.com> wrote:
>-=-=-=-=-=-
>
>How can I sort a value which is made up of integers and characters?
>
>Ex. 9012354500G
> 9034988988F
> 9012354500G
> 9030940934E
>
>after sort:
> 9030940934E
> 9034988988F
> 9012354500G
> 9012354500G
Geez... could you have given a little less information? This leaves a
few unanswered questions. But, hey, I'm game. Here's a solution that
will take the input you gave and print the output you specified. It
doesn't care how long each record is, but it assumes that the primary
sort key is the last character of the line and the secondary sort key
is the rest of the line. It also assumes you're reading from STDIN
and writing to STDOUT:
print sort {substr($a,-2,1) cmp substr($b,-2,1) || $a cmp $b} <>;
>Thx.
Wlcm.
--
_____
|/// | Brand Hilton bhilton@adc.com
| ADC| ADC Telecommunications, ATM Transport Division
|_____| Richardson, Texas
------------------------------
Date: Mon, 05 Oct 1998 17:26:14 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: Split question - retain the pattern?
Message-Id: <361c006c.19674464@news.ping.be>
A.J. Norman wrote:
>@sentences = split(/[?.]\s+/, $text);
>
>This puts the entire message into one variable, and then splits it on a
>question mark or full stop followed by whitespace. But it eats the
>question mark or full stop - is there any way I can use split so that
>the splitting pattern is retained?
Use parentheses around your regex. This will include the found pattern
matches between the data.
$text = "How are you
today? I am
fine.";
@sentences = split(/([?.])\s+/, $text);
($\,$,) = ("\n",'|'); print @sentences;
This results in:
How are you
today|?|I am
fine.
You see? First string, the part of the pattern between parentheses (the
spaces are gone), the second string. You always get an odd number of
array elements, and the odd numbered strings are the split patterns,
counting the first array elment as 0 (=even).
You still need to convert the newlines to spaces, preferably a single
space:
tr/ \n\t/ /s;
So the next code snippet completes what we got so far:
push @sentences,''; # make number of items even, to prevent warning
$output = '';
while (($sentence,$terminator) = splice(@sentences,0,2)) {
# equivalent to two shifts
$sentence =~ tr/ \n\t/ /s;
$output .= "$sentence$terminator\n";
}
print $output;
Result:
How are you today?
I am fine.
Looks fine to me.
Bart.
------------------------------
Date: Mon, 05 Oct 1998 14:16:37 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Split question - retain the pattern?
Message-Id: <36190D05.7C752149@min.net>
A.J. Norman wrote:
>
> I'm writing a script to parse text, and want to be able to split a block
> of text (an e-mail message for instance) into sentences. I can do
> something like this:
>
> @lines = <INFILE>;
> $text = join(" ", @lines);
> @sentences = split(/[?.]\s+/, $text);
>
> This puts the entire message into one variable, and then splits it on a
> question mark or full stop followed by whitespace. But it eats the
> question mark or full stop - is there any way I can use split so that
> the splitting pattern is retained?
#
# pass a string to parse.
# returns an array-ref of the sentences found, plus a string
# containing any remaining text.
#
sub parse_sentences {
my @sentences;
my $remainder;
local $_ = shift;
while ( /.*?[.!?](\s+|$)/gs ) {
push @sentences, $&;
$remainder = $';
}
( \@sentences, $remainder );
}
#
# test it:
#
my( $sent, $rem ) = parse_sentences( 'What? Hey! O.k. extra' );
for ( 0 .. $#{$sent} ) { print "$_: $sent->[$_]'\n"; }
if ( defined $rem ) { print "Remainder: '$rem'\n"; }
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Mon, 05 Oct 1998 18:07:44 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Sys::Syslog problems
Message-Id: <6vb208$pd3$2@nz12.rz.uni-karlsruhe.de>
Alexis Huxley <alexis@danae.demon.co.uk> wrote:
>I'm having problems using openlog, syslog and closelog. I have the following
>Perl script:
>Anyone offer any assistance please?
You gotta have your syslogd listen on the syslog port as this is the
way perl uses to do logging. (syslog -r).
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: 5 Oct 1998 18:55:44 GMT
From: doug@kittycat.france.seay (Douglas SEAY)
Subject: Re: Sys::Syslog problems
Message-Id: <slrn71i5ha.fc.doug@kittycat.france.seay>
[posted and CC'd]
On Mon, 05 Oct 1998 18:07:44 GMT, Marc Haber <Marc.Haber-usenet@gmx.de> wrote:
>Alexis Huxley <alexis@danae.demon.co.uk> wrote:
>>I'm having problems using openlog, syslog and closelog. I have the following
>>Perl script:
>>Anyone offer any assistance please?
>
>You gotta have your syslogd listen on the syslog port as this is the
>way perl uses to do logging. (syslog -r).
Either that or have Sys::Syslog use Unix Domain sockets. For my RH 5.0
installation, the default setting is Unix Domain only (TCP/IP not accepted).
This did not produce any error message, it just silently failed.
- doug
------------------------------
Date: Mon, 5 Oct 1998 13:06:57 -0400
From: "Kung-Ching Yeh" <kyeh@ix.directmedia.com>
Subject: Win32::EventLog::Read
Message-Id: <6vaube$r8e$1@news0-alterdial.uu.net>
Hi,
While reading eventlog, some NT hosts return currect "TimeGenerated" and
some don't. And some hosts return query and some don't. Does any have the
same experience?
This is the code:
while ($Eventlog->Read((EVENTLOG_SEEK_READ|EVENTLOG_BACKWARDS_READ),
$count - $i, \%event) || $!) {
$_ = localtime($event{'TimeGenerated'});
print "Generated Time is : $_\n";
if ( /$Today/ && $event{EventType} < 3) {
# only check for today's event and increase counter by 1
$Source{$event{Source}}++;
} else {
last;
}
$i++; # read it backward
}
Any help is appreciated.
Thanks,
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3894
**************************************