[16091] in Perl-Users-Digest
Perl-Users Digest, Issue: 3503 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 28 18:05:36 2000
Date: Wed, 28 Jun 2000 15:05:16 -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: <962229916-v9-i3503@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 28 Jun 2000 Volume: 9 Number: 3503
Today's topics:
Re: $_ (Tad McClellan)
Re: - Learn how to SPEED UP your INTERNET connection b newsposter@cthulhu.demon.nl
Book on Perl ASP <bob@inu.net>
Re: cgi/SSI question... <alexescott@my-deja.com>
Convert an ip adress to 4 strings, something wrong with (Bill Free)
Re: Convert an ip adress to 4 strings, something wrong <care227@attglobal.net>
Re: Convert an ip adress to 4 strings, something wrong <news@webneeds.com>
Re: Convert an ip adress to 4 strings, something wrong (Brandon Metcalf)
Re: dereferencing question (Tad McClellan)
Re: Does anyone have some exercises? (Peter J Scott)
Re: Embedding images into Perl script <gellyfish@gellyfish.com>
help submit buttons... <james@kcnet.com>
Re: help submit buttons... <Allan@due.net>
Re: Help: regex for changing NON-absolute urls in a htm <j.bessels@quicknet.nl>
Re: Help: regex for changing NON-absolute urls in a htm <j.bessels@quicknet.nl>
Re: Help: regex for changing NON-absolute urls in a htm <j.bessels@quicknet.nl>
Re: Help: regex for changing NON-absolute urls in a htm <j.bessels@quicknet.nl>
hopdelta program? <jfrankovNOjfSPAM@pobox.com.invalid>
Interpreting dev and rdev from stat (in perl) <jmoore@image.kodak.com>
Re: Interpreting dev and rdev from stat (in perl) (Casper H.S. Dik - Network Security Engineer)
Is this a job for Map or Grep? design@raincloud-studios.com
Re: Is this a job for Map or Grep? <abe@ztreet.demon.nl>
Need help for Perl Win32::Process fyau@my-deja.com
Need Help! tia_miller@my-deja.com
Re: Net::FTP not on CPAN <grichard@uci.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 Jun 2000 14:11:52 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: $_
Message-Id: <slrn8lkfv8.1u1.tadmc@magna.metronet.com>
On Wed, 28 Jun 2000 09:29:24 -0600, Robin Bank <rbank@csf.edu> wrote:
>What exactly does $_ signify?
It signifies the things that the docs say it signifies.
Perl's variable are documented in perlvar.pod:
perldoc perlvar
Is the explanation given there unclear or confusing?
If so, what parts?
If the documentation is broken (and it is, else you would have
understood it when you read it), help us fix it.
>What's the variable name?
$_ *is* the name.
or "dollar underscore"
or $ARG
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Jun 2000 18:41:50 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: - Learn how to SPEED UP your INTERNET connection by 70-100% for FREE!
Message-Id: <8jdgte$mcb$1@internal-news.uu.net>
Barry Grupe <bg@skypoint.com> wrote:
> <uyurpz@speedyinternet.com> wrote in message
> news:iIT55.93842$m5.59849@typhoon.kc.rr.com...
>> http://speedyinternet.cjb.net
> Just curious, does anybody track the headers for junk like this and contact
> the offender's provider?
Yes.
Try going to that url:
The web site you are trying to access either does not exist,
expired due to inactivity, or has been terminated for violating
our policies.
Erik
------------------------------
Date: Wed, 28 Jun 2000 15:11:23 -0500
From: Bob Martin <bob@inu.net>
Subject: Book on Perl ASP
Message-Id: <395A5BEB.2B06FDD@inu.net>
Can anyone recomend a book on Perl ASP?
Thanks!
Bob
------------------------------
Date: Wed, 28 Jun 2000 18:44:26 GMT
From: Alex <alexescott@my-deja.com>
Subject: Re: cgi/SSI question...
Message-Id: <8jdh25$no7$1@nnrp1.deja.com>
Hi guys:
- thank you for the help (those who could - and _did_ - I got it
working...)
- thank you for redirecting me to other groups - I will go there in the
future.
- sorry for the off-topic post - my mistake. I think you have all
probably done it at one point in time. Half the people out there who
write perl have done CGI programming before, so I thought I would find
someone who could answer my question. But no need to get stinky about
it though, guys.
-Alex
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 28 Jun 2000 18:11:10 GMT
From: bill@freeemail.org (Bill Free)
Subject: Convert an ip adress to 4 strings, something wrong with pattern?
Message-Id: <395a3edb.96310841@news.a2000.nl>
I need to convert an ip adress to 4 strings. An ip adress is separated
with a dot ( . )
I think the pattern /./ is not right and must be something else, could
you please help met out?
This is my code.
($ipa1, $ipa2, $ipa3, $ipa4) = split(/./, $ipaddr);
print $ipa1;
print $ipa2;
print $ipa3;
print $ipa4;
PS Please mail the answer to my email adress : jwi@chello.nl
thanks for your help.
------------------------------
Date: Wed, 28 Jun 2000 14:14:53 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Convert an ip adress to 4 strings, something wrong with pattern?
Message-Id: <395A409D.C49B2E22@attglobal.net>
Bill Free wrote:
>
>
($ipa1, $ipa2, $ipa3, $ipa4) = split(/\./, $ipaddr);
You didn't escape the special dot.
------------------------------
Date: Wed, 28 Jun 2000 12:15:58 -0600
From: "Dan Manion" <news@webneeds.com>
Subject: Re: Convert an ip adress to 4 strings, something wrong with pattern?
Message-Id: <b6t65.158$%O.199348@news.uswest.net>
try split(/\./, $ipaddr);
. matchings anything in a reg ex so you must escape it with a \. so you are
actually just looking for a period.
"Bill Free" <bill@freeemail.org> wrote in message
news:395a3edb.96310841@news.a2000.nl...
>
> I need to convert an ip adress to 4 strings. An ip adress is separated
> with a dot ( . )
> I think the pattern /./ is not right and must be something else, could
> you please help met out?
>
> This is my code.
>
>
> ($ipa1, $ipa2, $ipa3, $ipa4) = split(/./, $ipaddr);
>
> print $ipa1;
> print $ipa2;
> print $ipa3;
> print $ipa4;
>
>
> PS Please mail the answer to my email adress : jwi@chello.nl
> thanks for your help.
------------------------------
Date: 28 Jun 2000 18:50:09 GMT
From: bmetcalf@baynetworks.com (Brandon Metcalf)
Subject: Re: Convert an ip adress to 4 strings, something wrong with pattern?
Message-Id: <8jdhd1$550$1@bcrkh13.ca.nortel.com>
bill@freeemail.org writes:
> I need to convert an ip adress to 4 strings. An ip adress is separated
> with a dot ( . )
> I think the pattern /./ is not right and must be something else, could
> you please help met out?
>
> This is my code.
>
>
> ($ipa1, $ipa2, $ipa3, $ipa4) = split(/./, $ipaddr);
You need to escape the .
($ipa1, $ipa2, $ipa3, $ipa4) = split(/\./, $ipaddr);
Brandon
------------------------------
Date: Wed, 28 Jun 2000 14:03:22 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: dereferencing question
Message-Id: <slrn8lkffa.1u1.tadmc@magna.metronet.com>
[ Please put your comments *following* the quoted text that
you are commenting on.
Please do not quote an _entire_ article. Quote just enough
to establish the context.
Please never quote .sigs
Please visit news.announce.newusers
Thanks.
]
On Wed, 28 Jun 2000 10:48:21 -0400, Markachev, Naiden [SKY:4Y21:EXCH] <naidenm@americasm01.nt.com> wrote:
>I guess I needed to stop and think about the problem for a little bit
>longer insted of posting right away. :)
>So I did $#{$entry->{'key1'}[0]} and it works.. [somehow I was very
^^^^^^^^
Yes, but it does something *different* from what my code does.
Your code gets the last index (2 for your example).
My code gets the number of elements (3 for your example).
The "last index" and the "number of elements" is not the same thing...
>determined to do it with #.. ]
>> my $size = @{$entry->{key1}};
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 28 Jun 2000 20:36:30 GMT
From: peter@PSDT.com (Peter J Scott)
Subject: Re: Does anyone have some exercises?
Message-Id: <ilt65.12912$Zq.419888@news1.gvcl1.bc.home.com>
In article <8ib4i8$hka$1@mailnews.kub.nl>,
E.C.vEersel@KUB.NL (E.C.vEersel) writes:
>I tried to track down some exercises on the WWW, but no elaborate "exercise
>page" was to be found. Can someone help me out here? Does anyone has
>some old homework problems around in a dusty drawer? I'd like to test my
>knowledge by making some exercises that I don't define myself.
I found the exercises in "Perl: The Programmer's Companion" by Nigel
Chapman, to be excellent. YMMV.
--
Peter Scott
------------------------------
Date: 27 Jun 2000 23:02:28 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Embedding images into Perl script
Message-Id: <8jb89k$ak0$1@orpheus.gellyfish.com>
On Tue, 27 Jun 2000 15:59:02 +0400 Vladimir Rybintsev wrote:
> I find some Perl script, which generates HTML page with some
> images.
> Something like:
> $fG=<<'fC';
> M1TE&.#=A$@`/`+,``/_2+N.[*<>D)*J,'XYU&G)>%55&$#DO"QT8!@```/__
> M_____________________R'Y!`$```D`+``````2``\```1F,,E)C3DT4T0"
> M$(B6'0)@`H6$I*-WHE+!4NZ+D>&$E)]1$@D$P)`A``*%4`>!&`1RDD/@B2`2
> MF*594"`P-(D(Z:<(P`@"!XX'O1'<7B<B118<P,L9CJIF`HYR.R=L&E`)!29N
> %(@D1`#L`
>
> So in variable $fG is encoded image. But what kind of encoding is used?
> Does'nt seems like uuencode or Base64.
> I never meet before with such methods.
> May be, sombody knows?
>
It looks like uuencoded to me. I posted a short program that creates the
sort of thing in the last few months you can find it via Deja News.
/J\
--
** This space reserved for venue sponsor for yapc::Europe **
<http://www.yapc.org/Europe/>
------------------------------
Date: Wed, 28 Jun 2000 13:18:43 -0500
From: "James Nelson" <james@kcnet.com>
Subject: help submit buttons...
Message-Id: <8jdfh8$eoh$1@news3.kcnet.com>
I am in the process of writing a perl cgi that works with mysql. The script
outputs a form which will need to have several different types of submit
buttons.
What should the code look like to check which submit button was pressed, to
direct the cgi towards the proper subroutines?
An example would be much appreciated.
------------------------------
Date: Wed, 28 Jun 2000 15:26:38 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: help submit buttons...
Message-Id: <8jdjfs$dim$1@slb6.atl.mindspring.net>
James Nelson <james@kcnet.com> wrote in message
news:8jdfh8$eoh$1@news3.kcnet.com...
: I am in the process of writing a perl cgi that works with mysql. The script
: outputs a form which will need to have several different types of submit
: buttons.
: What should the code look like to check which submit button was pressed, to
: direct the cgi towards the proper subroutines?
: An example would be much appreciated.
Here is one I posted to a very similar request back in January.
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
'Out, out brief candle!
Life's but a walking shadow,
a poor player, that struts and frets his hour upon the stage,
And then is heard no more; It is a tale, told by an idiot,
full of sound and fury, signifying nothing'
- MacBeth
----------script--------
#!/usr/local/bin/perl -w
use strict;
use CGI qw(:standard :html3 -no_debug);
sub do_button1 {
print h4({-align=>'center'},"I am the result of Button 1");
}
sub do_button2 {
print h4({-align=>'center'},"I am the result of Button 2");
}
my $my_cgi = CGI->new();
print header(),start_html('show me the sub');
if (!$my_cgi->param()) {
print $my_cgi->start_form();
print $my_cgi->submit('button_name','button1');
print ' ';
print $my_cgi->submit('button_name','button2');
print $my_cgi->end_form();
}
elsif ($my_cgi->param('button_name') eq 'button1') {
do_button1();
}
elsif ($my_cgi->param('button_name') eq 'button2') {
do_button2();
}
else {
print h4({-align=>'center'},"I am a lost and lonely bit of stuff");
}
print end_html();
------------------------------
Date: Wed, 28 Jun 2000 22:24:01 +0200
From: Jan Bessels <j.bessels@quicknet.nl>
Subject: Re: Help: regex for changing NON-absolute urls in a html file.
Message-Id: <395A5EE1.5CD7FA2D@quicknet.nl>
arnet@hpcvplnx.cv.hp.com wrote:
> In comp.lang.perl Jan Bessels <jbessels@planet.nl> wrote:
>
> > Basicaly, the following has to be done. If an url is relative
> > (pics/menu.gif or relative to the root eg /content/pics/menu.gif) it has
> > to be changed into http://www.mysite.com/pics/menu.gif and
> > http://www.mysite.com/content/pics/menu.gif. In the latter case simply
> > concatenating http://www.mysite.com and /content/pics/menu.gif isn't
> > good because .com//content/ isn't valid html. Problem is that absolute
> > urls like "http://www.somehting.com/.....gif" have to be left alone.
> > The urls are used when using src= and href=. Of course src=url,
> > src="url" and src='url' and src = url are valid html which can be
> > found in the retrieved files.
>
> If you could explain the ".com//content/ isn't valid html" problem a
> bit more I might be able to help. I've written several scripts that
> do more or less what you want, but they simply look for references
> without the "http://..." part and add it. I don't understand your
> comment about concatenation.
I wasn't accurate enough it seems. Suppose I've got a pics dir in the docroot
which contains a gif called menu.gif. This pic (relative to dir doc is in) can
be used by a document in the docroot. It resolves to
http://www.mysite.com/pics/menu.gif. This is a valid name. The same gif can be
addressed/used as /pics/menu.gif - relative to the docroot. It resolves to
http://www.mysite.com/pics/menu.gif. Both under the assumption that
www.mysite.com is my domain. A script on a cgi-server wants to read in an url
from a server and outputs(after changing stuff a bit) it to the browser. All
paths have to be absolute to make things work. Cause of different docroots
(domain name). One can transform a relative path into an absolute ones by
adding a http://www.othersite.com/ to the url. In the former case the url
becomes www.othersite.com/pics/menu.gif. In the latter it becomes
www.othersitesite.com//pics/menu.gif. The double // makes both urls different
from each other !!. Hope this explains it a bit better.
Basicaly I want to transform relative paths into absolute paths. Hope you can
help me. Ohter ppl have given hints as well. Your input is still very much
appreciated.
JB.
------------------------------
Date: Wed, 28 Jun 2000 22:24:16 +0200
From: Jan Bessels <j.bessels@quicknet.nl>
Subject: Re: Help: regex for changing NON-absolute urls in a html file.
Message-Id: <395A5EF0.7CCBD829@quicknet.nl>
arnet@hpcvplnx.cv.hp.com wrote:
> In comp.lang.perl Jan Bessels <jbessels@planet.nl> wrote:
>
> > Basicaly, the following has to be done. If an url is relative
> > (pics/menu.gif or relative to the root eg /content/pics/menu.gif) it has
> > to be changed into http://www.mysite.com/pics/menu.gif and
> > http://www.mysite.com/content/pics/menu.gif. In the latter case simply
> > concatenating http://www.mysite.com and /content/pics/menu.gif isn't
> > good because .com//content/ isn't valid html. Problem is that absolute
> > urls like "http://www.somehting.com/.....gif" have to be left alone.
> > The urls are used when using src= and href=. Of course src=url,
> > src="url" and src='url' and src = url are valid html which can be
> > found in the retrieved files.
>
> If you could explain the ".com//content/ isn't valid html" problem a
> bit more I might be able to help. I've written several scripts that
> do more or less what you want, but they simply look for references
> without the "http://..." part and add it. I don't understand your
> comment about concatenation.
I wasn't accurate enough it seems. Suppose I've got a pics dir in the docroot
which contains a gif called menu.gif. This pic (relative to dir doc is in) can
be used by a document in the docroot. It resolves to
http://www.mysite.com/pics/menu.gif. This is a valid name. The same gif can be
addressed/used as /pics/menu.gif - relative to the docroot. It resolves to
http://www.mysite.com/pics/menu.gif. Both under the assumption that
www.mysite.com is my domain. A script on a cgi-server wants to read in an url
from a server and outputs(after changing stuff a bit) it to the browser. All
paths have to be absolute to make things work. Cause of different docroots
(domain name). One can transform a relative path into an absolute ones by
adding a http://www.othersite.com/ to the url. In the former case the url
becomes www.othersite.com/pics/menu.gif. In the latter it becomes
www.othersitesite.com//pics/menu.gif. The double // makes both urls different
from each other !!. Hope this explains it a bit better.
Basicaly I want to transform relative paths into absolute paths. Hope you can
help me. Ohter ppl have given hints as well. Your input is still very much
appreciated.
JB.
------------------------------
Date: Wed, 28 Jun 2000 22:24:48 +0200
From: Jan Bessels <j.bessels@quicknet.nl>
Subject: Re: Help: regex for changing NON-absolute urls in a html file.
Message-Id: <395A5F10.DFF7690D@quicknet.nl>
arnet@hpcvplnx.cv.hp.com wrote:
> In comp.lang.perl Jan Bessels <jbessels@planet.nl> wrote:
>
> > Basicaly, the following has to be done. If an url is relative
> > (pics/menu.gif or relative to the root eg /content/pics/menu.gif) it has
> > to be changed into http://www.mysite.com/pics/menu.gif and
> > http://www.mysite.com/content/pics/menu.gif. In the latter case simply
> > concatenating http://www.mysite.com and /content/pics/menu.gif isn't
> > good because .com//content/ isn't valid html. Problem is that absolute
> > urls like "http://www.somehting.com/.....gif" have to be left alone.
> > The urls are used when using src= and href=. Of course src=url,
> > src="url" and src='url' and src = url are valid html which can be
> > found in the retrieved files.
>
> If you could explain the ".com//content/ isn't valid html" problem a
> bit more I might be able to help. I've written several scripts that
> do more or less what you want, but they simply look for references
> without the "http://..." part and add it. I don't understand your
> comment about concatenation.
I wasn't accurate enough it seems. Suppose I've got a pics dir in the docroot
which contains a gif called menu.gif. This pic (relative to dir doc is in) can
be used by a document in the docroot. It resolves to
http://www.mysite.com/pics/menu.gif. This is a valid name. The same gif can be
addressed/used as /pics/menu.gif - relative to the docroot. It resolves to
http://www.mysite.com/pics/menu.gif. Both under the assumption that
www.mysite.com is my domain. A script on a cgi-server wants to read in an url
from a server and outputs(after changing stuff a bit) it to the browser. All
paths have to be absolute to make things work. Cause of different docroots
(domain name). One can transform a relative path into an absolute ones by
adding a http://www.othersite.com/ to the url. In the former case the url
becomes www.othersite.com/pics/menu.gif. In the latter it becomes
www.othersitesite.com//pics/menu.gif. The double // makes both urls different
from each other !!. Hope this explains it a bit better.
Basicaly I want to transform relative paths into absolute paths. Hope you can
help me. Ohter ppl have given hints as well. Your input is still very much
appreciated.
JB.
------------------------------
Date: Wed, 28 Jun 2000 22:29:20 +0200
From: Jan Bessels <j.bessels@quicknet.nl>
Subject: Re: Help: regex for changing NON-absolute urls in a html file.
Message-Id: <395A601F.364AEE40@quicknet.nl>
Someone mentioned HTML::Munger (CPAN). A snippet from the docs "The main
task which this module performs is attempting to make all the relative links
on the filtered page absolute, so that images, and hyperlinks work
correctly. It also makes frames and hyperlinks properly filter back through
the filter." Seems to be quite usefull.
Thanks guys/galls for the suggestions. Gonna give them a try tomorrow at
work (22:30 now).
Jan Bessels wrote:
> I've retrieved using LWP: a html file from a web-server. Before being
> usefull the contents has to be changed/parsed. I've experience with
> regexes but now I'm baffled. Have tried quite a few things.
>
> Basicaly, the following has to be done. If an url is relative
> (pics/menu.gif or relative to the root eg /content/pics/menu.gif) it has
> to be changed into http://www.mysite.com/pics/menu.gif and
> http://www.mysite.com/content/pics/menu.gif. In the latter case simply
> concatenating http://www.mysite.com and /content/pics/menu.gif isn't
> good because .com//content/ isn't valid html. Problem is that absolute
> urls like "http://www.somehting.com/.....gif" have to be left alone.
> The urls are used when using src= and href=. Of course src=url,
> src="url" and src='url' and src = url are valid html which can be
> found in the retrieved files.
>
> I'm confident the solution is elegant and simple but I currently don't
> see the solution.
> Any help is very much appreciated.
>
> JB.
------------------------------
Date: Wed, 28 Jun 2000 14:30:53 -0700
From: jfrankov <jfrankovNOjfSPAM@pobox.com.invalid>
Subject: hopdelta program?
Message-Id: <0a4bf00e.887abf9d@usw-ex0104-026.remarq.com>
Does anyone have a copy of the hopdelta program from the Perl
Cookbook, pages 87-89? I'd rather not type it in if I don't have
to!
Thanks tons,
-Jason
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Wed, 28 Jun 2000 14:11:01 -0400
From: Jim Moore <jmoore@image.kodak.com>
Subject: Interpreting dev and rdev from stat (in perl)
Message-Id: <395A3FB5.A8E3FDA5@image.kodak.com>
I am writing a user friendly wrapper for "stat" so that I can see among
other information all of the "times" at the same time. I am looking at
what to do with "dev" and "rdev". I have looked at the Sun answerbook,
and really don't seem to understand how to interpret them. Also, in
terms of permissions, I can see how you can get some information out of
the high order bits, to determine if it is a fifo, block, or character
special file.
What useful information is in dev, and rdev values, do they change (are
they dynamic -- i.e. will they change if I look at them at different
times of day?)
Thanks In Advance
Jim
--
Jim Moore Eastman Kodak Co.
Unix Systems Admin 6/69/RL
716-588-2006 Rochester, NY 14650-1925
jmoore@kodak.com
------------------------------
Date: 28 Jun 2000 19:03:25 GMT
From: Casper.Dik@Holland.Sun.Com (Casper H.S. Dik - Network Security Engineer)
Subject: Re: Interpreting dev and rdev from stat (in perl)
Message-Id: <8jdi5t$hkl$1@new-usenet.uk.sun.com>
[[ PLEASE DON'T SEND ME EMAIL COPIES OF POSTINGS ]]
Jim Moore <jmoore@image.kodak.com> writes:
>I am writing a user friendly wrapper for "stat" so that I can see among
>other information all of the "times" at the same time. I am looking at
>what to do with "dev" and "rdev". I have looked at the Sun answerbook,
>and really don't seem to understand how to interpret them. Also, in
>terms of permissions, I can see how you can get some information out of
>the high order bits, to determine if it is a fifo, block, or character
>special file.
"dev" is the block device the file resides on; interpreting it is hazardous;
it's composed of a major and minor number. In 32 bit perl on Solaris,
there are 14 bits of major and 18 bits of minor, IIRC. In 64 bit perl
on 64 bit SOlaris, there are 32 bits of minor and 32 bits of major.
"rdev" is meaningless except for "char" ad "block" devices for which
it indicates the actual device; interpreting it has the same
problem as "dev".
To determine whether a file is a fifo etc, use the perl file test
operators.
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
$type = "plain file" if -f _;
$type = "fifo" if -p _;
$type = "socket" if -S _;
..
("_" (underscore) is the special file that tests against the last "stat"
call, so i doesn't cause any system calls)
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
------------------------------
Date: Wed, 28 Jun 2000 18:13:54 GMT
From: design@raincloud-studios.com
Subject: Is this a job for Map or Grep?
Message-Id: <8jdf8e$m8d$1@nnrp1.deja.com>
After about a year of messing with for next and if, I'm ready to get a
bit more snappy in my coding. I'm looking at optimizing a library of
some of my URL processing code and wondered if Map or Grep might be the
tool for the job. I think I have a pretty good example to work from
here and I've read a good bit on the two functions, but I'm unsure if
they would be correct for what I'm wanting to achieve.
the following reads a CGI based URL that is used browsing database
records, grabs everything after the ?, then attempts to extract a few
key=value pairs for storage in an array. (there will probably be some
line breaks in this)
if ($query->{line} =~ /mysite.com(.*)\?(.*)/i){
my ($first_seen, $span) = (11, 10);
my @keyvals = split(/\&/,$2);
my $keyval = '';
foreach $keyval (@keyvals){
if(
(
($keyval =~ /^s=(.*)/i) ||
($keyval =~ /^t=(.*)/) ||
($keyval =~ /^x=(.*)/)
) && ($phrases eq ''))
{
$phrases = dehex_string($1); # a call to convert HEX entities
}elsif ($keyval =~ /^f=(.*)/){
$first_seen = $1;
}elsif ($keyval =~ /^p=(.*)/){
$span = $1;
}
}
my $first_last = $first_seen . "-" . ($first_seen + ($span - 1));
my $report = qq~User searched on: $phrases
within $first_last~;
}
What I am going for is some click little grep or map that can throw
each of my if-elsif results into an array... something like this
(pseudo code, please forgive):
($phrases, $first_seen, $span) =
somegrepormapfunction(
(regexp to detect $phrases),
(regexp for $firstseen),
(regexp for $span)
);
Can grep or map be used to achieve this? Would it be more efficient,
and what type of regexp'ing could I use to get a bit cleaner? I know
there are probably umpteen hundred ways to handle this.
I'm fairly certain my first step is looking for a way to reduce the ||
or'ing in the first if statement. It is unimportant to take notice of
if $phrases came from a s t or x, as long as it is found. However I'm
unsure of how to 'group' these in such a manner as to get the value
into $1 to pass to my hex conversion routine.
Thanks for any tips,
CT
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 28 Jun 2000 23:57:58 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Is this a job for Map or Grep?
Message-Id: <76skls8c4g45d1d9kveiejk6ktvislue49@4ax.com>
On Wed, 28 Jun 2000 18:13:54 GMT, design@raincloud-studios.com wrote:
> After about a year of messing with for next and if, I'm ready to get a
> bit more snappy in my coding. I'm looking at optimizing a library of
> some of my URL processing code and wondered if Map or Grep might be the
> tool for the job. I think I have a pretty good example to work from
> here and I've read a good bit on the two functions, but I'm unsure if
> they would be correct for what I'm wanting to achieve.
>
> the following reads a CGI based URL that is used browsing database
> records, grabs everything after the ?, then attempts to extract a few
> key=value pairs for storage in an array. (there will probably be some
> line breaks in this)
If you want your code to be snappy, then 'use CGI;' to do all the hard
work for you.
This is what I make of your example using map() and grep():
#!/usr/bin/perl -w
use strict;
use CGI qw(-nodebug);
my $cgi = CGI->new('s=get+this+right&f=1');
my %defaults = ( f => 11, p => 10, S => '', s => '', t => '', x => '' );
my($first_seen, $span, $phrases) =
map { $cgi->param($_) || $defaults{$_} }
('f', 'p', (grep /^[Sstx]$/=>$cgi->param())[0]);
my $first_last = $first_seen . "-" . ($first_seen + ($span - 1));
my $report = qq~User searched on: '$phrases'
within $first_last~;
print "$report\n";
__END__
--
Good luck,
Abe
------------------------------
Date: Wed, 28 Jun 2000 19:54:52 GMT
From: fyau@my-deja.com
Subject: Need help for Perl Win32::Process
Message-Id: <8jdl6d$cf2$1@nnrp2.deja.com>
How can I capture the return message and error
message when I run below script:
use Win32::Process;
Win32::Process::Create($ProcessObj,
"d:/appl/evprob.exe",
"evprob -h esmilabea6",
0,
NORMAL_PRIORITY_CLASS,
".");
Any suggestion is appreciate.
Fred
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 28 Jun 2000 19:39:25 GMT
From: tia_miller@my-deja.com
Subject: Need Help!
Message-Id: <8jdk9a$qaq$1@nnrp1.deja.com>
I need your help if possible.
I'm looking for several "perl" programmers who had/has experience with
socket programming. We desire knowledge of Linux. Must be a US
citizen. We will not sponsor H1-B Visa, BUT we do transfers.
I represent Avienda Technologies -- a pre-IPO internet company. We're
located in Atlanta, Ga. We specialize in globally distributed
messaging products. Our first product, which is what we call "next
generation email," will provide users with new capabilities such as,
streaming video techniques, audio and multimedia presentation, all in
one touch.
The salary is high with lucrative stock options, 401K, vacation, sick,
bonus, 100% health/dental benefits. Very casual environment (Shorts).
We are wrapping up our 2nd round of funding and we have other Venture
Capitalists waiting in line to invest in our company.
If you know of anyone, please have them call (404)262-4343 or email
tmiller@avienda.com
I truly appreciate your help!
Tia Miller
HR Specialist
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 28 Jun 2000 12:12:07 -0700
From: "Gabe" <grichard@uci.edu>
Subject: Re: Net::FTP not on CPAN
Message-Id: <8jditd$dqv$1@news.service.uci.edu>
> You did go to http://search.cpan.org/ and you did type in Net::Ftp,
> right? This search gives you a direct link to libnet so it's pretty
> hard to miss.
No, it's pretty easy to miss. Particularly if you're not familiar with
"bundles", the "libnet bundle" in particular, have never used the search
portion of the site before, and are expecting something that looks like the
descriptions you find when browsing the modules on the website. Also, when
you type in the search criteria, the most prominent link is "Net::FTP", but
that's a readme. So in other words, the most obvious link to get to what I
want is not what I want, so I missed the correct link quite easily.
Gabe
------------------------------
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 3503
**************************************