[17156] in Perl-Users-Digest
Perl-Users Digest, Issue: 4568 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 10 03:05:33 2000
Date: Tue, 10 Oct 2000 00:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971161512-v9-i4568@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 10 Oct 2000 Volume: 9 Number: 4568
Today's topics:
Re: $$Perl Programmer wanted for internet based company (Eric Bohlman)
Re: Backspace doesn't work? (Rafael Garcia-Suarez)
CGI::Push <troyr@vicnet.net.au>
Re: chown (Rafael Garcia-Suarez)
Re: comparing arrays <philipg@atl.mediaone.net>
Re: comparing arrays <stephenk@cc.gatech.edu>
Re: Critique/Comments: daemon() <uri@sysarch.com>
Re: Defining Headers for Module Mail::Mailer <dhighley@mail.highley-recommended.com>
Re: emacs written in perl? (Rafael Garcia-Suarez)
Re: extract a segment of strings in a text (Eric Bohlman)
Re: generating random number w/ specified bit size (Mark-Jason Dominus)
imagename.x and imagename.y confusion <jtulabing@onebox.com>
Re: List as keys for hash <ipetts@ozemail.com.au>
Re: List as keys for hash <ipetts@ozemail.com.au>
Re: List as keys for hash (Martien Verbruggen)
Re: reading into vars cputek1@my-deja.com
Re: reading into vars <wyzelli@yahoo.com>
regex matching troubles <jdb@wcoil.com>
Re: regex matching troubles (Sam Holden)
send email through perl?? <one@two.com>
Re: send email through perl?? <troyr@vicnet.net.au>
Re: send email through perl?? (Martien Verbruggen)
Re: silly UNIX question <anmcguire@ce.mediaone.net>
some1 help me with basic perl???? <jason@qcomtech.com.au>
Re: some1 help me with basic perl???? <wyzelli@yahoo.com>
Re: some1 help me with basic perl???? (Jon Bell)
substring search jack_1236@hotmail.com
Re: symlink utime and chown (Alan Barclay)
Re: system command (Rafael Garcia-Suarez)
Re: Where can I find more information of perldoc HTML:: (Eric Bohlman)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Oct 2000 05:34:29 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: $$Perl Programmer wanted for internet based company$$
Message-Id: <8ru9p5$3l6$3@news.enteract.com>
M.E. <me@menet.com> wrote:
> I am looking for someone who lives in Long Island, New York who has
> knowledge of Perl and MYsql DB for internet based company. Knowledge of
> html, java not required but a definite Plus!
I would suggest that a programmer who routinely uses $Perl as the name of
a variable holding a reference to a scalar would *not* be an asset for an
"internet based company." I'll bet he even uses it as a symbolic
reference.
------------------------------
Date: Tue, 10 Oct 2000 06:57:29 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Backspace doesn't work?
Message-Id: <slrn8u5frp.fbo.rgarciasuarez@rafael.kazibao.net>
NEWIMAGE wrote in comp.lang.perl.misc:
> I am a rookie at both Perl and Unix as I am sure my question will
>reflect. I am writing a perl script that will prompt the user for
>input. The development of the script is going ok with one exception.
>When I execute the script the STDIN input prompt does not allow for a
>"destructive" backspace. So, for example if they type in the full path
>of a file as STDIN and they made some typo's and backspaced to fix their
>mistake we have a problem. I do checks to make sure it is a valid path
>and file before allowing them out of the input loop. Basically it will
>take there input so long as they do not make a mistake other wise they
>got to keep typing it over until they make no mistakes.
> When I am at the Unix prompt the destructive backspace works fine. I
>don't know if this is by default or through modifications of my
>.profile. Regardless how can I make a destructive backspace work in my
>perl program.
You may want to use the Term::ReadLine package.
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Tue, 10 Oct 2000 15:30:57 +1100
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: CGI::Push
Message-Id: <uYwE5.24346$O7.374503@ozemail.com.au>
This example is from the man page. Works fine with Netscape but doesn't work
with Ie..in that the same data repeats itself. Does anyone know a work
around for this
Does this work on Internet Explorer?
use CGI::Push qw(:standard);
do_push(-next_page=>\&next_page,
-last_page=>\&last_page,
-delay=>0.5);
sub next_page {
my($q,$counter) = @_;
return undef if $counter >= 10;
return start_html('Test'),
h1('Visible'),"\n",
"This page has been called ", strong($counter)," times",
end_html();
}
sub last_page {
my($q,$counter) = @_;
return start_html('Done'),
h1('Finished'),
strong($counter),' iterations.',
end_html;
}
------------------------------
Date: Tue, 10 Oct 2000 07:03:28 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: chown
Message-Id: <slrn8u5g71.fbo.rgarciasuarez@rafael.kazibao.net>
Maggert wrote in comp.lang.perl.misc:
>On 09 Oct 2000 21:09:43 -0500, Tony Curtis <tony_curtis32@yahoo.com>
>wrote:
>
>
>>Read your article carefully. Can you see any perl
>>relevance? 'Cause I can't.
>>
> Yes of course there is relevance! chown is a perl function. I
>just want to know if this function can be used so I can create a
>directory.
> I've already assumed not and am looking at using Net::FTP to
>create the directory instead. I don't own the server and don't put too
>much hope in the admin changing server configuration!!
Strange ways to create directories. I usually use mkdir.
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Tue, 10 Oct 2000 04:09:04 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: comparing arrays
Message-Id: <ADwE5.19779$oA2.2753781@typhoon.southeast.rr.com>
dionysus <dionysus39@hotmail.com> wrote in message
news:39e29e1d.68976846@nntp.unsw.edu.au...
> I have two arrays, and wish to get a list of all strings in the second
> array that are not also in the first array. I understand that I could
> write everything out in (very)longhand, but there surely should be
> some simple perl set operations like this, shouldn't there? Any and
> all advice much appreciated.
Try Set::Scalar. Look for it on CPAN.
or alternatively,
my (%seen,@list1,@list2);
@list1 = qw(hello world);
@list2 = qw(hello there);
$seen{$_}++ for @list1;
my @results = grep { !$seen{$_} } @list2;
print join(",", @results), "\n";
hth,
p
------------------------------
Date: Tue, 10 Oct 2000 00:08:42 -0400
From: Stephen Kloder <stephenk@cc.gatech.edu>
Subject: Re: comparing arrays
Message-Id: <39E29649.3436F4F1@cc.gatech.edu>
dionysus wrote:
> I have two arrays, and wish to get a list of all strings in the second
> array that are not also in the first array. I understand that I could
> write everything out in (very)longhand, but there surely should be
> some simple perl set operations like this, shouldn't there? Any and
> all advice much appreciated.
>
The answer you seek is in perlfaq4. "How do I compute the difference of
two arrays?" is the closest to what you're looking for, but the
surrounding questions are also useful. The underlying principle is "use a
hash if you need to know X".
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: Tue, 10 Oct 2000 05:31:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Critique/Comments: daemon()
Message-Id: <x7aecd2rfr.fsf@home.sysarch.com>
did you get my critique? i can't seem to find it on my newserver so i am
posting it again.
uri
>>>>> "J" == Josiah <jdb@wcoil.com> writes:
J> sub daemon {
J> my $port = shift || 7778;
J> my $file = shift || 'words.xml';
J> my $inad = shift || INADDR_ANY;
J> my $dict = Lingua::EN::Dict->new(file=>$file,warn=>1);
J> socket(SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp')) || die
J> "socket: $!";
J> setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) || die
J> "setsockopt: $!";
J> bind(SERVER, sockaddr_in($port, $inad)) || die "bind: $!";
J> listen(SERVER,SOMAXCONN) || die "listen:
J> $!";
use IO::Socket::INET. you are doing too much work yourself there.
J> for (; $paddr = accept(CLIENT,SERVER); close Client) {
it might help to have the case of client match there. and that is an odd
use of a c style for loop. again, using IO::Socket will make this
cleaner as you can use handle objects. using fixed name handles is not
good if you ever want to accept multiple simultaneous connections.
J> RXLOOP:
why not put this code in a block and use next or redo. goto's are so ugly.
J> $_=<CLIENT>; chomp; chomp;
why the double chomp? and regarding the block i mentioned above, you
could just make a while loop like:
while( <CLIENT> ) {
and convert all your goto's to nexts. much nicer.
J> logmsg "received command $_
J> at port $port";
J> /^DICT-PING/ && do
yech. just use if statements. you seem to be choosing ugly idioms all
over the place. do blocks are best used when you need a return value
from the block or a few other places. just say:
if ( /^DICT-PING/ ) {
J> print CLIENT "DICT-PING: Ping? Pong! : You are: $name
J> [",inet_ntoa($iaddr),"] at port $port", EOL;
J> flush *CLIENT;
no need for flush if you set $| on the handle. you can call the
autoflush method if they are handle objects.
J> /^DICT-KEYS/ && do
J> my @keys = keys %{$dict};
J> print CLIENT '[\''.join('\',\'',@keys).'\']', EOL;
what is this EOL? and that string you have there is impossible to
parse. use q{} instead of escaping ' in a single quote string. how about
this:
print '[', join( ',', map( "'$_'", @keys ) ), ']', EOL ;
isn't that clearer?
J> flush *CLIENT;
J> goto RXLOOP;
J> };
J> /^DICT-TENSE/ && do {
J> /^(DICT-TENSE:)([\w]+)/;
why grab the first part when you don't use it? also why match twice? and
if you have only a single char in a class, you don't need the []
if ( /^DICT-TENSE:(\w+)/ ) {
print CLIENT $dict->tense($1), EOL;
J> /^DICT-TYPES/ && do {
J> /^(DICT-TYPES:)([\w]+)/;
same as above
J> my $type = $2;$type =~ s/\r//g;$type =~ s/\n//g;
use tr/\n\r//d ; it is faster and simpler
J> print CLIENT '[\''.join('\',\'',@{$dict->types($type)}).'\']',EOL;
use the same code as i show above.
J> /^DICT-SET/ && do {
J> /^(DICT-SET:)([\w]+)/;
J> my $word = $2;$word =~ s/\r//g;$word =~ s/\n//g;
$word can't have \r\n since it only matches \w chars. stop blindly
cutting and pasting your own code.
J> s/^(DICT-SET:$word)//g;
/g makes no sense if the regex is anchored. (unless you set /m and allow
internal anchors).
also why not do all that in one line:
if ( s/^DICT-SET:(\w+)// ) {
$word = $1 ;
J> $dict->{$word} = eval;
SECURITY ALERT!!
you are evaling what is left in $_ which is sent by the client. they can
send anything and you would just execute it. this is just as bad as
having an open account they could login to.
J> /^DICT-CLOSE/ && do
J> next
here you could do a last which would break out of the while( <CLIENT> )
loop.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 09 Oct 2000 22:34:01 -0700
From: David Highley <dhighley@mail.highley-recommended.com>
Subject: Re: Defining Headers for Module Mail::Mailer
Message-Id: <39E2AA49.A2B31A3D@mail.highley-recommended.com>
David Highley wrote:
> Tony Curtis wrote:
>
> > >> On Sun, 08 Oct 2000 11:41:48 -0700,
> > >> David Highley <dhighley@mail.highley-recommended.com> said:
> >
> > > Can someone give me an example of how to define the
> > > headers when using the module Mail::Mailer created bye
> > > Tim Bunce. I have looked at the interface and also
> > > compared what I have done with other mailing modules,
> > > but sendmail keeps telling me I need to define the
> > > Recipient.
> >
> > What have you tried so far? It's rather difficult to say
> > what's wrong if you don't show code.
>
> %headers= (
> to => 'dhighley',
> subject => 'Checkin Report',
> );
> $mailer->open(\%headers);
>
> or
>
> %headers{to} = 'dhighley';
> %headers{subject} = 'Checkin Report';
> $mailer->open(\%headers);
After doing more looking at the two modules Mail::Mailer and Mail::Send
I came to the
conclusion I should be using Mail::Send instead of Mail::Mailer. Now it
works for a real
system, Solaris, but when I try it on a Windows goober I get the
following error:
No mailer program specified (and no default available).
Pretty pathetic computers(PC) or is it pheeble computers.
local($Msg, $Fh);
$Msg = new Mail::Send;
$Msg->to('dhighley');
$Msg->subject('Checkin Report');
local($Fh) = $Msg->open;
print $Fh "\n Daily Checkin Report\n\n";
print $Fh "\n\n Files Checked In For $Date Are:";
$Fh->close;
>
> >
> >
> > hth
> > t
>
> --
>
> Regards,
>
> David Highley
> Highley Recommended, Inc.
> 2927 SW 339th Street
> Federal Way, WA 98023-7732
>
> Phone: (206) 669-0081
> FAX: (253) 838-8509
> Email: dhighley@highley-recommended.com
> WEB: http://www.highley-recommended.com
--
Regards,
David Highley
Highley Recommended, Inc.
2927 SW 339th Street
Federal Way, WA 98023-7732
Phone: (206) 669-0081
FAX: (253) 838-8509
Email: dhighley@highley-recommended.com
WEB: http://www.highley-recommended.com
------------------------------
Date: Tue, 10 Oct 2000 06:44:27 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: emacs written in perl?
Message-Id: <slrn8u5f3c.fbo.rgarciasuarez@rafael.kazibao.net>
Chris Fedde wrote in comp.lang.perl.misc:
>Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
>>
>>What about a vi with embedded Perl? http://www.vim.org/
>>
>>I believe there are other vi clones out there that have Perl embedded
>>(nvi?), but I don't have experience with any of those.
>>
>
>I've not seen any real additional utility provided by having an
>embedded interpreter in the VI (nvi) editor. Usually I can get what I
>want by doing bang(!) commands to little text processors written
>in Perl or through at(@) commands. Do you have any examples of
>functionality that has been added to VI through an embedded perl?
>Maybe it is time for me to start using vim.
It's a toy! Perl-embedded vi : a toy. Besides this, I've heard of an
edit-through-ftp function for vim + perl.
Another use for a Perl-embedded editor would be correct syntax
highlighting, even for the most obfuscated perl constructs (and for POD
comments). I don't think that vim + perl can be used for this.
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 10 Oct 2000 05:56:12 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: extract a segment of strings in a text
Message-Id: <8rub1s$3l6$4@news.enteract.com>
Ren Maddox <ren.maddox@tivoli.com> wrote:
> Be forewarned: this can get very complicated if tags can be nested, or
> if the tag characters can appear inside quotes or [lots of other
> things]. Depending on the particular data format, there are better
> ways to handle this sort of thing. For example, if the data is HTML,
> then the HTML::Parser module is the correct tool.
> That being said, this might be what you want:
> @tags = /<tag>(.*?)<tag>/sg;
I'd suggest looking at Damian's Text::Balanced module, which has methods
for dealing with fairly general tagged text.
------------------------------
Date: Tue, 10 Oct 2000 02:02:00 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: generating random number w/ specified bit size
Message-Id: <39e29de8.5d12$373@news.op.net>
Keywords: deus, equitable, fearsome, pirogue
In article <8rrm1d$djj$1@news-int.gatech.edu>,
Jorg Ziefle <gt4556a@prism.gatech.edu> wrote:
>For a crypto algorithm implementation, I need to generate a "true"
> random number with a pre-specified bit size.
You should have a look at 'yarrow', which is a cryptographically
strong random number generation system. Documentation and source code
is available from www.counterpane.com.
------------------------------
Date: Mon, 09 Oct 2000 22:57:01 -0700
From: John Tulabing <jtulabing@onebox.com>
Subject: imagename.x and imagename.y confusion
Message-Id: <39E2AFAD.AAD2343D@onebox.com>
I have a script that is executed when user clicks on one of my images.
On the top of this page, I have a form. So what I'm basically trying to
do is connect the user's information with image that was clicked.
After I parse the form, I notice that there is an ImageName.x and
ImageName.y. Can I do anything with these variables? All I'm trying to
do is add the ImageName info to the form.
$dummy = $FORM{ImageName.x};
If ($dummy != 0) {
$info = "shoes";
}
Thanks.
John
------------------------------
Date: Tue, 10 Oct 2000 04:34:16 GMT
From: Ian Petts <ipetts@ozemail.com.au>
Subject: Re: List as keys for hash
Message-Id: <8ru688$9q8$1@nnrp1.deja.com>
> Ugh! Why not
>
> 1;2;5;4;3
Ah, sorry, I hadn't explained it well. The field names in the real file
are not numeric, I just used one, two three... as an example. They're
actually more like 'num', 'date', 'time' etc.
> You are using strict, but you might as well not. You are lexically
> scoping almost all your variables to the whole file. You should scope
> them to the smallest enclosing block that uses them.
Now that's a great idea. I recall reading about now you mention it.
> undef($entry{$goodnames[$i]})) undefined that variable. You probably
> wanted 'if defined $var'.
Yes! Thank you very much! It now works as expected.
Thanks for all the other hints too. Looks like I've got quite a bit
more reading to do.
Regards,
Ian Petts.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 10 Oct 2000 04:38:59 GMT
From: Ian Petts <ipetts@ozemail.com.au>
Subject: Re: List as keys for hash
Message-Id: <8ru6h3$9tm$1@nnrp1.deja.com>
> Well, you've got some plenty hacked-up stuff in there.
:-) I never was much of a programmer. I only ever need to throw a
couple of scripts together a year...
> The main problem in line 33 is that you are using the undef function
> where you should
> probably be using the defined function. The undef function
*undefines*
> the hash entry you apparently think you are testing.
You are indeed correct. I had assumed the undef() function told me if a
variable was undefined. Unfortunately I did that line from 'memory'
instead of 'man page'.
Thank you, the script is now working.
Regards,
Ian Petts.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 10 Oct 2000 05:05:15 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: List as keys for hash
Message-Id: <slrn8u58ru.2ce.mgjv@verbruggen.comdyn.com.au>
On Tue, 10 Oct 2000 04:34:16 GMT,
Ian Petts <ipetts@ozemail.com.au> wrote:
>
> > Ugh! Why not
> >
> > 1;2;5;4;3
>
> Ah, sorry, I hadn't explained it well. The field names in the real file
> are not numeric, I just used one, two three... as an example. They're
> actually more like 'num', 'date', 'time' etc.
Ah. That changes a few things. Your post read as if the order of the
fields was defined in the file, but it's not. The order is defined in
the code. It's just that the names of the fields were a bit misleading
:)
In that case, I'd still go with the code I suggested. I'll repeat it
here, modified slightly, and only in the more compressed form:
#!/usr/local/bin/perl -w
use strict;
my %names;
@names{qw{name1 name2 name5 name4 name3}} = 0..4;
chomp(my $order = <DATA>);
my @order = map { $names{$_} } split /;/, $order;
while (my $line = <DATA>)
{
chomp $line;
print join(';', (split /;/, $line)[@order]), "\n";
}
__DATA__
name1;name2;name3;name4;name5
1;10Oct2000;bbbbb;aaaaa;12:00:00
2;10Oct2000;sxsxd;cassc;12:01:00
3;10Oct2000;sfgsf;aaeee;12:02:30
To shorten it, you could write this code without the names, and just
specify the @order array directly, as
my @order = (0, 1, 4, 3, 2);
And just document what that means.
> > undef($entry{$goodnames[$i]})) undefined that variable. You probably
> > wanted 'if defined $var'.
>
> Yes! Thank you very much! It now works as expected.
Glad to have been of help.
Maybe some golf.....
Your program could reduce to something like:
#!/usr/local/bin/perl -wp
BEGIN
{
local (*ARGVOUT);
@order = (0, 1, 4, 3, 2);
<>;
}
chomp;
$_ = join(';', (split /;/)[@order]) . "\n";
if you didn't need to do the name mapping. (the local line is there to
shut up -w.
If you also allow the first line to be part of the output file again,
it can become
#!/usr/local/bin/perl -wpl
BEGIN
{
@order = (0, 1, 4, 3, 2)
}
chomp;
$_ = join(';', (split /;/)[@order])
Or, as a one-liner:
perl -wpl -e 'BEGIN{@a=(0,1,4,3,2)}chomp,$_=join(";",(split/;/)[@a])'
Or, if you must skip that first line:
perl -wnl -e'BEGIN{@a=(0,4,3,2,1)}$.!=1and chomp,print \
join(";",(split/;/)[@a])'
Martien
--
Martien Verbruggen |
Interactive Media Division | +++ Out of Cheese Error +++ Reinstall
Commercial Dynamics Pty. Ltd. | Universe and Reboot +++
NSW, Australia |
------------------------------
Date: Tue, 10 Oct 2000 05:13:59 GMT
From: cputek1@my-deja.com
Subject: Re: reading into vars
Message-Id: <8ru8ik$bef$1@nnrp1.deja.com>
Thanks for the help.. this is basically what I had to do...
open (test, "<testfile");
$bar = "1";
while ( $foo =<test>)
{
chomp ($foo);
if ($bar == "1")
{
$foo1 = $foo;
}
if ($bar == "2")
{
$foo2 = $foo;
}
if ($bar == "3")
{
$foo3 = $foo;
}
$bar++
}
print "line one $foo1, Line two $foo2, line three $foo3\n";
close (test);
this will allow me to process the three separate VARs and be able to
use them in one command line when I update the file that needs to be
modified.
thanks for the help
cmf
In article <slrn8u4q7o.auv.clay@panix3.panix.com>,
clay@panix.com (Clay Irving) wrote:
> On Tue, 10 Oct 2000 00:25:31 GMT, cputek1@my-deja.com
> <cputek1@my-deja.com> wrote:
>
> >I have a temp file that I am using to store some data.
> >I need to be able to read that data and place it into multiple vars
for
> >use in a different perl script. the temp file will only have three
> >lines. I need to store each line into a separate var.
> >I tried the read command but it grabs all the lines...(don't think
I'm
> >doing it right)
> >
> >The problem is that the data is not a fixed length. each line of
data
> >can be as long as the user wants.
>
> Open your temp file:
>
> open TMP, "temp_file" or die "Can't open temp_file: $!\n";
>
> Process each record (by default the records will be separated by
newlines):
>
> while ($record = <TMP>) {
>
> Process the line (I assume fields in the records are delimited by
something?):
>
> print "I'm doing my stuff to $record...\n";
>
> You're finished.
>
> }
>
> Be nice. Close your filehandle:
>
> close TMP;
>
> --
> Clay Irving <clay@panix.com>
> Worlds may freeze and suns may perish, but there stirs something
within us
> now that can never die again.
> - H. G. Wells
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 10 Oct 2000 15:10:21 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: reading into vars
Message-Id: <iWxE5.10$7l4.3600@vic.nntp.telstra.net>
<cputek1@my-deja.com> wrote in message
news:8ru8ik$bef$1@nnrp1.deja.com...
> Thanks for the help.. this is basically what I had to do...
> open (test, "<testfile");
> $bar = "1";
> while ( $foo =<test>)
> {
> chomp ($foo);
> if ($bar == "1")
> {
> $foo1 = $foo;
> }
> if ($bar == "2")
> {
> $foo2 = $foo;
> }
> if ($bar == "3")
> {
> $foo3 = $foo;
> }
> $bar++
> }
> print "line one $foo1, Line two $foo2, line three $foo3\n";
> close (test);
Slightly simpler way to assign the first three lines to three variables:
#!/usr/bin/perl -w
use strict;
open (IN, 'd:/perl/scripts/test/vars.txt') or die "Cant $!";
my ($one, $two, $three) = <IN>;
print "$one$two$three";
Wyzelli
--
@x='07411711511603209711011111610410111403208010111410803210409709910710
1114'=~/(...)/g;
print chr for @x;
------------------------------
Date: 10 Oct 2000 04:57:11 GMT
From: "Josiah" <jdb@wcoil.com>
Subject: regex matching troubles
Message-Id: <8ru7j7$7hv$0@206.230.71.41>
greets perlfolk,
please consider the following:
$_ = 'str josiah';
if(/str[(\s\$)(\s\()(\$)]/) {
print 'matched';
} else {
print 'no match';
}
__END__
now, in my thinking it should print "no match" because "str" is NOT followed
by "\s\(" or "\s\(" or "\$".
but when i run it on my system, it prints "match";
I am trying to correctly print "match" for these cases:
str $josiah;
str ($josiah);
str$josiah;
Additionally, but im not sure if its possible with one regex, is to NOT
print "match" for these:
$str$josiah
$str ($josiah);
$str($josiah);
that is, if str is preceded by a $, then do NOT match. but the problem i see
is that i dont know if 'str' is anchored at '^' (start of line) or if it has
whitespace before it '\s'.
If anyone has any ideas as to how i might craft a regex to do such a chore,
i would be most grateful for the help.
basically, i am trying to figure out wether the op in question is actually a
sub call, i.e. looks like a sub call, or is just a word in text, according
to perl.
for example,
"i like the str function".
should not match, because it is not followed by whitespace then a $ or a (,
hence it doesnt look like a function.
Also,
"what is the value of the $str() function"
should not match, because it is preceded by $, even tho it looks like a
function with (.
similarly,
my $str = str $josiah, 1;
should match the 'str $josiah' but not the '$str = '.
and,
'substr $var, 1;
should not match, because 'str' is preceded by 'sub' with no whitespace.
if I need to define the problem more clearly, please tell me, and i will do
my best.
thankyou again for any help!
btw, if you can, could you please CC a copy of a reply to me at
jdb@wcoil.com?
thankyou!
regards,
josiah
------------------------------
Date: 10 Oct 2000 05:00:25 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: regex matching troubles
Message-Id: <slrn8u58km.mi5.sholden@pgrad.cs.usyd.edu.au>
On 10 Oct 2000 04:57:11 GMT, Josiah <jdb@wcoil.com> wrote:
>greets perlfolk,
>
>please consider the following:
>
>$_ = 'str josiah';
>
> if(/str[(\s\$)(\s\()(\$)]/) {
> print 'matched';
> } else {
> print 'no match';
> }
>
>__END__
>
>now, in my thinking it should print "no match" because "str" is NOT followed
>by "\s\(" or "\s\(" or "\$".
>but when i run it on my system, it prints "match";
[] doesn't do what you think it does.
Read the perlre documentation (with perldoc perlre).
[] matches any one of the characters inside (hence the name 'Character class'),
not any one of the regular expressions inside.
You can use (regex1|regex2|regex3) - of course you may have to bracket the
regexes and (?:) might be more efficient...
------------------------------
Date: Mon, 9 Oct 2000 23:19:11 -0500
From: "Easy Wind" <one@two.com>
Subject: send email through perl??
Message-Id: <8ru5fm$a3g$1@flotsam.uits.indiana.edu>
Is there any way to send an email message to an address through a perl
script?
------------------------------
Date: Tue, 10 Oct 2000 15:51:24 +1100
From: "Troy Rasiah" <troyr@vicnet.net.au>
Subject: Re: send email through perl??
Message-Id: <EfxE5.24358$O7.374795@ozemail.com.au>
# SENDING EMAIL
## or where ever it resides
my $mail_prog = '/usr/sbin/sendmail';
open (MAIL, "|$mail_prog -t");
print MAIL "To: someone\n";
print MAIL "From: someone\@somewhere\n";
print MAIL "Subject: Details\n";
print MAIL "\n\nYour Message\n\n";
close (MAIL);
----------------------------------------------------------------------------
----------------
"Easy Wind" <one@two.com> wrote in message
news:8ru5fm$a3g$1@flotsam.uits.indiana.edu...
> Is there any way to send an email message to an address through a perl
> script?
>
>
------------------------------
Date: Tue, 10 Oct 2000 05:15:00 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: send email through perl??
Message-Id: <slrn8u59ea.2ce.mgjv@verbruggen.comdyn.com.au>
[Please, in the future, put your reply AFTER the text you reply to.
It's easier to follow posts that way, and it conforms to the generally
accepted quoting style around here.
On Tue, 10 Oct 2000 15:51:24 +1100,
Troy Rasiah <troyr@vicnet.net.au> wrote:
[post reordered]
> "Easy Wind" <one@two.com> wrote in message
> news:8ru5fm$a3g$1@flotsam.uits.indiana.edu...
> > Is there any way to send an email message to an address through a perl
> > script?
>
> # SENDING EMAIL
> ## or where ever it resides
> my $mail_prog = '/usr/sbin/sendmail';
> open (MAIL, "|$mail_prog -t");
> print MAIL "To: someone\n";
> print MAIL "From: someone\@somewhere\n";
> print MAIL "Subject: Details\n";
> print MAIL "\n\nYour Message\n\n";
> close (MAIL);
Close, but not entirely there yet. You don't check the result of the
open, and you don't check the result of the close. Both should be
checked when doing piped opens. You use too many print statements,
where one would have sufficed.
\begin{offtopic}
You have too many newlines in that message as well. You only need two
between headers and body, and the ones at the end are just unnecessary
bytes.
You would also be wise to include -oi as options to sendmail.
Otherwise, a line with just a . on it might give you some surprising
results.
\end{offtopic}
For a better example of how to do this, see the perl FAQ
# perldoc -q 'send mail'
Found in /opt/perl/lib/5.6.0/pod/perlfaq9.pod
How do I send mail?
That entry also includes other suggestions, for when you don't have
sendmail.
The FAQ suggests using mail or mailx, but forgets to stress that that
should only ever be done if you have no other options. It's generally
not a safe idea to use those directly. They're too prone to bugs and
other problems.
Martien
--
Martien Verbruggen |
Interactive Media Division | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd. | reflects this.
NSW, Australia |
------------------------------
Date: Mon, 9 Oct 2000 23:47:22 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: silly UNIX question
Message-Id: <Pine.LNX.4.21.0010092345260.17901-100000@hawk.ce.mediaone.net>
On Tue, 10 Oct 2000, Elaine Ashton quoth:
EA> in article su4lufmqdnmkb8@corp.supernews.com, Randy Harris at
EA> harrisr@bignet.net quoth:
EA> > <cchristophe@my-deja.com> wrote in message
EA> > news:8rtg09$o78$1@nnrp1.deja.com...
EA> >> when I make a little script executable and run it, it does not work.
EA> >> I have to type;
EA> >> perl 'script name'
EA> >
EA> > Make the first line of your script:
EA> > #!/usr/bin/perl -w
EA>
EA> or, if that isn't the issue, try:
EA>
EA> chmod +x <script name>
Or if that does not work, put the script in your path or invoke it
as ./script.
anm
--
# Andrew N. McGuire - Just another Perl Hacker
package News::NNTPClient;use subs q;warn;;sub warn{0}package main;use
News::NNTPClient;$;=News::NNTPClient->new();($==>$$)=($;->group(($|||
((<comp.lang.perl.misc>)))));for$)(<$=>..<$$>){map{$\=v12;die 1?qq{$1
}:q--while s<^.+(j..T .{6}(r) p.R. .{5}\2).+>[$1]mig}$;->article($))}
------------------------------
Date: Tue, 10 Oct 2000 13:00:43 +0800
From: "Jason Lee" <jason@qcomtech.com.au>
Subject: some1 help me with basic perl????
Message-Id: <BlxE5.54$On.565@wa.nnrp.telstra.net>
im meant to be making an assignment for uni....
i need to have some sort of knowledge of perl scripting with cgi or
something....
and i dont know how perl has anything to do with search engines....which is
what i have to do for the assignment
i have good skills in html if that would help...
some1 please send me anything or reply with any information with perl
thanks all
:)
------------------------------
Date: Tue, 10 Oct 2000 14:38:00 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: some1 help me with basic perl????
Message-Id: <XrxE5.9$7l4.3569@vic.nntp.telstra.net>
"Jason Lee" <jason@qcomtech.com.au> wrote in message
news:BlxE5.54$On.565@wa.nnrp.telstra.net...
> im meant to be making an assignment for uni....
> i need to have some sort of knowledge of perl scripting with cgi or
> something....
> and i dont know how perl has anything to do with search
engines....which is
> what i have to do for the assignment
>
> i have good skills in html if that would help...
> some1 please send me anything or reply with any information with perl
>
> thanks all
> :)
www.perl.com
www.activestate.com
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Tue, 10 Oct 2000 06:18:03 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: some1 help me with basic perl????
Message-Id: <G27Au3.Gx7@presby.edu>
In article <BlxE5.54$On.565@wa.nnrp.telstra.net>,
Jason Lee <jason@qcomtech.com.au> wrote:
>and i dont know how perl has anything to do with search engines....which is
>what i have to do for the assignment
Perl is a general-purpose programming language that, like any other
general-purpose programming language, can be used to write search engines.
How you interface your search engine (regardless of what language it's
written in) with a Web page (which I assume is what you want to do) is
specified by the CGI protocol, for which there is a separate newsgroup,
comp.infosystems.www.authoring.cgi.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
[ Questions about newsgroups? Visit http://www.geocities.com/nnqweb/ ]
[ or ask in news:news.newusers.questions ]
------------------------------
Date: Tue, 10 Oct 2000 05:04:21 GMT
From: jack_1236@hotmail.com
Subject: substring search
Message-Id: <8ru80i$b1p$1@nnrp1.deja.com>
Hi,
I am new to Perl and have an urgent need to find number of occurrences
of a given expression like "Runner is done" in a text file *.txt) using
Perl. how is it done in perl?.
jack
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 10 Oct 2000 04:12:02 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: symlink utime and chown
Message-Id: <971151092.898800@elaine.furryape.com>
In article <H9kE5.1296$X76.39282@carnaval.risq.qc.ca>,
Steeve McCauley <steeve@pebbles.eps.mcgill.ca> wrote:
>How can I set atime, mtime and uid,gid for a symlink.
>chown() and utime() operate on the link target and
>not the symlink itself.
You can't, and there isn't any point in even trying to do so anyway.
symlinks aren't updated with atime when accessed. They always have
permission of 777, so anyone can follow them, and they can't be
modified except by deleting and recreating. The only reason that
they use the same inode structure as other files is because it
would be unnecessary complex to do otherwise.
------------------------------
Date: Tue, 10 Oct 2000 06:48:17 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: system command
Message-Id: <slrn8u5fah.fbo.rgarciasuarez@rafael.kazibao.net>
brian d foy wrote in comp.lang.perl.misc:
>In article <m366n1aa27.fsf@dhcp11-177.support.tivoli.com>, Ren Maddox <ren.maddox@tivoli.com> posted:
>
>
>> system("perl rss2html.pl $urlsource > myfile.html");
>
>
>don't use the single argument version of system(). use it
>in the list form:
>
> system( $coomand, $options, $arguments ).
This will not work in this case. The '>' must be interpreted by a shell.
BTW, why use system() to execute a perl script?
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: 10 Oct 2000 06:17:02 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Where can I find more information of perldoc HTML::Parser?
Message-Id: <8ruc8u$3l6$5@news.enteract.com>
Carfield Yim <carfield@programmer.net> wrote:
> Thx a lot! I solve my problem with TokeParser. But I think I still need
> to learn more about HTML::Parser, as it act very difference compare with
> most other module.
Its interface is event-driven, which is in fact something that takes a bit
of getting used to. The idea is that instead of your code being in
control and asking the parser to give it data, the parser is in control
and asks your code (via callbacks) to do stuff with the data the parser
gives it. This means that you can't use simple flow-of-control to
maintain state. It's rather similar to the way a GUI program works.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4568
**************************************