[18067] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 227 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 6 21:05:47 2001

Date: Tue, 6 Feb 2001 18:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <981511514-v10-i227@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 6 Feb 2001     Volume: 10 Number: 227

Today's topics:
    Re: Array and splits =help! <uri@sysarch.com>
    Re: Array and splits =help! <m_ario@my-deja.com>
    Re: Can't read entire file into string. <m_ario@my-deja.com>
    Re: Check for no value? (David Efflandt)
        Convert postscript to jpeg? <Scott.Bossi@fmr.com>
    Re: Convert postscript to jpeg? (Abigail)
    Re: Convert postscript to jpeg? (Chris Fedde)
    Re: Convert postscript to jpeg? (Martien Verbruggen)
    Re: date select <choate@spot.colorado.edu>
    Re: getting line number n of a file (Abigail)
    Re: Is scalar a float, int or string? (Mark Jason Dominus)
    Re: Is scalar a float, int or string? (Mark Jason Dominus)
    Re: Is scalar a float, int or string? (Abigail)
    Re: Is scalar a float, int or string? <elijah@workspot.net>
        Logfile pattern search & print mgrime@my-deja.com
    Re: Need Help Checking IP Address Syntax w/ PERL? <root@novastar.dtdns.net>
    Re: Need Help Checking IP Address Syntax w/ PERL? <peter.sundstrom-eds@eds.com>
    Re: Need Help Checking IP Address Syntax w/ PERL? <comdog@panix.com>
    Re: Need Help Checking IP Address Syntax w/ PERL? <godzilla@stomp.stomp.tokyo>
    Re: newbie - grep non-used uid from passwd (Richard J. Rauenzahn)
    Re: Perl & arrays <m_ario@my-deja.com>
    Re: Perl / Java and checkbox (Chris Fedde)
    Re: Perl for the Fortran programmer <uri@sysarch.com>
        return value from find() ? <ddunham@redwood.taos.com>
    Re: This is driving me nuts and I need a guru (Abigail)
    Re: unidentified reference (Chris Fedde)
    Re: Using Braces (Abigail)
    Re: Using global var in subroutine <steve@teamITS.com>
    Re: win32::iphelp for retrieving mac addresses <carvdawg@patriot.net>
        XML::Parser question kumar22@my-deja.com
    Re: XML::Parser question (Martien Verbruggen)
    Re: XML::Parser question (Tad McClellan)
    Re: XML::Parser question kumar22@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 07 Feb 2001 01:10:11 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Array and splits =help!
Message-Id: <x7u267pabw.fsf@home.sysarch.com>


use CGI.pm.

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: Wed, 07 Feb 2001 01:09:19 GMT
From: Mario <m_ario@my-deja.com>
Subject: Re: Array and splits =help!
Message-Id: <95q77r$8p6$1@nnrp1.deja.com>

In article <95po9k$qmd$1@nnrp1.deja.com>,
  vivekvp <vivekvp@spliced.com> wrote:
>  I am trying ot take and array and split it in 2 arrays:
>
> basically the array @pairs should split into 2 arrays - @names and
> @values - but it never works - printing @name only give the last
record
> and the @values is blank.
>
> If the @pairs is (a=1&b=2&c=3&d=4)  (the '&'s are already gone)
> I want to get:
> @name=(abcd)
> @value=(1234)
>

This should work (not tested):

$string='a=1&b=2&c=3&d=4';
for ( split(/&/,$string) ) {
    ($name,$value)=split(/=/,$_);
    push @name,$name;
    push @value,$value;
}

--
Mario
diab.litoATusa.net


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Wed, 07 Feb 2001 01:51:00 GMT
From: Mario <m_ario@my-deja.com>
Subject: Re: Can't read entire file into string.
Message-Id: <95q9m2$app$1@nnrp1.deja.com>

In article <pugzjnhy.fsf@pobox.com>,
  Jonathan Feinberg <jdf@pobox.com> wrote:
> Mario <m_ario@my-deja.com> writes:
>
> > It's not an error,it behaves in this way (reading a line at once).
> > You read the entire file by accessing all the lines sequencially.
>
> This is misleading.  The correct (efficient, commonly used, idiomatic)
> way to do it is described in perlfaq3.
>

Thanks,I didn't know about this way.

However it's hard to say it is the correct way in absolute: if you have
to read a 1GB file and write it in another file,it is not so efficient.


--
Mario
diab.litoATusa.net


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Wed, 7 Feb 2001 01:48:21 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Check for no value?
Message-Id: <slrn981a9f.8s7.efflandt@efflandt.xnet.com>

On Tue, 06 Feb 2001 18:27:48 GMT, vivekvp <vivekvp@spliced.com> wrote:
>
>I have a perl script which takes values from a web page (a form).  Some
>of these have check boxes - and I want to user to either check a value
>off - if they don't - I still want a value pass - either a 1 or 0 -
>no 'null' values.  How do I have either a blank or check?

There is a cgi newsgroup for CGI questions, this is not really Perl
specific.  A checkbox that is not checked has no value.  You can assign a
value of zero to it easily enough (CGI.pm function method):

param('checkbox-x',0) unless param('checkbox-x');

But if don't already know the names of the checkboxes, you would need to
pass a list of them in a hidden variable or something and loop through
them.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


------------------------------

Date: Tue, 06 Feb 2001 15:20:54 -0500
From: Scott Bossi <Scott.Bossi@fmr.com>
Subject: Convert postscript to jpeg?
Message-Id: <3A805CA6.7797164A@fmr.com>

Hi,

I have an application that generates output in postscript format, which
is no good, since it needs to be viewed from a web browser. Does anyone
know of a way to convert postscript to another format, such as a jpeg?
Or am I missing something obvious here...

Thanks...





------------------------------

Date: 7 Feb 2001 00:37:45 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Convert postscript to jpeg?
Message-Id: <slrn98166p.g7d.abigail@tsathoggua.rlyeh.net>

Scott Bossi (Scott.Bossi@fmr.com) wrote on MMDCCXVI September MCMXCIII in
<URL:news:3A805CA6.7797164A@fmr.com>:
'' Hi,
'' 
'' I have an application that generates output in postscript format, which
'' is no good, since it needs to be viewed from a web browser. Does anyone
'' know of a way to convert postscript to another format, such as a jpeg?
'' Or am I missing something obvious here...


Yeah, .mailcap, and that PostScript usually is used for documents which
aren't very suited as jpg images.


But what does this have to do with Perl?


Abigail


------------------------------

Date: Wed, 07 Feb 2001 00:47:41 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Convert postscript to jpeg?
Message-Id: <NW0g6.103$M8.170965504@news.frii.net>

In article <3A805CA6.7797164A@fmr.com>,
Scott Bossi  <Scott.Bossi@fmr.com> wrote:
>Hi,
>
>I have an application that generates output in postscript format, which
>is no good, since it needs to be viewed from a web browser. Does anyone
>know of a way to convert postscript to another format, such as a jpeg?
>Or am I missing something obvious here...
>
>Thanks...
>

Look for ghostscript at your nearest GNU ftp site. 

good luck
chris
-- 
    This space intentionally left blank


------------------------------

Date: Wed, 07 Feb 2001 01:05:30 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Convert postscript to jpeg?
Message-Id: <slrn9817on.ani.mgjv@verbruggen.comdyn.com.au>

On Tue, 06 Feb 2001 15:20:54 -0500,
	Scott Bossi <Scott.Bossi@fmr.com> wrote:
> Hi,
> 
> I have an application that generates output in postscript format, which
> is no good, since it needs to be viewed from a web browser. Does anyone
> know of a way to convert postscript to another format, such as a jpeg?
> Or am I missing something obvious here...

Download a tool for your OS from the Internet somewhere.

ObPerl:
One such a tool which can be used from within Perl, directly, is
Image::Magick. Visit http://www.imagemagick.org/ to find out more.
Image::Magick will require ghostscript to be installed on your system.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.   | you come to the end; then stop.
NSW, Australia                  | 


------------------------------

Date: Tue, 6 Feb 2001 16:22:56 -0700
From: "Phyllis Choate" <choate@spot.colorado.edu>
Subject: Re: date select
Message-Id: <95q14s$gv5$1@peabody.colorado.edu>

geeze!...can't seem to get this posting right..and my computer is not
cooperating either....anyway, I figured it out....
        thanks anyway
"Rudolf Polzer" <rpolzer@web.de> wrote in message
news:slrn980o7g.4h2.rpolzer@rebounce.rpolzer-lx...
> Phyllis Choate <choate@spot.colorado.edu> schrieb Folgendes:
> > I cannot get the select day...as in 6th or 31st of the month to show in
my
> > html. can anyone help?
>
> Please post URLs to such big beasts and NEVER post attachments in
> newsgroups.
>
> > begin 666 calendar.pl
>          ^^
> Why is everybody allowed to write to your files? Windoze?
>
>
> --
> $p=q;.;;$_=<<'learn.to/quote';s/./pack"C",9^unpack"C",$&/gem;eval;'RP'
> -u""2of{!zye`}&&%+khza)*)'{'d')'$'{'o')'&'Ug'''khza)*)'e'f'n'f'|'}'UgU
> C|z})b`mm`gn.g.hgf}al{)'Y'l'{'e)ahjbl{Ug+ r-V)lx-y//zelly)8'9uuy{`g}2t
> learn.to/quote




------------------------------

Date: 6 Feb 2001 23:31:52 GMT
From: abigail@foad.org (Abigail)
Subject: Re: getting line number n of a file
Message-Id: <slrn9812b8.g7d.abigail@tsathoggua.rlyeh.net>

Craig Berry (cberry@cinenet.net) wrote on MMDCCXVI September MCMXCIII in
<URL:news:t80ekm9fm3fc8d@corp.supernews.com>:
~~ Abigail (abigail@foad.org) wrote:
~~ : FooQuuxShell isn't a "standard" Unix command; head and tail are.
~~ : For most commands, it's quite clear whether they are "standard Unix",
~~ : or not.
~~ 
~~ Yes, but a fair number of people are running Perl on NT, or Win9x, or
~~ BeOS, or...  In my view, a golf submission should be pure perl, useable on
~~ any platform.


So, you install PPT....



Abigail
-- 
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
             "\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
             "\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'


------------------------------

Date: Tue, 06 Feb 2001 23:09:13 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Is scalar a float, int or string?
Message-Id: <3a808419.149a$176@news.op.net>

In article <slrn980dt4.3no.rpolzer@rebounce.rpolzer-lx>,
Rudolf Polzer <grauezellen@gibts.net> wrote:
>You have just to know IPC and make a newline after every
>command-terminator ; and such characters and do the decoding of @P by
>hand.

What is the decoding of @P?
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: Tue, 06 Feb 2001 23:11:17 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Is scalar a float, int or string?
Message-Id: <3a808495.14ac$7a@news.op.net>

In article <95pa48$buh$1@nnrp1.deja.com>,
Daniel Pfeiffer  <occitan@esperanto.org> wrote:
>> I don't think there is any way to do it in pure Perl without using an
>> extension.
>
>That is my feeling from all I have read.  If it isn't standard Perl, I
>can't make it a prerequisite for a standard Math::BigInt.

I suggest you ask perl5-porters for advice.  They will be able to
offer a suggestion that is most practical for the realities of Perl.
That might be that you bundle a small XS module with Math::BigInt, or
it might be to include Devel::Peek in the standard distribution, or
there might be a soltuion I don't know about.
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


------------------------------

Date: 6 Feb 2001 23:42:49 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Is scalar a float, int or string?
Message-Id: <slrn9812vp.g7d.abigail@tsathoggua.rlyeh.net>

Rudolf Polzer (rpolzer@web.de) wrote on MMDCCXVI September MCMXCIII in
<URL:news:slrn980e6q.3no.rpolzer@rebounce.rpolzer-lx>:
%% 
%% (what about self-modification?)


Been there, done that.

In .sig, one that use computed goto, eval, self modifying code, POD,
a loop with only unconditional jumps (but it terminates anyway),
it's strict and -w clean, and fits in 1 line of 80 characters.

You, on the other hand, just dismisses things as trivial, without
producing much.


Abigail
-- 
perl -Mstrict -we '$_ = "goto F.print chop;\n=rekcaH lreP rehtona tsuJ";F1:eval'


------------------------------

Date: 7 Feb 2001 01:06:23 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Is scalar a float, int or string?
Message-Id: <eli$0102061941@qz.little-neck.ny.us>

In comp.lang.perl.misc, Rudolf Polzer <grauezellen@gibts.net> wrote:
> Are there ANY real JAPH scripts? Either they are very easy to read (like
> yours) or use lame encryption and therefore cannot do very much (like
> mine).

Care to clarify what you mean about 'real'?

Personally I think 'easy to read' ones are often good ways to learn
obscure syntax, methods, etc.

Consider this one of mine:

sub S(){@s=caller($/);$s[3]=~s s\w+:+ss&&print$s[3].q. .}$/=$^=~s/\S+/\n/;
$_="Just (eli) Another (the) Perl (bearded) Hacker";sub s($){eval$_[0];$/}
while(s&&&&& &s(qq&sub$^&.$&.q&{\&S}&)&& &{$&}&&s&&&){$/}$\=$^;print"\b,";

I rather happy with the way that functions are created and called
at run time. Plus there is some fun obscure interactions between
various parts of the script. Though I do consider the \b a bit
ugly.

And <aradia@user2.teleport.com> has this very interesting one:

$j=\$j;{$_=unpack(P25,pack(L,$j));/Just Another Perl Wannabe/?print:$j++&&redo}

That that even works is fairly surprising to me. Playing around with
that, trying to make it shorter I had perl core dump on me several
times. Not bad for portable one liner.

Elijah
------
use X11::Protocol;$X=new X11::Protocol;END{$X->FreeGC($G);undef$X}map{$$_=$X->
new_rsrc}(W,F,G);$X->event_handler('queue');$X->CreateWindow($W,$X->root,'Inp'
 .'utOutput',$D=$X->root_depth,'CopyFromParent',(0,0),300,30,4,'event_mask',01,
background_pixel=>2**$D-1);$X->CreateGC($G,$W);$X->MapWindow($W);$X->PolyText8
($W,$G,25,28,[0,'Eli the Bearded:Just Another Perl Hacker']);$X->handle_input;


------------------------------

Date: Wed, 07 Feb 2001 01:34:52 GMT
From: mgrime@my-deja.com
Subject: Logfile pattern search & print
Message-Id: <95q8ns$a4v$1@nnrp1.deja.com>

Hi,

I have a log file where the first field is a date followed by the time
and finally followed by some details like this:

06Feb01  15:49:33 [6] OK:exec sendfsock

Is there someone who would give me a hand with some simple code to
search for a pattern (preferably the whole line) and print that line and
all the following lines? Is there maybe a one-liner?

Thanks for the help,
Mike



Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Wed, 7 Feb 2001 01:34:24 +0200
From: "SysAdmin" <root@novastar.dtdns.net>
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <95q1m0$9in$1@usenet.otenet.gr>

$_="100.168.0.1";

die "not valid IP format\n" if ! /^\d+\.\d+\.\d+\.\d+$/;
@ip=split /\./;
foreach (@ip){if (($_<=0) || ($_>=255)){die "IP octet $_ out of range\n";}}
undef @ip;
print "ok";


"webbgroup" <webbgroup@my-deja.com> wrote in message
news:95p93u$as8$1@nnrp1.deja.com...
> I am writing a script right now that is asking for an IP address.
> It needs to check the syntax with limiting it to a valid IP address.
> Obviously the end user should be able to put in any three numbers, but
> not > 256 for each octect.
>
> Does anybody know a simpler way of doing it than the following?
>
> unless (($ip2add =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-
> 9][0-9][0-9]) || ($ipadd =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9]
> [0-9].[0-9][0-9]) || (ip2add =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-
> 9].[0-9][0-9][0-9]) || ($ip2add =~ [0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]
> [0-9].[0-9][0-9][0-9]))
>    {
>    print "Invalid IP address.";
>    }
>
> Any suggestions??? Comments???
>
>
> Sent via Deja.com
> http://www.deja.com/




------------------------------

Date: Wed, 7 Feb 2001 11:13:14 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <95pstq$lpi$1@hermes.nz.eds.com>


"webbgroup" <webbgroup@my-deja.com> wrote in message
news:95p93u$as8$1@nnrp1.deja.com...
> I am writing a script right now that is asking for an IP address.
> It needs to check the syntax with limiting it to a valid IP address.
> Obviously the end user should be able to put in any three numbers, but
> not > 256 for each octect.
>
> Does anybody know a simpler way of doing it than the following?
>
> unless (($ip2add =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9][0-9].[0-
> 9][0-9][0-9]) || ($ipadd =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-9]
> [0-9].[0-9][0-9]) || (ip2add =~ [0-9][0-9][0-9].[0-9][0-9][0-9].[0-9][0-
> 9].[0-9][0-9][0-9]) || ($ip2add =~ [0-9][0-9][0-9].[0-9][0-9].[0-9][0-9]
> [0-9].[0-9][0-9][0-9]))
>    {
>    print "Invalid IP address.";
>    }
>

You could use the IPv4Addr.pm module from CPAN.

use Net::IPv4Addr qw(:all);
my $ip2add='123.123.123.999';
print "Invalid IP address\n" unless ipv4_checkip($ip2add);





------------------------------

Date: Tue, 06 Feb 2001 19:11:38 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <comdog-E4F664.19113806022001@news.panix.com>

In article <95q1m0$9in$1@usenet.otenet.gr>, "SysAdmin" 
<root@novastar.dtdns.net> wrote:

> $_="100.168.0.1";
> 
> die "not valid IP format\n" if ! /^\d+\.\d+\.\d+\.\d+$/;

that should say "dotted decimal IP format, although it is still
incorrect.

what about all of these invalid IP numbers:

    256.0.0.1
    1000.0.0.1

and so on.

-- 
brian d foy <comdog@panix.com>



------------------------------

Date: Tue, 06 Feb 2001 17:29:42 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Need Help Checking IP Address Syntax w/ PERL?
Message-Id: <3A80A506.32583AAB@stomp.stomp.tokyo>

webbgroup wrote:
 
> I am writing a script right now that is asking for an IP address.
> It needs to check the syntax with limiting it to a valid IP address.
> Obviously the end user should be able to put in any three numbers, but
> not > 256 for each octect.
 
> Does anybody know a simpler way of doing it than the following?
 
> unless (($ip2add =~ 

(snipped)

> Any suggestions??? Comments???


Others have posted vaild methods of attaining
your goal using grep and, continue to argue
about a best method. A person has posted a
method using inet_ntoa and inet_aton. You 
asked about 'use Socket' in response.

His use of inet_nton and inet_aton will compile
but is flawed and will return no results. He did
not test his code before posting; a fatal error.

You have asked for comments and, here are some
which might be of interest. There are many ways
to validate an IP Address. There are no methods which
are completely reliable. Most work for many cases.
However, there are times you will receive a valid
IP Address and your checks indicate it is not.

Below my signature you will read a method which
works relatively well and, fails for selected
IP Addresses. I have used 196.168.23.1 to
display a flaw, a failure. This IP Address is
a valid assigned IP Address. Nonetheless, my 
method fails to indicate it is valid.

To validate an IP Address is a formidable task often
requiring personal research; no script can do this
for all cases.

You can read and learn about 'Socket' and 'Net Ping'
at CPAN. This is a great site staffed by hard
working volunteers but is challenging to navigate.

http://www.perl.com/CPAN-local/README.html

There are various syntax available for Socket
and Net Ping. Both tools will prove useful to
you, if you are interested in this area. Do
note, no one tool is completely flawless.
Be wary of Net Ping, it does not work on
all internet service providers nor systems.
I am guesstimating the reliability rate of
Net Ping to be sixty percent or less. You
need to test Net Ping on specific systems
to give it a fair reliability assessment.
Nothing wrong with Net Ping itself, it just
doesn't work under all circumstances. 

A system ping might work for you, might not.
Like Net Ping, a system ping is often as 
unreliable; it may or may not be available
to you via your ISP account.


Godzilla!
--

TEST SCRIPT:
____________

#!perl

print "Content-type: text/plain\n\n";

use Socket;

## Try To Locate Ping Device:

if (-x "/windows/ping.exe") 
 { $ping = "/windows/ping.exe"; }
elsif ( -x "/bin/ping") 
 { $ping = "/bin/ping"; }
elsif ( -x "/sbin/ping") 
 {$ping = "/sbin/ping"; }
elsif ( -x "/opt/bin/ping") 
 { $ping = "/opt/bin/ping"; }
elsif ( -x "usr/bin/ping") 
 { $ping = "/usr/bin/ping"; }
elsif ( -x "/usr/etc/ping")
 { $ping = "/usr/etc/ping"; }
else
 { $ping = ""; }

@IP_Address = qw (207.167.96.28 209.179.232.4 63.162.241.196 196.168.23.1);

foreach $ip_address (@IP_Address)
 {

## Socket Function:

  $hostname  = gethostbyaddr (inet_aton ($ip_address), AF_INET);

  if ($hostname)
   { print "Hostname: $hostname  IP Address: $ip_address\n\n"; }

## Ping Function:

  else
   {
    print "Hostname Not Found For: $ip_address\n  Trying Ping.\n";
    if ($ping)
     { system ($ping, $ip_address); print "\n\n"; }
    else
     { print "    $ip_address : Ping Device Not Found\n\n"; }
   }
 }

exit;


PRINTED RESULTS:
________________


Hostname: lats1-28.znet.net  IP Address: 207.167.96.28

Hostname: pool0004.cvx17-bradley.dialup.earthlink.net  IP Address: 209.179.232.4

Hostname Not Found For: 63.162.241.196
  Trying Ping.

Pinging 63.162.241.196 with 56 bytes of data:

1	63.162.241.196	56	441ms	Success	
2	63.162.241.196	56	420ms	Success	
3	63.162.241.196	56	455ms	Success	
4	63.162.241.196	56	441ms	Success	
5	63.162.241.196	56	426ms	Success	


Hostname Not Found For: 196.168.23.1
  Trying Ping.

Pinging 196.168.23.1 with 56 bytes of data:

1	196.168.23.1	56	0ms	Failure - Timed Out	
2	196.168.23.1	56	250ms	Failure - Host Unreachable	
3	196.168.23.1	56	205ms	Failure - Host Unreachable	
4	196.168.23.1	56	230ms	Failure - Host Unreachable	
5	196.168.23.1	56	204ms	Failure - Host Unreachable


------------------------------

Date: 7 Feb 2001 00:17:39 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: newbie - grep non-used uid from passwd
Message-Id: <981505058.852563@hpvablab.cup.hp.com>

"John W. Krahn" <krahnj@acm.org> writes:
>- = k o l i s k o = - wrote:
>> Is possible to grep from my /etc/passwd the 1st non-used uid in
>> range from 100 to 999?
>> 
>Well, here's one way to do it.
>
>
>#!/usr/bin/perl -w
>use strict;
>
>my $uid;
>my %hash;
>
>while ( ( undef, undef, $uid ) = getpwent() ) {
>    if ( $uid >= 100 && $uid <= 999 ) {
>        $hash{ $uid } = 1;
>        }
>    }
>
>my @keys = sort {$a <=> $b} keys %hash;
>
>for ( $keys[0] .. $keys[-1] ) {
>    unless ( exists $hash{ $_ } ) {
>        print "$_\n";
>        last;
>        }
>    }

You have a minor bug -- you will report no number if there isn't a hole
between $keys[0] and $keys[-1].

One way to fix it...

	push(@keys, $keys[-1]+1) if($keys[-1] < 999);

After you perform the sort.

Rich


-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


------------------------------

Date: Wed, 07 Feb 2001 01:27:57 GMT
From: Mario <m_ario@my-deja.com>
Subject: Re: Perl & arrays
Message-Id: <95q8am$9ok$1@nnrp1.deja.com>


> > > Does anyone know if Perl has a limitation on the number of
elements an
> > > array can have? Thanks,      T.
> >
> > It has not.Of course there is the phisical limit of the ram.



> Actually, the limit is more the amount of available swap space.
> And the available address space of the OS (which can range from 64KB
to a
> couple of TB).

What do you mean with OS address space?

--
Mario
diab.litoATusa.net


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Wed, 07 Feb 2001 01:26:11 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl / Java and checkbox
Message-Id: <Tu1g6.109$M8.170853888@news.frii.net>

In article <95pesf$isj$1@taliesin.netcom.net.uk>,
abu eesaa <totalmailer@yahoo.com> wrote:
>I am trying to code the following scenario in perl :
>
>List some filenames within a directory (the number of files is undefined)
>Put a "checkbox" next to each of these listed filenames
>Allow a user to tick as many of these boxes as required
>Delete all these files that have ticks in the checkboxes.
>
>I am talking in similar fashion as the one provided by "hotmail" and "yahoo"
>where it lists all your emails and then you tick the ones you wish to
>delete.
>I believe its written in Java... how would one incorporate this Java to pass
>on its results to the perl auction script and hence delete all the ticked
>items.
>
>Or can this be done in pure perl.
>


This seems a little muddled.  While Java and Perl can work together it
seems unlikely that this is what is going on in your scenario.  I suspect
that the html has some javascript features and that a CGI script (or other
interface technology) on the server side interacts with it.  I'd recommend
that you examine the situation more closely and post a question to one of
the groups in comp.infosystems.www.authoring.

good luck
chris
-- 
    This space intentionally left blank


------------------------------

Date: Wed, 07 Feb 2001 00:22:06 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl for the Fortran programmer
Message-Id: <x7y9vjpck8.fsf@home.sysarch.com>

>>>>> "MP" == Michael Prager <Mike.Prager@noaa.gov> writes:

  MP> I am looking for a book to teach myself basic Perl.  Ideally, it
  MP> would be written for programmers, but not necessarily for
  MP> programmers of the C or related languages.  By that, I mean the
  MP> book should be concise, yet avoid explanations like "The foo
  MP> statement works the same as in C" or the general assumption that
  MP> something not explained will be as in C.

  MP> (Reviews of the book _Learning Perl_ at Amazon lead me to think
  MP> that it is concise, but that too much C knowledge is assumed.)

elements of programming in perl is a good beginner book that doesn't
assume c knowledge. in fact it assumes no programming knowledge.

perl, the programmer's companion is a good choice if you know some
programming but want to learn perl. it also doesn't assume c.

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: Wed, 07 Feb 2001 00:43:13 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: return value from find() ?
Message-Id: <BS0g6.191$M5.100800@news.pacbell.net>

The unix find program has a non-zero exit status if it cannot traverse
some portion of the path passed to it.

File::Find::find() seems to return a false but defined value in all
situations.

Since any subroutine I pass to find will not be run to detect such
problems, it might be nice to know if find was able to do anything at
all by a return value.

Am I missing anything that is present but I've overlooked?

Currently I'm using 5.005_03...

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
      < Please move on, ...nothing to see here,  please disperse >


------------------------------

Date: 6 Feb 2001 23:36:25 GMT
From: abigail@foad.org (Abigail)
Subject: Re: This is driving me nuts and I need a guru
Message-Id: <slrn9812jp.g7d.abigail@tsathoggua.rlyeh.net>

Richard J. Rauenzahn (nospam@hairball.cup.hp.com) wrote on MMDCCXVI
September MCMXCIII in <URL:news:981482039.809409@hpvablab.cup.hp.com>:
"" 
"" Actually, Abigail killfiled Tim (original poster), not John.


Actually, Abigail killfiled both.


Abigail
-- 
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} #  Yet Another silly JAPH by Abigail
sub A::FETCH     {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}


------------------------------

Date: Wed, 07 Feb 2001 01:01:45 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: unidentified reference
Message-Id: <Z71g6.105$M8.170903552@news.frii.net>

In article <R7Yf6.36183$E6.918141@news1.rdc1.sdca.home.com>,
John Hall <jhall@ifxonline.com> wrote:
>Some code I am modifying contains a reference I haven't been able to locate
>in any documentation.
>
>The sub that it is in contains grabs some directory listings and puts the
>filenames in an array so that it can access them later.
>
>Pat of a mechanism that builds a list out of filenames includes:
>
>   for(@{$files{'__base__'}})
>
>I haven't been able to find '__base__' anywhere. I found some "global
>special constants" that use the beginning and trailing double underscore,
>but I can't find '__base__'.
>

That's not how a special literal would be used. The single quotes
make it just a string of characters.  I suspect that this is just
a conveniant hash key for an array that contains filenames.

good luck
chris
-- 
    This space intentionally left blank


------------------------------

Date: 6 Feb 2001 23:38:34 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Using Braces
Message-Id: <slrn9812nq.g7d.abigail@tsathoggua.rlyeh.net>

Rudolf Polzer (rpolzer@web.de) wrote on MMDCCXVI September MCMXCIII in
<URL:news:slrn980det.2sm.rpolzer@rebounce.rpolzer-lx>:
}} Abigail <abigail@foad.org> schrieb Folgendes:
}} > 
}} >     for (s;s;s;s;s;s;s;s;s;s;s;s) { .... }
}} 
}} That is a good one! Perhaps useful for a JAPH... when you have removed all
}} s's from the string, you're done.

Haven't been around here long, have you?


Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
	      {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


------------------------------

Date: Tue, 6 Feb 2001 18:52:38 -0600
From: "Steve Yates" <steve@teamITS.com>
Subject: Re: Using global var in subroutine
Message-Id: <t8173r1c7grp20@corp.supernews.com>

"Steve Yates" <steve@teamITS.com> wrote in message
news:t7uap627c0p697@corp.supernews.com...
>So I'm not sure why I'm seeing what I'm seeing.

    Well, I am reasonably sure now (sheepish grin).  Thanks for all the
efforts at aid, I ended up resorting to the "print out the variables one at
a time" approach and found the program wasn't doing what I thought it was
doing when it was doing it.

Steve

"You keep using that word...I do not think it means what you think it
means."




------------------------------

Date: Tue, 06 Feb 2001 18:50:34 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: win32::iphelp for retrieving mac addresses
Message-Id: <3A808DC9.4C6C1FE8@patriot.net>



Anonymous wrote:

> Go to http://www.generation.net/~aminer/Perl/.

Clicking on the link to the IpHelp module archive returns a 404 Not Found



------------------------------

Date: Wed, 07 Feb 2001 00:08:38 GMT
From: kumar22@my-deja.com
Subject: XML::Parser question
Message-Id: <95q3lv$5mm$1@nnrp1.deja.com>

Hi,

I'm new to Object-Oriented programming, and I'm just starting to mess
around with the XML::Parser module because I use Perl with XML a lot
and I think this module could eventually make my life a lot easier.

I'm wondering if anyone who's used it can tell me how to use the
option "style=>'tree'" to get some sort of data structure that can be
easily worked with.

So far I've got

use XML::Parser;
$p1 = new XML::Parser(Style => 'Tree');
@a = $p1->parse("<foo><question>what's this?</question><answer>oh, just
a dopey little xml file</answer></foo>");

I'm getting confused by @a.  Some of its elements are scalars, but
others are references to scalars (or arrays or hashes.)  I'd like to
get the tree into an array where the elements are just scalars, hashes,
or arrays, and not references to them.  How do I do this?

None of the examples I can find in the documentation use (Style
=> 'Tree').  If anyone knows where to find such an example please tell
me.

Thanks, Rakesh
--
This ball of the Lords of Death -- it is just a spherical knife.

-Popol Vuh


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: Wed, 07 Feb 2001 01:11:29 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: XML::Parser question
Message-Id: <slrn98183t.ani.mgjv@verbruggen.comdyn.com.au>

On Wed, 07 Feb 2001 00:08:38 GMT,
	kumar22@my-deja.com <kumar22@my-deja.com> wrote:

> use XML::Parser;
> $p1 = new XML::Parser(Style => 'Tree');
> @a = $p1->parse("<foo><question>what's this?</question><answer>oh, just
> a dopey little xml file</answer></foo>");
> 
> I'm getting confused by @a.  Some of its elements are scalars, but
> others are references to scalars (or arrays or hashes.)  I'd like to
> get the tree into an array where the elements are just scalars, hashes,
> or arrays, and not references to them.  How do I do this?

Did you read the section of the manual page for XML::Parser with the
title 'Tree'?

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd.   | enough features yet.
NSW, Australia                  | 


------------------------------

Date: Wed, 07 Feb 2001 01:46:56 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: XML::Parser question
Message-Id: <slrn9812sl.8mj.tadmc@tadmc26.august.net>

kumar22@my-deja.com <kumar22@my-deja.com> wrote:

>I'd like to
>get the tree into an array where the elements are just scalars, hashes,
>or arrays, and not references to them.  How do I do this?
                ^^^^^^^^^^^^^^^^^^^^^^

You cannot do that in Perl.

In Perl, array elements can *only* be scalars. 

Arrays and hashes are not scalars so they cannot be array elements.

References are scalars, so you _can_ have those in array elements.

Reading 

   perldoc perlreftut

would help you, I think.

What's the problem with them being references? Just dereference them.


>None of the examples I can find in the documentation use (Style
>=> 'Tree').  If anyone knows where to find such an example please tell
>me.


Understanding the data structures is what you need. See also:

   perldoc perlref
   perldoc perllol
   perldoc perldsc


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Wed, 07 Feb 2001 01:41:58 GMT
From: kumar22@my-deja.com
Subject: Re: XML::Parser question
Message-Id: <95q956$abc$1@nnrp1.deja.com>

Martien asked:
> Did you read the section of the manual page for XML::Parser with the
> title 'Tree'?

I did, actually.  This section says:

"Parse will return a parse tree for the document. Each node in the tree
takes the form of a tag, content pair. Text nodes are represented with
a pseudo-tag of ``0'' and the string that is their content. For
elements, the content is an array reference. The first item in the
array is a (possibly empty) hash reference containing attributes. The
remainder of the array is a sequence of tag-content pairs representing
the content of the element."

OK, cool.  Now, what's a good way to dereference everything, and wind
up with an array that contains other arrays and hashes and scalars
rather than references to them?

-Rakesh


Sent via Deja.com
http://www.deja.com/


------------------------------

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 V10 Issue 227
**************************************


home help back first fref pref prev next nref lref last post