[10914] in Perl-Users-Digest
Perl-Users Digest, Issue: 4515 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 29 20:07:12 1998
Date: Tue, 29 Dec 98 17:00:16 -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 Tue, 29 Dec 1998 Volume: 8 Number: 4515
Today's topics:
Re: An interesesting? problem.... (Tad McClellan)
DBD Oracle 'make test' fails <bageshpu@pa.dec.com>
Re: Delimeters in Data <gellyfish@btinternet.com>
Re: EXPERIENCED IN PERL ? <chatmaster@c-zone.net>
Re: fix Config.pm <gellyfish@btinternet.com>
Homepage- Search Engine with ASP or PERL ? <philip.class@popcorn-studio.ch>
Re: I need a little help with PERL Script <chatmaster@c-zone.net>
Re: matching parentheses quickly <Mukke@get2net.dk>
Re: Need file upload to display date, size <tamaraw@mindspring.com>
Re: net::time question <gellyfish@btinternet.com>
Re: Newest precompiled version of Perl? (Randy Kobes)
Re: Perl Cookbook <chatmaster@c-zone.net>
Re: Perl Cookbook (Sam Holden)
Re: perl with sed question? <zenin@bawdycaste.org>
Re: perl with sed question? <kprice@cardinal.co.nz>
Re: Perl--sql--win32--command??? <ahongun@ecsysinc.com>
Re: Protecting my script from form data <gellyfish@btinternet.com>
random number problem <jjpark@home.com>
Re: random number problem <che@debian.org>
Re: When hashing won't work... <gellyfish@btinternet.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 29 Dec 1998 18:24:58 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: An interesesting? problem....
Message-Id: <qsrb67.pd1.ln@magna.metronet.com>
[ Please limit your line lengths to 70-72 characters as
is Usenet custom
]
Jim Matzdorff (syran@best.com) wrote:
: I have a problem here at work that I was wondering if anyone may
: have thoughts on.
: I have an string (suspiciously like an ip address) such as:
: 10(4).3.4(2).2(2)
: I need to get every combination of ip address out of that,
: assuming the number in parens
: are number of addtions to that particular part of the ip address.
: ALL the iterations and possible combinations.
My first cut:
----------------------
#!/usr/bin/perl -w
use strict;
my $ip = '10(4).3.4(2).2(2)';
my($p1, $p2, $p3, $p4) = split /\./, $ip; # split the four parts
foreach my $q1 ( range($p1) ) { # first quad
foreach my $q2 ( range($p2) ) { # second quad
foreach my $q3 ( range($p3) ) { # third quad
foreach my $q4 ( range($p4) ) { # fourth quad
print "$q1.$q2.$q3.$q4\n";
}
}
}
}
sub range {
my($lo) = @_;
my $hi = $lo =~ s/\((\d+)\)$// ? $lo + $1 : $lo;
return $lo .. $hi;
}
----------------------
But I've been wanting to use lookbehind assertions for a while,
and here is my chance, so a second cut:
----------------------
#!/usr/bin/perl -w
use strict;
my $ip = '10(4).3.4(2).2(2)';
# convert to range notation. eg: 10(4) becomes 10..14
$ip =~ s/(\d+)(?:\((\d+)\))?/ defined($2) ? "$1.." . ($1+$2) : "$1..$1"/eg;
my($p1, $p2, $p3, $p4) = split /(?<!\.)\.(?!\.)/, $ip; # split the four parts
foreach my $q1 ( eval($p1) ) { # first quad
foreach my $q2 ( eval($p2) ) { # second quad
foreach my $q3 ( eval($p3) ) { # third quad
foreach my $q4 ( eval($p4) ) { # fourth quad
print "$q1.$q2.$q3.$q4\n";
}
}
}
}
----------------------
I gotta admit though that I find myself wondering why you want
to do this.
Seems easier to test if a particular IP is in the range described
by the string, rather than generate all in the range and see if
the particular IP is in the generated list.
I trust that that is not why you want to do it...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 29 Dec 1998 15:27:08 -0800
From: Asha Bageshpura <bageshpu@pa.dec.com>
Subject: DBD Oracle 'make test' fails
Message-Id: <3689654C.873CBA73@pa.dec.com>
I have difficulty passing 'make test' when I am trying to install
DBD::Oracle
I get the following error
install_driver(Oracle) failed: Can't load './blib/arch/auto/D
BD/Oracle/Oracle.so' for module DBD::Oracle: Unresolved symbol in
./blib/arch/aut
o/DBD/Oracle/Oracle.so: upioep at
/log/perlmodules/perl4/lib/alpha-dec_osf/5.0040
4/DynaLoader.pm line 166.
Note : I set the LD_LIBRARY_PATH $ORACLE/lib;$ORACLE/network/lib.
If I do not set the path then I get the following error
t/general...........install_driver(Oracle) failed: Can't load
'./blib/arch/auto/D
BD/Oracle/Oracle.so' for module DBD::Oracle: dlopen: cannot load
./blib/arch/auto
/DBD/Oracle/Oracle.so at
/log/perlmodules/perl4/lib/alpha-dec_osf/5.00404/DynaLoa
der.pm line 166.
Any ideas?
Asha
------------------------------
Date: 29 Dec 1998 17:33:43 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Delimeters in Data
Message-Id: <76b3pn$pb$1@gellyfish.btinternet.com>
On Tue, 29 Dec 1998 22:34:54 +0800 D.C.Karthikeyan <ckdasari@cs.hku.hk> wrote:
> Hi,
>
> I am trying to join and split a list using a colon as a delimeter. The
> problem comes when the actual list contains a colon. For instance:
>
> This one works fine:
>
> $test = join (":", "Test", "Fine");
> @test = split (":", $test);
>
> BUT this one does not.
>
> $test = join (":", "Te:st", "Fine");
> @test = split (":", $test);
>
> This is because the delimeter is part of the actual data. I know I could
> write a function to get around this problem. But is there a built-in perl
> function that could do this or some kind of efficient code to do this as
> quickly as calling the actual join and split function.
In the instances that you cite there is no real way around the problem
except for changing the delimiter. Alternatively if you must include your
delimiter character in your data then you will have to further delimit it
if you see what I mean ...
You can have a string like this:
1234:"This is : a test":blah:"Yes: I like bananas"
and that is susceptible to splitting except without using split() - you
should check out the section in perlfaq4 entitled:
How can I split a [character] delimited string except when
inside [character]? (Comma-separated files)
This solution works fine the problem comes when constructing the data - I
will leave that as an exercise for the reader - and besides there is a Rat
Pack Movie on right now.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 29 Dec 1998 15:36:27 -0800
From: TRG Software <chatmaster@c-zone.net>
Subject: Re: EXPERIENCED IN PERL ?
Message-Id: <3689677B.3C0DA972@c-zone.net>
Erik wrote:
>
> In article <368931C2.20681CEE@usa.net>,
> GSX <gsx97@usa.net> writes:
> > I'm presently writing a Perl Coffee Maker. I've got the code to brew a
> > great cup of Hazelnut...but I'm having a problem with the code for
> > decaf.
> >
> > Will this make me ineligible for the job?
>
> No, but you better get that code for the cappucino extension working
> properly...these people are obviously high class.
>
> --
> Erik Nielsen, Cyberhighway Internet Services NOC
> I think it's a new feature. Don't tell anyone it was an accident. :-)
> -- Larry Wall on s/foo/bar/eieio in <10911@jpl-devvax.JPL.NASA.GOV>
Now now everyone. I've emailed this guy/person, and he/she has assured
me that this is *not* usenet SPAM, and they just *really* need someone
(to do anything apparently) :
"This is not "SPAM" .. it is a completely legit opportunity for some one
who has talent and skill with PERL and the like. We have a need for a
qualified person due to the fact we have grown so much, we require
additional assistance on product production.
If this is a concern, we can stop including the news groups in general
for our search.
Thank you for your time."
Whatever.. :-)
--
Regards,
Tim Greer - chatmaster@c-zone.net
TRG Software and The Link Worm
http://www.linkworm.com
The Chat Base
http://www.chatbase.com
-----------------------------------------------------------------------
* Creator of Paradise Chat, Chat Central & Spiral Chat
* Receiving over 250,000+ hits a day from users Worldwide!!!
* Sales of custom chat server scripts * CGI/Perl scripting
* Script trouble shooting/security * Modify & debug scripts
* Freelance Perl Scripting for any purpose or application
Copyright ) 1998 TRG Software and The Link Worm.
------------------------------
Date: 29 Dec 1998 17:39:31 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: fix Config.pm
Message-Id: <76b44j$pe$1@gellyfish.btinternet.com>
On Tue, 29 Dec 1998 14:31:31 GMT nguyen.van@imvi.bls.com wrote:
> Hi guys,
>
> I tried to debug my script and get this message:
>
> "Perl lib version (5.00404) doesn't match executable version (5.001) at
> /opt/lib/perl5/sun4-solaris/5.00404/Config.pm line 7"
>
> How can I fix this problem? Thanks for your help.
>
I would suggest that you have got two installations confused there and even if
if you could fix your config.pm to get one script to work it will almost
certainly result in problems later.
My suggestion would be to delete all of the previous Perl library directories
and so forth and then reinstall.
There is a possibility however before you do that that you are using an
executable perl that is not the one that you have most recently installed.
Look at the file pointed to by your #! line (do a 'perl -v') and then look
for another perl executable and try to put that in your script.
I still think you may probably need to reinstall..
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Wed, 30 Dec 1998 00:16:56 +0100
From: "Philip Class" <philip.class@popcorn-studio.ch>
Subject: Homepage- Search Engine with ASP or PERL ?
Message-Id: <76bntf$8de$1@bw107zhb.bluewin.ch>
Does someone have an example of a Search Engine, to browse through indexed
pages on a Homepage (not to crawl through the whole WWW). ?
There's a nice example of a Search Engine using Javascript on
http://www.infohiway.com/javascript/search/wildcard.htm. But this might
become too slow to index big Websites with many pages.
Is there a similar way of using ASP to automatically index a whole directory
& subdirectories and use these keywords lateron in a search-field in the
Website ?
These keywords may be stored in an array (like in the Javascript example).
Or would it be more efficient to use a cgi-PERL Script instead of ASP or
Javascript ?
Thanks for hints & helping links,
Philip
------------------------------
Date: Tue, 29 Dec 1998 15:42:50 -0800
From: TRG Software <chatmaster@c-zone.net>
Subject: Re: I need a little help with PERL Script
Message-Id: <368968FA.F0B46E4E@c-zone.net>
amigolatino@my-dejanews.com wrote:
>
> Please reply by e-mail to this message Thanks!!
Sorry...
> First of all please let me thanks you for reading or trying to help me with
> the script. Please excuse any wrong written words.
^^^^^^^^^^^^^^^^^^^
And phrasings. -- just kidding. :-)
> Plus I am new to Perl
>
> The Problem:
> I need a little help with a perl script I am setting up on my website.
> The problem is that when it gets a keyword that has a space between it, it
> gives the first results ok, like REsults for "Perl Scripts", then the results
> are given. But I have an option to change the webpage on spanish.
> but the results come only for the word Perl because of the space between it.
> Example:
> http://server/cgi-bin/script.pl?keyword=perl scripts&x=34&y=45
> In Script: http://server/cgi-bin/script.pl?$content{'keyword'}&x=34&y=45
>
> as I understand for the results to work the script have to replace the SPACE
> in the keyword to a + sign. To Something Like:
> http://server/cgi-bin/script.pl?keyword=perl+scripts&x=34&y=45
Yes...
>
> Can you help me make the perl/cgi script change that space to a + sign ??
You need to URL-encode it.
> If you do or know where I can get that part of scrit please let me know.
Go to http://www.perl.com, or look in any perl book that explains how
to use it with CGI.
>
> That's all I need, Thanks
Are you sure about that? If you don't know that much, something else is
sure to come up very soon, especially security and bug issues. - that's
not to say for sure though. :-)
>
> P.S. - Please reply by e-mail, as it will be easier for me, and faster to
> reply to your Help.
>
> att..: jose enrique
> info@amigoslatinos.com
Sorry...
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
Regards,
Tim Greer - chatmaster@c-zone.net
TRG Software and The Link Worm
http://www.linkworm.com
The Chat Base
http://www.chatbase.com
-----------------------------------------------------------------------
* Creator of Paradise Chat, Chat Central & Spiral Chat
* Receiving over 250,000+ hits a day from users Worldwide!!!
* Sales of custom chat server scripts * CGI/Perl scripting
* Script trouble shooting/security * Modify & debug scripts
* Freelance Perl Scripting for any purpose or application
Copyright ) 1998 TRG Software and The Link Worm.
------------------------------
Date: Wed, 30 Dec 1998 00:18:35 +0100
From: "Thomas Turn Jensen" <Mukke@get2net.dk>
Subject: Re: matching parentheses quickly
Message-Id: <Hqdi2.16$74.321@news.get2net.dk>
I'm not really sure if this is what you're looking for :
$String =~ s/.*?\((.*)\)/$1/;
Where String from the start holds what to be scanned and afterwards holds
the parameters..
This will ONLY wotk if you only have one "function" per string...
***
Thomas Turn Jensen
Icq uin => 8128636
IRC, Undernet => Mukke
***
So long, and thanks for all the fish
***
Andrew Mayo skrev i meddelelsen <76blrp$b47$1@news.akl.netlink.net.nz>...
>I have this nagging feeling that the problem below can be solved with an
>elegant regular expression - but for the life of me I can't see the
>solution.
>
>The problem, stated canonically, is simple; given some input via STDIN
>(which is actually source code itself), look for a particular function;
>we'll call it foo(), in this case, where foo's arguments can themselves be
>parenthesized, viz:-
>
>foo(arg1,(arg2+arg3),(arg4))
>
>etc.
>
>We want to return
>
>arg1,(arg2+arg3),(arg4)
>
>as the argument list to foo.
>
>The classic algorithm is of course to iterate through the text string, one
>character at a time from the opening bracket, adding one to a counter for
>each open bracket and decrementing by one for each closing bracket. Then
the
>argument list is found when the counter returns to zero.
>
>This is not stunningly fast (if you have a lot of source code to scan),
>though obviously using a global match and iterating over the match set will
>optimise it somewhat. But being that time of year, I got to wondering if
>there's a *really* cunning solution.
>
>Has anyone got a cunning regular expression that might do the trick - some
>kind of ingenious use of negative lookahead assertions etc?. Or is this
>particular problem not resolvable via a regular expression?. In any case,
>would anyone care to suggest an elegant and fast solution to the generic
>problem of returning a substring inside balanced parentheses? It seems like
>an interesting problem for you Perl experts out there - I am but an
>insignificant hacker, as yet, though I gain confidence by the day.....
>
>
------------------------------
Date: Tue, 29 Dec 1998 18:53:26 -0500
From: Tamara Williams <tamaraw@mindspring.com>
Subject: Re: Need file upload to display date, size
Message-Id: <36896B76.C6110D7B@mindspring.com>
Thanks for the advice.
I know those commands are SSI directives and not Perl, but I thought there might be a way to
weave it in there.
I'll try your method.
Thanks for the links, too.
Tamara
------------------------------
Date: 29 Dec 1998 17:20:57 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: net::time question
Message-Id: <76b31p$ou$1@gellyfish.btinternet.com>
On Tue, 29 Dec 1998 12:32:52 +0100 Damoi <damoi985@hotmail.com> wrote:
> I do not get it.
> What is a simple way to get the time of a host (win32)
> I am using this code without success:
<snip>
I am not entirely sure that NT has a 'time' server you might want to try
using 'localtime' (for instance) in your script instead of Net::Time unless
you have a unix server that serves daytime on port 13 or time on port 37 on
your network.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 29 Dec 1998 22:45:59 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: Newest precompiled version of Perl?
Message-Id: <slrn78inf1.dqv.randy@theory.uwinnipeg.ca>
On Tue, 29 Dec 1998 16:38:04 -0600,
Michael D. Schleif <mds-resource@mediaone.net> wrote:
>To the point: what is the difference between ActivePerl and compiling
>stable.zip source on win32?
>Clearly, there is a difference; but, why the divergence? Or, is there
>divergence?
>
>Jonathan Stowe wrote:
>>
>> ActivePerl is based on the same code as the standard source code
>> distribution indeed their extensions have been applied to that source
>> code - if you are in a position to compile your own Perl with a Borland or
>> Microsoft compiler then you would end up with largely the same executable.
Hi,
They're both based on the same 5.005_02 sources, but
ActiveState has applied several patches of their own (which
have been submitted for inclusion in the next official release).
Recently ActiveState has released the sources they base their
build on, as well as the diffs with the official release - you
can get these at their web site.
--
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: Tue, 29 Dec 1998 15:46:15 -0800
From: TRG Software <chatmaster@c-zone.net>
Subject: Re: Perl Cookbook
Message-Id: <368969C7.25437A0B@c-zone.net>
It's a great book, in my opinion. There's no doubt it was worth more
money then I paid for it... A newbie might not be able to figure out the
few errors here and there, but it's not really a "newbie" book anyway.
So anyone reading it should see the errors and know it's not a big deal.
--
Regards,
Tim Greer - chatmaster@c-zone.net
TRG Software and The Link Worm
http://www.linkworm.com
The Chat Base
http://www.chatbase.com
-----------------------------------------------------------------------
* Creator of Paradise Chat, Chat Central & Spiral Chat
* Receiving over 250,000+ hits a day from users Worldwide!!!
* Sales of custom chat server scripts * CGI/Perl scripting
* Script trouble shooting/security * Modify & debug scripts
* Freelance Perl Scripting for any purpose or application
Copyright ) 1998 TRG Software and The Link Worm.
------------------------------
Date: 30 Dec 1998 00:33:27 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Cookbook
Message-Id: <slrn78it6n.ap0.sholden@pgrad.cs.usyd.edu.au>
On 29 Dec 1998 20:20:15 GMT, Mike Stillman <mikebvc@ripco.com> wrote:
>Tom Christiansen (tchrist@mox.perl.com) wrote:
>: In comp.lang.perl.misc, mikebvc@ripco.com (Mike Stillman) writes:
>: :Lots of errors, too. Check the O'Reilly website for a list of errata that
>: :runs 25+ pages.
>
>: Listen: this is a myth, and it deeply annoys me to hear it repeated.
>
>How is it a myth? The 25+ page list of errors exists.
Well the bit futher down answers your question.
Let me post some snippets of these errors (I hope I'm not violating any
copyrights here...) Here are the first 10 'errors'.
1) <orthography, bug>
ix Bytes to Read 254
the 254 should be ............. 254
like the rest of the ToC entries
Wow that going to kill you isn't it... they left off some dots in the table of
contents...
2) <orthography, bug>
x There is a spelling error in the 10.14 title!
It's redefining, not redifining.
A spelling error, show me book without a lot of these...
3) <orthography, update>
xxxvi.1.8 discussing how to make
^^^^^^^^^^
should read: "we discuss" instead of "discussing"
They prefer to use a different way of expressing some English, I bet that'll
cause all your perl scripts to break.
4) <wording, update>
xxxii: I knew I'd forget folks. Add "Jason Ornstein" right before
"Jason Stewart" in the second set of reviewers. Add "Eric
Watt Forste" right after "Eric Eisenhart".
They forgot to credit some people (a big error to the authors and those people
but I don't think it effects you at all).
5) <technical, bug>
3.3.1 Change
as we do with ' here
to
as we do with / here
The first real technical error that could cause you to write some perl code
incorrectly. Note however, the code isn't wrong, the description of the code
makes an error that is plainly obvious.
6) <wording, update>
3.-3.1 write to bits of the string
^^^^
should read: portions
Another simple choice of wording... I'm sure this won't worry anyone except
teh authors.
7) <technical, nit>
4.-1.6 Change
# "This wasn't wondrous"
to
# replace last 12 characters
They want to change a comment to be more informative (note the comment is
correct as it stands just not as useful).
8) <technical, update>
6.-4.2 Semi-colon missing at end of line
Missed a semi-colon, note however, that this occurs in an example snippet of
code, which contains only one statement. In perl you can leave off that
semi-colon if you want anyway...
9) <technical, update>
7.8.2 resort to the ternary ("hook")
^^^^^^^^
should read: resort to the ternary conditional ("hook-colon")
They want to change the name they gave to the ?: operator... I can't
see this ruinign anyone's day.
10) <technical, update>
7.-5.1 Using the hook operator as a condition
in a ?: statement evaluates
should read: Using @ARGV as the condition in the hook-colon operator
statement evaluates
They want to add some words to explain something more clearly. Please note that
the rest of the sentence read '@ARV in a scalar context' so it made perfect
sense the way it was (to me anyway).
So there are the first ten errors. None of them were correcting technically
incorrect code. The worst one was a missing semi-colon, let he who has never
done that cast the first stone.
>
>: If you consider that a lot of bugs in a 750 page book, then you have
>: never written one. I could produce many more `errors' than that if I
>: went over any other book with as finely-toothed a comb as I do my own.
>: It is misleading of you to make so much of this.
>
>I don't see how I made "so much of this." I did say that it is a very useful
>book. But I thought that anyone else, like me, who purchased the first
>edition would also want the list of errors, most of which are very minor
>errata. I don't think that I implied that the entire book is invalid because
>of these errors.
>
>: I happen to have listed *all* the changes I wanted to make for the
>: second printing. That includes things like the alignment of equals
>: signs in expressions.
>
>: I believe that the only thing I can do now is to remove those.
>: I am tired of this unmerited whining. And anyway, we burned up
>: the first printing in early September, so that is no longer
>: relevant anyway.
>
>The first printing is still in the stores. Why would you remove the list of
>errors from the website?
I belive he means remove the errors that are not technical bugs which would
cut the errata down to 45 (I think that's what Tom said earlier) errors.
Of course I could be wrong... but it might make another cool example to
add to a future edition.
Problem
You want to remove the non-technical errors from your books errata, because
people keep complaining of the huge number of errors, when in fact most of
the are trivial things like the alignment on equals signs in expressions.
Solution
Each error starts with <a, b> preceeded by a blank line. We can read these
in one at a time by setting $/ to the magic value, and checking for
a = technical and b = bug.
etc,etc...
>
>: Thank for nothing,
>: tom
>
>I think you're being a little oversensitive here.
You publically implied that an extremely good book that he partly authored
was full of errors, without mentioning that the _vast_ majority of those
errors were trivial details that no one other than the authors really care
about.
I think he acted with a great deal of restraint.
--
Sam
Another result of the tyranny of Pascal is that beginners don't use
function pointers.
--Rob Pike
------------------------------
Date: 29 Dec 1998 23:10:55 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: perl with sed question?
Message-Id: <914973200.395043@thrush.omix.com>
hallian@hotmail.com wrote:
: Hi everyone..,
:
: I have a simple statement:
: sed -e "1,5d" $file > /tmp/test
:
: I need to put this statement in Perl:
: system "sed -e '1,5d' $file > /tmp/test";
:
: My statement does not work!!
Did you get any stderr from sed? Are you checking the return value
of system() as `perldoc -f system' shows?
: It's does work form the prompt, but when calling within Perl with the
: system command, it does not and dump /tmp/test with file size of zero.
: Any help would be appreciated.
BTW, calling sed is not needed.
open FOO_IN, $file
or die $!;
open FOO_OUT, "/tmp/text"
or die $!;
while (<FOO_IN>) {
print FOO_OUT $_ if ($. < 5);
}
Of course, the temp file probably isn't needed either, but I don't
know your application.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Wed, 30 Dec 1998 13:46:27 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: perl with sed question?
Message-Id: <368977E3.47E6614@cardinal.co.nz>
Zenin wrote:
>
<SNIP>
> BTW, calling sed is not needed.
>
> open FOO_IN, $file
> or die $!;
> open FOO_OUT, "/tmp/text"
> or die $!;
> while (<FOO_IN>) {
> print FOO_OUT $_ if ($. < 5);
^
s/</>/
He wanted to delete the 1st 5 lines, not get them. sed -e '1,5d' means
delete lines 1 thru 5. Your perl code equates to sed -e '1,5p'
------------------------------
Date: Tue, 29 Dec 1998 15:13:23 -0800
From: "A. H. Ongun" <ahongun@ecsysinc.com>
Subject: Re: Perl--sql--win32--command???
Message-Id: <76bnka$n2o$1@news-1.news.gte.net>
Your question has more to do with databases than Perl, however here goes.
If the number field you are talking about is the sequence number that Access
assigns as key you can not change it.
If it is a column you have created the following SQL statement should work:
UPDATE tablename SET column_name = column_name +2 WHERE row_criteria
Be careful to set you row criteria exactly otherwise you'll change every row
where your WHERE portion of the statement applies.
Hope this helps,
Andy...
Damoi wrote in message <36894DC2.F01CBBE6@hotmail.com>...
>I have a base named: Data
>consist of two tables: One and Two
>Table one has three fields: Name, Number and City
>
>What would be the sql command to add a value (let's say: '2') straigth
>into the Number-field in Table One of Data??????
>
>I keep getting the error that a constant can't be changed and it drives
>me nuts by now.
>
>I am using an Access Database over NET::ODBC Perl.....
>but I am interested in the command to increase the integer value of the
>field Number only.
>
>Thanks a zil.
>
------------------------------
Date: 29 Dec 1998 18:24:20 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Protecting my script from form data
Message-Id: <76b6ok$q2$1@gellyfish.btinternet.com>
On 29 Dec 1998 07:29:49 -0800 Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "Jonathan" == Jonathan Stowe <gellyfish@btinternet.com> writes:
>
> Jonathan> Check that external commands are only getting the type of
> Jonathan> input that is required i.e. you might consider that an
> Jonathan> E-Mail address might match :
>
> Jonathan> /[-\w@.]+/ # That might not be exhaustive
>
> It's clearly not. <fred&barney@stonehenge.com> is a legal email
> address, and you've just ruled it out.
Except of course:
gellyfish@gellyfish:/home/gellyfish > mail <fred&barney@stonehenge.com>
bash: syntax error near unexpected token `&barney@stonehenge.com>'
Now I know and you know that doesnt preclude its being a valid email address
but will cause a problem for the shell.
I think that what I was trying to get across was that it was better to
set an inclusive set of characters rather than an exclusive one for data
cleansing purposes - the original posters regex would have thrown out as
many if not more legal addresses (Of course I have no evidence that this
was the purpose of the exclusion).
It might be borne in mind that I said:
i.e. you might consider that an E-Mail address might match :
There are words in there such as 'you','might','consider' that would
indicate that *I* was not making this a dictum of any sort. However I
would accept that using email addresses as an example in this case is
probably a mistake in retrospect.
> Don't do that. Don't ignore
> the FAQ on this point. Stop passing around BAD INFORMATION. <sigh>
>
*I didnt ignore* the FAQ however I was a little cavalier in using an email
example in this case. In order that anyone unfamiliar with the debate is
reading I quote perlfaq9:
How do I check a valid mail address?
You can't, at least, not in real time. Bummer, eh?
> Jonathan> You cant do any harm simply manipulating data.
>
> Yes, you can. You just did.
>
Actually I dont think that I done gone no manipulating in that example some
ideas perhaps but no actual data :-)
> print "Just another Perl hacker,"
>
print "Just another Perl FAQ f***er";
:-}
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 29 Dec 1998 23:53:28 GMT
From: Justin <jjpark@home.com>
Subject: random number problem
Message-Id: <36896BD4.2DAE9A0@home.com>
i'm trying to get 10 random numbers between 0-50
and i want all 10 random numbers to be different numbers
so how do i make sure they are not same?
------------------------------
Date: 29 Dec 1998 16:05:27 -0800
From: Ben Gertzfield <che@debian.org>
Subject: Re: random number problem
Message-Id: <yttr9tiqyt4.fsf@gilgamesh.cse.ucsc.edu>
>>>>> "Justin" == Justin <jjpark@home.com> writes:
Justin> i'm trying to get 10 random numbers between 0-50 and i
Justin> want all 10 random numbers to be different numbers so how
Justin> do i make sure they are not same?
Here's one way to do it, taken from man perlfaq4, "How do I shuffle an
array randomly?"
srand; # unnecessary in Perl >= 5.004
my @new;
my @old = (0..50);
for (1..10) {
push (@new, splice (@old, rand @old, 1));
}
Ben
--
Brought to you by the letters F and X and the number 18.
"Mmm.. incapacitating.." -- Homer Simpson
Debian GNU/Linux -- where do you want to go tomorrow? http://www.debian.org/
I'm on FurryMUCK as Che, and EFNet and YiffNet IRC as Che_Fox.
------------------------------
Date: 29 Dec 1998 17:13:20 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: When hashing won't work...
Message-Id: <76b2jg$oo$1@gellyfish.btinternet.com>
On 29 Dec 1998 09:10:38 -0500 Uri Guttman <uri@home.sysarch.com> wrote:
>>>>>> "dhoward johnson's " == dave <dave@mag-sol.com> writes:
You just misnamed 'Dave Cross' as someone we dont understand :-}
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
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 4515
**************************************