[22406] in Perl-Users-Digest
Perl-Users Digest, Issue: 4627 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 26 14:06:09 2003
Date: Wed, 26 Feb 2003 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 26 Feb 2003 Volume: 10 Number: 4627
Today's topics:
Anyway to do away with ?: in the map function <oxmard.Rules@ab.ab>
Re: better way to avoid "uninitialized value in join" ? <NoSpamPleaseButThisIsValid2@gmx.net>
Re: better way to avoid "uninitialized value in join" ? nobull@mail.com
Re: better way to avoid "uninitialized value in join" ? <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl>
Re: better way to avoid "uninitialized value in join" ? (Anno Siegel)
Capturing STDOUT from Proc::Background processes on Win (Dean J. Pompilio)
CGI redirecdt to another CGI by POST? <raymond.chui@noaa.gov>
Re: CGI redirecdt to another CGI by POST? <noreply@gunnar.cc>
Re: CGI redirecdt to another CGI by POST? (Malcolm Dew-Jones)
Re: FAQ proposal: Why can't I compare two strings using <REMOVEsdnCAPS@comcast.net>
Re: FAQ proposal: Why can't I compare two strings using (Gary E. Ansok)
Re: Feedback request: photobrowser <asu1@c-o-r-n-e-l-l.edu>
Re: Feedback request: photobrowser <asu1@c-o-r-n-e-l-l.edu>
Re: Getting answers with perldocs (Graham Patterson)
Re: Getting answers with perldocs (C Marshall)
Re: Getting answers with perldocs (Tad McClellan)
Re: newbie regexp question <mike@luusac.co.uk>
Re: newbie regexp question (Kevin Cline)
Re: newbie regexp question <mike@luusac.co.uk>
PERL & ORBit <aajii@yahoo.com>
Re: Perl & VB without activeperl on Windows?? <noemail@nowhere.net>
Re: Perl & VB without activeperl on Windows?? <bart.lateur@pandora.be>
Re: Perl -- CGI and background process <mlm@nospam.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Feb 2003 12:57:13 -0600
From: "Peter Shankey" <oxmard.Rules@ab.ab>
Subject: Anyway to do away with ?: in the map function
Message-Id: <6JidnRpumfKUk8CjXTWcpw@comcast.com>
I would like to be able to do away with the trinary ?: in the map function.
I do not seem to be able to. I need the values of $1 through $4. A look at
the __DATA__ shows I need to do a 'grep' on it which I am doing in the map.
My regex is getting the values I want. The statement is doing what I want,
however __DATA__ is really a very large file. Some of the lines have the
data I want and some do not. I am thinking maybe it would run faster on the
real file if I could somehow get just the lines I want into $1.. and not
test them as I do not need if false. I did started out doing a test if it
was a line I was looking for then a split, but it was very slow. Here is the
code:
Thank you very much for your time
Pete
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect('dbi:Oracle:to5',
'XXX',
'XXX',
{RaiseError => 1,
PrintError => 0,
AutoCommit => 0}) or die "Unable to connect $DBI::errstr";
map {
/ values \((\w*),('[\W*|\w*]*'),([\w]*),([\w]*)/
?($dbh->do("insert into customers values ( $1, $2, $3, $4 ) ")):()}
<DATA>;
$dbh->commit;
$dbh->disconnect();
__DATA__
/* comment commnet */
line of junk
/* Needs to be changed as the & is being used in the company column */
set define ~
will need to drop table customers;
will need to create table customers
line of junk
values (2111,'JCP Inc.',103,50000);
line of junk
values (2102,'First Corp.',101,65000);
insert into customers (cust_num, company, cust_rep, credit_limit)
values (2103,'Acme Mfg',105,50000);
another line of junk I do not want
values (2123,'Carter & Sons',102,40000);
values (2107,'Ace International',110,35000);
values (2115,'Smithson',101,20000);
I do not want this line
values (2101,'Jones Mfg.',106,65000);
values (2112,'Zeta corp',108,50000);
commit;
set define &
__END__
------------------------------
Date: Wed, 26 Feb 2003 15:23:12 +0100
From: Wolf Behrenhoff <NoSpamPleaseButThisIsValid2@gmx.net>
Subject: Re: better way to avoid "uninitialized value in join" ?
Message-Id: <3E5CCDCF.61A9F569@gmx.net>
Anno Siegel wrote:
>
> Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl> wrote in comp.lang.perl.misc:
> > I found one solution that works:
> > print HANDLE1 join("\t",map{defined $_ ? $_ : ''} @$arrayref);
> >
> > but I think this will cost a lot of extra execution time. Is there an
> > easier/quicker way?
>
> You could switch off 'uninitialized' warnings as shown in another reply.
>
> Other than that, you approach of filtering out the undef's is fine,
> but is better written with grep() instead of map()
>
> grep defined, @$arrayref;
That doen't do the same. Your grep removes all undefined values whereas
Rene's map replaces undef by ''.
Given the input
$arrayref=['a',undef]
your grep returns ('a') and then join will return 'a'.
Rene's map returns ('a','') so that join will return "a\t".
Wolf
------------------------------
Date: 26 Feb 2003 09:42:48 -0800
From: nobull@mail.com
Subject: Re: better way to avoid "uninitialized value in join" ?
Message-Id: <4dafc536.0302260942.62810fbf@posting.google.com>
Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl> wrote in message news:<b3ia38$rv2$1@reader10.wxs.nl>...
> I need to reduce this array to a string, but I get errors like:
> Use of uninitialized value in join or string at ./dbi_bcp.pl line 133
> if I do:
> print HANDLE1 join("\t",@$arrayref);
> what I want is:
> ('foo',undef,'bar') => "foo\t\tbar"
>
> I found one solution that works:
> print HANDLE1 join("\t",map{defined $_ ? $_ : ''} @$arrayref);
>
> but I think this will cost a lot of extra execution time. Is there an
> easier/quicker way?
Warnings are good - but the reason they are warnings not fatal errors
is that they warning you of things that are still meaningful. If you
really did mean to so thatever it is that Perl is warning about then
simply disable the warning. You should usually do this in small
lexical scope, even if this means introducing an additional set of {}.
{
no warnings 'uninitialized';
print HANDLE1 join("\t",@$arrayref);
}
Note that the no warnings pragma also serves as a comment.
------------------------------
Date: 26 Feb 2003 18:51:49 GMT
From: Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl>
Subject: Re: better way to avoid "uninitialized value in join" ?
Message-Id: <b3j2c5$c1a$1@reader10.wxs.nl>
In article <4dafc536.0302260942.62810fbf@posting.google.com>, nobull@mail.com wrote:
> Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl> wrote in message news:<b3ia38$rv2$1@reader10.wxs.nl>...
>
> Warnings are good - but the reason they are warnings not fatal errors
> is that they warning you of things that are still meaningful. If you
> really did mean to so thatever it is that Perl is warning about then
> simply disable the warning. You should usually do this in small
> lexical scope, even if this means introducing an additional set of {}.
>
> {
> no warnings 'uninitialized';
> print HANDLE1 join("\t",@$arrayref);
> }
>
> Note that the no warnings pragma also serves as a comment.
I didn't know you could switch off warnings in a part of the script.
This will do fine.
Thanks all!
--
___ _
| _ \___ _ _ ___//
| / -_) ' \/ -_)
|_|_\___|_||_\___|
------------------------------
Date: 26 Feb 2003 18:58:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: better way to avoid "uninitialized value in join" ?
Message-Id: <b3j2o4$8nd$1@mamenchi.zrz.TU-Berlin.DE>
Wolf Behrenhoff <NoSpamPleaseButThisIsValid2@gmx.net> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> >
> > Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl> wrote in
> comp.lang.perl.misc:
> > > I found one solution that works:
> > > print HANDLE1 join("\t",map{defined $_ ? $_ : ''} @$arrayref);
> > >
> > > but I think this will cost a lot of extra execution time. Is there an
> > > easier/quicker way?
> >
> > You could switch off 'uninitialized' warnings as shown in another reply.
> >
> > Other than that, you approach of filtering out the undef's is fine,
> > but is better written with grep() instead of map()
> >
> > grep defined, @$arrayref;
>
> That doen't do the same. Your grep removes all undefined values whereas
> Rene's map replaces undef by ''.
> Given the input
> $arrayref=['a',undef]
> your grep returns ('a') and then join will return 'a'.
> Rene's map returns ('a','') so that join will return "a\t".
Oh, right. I didn't realize it matters. In that case, locally
switching off the warning would be the right thing. Replacing
undef with an empty string is Perl's default behavior, so you
can just let it do it.
Anno
------------------------------
Date: 26 Feb 2003 11:00:51 -0800
From: dean_j_pompilio@yahoo.com (Dean J. Pompilio)
Subject: Capturing STDOUT from Proc::Background processes on Win32
Message-Id: <f4c11e64.0302261100.225dda75@posting.google.com>
Hello,
I have written a script using ActivePerl on Win2000 to tail error log
files. The output of these error logs needs to be sent in real time
to a home-grown monitoring console.
I have used Proc::Background to launch multiple "tail -F" commands
whose output currently goes to stdout. (Check out Cygwin for some
great Unix-style tools on Windoze systems!)
I have tried to capture the output stream of each process using
filehandles and redirects to a file, but nothing seems to work yet.
Ideally the "ERROR MESSAGE" text will be replaced by each line from
the error log file.
Here is the relevant code:
sub launch_tail_process {
$tail = "\\\\radon\\binlib\\eops\\cygwin\\bin\\tail";
$process = Proc::Background->new( "$tail -F $logfile" );
push( @pids, $process->pid );
open( PROC, "$process |" ) or die "Can't read from $process:
$!\n";
$error_out = print PROC;
$gas_pushpin = '\\\\radon\\binlib\local\\gas_send -m
$error_out';
}
I get an error saying "The Filename, directory name or volume label
syntax is incorrect" when using the filehandle approach. Any help is
appreciated!!!
~dean
------------------------------
Date: Wed, 26 Feb 2003 09:37:14 -0500
From: Raymond Chui <raymond.chui@noaa.gov>
Subject: CGI redirecdt to another CGI by POST?
Message-Id: <3E5CD11A.848083E2@noaa.gov>
This is a multi-part message in MIME format.
--------------A64E1D4956494138E3121BB8
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I have a CGI program try to parse and do something, then redirect to
another CGI.
#!/usr/bin/perl -w
use CGI;
use DBI;
use HTTP::Request::Common;
use LWP::UserAgent;
my $parse = new CGI;
# do parse->param("...")
......
# do SQL by DBI
.......
# Everything works fine and correct, no error so far.
# Then redirect to another CGI
$ua = LWP::UserAgent->new;
$response = $ua->request(POST 'http://hostname/cgi-bin/anotherCGI.pl',
[
name1 => 'value1',
name2 => 'value2'
]);
Once I try to redirected to another CGI, I got 404 Errors! Why???!!!
But if I try redirected by GET like
print
$parse->redirect(-uri=>'http://hostname/cgi-bin/anotherCGI.pl?name1=value1&name2=value2',
now,
-nph=>1);
Then it works fine, redirect to new CGI.
I am just wonder how to use HTTP and LWP packages to do the redirect
instead CGI package.
The reason I want to use POST instead GET is because I have too many
name/value pairs, they are long
values.
Please help
Thank you very much in advance!
--------------A64E1D4956494138E3121BB8
Content-Type: text/x-vcard; charset=us-ascii;
name="raymond.chui.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Raymond Chui
Content-Disposition: attachment;
filename="raymond.chui.vcf"
begin:vcard
n:Chui;Raymond
tel;work:301-713-0640 x168
x-mozilla-html:FALSE
url:http://www.nws.noaa.gov/
org:NWS, NOAA;OHD13
version:2.1
email;internet:raymond.chui@noaa.gov
title:CS
adr;quoted-printable:;;1325 East-West Highway=0D=0ASSMC2, Room 8113;Silver Spring;MD;20910-3282;U.S.A.
fn:Raymond Chui
end:vcard
--------------A64E1D4956494138E3121BB8--
------------------------------
Date: Wed, 26 Feb 2003 15:51:04 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI redirecdt to another CGI by POST?
Message-Id: <b3ilhp$1m8s11$1@ID-184292.news.dfncis.de>
Raymond Chui wrote:
> I have a CGI program try to parse and do something, then redirect to
> another CGI.
> [snip]
> $ua = LWP::UserAgent->new;
> $response = $ua->request(POST 'http://hostname/cgi-bin/anotherCGI.pl',
> [
> name1 => 'value1',
> name2 => 'value2'
> ]);
You should use strictures and warnings to make Perl tell you why you got
those errors.
Anyway, you might want to try something like this:
$ua = LWP::UserAgent->new;
$response = $ua->request(new HTTP::Request POST,
'http://hostname/cgi-bin/anotherCGI.pl',
[
name1 => 'value1',
name2 => 'value2'
]);
[untested]
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 26 Feb 2003 09:39:24 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: CGI redirecdt to another CGI by POST?
Message-Id: <3e5cfbcc@news.victoria.tc.ca>
Raymond Chui (raymond.chui@noaa.gov) wrote:
: # Then redirect to another CGI
: $ua = LWP::UserAgent->new;
: $response = $ua->request(POST 'http://hostname/cgi-bin/anotherCGI.pl',
: [
: name1 => 'value1',
: name2 => 'value2'
: ]);
: Once I try to redirected to another CGI, I got 404 Errors! Why???!!!
: But if I try redirected by GET like
: print
: $parse->redirect(-uri=>'http://hostname/cgi-bin/anotherCGI.pl?name1=value1&name2=value2',
: now,
: -nph=>1);
: Then it works fine, redirect to new CGI.
In addition to any other errors, notice that the two techniques you use
are completely different. The first example is not a redirect. What it
does is turn your cgi script into a client that gets some data and must
then still return some headers and data to the original browser. The
second technique is a redirect. It tells the browser to make another
query to a different location.
In the second technique, once you have sent the redirect that you are
finished. In the first technique, even if you correctly use the
$ua-request then you will still get browser errors unless you create a
valid set of headers and data and send it to the browser. (You might be
able to simply re-print the $response, I don't know those details for
sure.)
-1st technique-
+------+ +--------+ +-------------+
| | | | | |
|client| -> request -> |your cgi| -> $ua-request -> |anotherCGI.pl|
| | | | | |
| | <- response<- | | <-returning data <- | |
| | | | | |
+------+ +--------+ +-------------+
-2nd technique-
+------+ +--------+
| | | |
|client| -> request -> |your cgi|
| | | |
| | <- redirect <- | |
| | to new url | |
+------+ +--------+
+------+ +-------------+
| | | |
|client| -> new request -> |anotherCGI.pl|
| | | |
| | <- returning <- | |
| | data | |
+------+ +-------------+
------------------------------
Date: Wed, 26 Feb 2003 11:19:02 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <Xns932E7D3B9F7DDsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
pjlees@ics.forthcomingevents.gr (Philip Lees) wrote in
news:3e5cc3d7.84597531@news.grnet.gr:
> On Wed, 26 Feb 2003 05:54:00 -0600, tadmc@augustmail.com (Tad
> McClellan) wrote:
>
>>Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>>
>>> NOTE: If you use strictures and warnings (as you should) then Perl
>>> will warn you about what's wrong.
>>
>>strictures have nothing to do with the warning.
>>adding warnings alone will be enough to have perl tell you about it.
>
> I know that. I just thought it wouldn't hurt to mention the strictures
> as well.
Strictures are a good thing; however, we need not stoop to lying about them
to make them look more useful than they are. ;-)
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPlz26GPeouIeTNHoEQJ6GgCbBNQhvAISha+OOjb3OgGTfuBlCaYAoON6
7PyvS4XBmzDbnhdhMpZ6UOXf
=YKb1
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 26 Feb 2003 17:19:07 +0000 (UTC)
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <b3isub$b6e$1@naig.caltech.edu>
In article <3e5b385c.69650578@news.grnet.gr>,
Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
>On 24 Feb 2003 18:21:58 +0000, Brian McCauley <nobull@mail.com> wrote:
>>"Jürgen Exner" <jurgenex@hotmail.com> writes:
>>> One of the most frequently asked questions is
>>> "Why can't I compare two strings using == ?"
>>
>>Unfortuately I can't think of a way to phrase the question.
>
>How about: 'Why don't my equality tests work right?'
Is that a question that new users will find when they look
through the FAQ list? Personally, I don't think so.
Imagine yourself a user fairly new to Perl, who's just discovered
the -q option to perldoc. What keywords would you be likely to
use to find the answer you're looking for?
I think the original title is more likely to be found by such a
user -- the keywords that come to my mind are "compare", "strings",
"equal", and maybe "==" if that's allowed. "Tests" and "equality"
are way down my list.
I prefer the original title -- it's more direct, and immediately
tells the reader what this FAQ deals with. When I see Philip's
proposal, I think of floating-point inaccuracies (also an FAQ,
but not part of the same topic).
If we want to make the topic more general, I agree with
"Why can't I compare two strings using == (or = ) ?"
Gary Ansok
--
3M suggests that to obtain the best results, one should make the bond
"while the adhesive is wet, aggressively tacky." I did not know what
"aggressively tacky" meant until I saw a recent notice in the Bboard.
-- Mario Barbacci
------------------------------
Date: 26 Feb 2003 14:19:23 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Feedback request: photobrowser
Message-Id: <Xns932E5ED7744B2asu1cornelledu@132.236.56.8>
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
news:b3hpvh$12e$1@nets3.rz.RWTH-Aachen.DE:
> Also sprach A. Sinan Unur:
...
>> I would appreciate comments on how to improve the script,
...
> Given your "inexperience", the script is pretty well done. Rather a
> pleasant exception for posts like "Comment my script".
Thank you.
>> my $query = CGI::new();
>
> You are calling the constructor as a function, but it really is a
> class-method:
>
> my $query = CGI->new;
>
> This should make a difference actually and I wonder that it also
> worked the way you did it. Anyway, keep in mind that class methods are
> not functions so call them with 'CLASS->method'.
Thank you for catching that. I didn't get any warnings, so I would probably
never have noticed it.
...
(I didn't want to lengthen my post by repeating all your other comments,
but I should note that I understand them, and see how they improve the
quality of the script. Thanks.)
>
>> my $desc = $descriptions->getProperty(lc($file));
>> $iter_data->{'DESC'.($photos_per_row ? $counter : '')}
>> = $desc ? $desc : $config{default_description};
>> $counter = ($counter + 1) % ($photos_per_row || 1);
>> if(!$counter) {
>> push(@loop_data, $iter_data);
>> $iter_data = {};
>> }
>> }
>> push(@loop_data, $iter_data) if scalar keys %$iter_data;
>
> I have some problems with the logic of the last six lines. Currently
> it looks like:
>
> do {
> my $iter_data;
> foreach (...) {
> ...
> if (! $counter) {
> push @loop_data, $iter_data;
> $iter_data = { };
> }
> }
> push @loop_data, $iter_data if keys %$iter_data;
> }
>
> It has something to do with the amount of photos that can be stored in
> one row.
yes, the last push is for 'left-over' photos. So, if I had 50 photos in the
directory, and $photos_per_row was 4, I would have two left over in
iter_data when at the end of the loop. So, I make sure to push them as
well.
> It might be better to change the structure of @loop_data and
> $iter_data to make the intent of the above clearer. @loop_data should
> be a two-dimensional array, like a table, and $iter_data should become
> $picture or so:
I understand that. However, my purpose was to find a way to have a single
loop in the template for displaying the links to the photos, as well as
finding a way to have the number of photos be determined by the template.
Given the way parameters are passed to the template, I couldn't figure out
how work the mechanics with a multi-dimensional array. But I'll try again,
taking your suggestions into account.
> would be easier to handle. You make quite some contortions to give the
> several entries in the hash unique prefixes to distinguish later which
> "URL"-key belongs to which "FILE"-key.
See above.
>> print header, $template->output;
>
> You are mixing the object-oriented interface of CGI.pm with the
> functional one. Not wrong, but a little inconsistent IMHO.
That's where my inexperience shines :)
Thank you.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 26 Feb 2003 14:27:43 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Feedback request: photobrowser
Message-Id: <Xns932E60411672Easu1cornelledu@132.236.56.8>
tadmc@augustmail.com (Tad McClellan) wrote in
news:slrnb5pcu9.4np.tadmc@magna.augustmail.com:
> A. Sinan Unur <asu1@c-o-r-n-e-l-l.edu> wrote:
>
>> I spent some time over the last few days, incorporating comments I
>> received on an earlier version of this script, and looking for more
>> code to steal :).
> ^^^^^^^^
> The correct term is "to reuse". :-)
>
>
>> # See if location contains any relative paths
>
> The comment does not match what the code actually does.
Correct. Thanks.
> It doesn't check for *any* relative paths, only those that
> might go "higher" in the dir tree.
>
> ./me.jpg and family_reunion/sis.jpg
I figured the first is not material for this script because I prepend the
absolute path $htdocs. I actually want the second type of request to be
permissable, so I can use the script to navigate subcategories. The
specific usage I intend should be documented, however.
> Absolute paths can be bad too, but you don't check for them.
>
> if $location =~ /\.\./ or $location =~ m#^/#;
Right, however, I thought prepending the absolute path to htdocs (I
should actually change the name of that parameter to something like
album_path) to location took care of the possibility of browsing to
unallowed locations.
> You should probably have an explicit chdir() somewhere near
> the top of your program too.
Good idea. That would probably simplify the later logic.
>> sub bail_out {
>> my $file = shift;
>> my $message = shift;
>
>
> my($file, $message) = @_;
>
> Makes it easier to add a 3rd argument...
Cool.
Thank you for all your comments.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 26 Feb 2003 06:38:52 -0800
From: gpatterson@opec.org (Graham Patterson)
Subject: Re: Getting answers with perldocs
Message-Id: <7dfc2de8.0302260638.5002b8c0@posting.google.com>
> The _Perl Cookbook_ (O'Reilly) would come close to what you expect,
> but it's only available in print.
The Cookbook (and many others) is on online at Safari
(http://safari.oreilly.com) -- it's not free but last time I checked
they were offering a 14-day free trial.
Cheers, Graham
------------------------------
Date: 26 Feb 2003 06:55:50 -0800
From: c_j_marshall@hotmail.com (C Marshall)
Subject: Re: Getting answers with perldocs
Message-Id: <cb9c7b76.0302260655.41dcb381@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message
> perl -ne "print if /remove/ and /space/" *.pod
Is there any way to get this line to also print the name of the file
it found the match in ?
The only way I've found to do it is to "grep ." first and pipe the
output into perl like this:
perl -ne 'print if /hello/' test.txt test2.txt
hello
hello
grep . test.txt test2.txt | perl -ne 'print if /hello/'
test.txt:hello
test2.txt:hello
Is there a more elegant solution ?
------------------------------
Date: Wed, 26 Feb 2003 10:00:29 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Getting answers with perldocs
Message-Id: <slrnb5pp4t.5ac.tadmc@magna.augustmail.com>
C Marshall <c_j_marshall@hotmail.com> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message
>> perl -ne "print if /remove/ and /space/" *.pod
>
>
> Is there any way to get this line to also print the name of the file
> it found the match in ?
Yes.
perl -ne 'print qq($ARGV: $_) if /remove/ and /space/' *.pod
or
perl -ne 'print "$ARGV: $_" if /remove/ and /space/' *.pod
And since this was meant for a silly OS that doesn't do globbing in
the shell, we'll have to glob ourselves too:
perl -ne "BEGIN{@ARGV = glob $ARGV[0]} print qq($ARGV: $_) if /remove/ and /space/" *.pod
(use single instead of double quotes if on a sensible OS)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 26 Feb 2003 15:37:41 -0000
From: "Mike" <mike@luusac.co.uk>
Subject: Re: newbie regexp question
Message-Id: <Ja57a.5275$EN3.41153@newsfep4-glfd.server.ntli.net>
beacuse I have been told that the code must be free standing - not rely on
external modules (other than I guess those installed by default).. I know it
sounds like reinventing the wheel, but the script will only ever perform a
limited function on a single file.
I have run into another problem:
I am trying to tokenize words by using a regexp (not split)
$var =~ s/(\b)/$1\n/gsi;
fails because where a word has an apostrophe or is surrounded by quotations
it is treated as the word having stopped and the apostrophe is put in the
next line.
Can you point me at some basic tutorials for perl regexps (I am trying to
get hold of a copy of the O'Reilly book) & parsing etc
thanks
Mike
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb5pekp.4pc.tadmc@magna.augustmail.com...
> Mike <mike@luusac.co.uk> wrote:
>
> > can't use pre-built
> > modules.
>
>
> Why not?
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 26 Feb 2003 10:16:04 -0800
From: kcline17@hotmail.com (Kevin Cline)
Subject: Re: newbie regexp question
Message-Id: <ba162549.0302261016.5d4c83f0@posting.google.com>
"Mike" <mike@luusac.co.uk> wrote in message news:<Ja57a.5275$EN3.41153@newsfep4-glfd.server.ntli.net>...
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnb5pekp.4pc.tadmc@magna.augustmail.com...
> > Mike <mike@luusac.co.uk> wrote:
> >
> > > can't use pre-built
> > > modules.
> >
> >
> > Why not?
> >
> beacuse I have been told that the code must be free standing - not rely on
> external modules (other than I guess those installed by default).. I know it
> sounds like reinventing the wheel, but the script will only ever perform a
> limited function on a single file.
It's just silly. You will have to distribute your script somehow.
You can just wrap up the additional modules with the script,
and make your installation script also install whatever modules
are required.
------------------------------
Date: Wed, 26 Feb 2003 19:00:46 -0000
From: "Mike" <mike@luusac.co.uk>
Subject: Re: newbie regexp question
Message-Id: <b987a.5487$EN3.43965@newsfep4-glfd.server.ntli.net>
> It's just silly. You will have to distribute your script somehow.
> You can just wrap up the additional modules with the script,
> and make your installation script also install whatever modules
> are required.
it won't be distributed ... just left where it is once completed .....
------------------------------
Date: Wed, 26 Feb 2003 15:48:50 GMT
From: "A.J" <aajii@yahoo.com>
Subject: PERL & ORBit
Message-Id: <3E5CE1DF.F8376AA8@yahoo.com>
ORBit-0.5.8
PERL5.00503
CORBA-ORBit-0.4.3
I'm trying to connect to a VisiBroker5.02 corba server.
I'm able to connect directly to service I need using it's IOR but I
want to use NameService. I'm having some problems with it:
Should this go like this:
28: my $orb = CORBA::ORB_init( "orbit-local-orb" );
29: my $nameService = $orb->string_to_object( $nsIor );
30: $nameService->_narrow('IDL:omg.org/CosNaming/NamingContextExt:1.0');
31: my $name = [{id => "TestFactory", kind => ""}];
32: my $object = $ns->resolve( $name );
33: # At this point I should have the TestFactory object which I'm able
34: # to connect to using direct IOR
>./test.pl
autoloading _narrow
Can't get interface
at ./test.pl line 30
------------------------------
Date: 26 Feb 2003 14:45:19 GMT
From: nobody <noemail@nowhere.net>
Subject: Re: Perl & VB without activeperl on Windows??
Message-Id: <Xns932E63F4972FFabccbaabc@129.250.170.100>
>> (replying to myself)
>> But it still needs core Perl on the target machine. :(
> Uh no, it doesn't. ... although if the perl is built
> as a shared library, it will then need a perl58.dll (or perl56.dll,
> etc) in the path.
> Would you tell me (via email to par@perl.org) which part of my
> documentation indicated that it requires core perl? ...
I've read the documentation again and I can't think what led me to
my earlier conclusion. My mistake.
For an MSWIN app using ActivePerl, it sounds like I'd just need to
deliver the app .exe and perl56.dll (for example). Great!
------------------------------
Date: Wed, 26 Feb 2003 16:42:30 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl & VB without activeperl on Windows??
Message-Id: <scrp5vgcq6hi7a406k6cl7jeo6e38bl2n4@4ax.com>
nobody wrote:
>For an MSWIN app using ActivePerl, it sounds like I'd just need to
>deliver the app .exe and perl56.dll (for example). Great!
I suggest also looking into tinyperl:
<http://sourceforge.net/projects/tinyperl/>
There were a few announcements and small discussions on Perlmonks:
<http://perlmonks.org/index.pl?node_id=224166>
<http://perlmonks.org/index.pl?node_id=222465>
--
Bart.
------------------------------
Date: Wed, 26 Feb 2003 09:00:47 -0600
From: mlm <mlm@nospam.com>
Subject: Re: Perl -- CGI and background process
Message-Id: <JkmdnQhw9KoCS8GjXTWcqQ@giganews.com>
merlyn@stonehenge.com (Randal L. Schwartz) wrote in
news:7faa2f6fef391e99f2fcbfb2ace12950@news.teranews.com:
> http://www.stonehenge.com/merlyn/WebTechniques/col62.html
Very nice of you to point that out and I'm sure it will be of some use.
Google didn't find that reference when I searched madly for net:NNTP etc.
Thanks Randall
Regards
Mark
------------------------------
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 4627
***************************************