[11299] in Perl-Users-Digest
Perl-Users Digest, Issue: 4899 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 15 17:07:25 1999
Date: Mon, 15 Feb 99 14:00:28 -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 Mon, 15 Feb 1999 Volume: 8 Number: 4899
Today's topics:
Re: #!/usr/bin/perl AND #!/usr/local/bin/perl both pos (Greg Ward)
Re: #!/usr/bin/perl AND #!/usr/local/bin/perl both pos <ekkis@arix.com>
Re: ActivePerl vs. Standard Perl for Win32 <jwarner@tivoli.com>
Re: checking 'use' (Greg Ward)
Creating individual arrays from an array lchuck@home.com
Re: Creating individual arrays from an array <allan@due.net>
delete a line in a file (Mark P.)
embedded SQL in perl? amanda.leaman@atl.bluecross.ca
Re: embedded SQL in perl? <ebohlman@netcom.com>
Re: getting full path of program name (Greg Ward)
Re: greedy operators - help! <usenet@arix.com>
Re: How do I get local IP Address ? (Greg Ward)
I Need Help With a Process Pipe <rbobo@spd.dsccc.com>
Re: Interleaving two lists? (Larry Rosler)
ip address search <kayer@wou.edu>
Making a Subject Index with Perl <jeaton@tamworth.u-net.com>
Re: Need your opinion ---> starting my own web company? <occuserv@globalnet.co.uk>
Newbie Q: a better sort? <mmorgan@gladstone.uoregon.edu>
newbie question, basepath <lost_ark@yahoo.com>
Perl and Javascript - combining the two rjeffers@caltex.com.au
Re: REGEX $1, $2 ... array? (Larry Rosler)
Re: REGEX $1, $2 ... array? (I R A Aggie)
Re: REGEX $1, $2 ... array? (Ilya Zakharevich)
rename files with perl <derrick@mercuryfilmworks.com>
Re: retrieving java with pearl (Mark P.)
Socket Q: Minimum listen queue size <Andrew.Wild@env.qld.gov.au>
Re: String Compare (Larry Rosler)
Re: String Compare <ludlow@us.ibm.com>
US-BOSTON-UNIX/PERL/CGI DEVELOPERS NEEDED-recruiter <craig@architechs.net>
Web Crawler <ankadakia@hotmail.com>
Web Crawler <ankadakia@hotmail.com>
Re: Web Crawler (Clay Irving)
XS code in PFR [was: Re: PFR: read_file, write_file] (Markus Laker)
YADF (Yet another date function(s)) <bmb@ginger.libs.uga.edu>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Feb 1999 21:22:55 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: #!/usr/bin/perl AND #!/usr/local/bin/perl both posible?
Message-Id: <7aa37f$q35$3@news0-alterdial.uu.net>
Joel Wijngaarde <vasquez@zap.a2000.nl> wrote:
> Is it possible to give to search paths. I run my Perl script son two
> machines and both have Perl in different directories. One has Perl in
> /usr/bin/perl and the other in /usr/local/bin/perl.
>
> Now i'm always changing the first line...
There are a couple options here. The easiest is to make /usr/bin/perl a
symlink to /usr/local/bin/perl, or vice-versa -- not always an option,
depending on whether you are root or are friends with root.
Next is to use the "eval ... if $not_running_under_some_shell" hack
explained in the Camel Book. (I won't try to reproduce it from memory,
as I'd just get it wrong. It's somewhere near the beginning of the
Camel, though.)
A nicer but less flexible alternative comes from the Python world:
#!/usr/bin/env perl
This is subtle and clever, just like the "eval" hack -- but *much*
cleaner (IMHO). I recall having some difficulties with getting Perl to
parse command-line options from the #! line when using the 'env' hack,
but it seems to work just fine now. Hmmm.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Mon, 15 Feb 1999 13:47:25 -0800
From: "Ekkis" <ekkis@arix.com>
Subject: Re: #!/usr/bin/perl AND #!/usr/local/bin/perl both posible?
Message-Id: <JA0y2.3707$bP2.29612@typhoon-sf.pbi.net>
sorry, and what would the env.perl contain?
Greg Ward wrote in message <7aa37f$q35$3@news0-alterdial.uu.net>...
>Joel Wijngaarde <vasquez@zap.a2000.nl> wrote:
>> Is it possible to give to search paths. I run my Perl script son two
>> machines and both have Perl in different directories. One has Perl in
>> /usr/bin/perl and the other in /usr/local/bin/perl.
>>
>> Now i'm always changing the first line...
>
>There are a couple options here. The easiest is to make /usr/bin/perl a
>symlink to /usr/local/bin/perl, or vice-versa -- not always an option,
>depending on whether you are root or are friends with root.
>
>Next is to use the "eval ... if $not_running_under_some_shell" hack
>explained in the Camel Book. (I won't try to reproduce it from memory,
>as I'd just get it wrong. It's somewhere near the beginning of the
>Camel, though.)
>
>A nicer but less flexible alternative comes from the Python world:
>
>#!/usr/bin/env perl
>
>This is subtle and clever, just like the "eval" hack -- but *much*
>cleaner (IMHO). I recall having some difficulties with getting Perl to
>parse command-line options from the #! line when using the 'env' hack,
>but it seems to work just fine now. Hmmm.
>
> Greg
>--
>Greg Ward - software developer gward@cnri.reston.va.us
>Corporation for National Research Initiatives
>1895 Preston White Drive voice: +1-703-620-8990 x287
>Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Mon, 15 Feb 1999 15:15:41 -0600
From: John Warner <jwarner@tivoli.com>
Subject: Re: ActivePerl vs. Standard Perl for Win32
Message-Id: <36C88E7D.161089E@tivoli.com>
You will want to use the ActiveState version. Perl 5.005 fixes a bunch of bugs
and memory leaks in Perl 5.004.
--John
Jalil Feghhi wrote:
> What is the difference b/w ActivePerl (5.005) and Standard Perl (5.004) for
> Win32? I am new to Perl and would like to know which one I should go for. Is
> one a superset of the other, etc?
>
> Thanks,
>
> -Jalil
------------------------------
Date: 15 Feb 1999 21:26:39 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: checking 'use'
Message-Id: <7aa3ef$q35$4@news0-alterdial.uu.net>
Andrew Fry <andrewf@beausys.demon.co.uk> wrote:
> I have a program which accesses various types of database,
> and so it has a number of 'use ...' statements for the
> modules which provide appropriate APIs (for database access).
> Of course, on any particular system, the chances are that not
> all these modules will be available, and so some must be
> commented out.
>
> Further down the code, I have a number of subroutines ...
> one for each database type. If I enter one for which the
> 'use ...' statement was commented out, then the program
> bombs out. Is there some way to avoid this ? ie some way
> to check whether the current database type is "supported",
> perhaps by determining if the appropriate 'use...'
> statement was included / commented-out ?
> I guess what I want to do is something like this...
> if use statement for GDBM included
> then $gdbm_supported = 1;
> else
> $gdbm_supported = 0;
Sounds like you need to learn about Perl's exception handling mechanism,
aka eval-with-blocks. You want something like this:
eval { code that crashes if GDBM isn't loaded }
if (defined $@ and $@ =~ /die message when that code crashes/) {
# GDBM isn't loaded
}
elsif (defined $@) {
# the code crashed for some other reason -- pass the exception on
die $@;
}
else {
# all is well, carry on
}
RTFM: "perldoc -f eval"
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Mon, 15 Feb 1999 19:46:10 GMT
From: lchuck@home.com
Subject: Creating individual arrays from an array
Message-Id: <7a9thv$s6$1@nnrp1.dejanews.com>
Sorry about the title of the message. What I'm looking to do is to take an
array of values (numbers, words, etc) and create an array for each of the
values in the initial array. Example:
@furniture=("chair", "table", "couch");
I would like to write a snippet of code that could take each item in the
@furniture array and create seperate arrays, called @chair, @table, and
@couch.
I have attempted to do this, but can't get it to quite work out correctly. If
anyone can please help me out, I would be most appreciative. Thanks!! Please
email me, as I don't get many chances to look through newsgroups. Thanks
again!!!!
Lucky Chuck
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 15 Feb 1999 16:51:09 -0500
From: "Allan M. Due" <allan@due.net>
Subject: Re: Creating individual arrays from an array
Message-Id: <HF0y2.1149$L1.26666@nntp1.nac.net>
lchuck@home.com wrote in message <7a9thv$s6$1@nnrp1.dejanews.com>...
:Sorry about the title of the message. What I'm looking to do is to take an
:array of values (numbers, words, etc) and create an array for each of the
:values in the initial array. Example:
:@furniture=("chair", "table", "couch");
:I would like to write a snippet of code that could take each item in the
:@furniture array and create seperate arrays, called @chair, @table, and
:@couch.
Well you could do the following (but you don't want to)
#!/usr/local/bin/perl -w
#use strict;
my @furniture=("chair", "table", "couch");
foreach (@furniture) {
@$$_ = "I am a $_";
}
foreach (@furniture) {
print "@$$_\n";
}
You really want to use a hash instead. You will note that use strict has to
be commented out for this to run, basically becuase it is a bad idea to use
soft referrences. For a great discussion of why this is not a great idea see
Mark-Jason Dominus discussion at:
http://www.plover.com/~mjd/perl/varvarname.html
HTH
AmD
[posted and emailed]
------------------------------
Date: Mon, 15 Feb 1999 21:17:13 GMT
From: mag@imchat.com (Mark P.)
Subject: delete a line in a file
Message-Id: <36c88d1c.1104994097@news.ionet.net>
Hi, I've read the Faq 5 on deleting but it only covers deleting the
last line in a file. I want to delete a line based on the first item
of a comma delimited file. First I print out the file and then the
user can enter the value of the item to delete, which will then delete
the whole line. The lines of the file look like this.
null-3,test@test.com,what's the poop.,1,7
The first entry will always be null-##. I can replace null-3 easily,
but need something to delete the whole line. You guy's have probably
answered this type of question 1000 times, but I was unable to find a
typical answer to guide me.
------------------------------
Date: Mon, 15 Feb 1999 19:55:31 GMT
From: amanda.leaman@atl.bluecross.ca
Subject: embedded SQL in perl?
Message-Id: <7a9u3f$14a$1@nnrp1.dejanews.com>
Hi.
We currently have c programs running on Unix that have embedded sql for
querying our Oracle database. I would like to start programming this stuff
in perl and am looking for documentation/examples of SQl embedded in perl.
Is it the same as in c?
Thanks
Amanda
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 15 Feb 1999 21:50:31 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: embedded SQL in perl?
Message-Id: <ebohlmanF77u07.MKq@netcom.com>
amanda.leaman@atl.bluecross.ca wrote:
: We currently have c programs running on Unix that have embedded sql for
: querying our Oracle database. I would like to start programming this stuff
: in perl and am looking for documentation/examples of SQl embedded in perl.
: Is it the same as in c?
Not quite. Take a look at the documentation for DBI and DBD::Oracle.
------------------------------
Date: 15 Feb 1999 21:09:44 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: getting full path of program name
Message-Id: <7aa2eo$q35$1@news0-alterdial.uu.net>
Xah <xah@best.com> wrote:
> What is a reliable and portable way of getting the absolute path of the
> running script?
>
> Obviously, qw{pwd}, File::Basename, $0 are not solutions...
>
> (I was thinking that $0 should do it. Perhaps this makes a good feature
> request?)
Well, you don't say what about $0 doesn't do it, so I assume you mean
the fact that it's not always an absolute path. Here's a completely-
off-the-top-of-my-head solution:
use Cwd;
use File::Spec;
$script = $0;
$script = File::Spec->join (getcwd, $script)
unless File::Spec->file_name_is_absolute ($script);
($script) = File::Spec->no_upwards (File::Spec->canonpath ($script));
This works (at least under Unix -- but then File::Spec is designed for
portable filename manipulation!), but the interface to File::Spec is
really bizarre. (It's object-oriented for no obvious reason,
no_upwards() takes and returns a list while all the other functions --
sorry, methods -- take and a return a scalar, and the name
'file_name_is_absolute' is a bit overboard.)
Take it or leave it...
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Mon, 15 Feb 1999 12:15:32 -0800
From: "Asterix" <usenet@arix.com>
Subject: Re: greedy operators - help!
Message-Id: <ye%x2.3677$bP2.28507@typhoon-sf.pbi.net>
hmm... Alan brings up an interesting point I hadn't thought about... if I
get a filename like: "/foo.bar/baz" the solution below will/should return
"/foo" when what one wants is "/foo.bar/baz". so to wrap this up, I think
the expression:
s/\.[^.\/]*?$//;
should do it!
Ka-shu Wong wrote in message ...
>
>
>On Sun, 14 Feb 1999, Asterix wrote:
>
>[snip]
>
>> which works but if I use the more elegant:
>>
>> $fn =~ s/\..*$//;
>>
>> I get greedy behaviour by default and the non-greedy operator I can't
seem
>> to make work. What's wrong with this?
>>
>> $fn =~ s/\..*?$//;
>
>The problem with using the default greedy behaviour is that .* is also
>matching the dots. If you use [^.]* instead it would not match the dots
>and therefore it will only match the last part of the filename:
>
>$fn =~ s/\.[^.]*?$//;
>
>The \. always matches on the first dot for which the rest of the
>expression would match. Doing it this way ensures that the rest of the
>expression can only match _after_ the last dot.
>
>
>KS
>
------------------------------
Date: 15 Feb 1999 21:14:31 GMT
From: gward@cnri.reston.va.us (Greg Ward)
Subject: Re: How do I get local IP Address ?
Message-Id: <7aa2nn$q35$2@news0-alterdial.uu.net>
Walt Mankowski <waltman@netaxs.com> wrote:
> When I run this on my machine (linux, ppp, dynamically-generated IP
> address) I get
>
> 0.0.0.0
That's odd, you *should* get 127.0.0.1. In fact, the answer to "how do
I get the local IP address" is quite simple:
sub local_ip_address { return "127.0.0.1" }
but that, of course, is rarely the answer people want. ;-)
> I had this same problem a while back. I ended up parsing the output
> of ifconfig to get my IP address. I never did figure out where
> ifconfig was getting it from.
Probably comes from some internal kernel data structure. The question
is: Does ifconfig go grubbing through kernel memory to get this? is it
buried in /proc or /dev in a halfway-elegant fashion? or is there a
system call for it? Whatever, this is probably one of those corners of
Unix that is undocumented and extremely unportable.
If all you need is a solution for Linux, the answer is easy: Use the
Source, Luke. (The source to ifconfig, that is.) Other Unices, alas,
are not blessed with source availability.
Greg
--
Greg Ward - software developer gward@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990 x287
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
------------------------------
Date: Mon, 15 Feb 1999 14:08:16 -0600
From: Richard Bobo <rbobo@spd.dsccc.com>
Subject: I Need Help With a Process Pipe
Message-Id: <36C87EB0.DE91CABC@spd.dsccc.com>
When I use an ftp pipe from my Sun to the VAX as in this script snipit,
all is well.
(.netrc and .rhosts files are set up).
open ( FTP_PIPE, "| ftp -i devel \n" );
print FTP_PIPE "cd crprint.dir \n";
print FTP_PIPE "mget \* \n";
print FTP_PIPE "quit \n";
When I try something similar, with a telnet pipe, I am immediately
logged off of the remote machine (the VAX).
open ( TELNET_PIPE, "| telnet devel \n" );
print "Getting CR $_ from the PRT tool ... \n\n";
$_ = 122441;
$newName = "cr" . $_;
print TELNET_PIPE "prt show
problem\/full\/problem=$_\/output=$newName\n";
print TELNET_PIPE "logoff\n";
close TELNET_PIPE;
When I try this with an rlogin pipe, I get a lot of errors concerning
the device or address although
rlogin works fine if I use it interactively from an xterm.
open ( RLOGIN_PIPE, "| rlogin devel \n" );
foreach ( @cmdParms ) {
$newName = "cr" . $_;
print "Getting CR $_ from the PRT tool ... \n\n";
print RLOGIN_PIPE "prt show
problem\/full\/problem=$_\/output=$newName\n";
push ( @crFiles, $newName );
}
print RLOGIN_PIPE "logoff\n";
close RLOGIN_PIPE;
Output:
ioctl TIOCGETP: No such device or address
ioctl TIOCLGET: No such device or address
ioctl TIOCGETC: No such device or address
ioctl TIOCGLTC: No such device or address
ioctl TIOCGETP: No such device or address
ioctl TIOCLGET: No such device or address
ioctl TIOCSLTC: No such device or address
ioctl TIOCSETC: No such device or address
ioctl TIOCSETN 3: No such device or address
ioctl TIOCLSET: No such device or address
Closed connection.
ioctl TIOCGETP: No such device or address
ioctl TIOCLGET: No such device or address
ioctl TIOCSLTC: No such device or address
ioctl TIOCSETC: No such device or address
ioctl TIOCSETN 3: No such device or address
ioctl TIOCLSET: No such device or address
Has anyone used a telnet or rlogin process pipe successfully from Sun to
VAX? If so, can you offer
any pointers?
Thanks in advance,
Richard Bobo
------------------------------
Date: Mon, 15 Feb 1999 12:43:14 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Interleaving two lists?
Message-Id: <MPG.113226bba3a34af9989a40@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7a9s13$3jr$1@news1.cableinet.co.uk> on Mon, 15 Feb 1999
19:18:34 -0000, Howard Jones <hjones@vossnet.co.uk> says...
...
> Given a Tab-delimited text file, I want to read line 1, to get the Field
> names, then each line afterwards into a hash where the keys are the field
> names.
>
> chomp($first_line = <STDIN>);
> @fieldnames=split(/\t/,$firstline);
>
> chomp($nextline = <STDIN>);
> @values=split(/\t/,$nextline);
>
> # the hard bit
> %data = {magic code} @fieldnames, @values;
>
> - How do I get @fieldnames and @values into a hash? I am sure there is some
> way of using map() to do this in one line... The first way I saw is just to
> use shift on each list in turn, but that'll mangle my list of field names.
What you are looking for is a hash slice:
@data{@fieldnames} = @values;
This handles only one line of data. How you handle a set of lines is up
to you -- the obvious way would be to set up an array of references to
hashes luke the one above. Remember to copy the hash in the loop, or
allocate a new one each time through using 'my'.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 15 Feb 1999 12:44:01 -0800
From: Roger Kaye <kayer@wou.edu>
Subject: ip address search
Message-Id: <36C88710.1E64916E@wou.edu>
I'm a newbie and trying to write a script on a unix server to poll ip
address within
a given range to test if they ping. Then I need to test each connection
to see if any are set up as Web servers.
Thanks
Roger
------------------------------
Date: Mon, 15 Feb 1999 20:32:52 -0800
From: "Jonathan Eaton" <jeaton@tamworth.u-net.com>
Subject: Making a Subject Index with Perl
Message-Id: <Zj%x2.2184$V3.3459@newsr2.u-net.net>
I need some help with using Perl to create a subject index for book titles.
I have a flat file of book records in which each title may have one or more
subject terms (delimited by a slash), as follows:
Title | Date | Subject Term(s)
Beginner's Course in Finance|1998|FINANCE
Finance for Accountants|1995|FINANCE/ACCOUNTANCY
Marketing for Financial Services|1997|FINANCE/MARKETING
I want to generate an alphabetically sorted subject index as follows (using
above as example)
ACCOUNTING
Finance for Accountants
FINANCE
Beginner's Course in Finance
Finance for Accountants
Marketing for Financial Services
MARKETING
Marketing for Financial Services
I understand how to parse each record, to split the subject term field to
get individual terms, and am familiar with hashes, but can't see how best to
achieve the one-to-many relationship between subject term and title, and
then how to ensure I get a correctly keyed sort on title within subject
term.
Any suggestions would be gratefully received - thanks in advance.
Jonathan Eaton
jeaton@tamworth.u-net.com
------------------------------
Date: Mon, 15 Feb 1999 21:30:14 -0000
From: "A. Scott" <occuserv@globalnet.co.uk>
Subject: Re: Need your opinion ---> starting my own web company?
Message-Id: <7aa3pf$i2e$1@newnews.global.net.uk>
there's no reason you cant.. If you know what you are doing, and you have
the time, go for it!!
LukeV wrote in message ...
>Hi,
> i know this as nothing to do with prg support, but i'm sure someone
here
>could help me. I'm seriously thinking about starting my own web design
>company. I've been doing pages for about 2 years, but lately i've been
>learning a lot about .CGIs and starting to learn about ASP. I was wondering
>if any people just did what i wanna do, and if so, their opinion about the
>whole thing. If anyone has any suggestions, please do not hesitate. Taking
a
>look at my web site might not be a bad idea too! Thanks everyone for your
>time!
>
>--
>LukeV
>illusion@illusion.qc.ca
>www.illusion.qc.ca
>
>
>
------------------------------
Date: Mon, 15 Feb 1999 12:30:37 -0800
From: "M. Morgan" <mmorgan@gladstone.uoregon.edu>
Subject: Newbie Q: a better sort?
Message-Id: <7a9vrb$37o$1@pith.uoregon.edu>
I am looking for a way to sort a list as one would find in a dictionary
rather than use the "naked" sort function. I like to learn by example and I
haven't been able to anything similar to what I am looking for.
The parameters for the sort I need is:
(I know about sort {uc($a) cmp uc($b)} but it doesn't sort consistently)
sort...
alphabetically
special characters and numbers first
lower case first
exclude the word "The" on sort but keep it for output
any other parameters I haven't thought of for a dictionary word list
Any help at all is greatly appreciated.
Mike Morgan
------------------------------
Date: Mon, 15 Feb 1999 11:44:43 -0800
From: weasel <lost_ark@yahoo.com>
Subject: newbie question, basepath
Message-Id: <36C8792B.58D52E7@yahoo.com>
i've recently changed providers, from a unix to nt host. my script
needs a new basepath, can it be formatted as such :
$basepath = 'D:\Inetpub\wwwroot\102133\q1j8tlte\';
or is there some alteration i must do to this? i have no idea.
thanks,
mb
------------------------------
Date: Mon, 15 Feb 1999 21:34:08 GMT
From: rjeffers@caltex.com.au
Subject: Perl and Javascript - combining the two
Message-Id: <7aa3sg$689$1@nnrp1.dejanews.com>
I have some javascript functions that are built into some Perl code. A brief
explanation: I run a function with Javascript that returns a particular
variable, what I need to do is create a Perl scalar that recalls this
[javascript defined] variable.
Any ideas?
Thanks in advance!
RJ
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 15 Feb 1999 12:19:41 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <MPG.11322134a03ac2c989a3f@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7a9mkp$12c@enews2.newsguy.com> on Mon, 15 Feb 1999 11:42:24
-0600, William H. Asquith <asquith@macconnect.com> says...
> Why isn't there a special array that contains
> $1, $2, $3, etc . . . from application of a regex.
> This would really make things easier.
Why do you nead a special array? Use an array of your own.
my @matches = 'Fee, fie, foe, fum!' =~ /(\w+)\W+\w+\W+(\w+)\W+(\w+)/;
print "@matches\n";
__END__
Fee foe fum
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 15 Feb 1999 19:31:35 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <slrn7cgtlg.ee2.fl_aggie@enso.coaps.fsu.edu>
On Mon, 15 Feb 1999 11:42:24 -0600, William H. Asquith
<asquith@macconnect.com> wrote:
+ Why isn't there a special array that contains
+ $1, $2, $3, etc . . . from application of a regex.
+ This would really make things easier.
Try this. Tested. It worked. First time out. That's very scary --
regexen are not my strong suit, even if it is a trivial regex. I also
don't normally use the 'action IF condtion' construct, nor do I have
cause to use the ${$var} construct. And it friggin' worked. I won't
guarantee that its the best way... :)
$addy='111.222.333.444';
$addy=~m#(\d+)\.(\d+)\.(\d+)\.(\d+)#;
foreach $special (1..9) { # I *think* there are only 9 possible ()'s
push @special, ${$special} if ${$special};
}
foreach $special (@special) {
print "$special\n";
}
James
------------------------------
Date: 15 Feb 1999 21:41:29 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <7aa4a9$ie4$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to William H. Asquith
<asquith@macconnect.com>],
who wrote in article <7a9mkp$12c@enews2.newsguy.com>:
> Why isn't there a special array that contains
> $1, $2, $3, etc . . . from application of a regex.
@+ and @- (in contemporary Perls, note that documentation contains
some misprints).
> This would really make things easier.
It does.
Ilya
------------------------------
Date: Mon, 15 Feb 1999 13:13:28 -0800
From: Derrick MacPherson <derrick@mercuryfilmworks.com>
Subject: rename files with perl
Message-Id: <36C88DF8.2214E797@mercuryfilmworks.com>
I am in need of a huge hand, I was wondering if someone can help me.
I am needing to rename a list of files. The files are in the format
?-*.pnt and ?-*.scan (so m-31.pnt and m-31.scan)
I would like at least to be able to change the first character to a
different letter.
Bonus points if it can include moving directories, and flexibility..
Thanks.
--
Derrick MacPherson
Systems Administrator
Mercury Filmworks
------------------------------
Date: Mon, 15 Feb 1999 20:59:48 GMT
From: mag@imchat.com (Mark P.)
Subject: Re: retrieving java with pearl
Message-Id: <36c88aa9.1104367676@news.ionet.net>
What type of info do you want to gather?
On Fri, 12 Feb 1999 21:17:26 GMT, frank@divita.com (Frank Di Vita)
wrote:
>i am looking for a method of retrieving java applet information. Does
>anyone have any experience using Perl for this. If so, what shouls I
>be looking at?
>
>Any help would be appreciated.
>
>Frank Di Vita
------------------------------
Date: Mon, 15 Feb 1999 08:37:12 +1000
From: Andrew Wild <Andrew.Wild@env.qld.gov.au>
Subject: Socket Q: Minimum listen queue size
Message-Id: <36C75018.B5FB42EC@env.qld.gov.au>
This question relates to the uses of sockets for a server and the listen
queue size. I would like to create a socket server with a listen queue
size of 0. i.e. When it is processing 1 connection it will refuse all
other connections (a queue size of 0). The problem is, if you specify 0
as the listen queue size, it actually defaults to SOMAXCON, which is 5
or more depending upon your system. I also tried -1 and it still appears
to default back to SOMAXCON. Is anyone aware of how you can setup a
listen queue size of 0????
Thanks, Andrew.
--
Andrew Wild
Coordinator (Web Technology)
Information Systems Branch
Queensland Department of Environment and Heritage
Australia
Ph: (07) 3227 7991 Fax: (07) 3227 6534
--------------------------------------------------
Visit us online at http://www.env.qld.gov.au
--------------------------------------------------
------------------------------
Date: Mon, 15 Feb 1999 13:01:43 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: String Compare
Message-Id: <MPG.11322b13daf6c739989a41@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36C87877.B0F54B60@btv.ibm.com> on Mon, 15 Feb 1999 14:41:44
-0500, Paul J. Sala <psala@btv.ibm.com> says...
> I'm trying to construct a REGX that will determine if
> a string contains a character other than
> these: a-z A-Z 0-9 @ . _ -
>
> I tried:
> if ($MyStr =~ /[\W\@\._-]+/)
> { dosomething; }
> else
> { dosomethingelse; }
if ($MyStr =~ /[^\w@.-]/)
\W means 'not [a-zA-Z0-9_]'. So does [^\w...] but it also excludes the
other characters, whereas your regex includes them.
The '_' in your character class is in '\w'. The backslashes are
superfluous, because '@' and '.' have no special meaning in a character
class. The '+' quantifier is superfluous, because it means 'one or
more', and 'one' is part of that set.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 15 Feb 1999 15:26:05 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: String Compare
Message-Id: <36C890ED.F04C9062@us.ibm.com>
Paul J. Sala wrote:
>
> I'm trying to construct a REGX that will determine if
> a string contains a character other than
> these: a-z A-Z 0-9 @ . _ -
>
> I tried:
> if ($MyStr =~
> /[\W\@\._-]+/)
\W matches nonwords. You want \w.
if ($MyStr =~ m/[^\w.\@-]+/) {
# string contains characters other than a-z A-Z 0-9 @ . _ -
}
I'll try to anticipate your next question and point you to perlfaq9:
"How do I check a valid email address?"
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_do_I_check_a_valid_email_ad
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: Mon, 15 Feb 1999 15:26:55 -0500
From: "Craig Hosterman" <craig@architechs.net>
Subject: US-BOSTON-UNIX/PERL/CGI DEVELOPERS NEEDED-recruiter
Message-Id: <7a9vpc$of6@news-central.tiac.net>
For more information contact: craig@architechs.net
Craig Hosterman
Architechs
Recruiter
978-777-8500-voice
------------------------------
Date: Mon, 15 Feb 1999 20:27:57 GMT
From: ankadakia <ankadakia@hotmail.com>
Subject: Web Crawler
Message-Id: <7aa003$2uj$1@nnrp1.dejanews.com>
Hi, I am looking for the program that can crawl serveral web sites (approx
4000) and fetch the webpages for that and put in a perticular folder. And
check for the updates according to schedule etc... Now does anyone knows
packages for this, and/or it will be easy to build with Perl:LWP?
Thank You
ANK
||Beautify|||||||||||||||
||||||||||Your|||||||||||
||||||||||||||Existance||
||ANK||||||||||||||||||||
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 15 Feb 1999 21:37:12 GMT
From: ankadakia <ankadakia@hotmail.com>
Subject: Web Crawler
Message-Id: <7aa427$6j8$1@nnrp1.dejanews.com>
Hi, I am looking for web crawler, that can crawl upto 4000 urls as per
individual schedule, updates etc..
Does anyone know the programs that I am looking for and/or it will be easy to
build it with Perl:LWP?
Thanks for your answer..
||Beautify|||||||||||||||
||||||||||Your|||||||||||
||||||||||||||Existance||
||ANK||||||||||||||||||||
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 15 Feb 1999 15:57:29 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Web Crawler
Message-Id: <7aa1np$bht$1@panix.com>
In <7aa003$2uj$1@nnrp1.dejanews.com> ankadakia <ankadakia@hotmail.com> writes:
>Hi, I am looking for the program that can crawl serveral web sites (approx
>4000) and fetch the webpages for that and put in a perticular folder. And
>check for the updates according to schedule etc... Now does anyone knows
>packages for this, and/or it will be easy to build with Perl:LWP?
Have you taken a look at LWP or the many examples provided?
libwww-perl
http://www.linpro.no/lwp/
--
Clay Irving
clay@panix.com
------------------------------
Date: Sat, 13 Feb 1999 22:56:45 GMT
From: lakerDeleteThisBit@tcp.co.uk (Markus Laker)
Subject: XS code in PFR [was: Re: PFR: read_file, write_file]
Message-Id: <36c6fa13.104058568@news.tcp.co.uk>
Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:
> Also, to address a point in another message,
> I don't have any problem with including XS code as well as `pure' perl.
> As far as I'm concerned XS _is_ part of perl- it's just a different
> part with different capabilities.
XS is a valuable tool, but remember the tens of millions of machines
(most PCs running Windows NT, 95 or 98 and probably others) that are
capable of running Perl but don't have C compilers. It takes five
minutes to instal Perl on a Win32 box using ActiveState's Win32 port.
If a Win32 user has to find GNU C, download it over a modem, work out
how to drive it and then compile your XS code, it's a racing certainty
that he'll just reinvent the wheel instead. That's why XS modules for
Win32 generally come precompiled.
And I don't suppose Daniel Grisinger wants to get into compiling and
packaging binaries for Win32.
Markus
--
Delete the 'delete this bit' bit of my address to reply
------------------------------
Date: Sun, 14 Feb 1999 21:19:00 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: YADF (Yet another date function(s))
Message-Id: <Pine.A41.4.02.9902142105590.44112-100000@ginger.libs.uga.edu>
For dgris, the Repo Man! I'll be glad to take the blame for these, but
the credit goes to the Perl Cookbook.
# "Today's Date (and Time)" Function Samples
# Brad Baxter, 1999/02/14
# This code committed to the public domain.
#
# Naming conventions:
# yyyy => four digit year
# mm => two digit month
# mon => three letter month abbrev. (English)
# month=> month string (English)
# dd => two digit day
# d => one or two digit day, depending
# hh => two digit hour
# mm => two digit minutes
# ss => two digit seconds
#
# All functions return a scalar string.
# The 'fixed format' functions take no parameters.
# Others take an optional parameter, the delimiter between elements.
# One, yyyy_mm_dd_hh_mm_ss, takes three optional parameters (see below).
# yyyymmdd, today's date, e.g., 19990214
# note: fixed format
sub yyyymmdd {
sprintf( "%04d%02d%02d",
sub { ( $_[5] + 1900, $_[4] + 1, $_[3] ) }->( localtime ) );
}
# yyyy_mm_dd today's date, e.g., yyyy_mm_dd('-') yields 1999-02-14
# optional parameter: delimiter
sub yyyy_mm_dd {
my $delim = shift||'';
sprintf( "%04d$delim%02d$delim%02d",
sub { ( $_[5] + 1900, $_[4] + 1, $_[3] ) }->( localtime ) );
}
# yyyy_mm_dd_hh_mm_ss, today's date, e.g.,
# yyyy_mm_dd_hh_mm_ss('-', ' ', ':' ) yields 1999-02-14 16:06:59
# optional parameters: date delimiter, separator, time delimiter
sub yyyy_mm_dd_hh_mm_ss {
my $d1 = shift||'';
my $d2 = shift||'';
my $d3 = shift||'';
sprintf( "%04d$d1%02d$d1%02d$d2%02d$d3%02d$d3%02d",
sub { ( $_[5] + 1900, $_[4] + 1, $_[3],
$_[2], $_[1], $_[0] ) }->( localtime ) );
}
# mm_dd_yyyy, today's date, e.g., 02-14-1999
# optional parameter: delimiter
sub mm_dd_yyyy {
my $delim = shift||'';
sprintf( "%02d$delim%02d$delim%04d",
sub { ( $_[4] + 1, $_[3], $_[5] + 1900 ) }->( localtime ) );
}
# dd_mm_yyy, today's date, e.g., 14-02-1999
# optional parameter: delimiter
sub dd_mm_yyyy {
my $delim = shift||'';
sprintf( "%02d$delim%02d$delim%04d",
sub { ( $_[3], $_[4] + 1, $_[5] + 1900 ) }->( localtime ) );
}
# dd_mon_yyyy, today's date, e.g., 14-Feb-1999
# optional parameter: delimiter
sub dd_mon_yyyy {
my $delim = shift||'';
sprintf( "%02d$delim%s$delim%04d", sub { ( $_[3],
(qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]],
$_[5] + 1900 ) }->( localtime ) );
}
# dd_month_yyyy, today's date, e.g., 14-February-1999
# optional parameter: delimiter
sub dd_month_yyyy {
my $delim = shift||'';
sprintf( "%02d$delim%s$delim%04d", sub { ( $_[3],
(qw(January February March April May June
July August September October November December))[$_[4]],
$_[5] + 1900 ) }->( localtime ) );
}
# mon_dd_yyyy, today's date, e.g., Feb-14-1999
# optional parameter: delimiter
sub mon_dd_yyyy {
my $delim = shift||'';
sprintf( "%s$delim%02d$delim%04d", sub { (
(qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]],
$_[3], $_[5] + 1900 ) }->( localtime ) );
}
# month_d_yyyy, today's date, e.g., February 14, 1999
# note: fixed format
sub month_d_yyyy {
sprintf( "%s %d, %04d", sub { (
(qw(January February March April May June
July August September October November December))[$_[4]],
$_[3], $_[5] + 1900 ) }->( localtime ) );
}
# day_mon_dd_hh_mm_ss_yyyy, today's date, e.g.,
# Sun Feb 14 20:32:19 1999
# note: fixed format
sub day_mon_dd_hh_mm_ss_yyyy {
sprintf( "%s %s %02d %02d:%02d:%02d %04d", sub { (
(qw(Sun Mon Tue Wed Thu Fri Sat))[$_[6]],
(qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec))[$_[4]],
$_[3], $_[2], $_[1], $_[0], $_[5] + 1900 ) }->( localtime ) );
}
------------------------------
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 4899
**************************************