Re: How to determine if STDIN has piped data?

2004-03-31 Thread Bryan Harris


> Bryan Harris wrote:
>> So an example use of a socket would be, say, a script that would listen on a
>> socket (?) and notify me in response to a message from a particular cgi
>> being executed on my webserver?
>> 
>> I guess I'm not sure where anyone would use this...
> 
> A socket or your example?


=)  I was referring to a socket.  I couldn't think of any place where I
might need to use one.

- B


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How to determine if STDIN has piped data?

2004-03-31 Thread WC -Sx- Jones
Bryan Harris wrote:
So an example use of a socket would be, say, a script that would listen on a
socket (?) and notify me in response to a message from a particular cgi
being executed on my webserver?
I guess I'm not sure where anyone would use this...
A socket or your example?

Your example can be handled in better ways then
listening for CGI responses.
Why not have the CGI just notify you?
Via SMTP?
Via WWW logs?
Via syslog?
Via file output you collect and process
autonomously?
Or the WWW server itself configured to
"tattle" about things...
So, in answer to your example - yes;
you can have a Perl script wait on a
Socket and get data -- so long as the
"other" application is written to
"speak" to your "listener."
HTH/Sx

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: How to determine if STDIN has piped data?

2004-03-31 Thread Bryan Harris


>> By the way, what's a socket?
> 
> Usually, a network protocol end-point which for most I/O purposes looks
> like a file handle. Instead of reading or writing from a file, the
> program reads or writes a socket which is typically connected to
> another program via a network protocol which is either local or remote.
> See perldoc -f socket.


So an example use of a socket would be, say, a script that would listen on a
socket (?) and notify me in response to a message from a particular cgi
being executed on my webserver?

I guess I'm not sure where anyone would use this...

- B


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: LWP::UserAgent Question

2004-03-31 Thread Oliver Schnarchendorf
On Thu, 1 Apr 2004 09:49:20 +0700, Hari Fajri wrote:
> "$ua->credentials($netloc, $realm, $uname, $pass)"
> but i do not understand what is $netloc and  $realm is...

$netloc is the network location. Meaning the http address plus the port the 
server is running on.

$realm is the alias for the secured directory. It is normally shown as 'area' 
or 'realm' above the the login request of your browser.

Example:

$ua->credentials(
"http://the.server.com:80";,
"THE SERVER members area",
"uname" => "pass"
);

Hope this helps.

/oliver/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




LWP::UserAgent Question

2004-03-31 Thread Hari Fajri
Hi all

i'm new to perl. I'm trying to download file using LWP::UserAgent module 
from  "http://www.abcd.com/thisfile.zip";
but, i need to supply user name & password first before downloading that 
file.
how to do that using LWP::UserAgent?
for example, user name = "user" and password = "password"
i have read the LWP::UserAgent manual, i found method below :
"$ua->credentials($netloc, $realm, $uname, $pass)"
but i do not understand what is $netloc and  $realm is...



Thank you
[sorry about my bad english]





file operations

2004-03-31 Thread MuthuKumar
Hai All,

   I have a directory with more files.. Some file contains a pattern as
http://yahoo.com/corner_4.gif"; width="10" height="10">
http://yahoo.com/corner_1.gif"; width="10" height="10">
and lot of more lines.. with out the key word yahoo.com

I want to change the above line as


http://perl.com/corner_4.gif"; width="10" height="10">






yahoo domain must be changed to perl.Where the keyword is yahoo domain.

Using the shell scipt I have done it easily. how to do it in perl..

cat $filename | sed -e 's/\
$/td>\
<\\sample>/g'


Thanks for reviewed help for this.
Muthukumar.





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: split

2004-03-31 Thread ewalker


-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 31, 2004 4:03 PM
To: [EMAIL PROTECTED]
Subject: Re: split


[EMAIL PROTECTED] wrote:
> 
> Hey if I do split like the line below.  What is put in options when there are only 3 
> .
> 
> ($hello,$good,$etc,$options) = split /\s/,$line;

What happened when you tried it?


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 

Just finished my test., what happened was that I was using my(..,$options) = @_; 
So no matter what I always had a $options , no matter if it was empty or not. So I 
changed my test from. if(defined($options)) to if($options) and this worked.

Thanks



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: A long time helper needs help

2004-03-31 Thread Jenda Krynicky
From: <[EMAIL PROTECTED]>
> Thanks for your response.  Now I can concentrate on how to hack the
> code. What what is your take on how to represent the table entries
> (cells)?  What is the most efficient way to associate each cell with
> its parent header?

It's a bit hard to give good suggestions if I do not understand the 
data.

Are all the data yearly like the stuff in page6.prn?

If so it would IMHO be best to have one table with the headers and 
another with the data.

So you'd have something like
HEADERS
ID| Name
1 | Domestic nonfinancial sectors: Total
2 | Domestic nonfinancial sectors: Federal government
3 | Domestic nonfinancial sectors: Nonfederal: Total nonfederal
...

and
DATA
HeaderID| Year  | Value
1   | 1969  | 7.2
2   | 1969 | -1.1
...


Parsing the headers from the document will be tricky. Since the 
columns are not all the same width (and I believe the Nth column in 
one report will be on a different place than in another) you'll have 
to start by looking at the last line and finding the places to split 
the lowest level headers.

Actually .. I felt like doing some Perl again today ... you can find 
the code attached. It does the tricky job of extracting the complete 
headers, extracting the values and inserting into the database should 
be simple.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


use strict;

open IN, '< c:\temp\page6.prn';
my $report_text = do {local $/; };
close IN;

$report_text =~ s/\n\n+/\n/g; # remove empty lines
$report_text =~ s/^.*^+\n//sm; # remove the header

#print 
"=\n$report_text\n=\n";

my @report = split /\n/, $report_text; # split to lines

#print "lines: "[EMAIL PROTECTED]"\n";

my @last_line = ($report[-1] =~ /(.*?-?\d+(?:\.\d+)?)/g); # split the last line into 
fields (including spaces!)

#print join("\n", @last_line),"\n";

my @lengths = map {length($_)} @last_line;
my @end_pos = do {
my $sum = 0; # this variable is local to the map, I keep the sum of the 
lengths in it
map {$sum += $_} @lengths
};

#print join(", ", @lengths),"\n";
#print join(", ", @end_pos),"\n";

my (@section_lines, @header_lines);
while ($report[0] =~ /^\s+--/) { # move the rows starting with spaces and -- to 
@section_lines array
push @section_lines, shift(@report);
}
print "\n", join("\n", @section_lines), 
"\n\n";

while ($report[0] =~ /^\s+\w/) { # move the rows starting with spaces followed by text 
to @header_lines array
push @header_lines, shift(@report);
}
#print "\n", join("\n", @header_lines), 
"\n\n";

shift(@report); # remove the 

my $unpack_format = 'A' . join( 'A', @lengths);

my @headers = unpack( $unpack_format, shift(@header_lines)); # split the first line of 
column headers

foreach my $header_line (@header_lines) {
my @next = unpack( $unpack_format, $header_line);
for(my $i=0; $i <= $#headers; $i++) {
$headers[$i] .= $next[$i];
}
}

foreach (@headers) {
s/^\s+//;
s/\s+$//;
s/\s+/ /g;
}

#print "\n", join("\n", @headers), 
"\n\n";

foreach my $section_line (reverse(@section_lines)) {
print "\$section_line=$section_line\n";
for(my $i=0; $i <= $#headers; $i++) {
my ($begin, $end) = ( substr($section_line, 0, $end_pos[$i]), 
substr($section_line, $end_pos[$i]) );

if  ($begin =~ /-([^-]*\w\s*)$/ and (my $tmp = $1) and $end =~ 
/^(\s*\w[^-]*)-/) {
$headers[$i] = $tmp . $1 . ': ' . $headers[$i];
} elsif ($begin =~ /-(\w[^-]*)-+$/) {
$headers[$i] = $1 . ': ' . $headers[$i];
} elsif ($end =~ /^-*(\w[^-]*)-/) {
$headers[$i] = $1 . ': ' . $headers[$i];
}
}
}

print "\n", join("\n", @headers), 
"\n\n";

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: split

2004-03-31 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
> 
> Hey if I do split like the line below.  What is put in options when there are only 3 
> .
> 
> ($hello,$good,$etc,$options) = split /\s/,$line;

What happened when you tried it?


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: split

2004-03-31 Thread Jayakumar Rajagopal
it will be undefined. kind of null. 
and 
defined( $options) -- will result in false. If you use it in expressions, you will get 
"".

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 31, 2004 5:37 PM
To: [EMAIL PROTECTED]
Subject: split


Hey if I do split like the line below.  What is put in options when there are only 3 .


($hello,$good,$etc,$options) = split /\s/,$line;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




split

2004-03-31 Thread ewalker
Hey if I do split like the line below.  What is put in options when there are only 3 .


($hello,$good,$etc,$options) = split /\s/,$line;

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Matching ranges of IP addresses

2004-03-31 Thread John W. Krahn
James Edward Gray II wrote:
> 
> On Mar 31, 2004, at 3:09 PM, James Edward Gray II wrote:
> 
> > On Mar 31, 2004, at 3:02 PM, James Edward Gray II wrote:
> >
> >> On Mar 31, 2004, at 2:50 PM, Price, Jason (TLR Corp) wrote:
> >>
> >>> I am working on a script that searches through a log file, looking
> >>> for IP matches based on several ranges of IPs.  I'm trying to find a
> >>> way to do something like this:
> >>>
> >>> @results = grep /192.168.0.[192-254]/, @list
> >>
> >> @results = grep m/192.168.0.\d{3}/ and $1 >= 192 and $1 <= 254, @list;
> >
> > Sorry to reply to my own message, but I believe I made a mistake up
> > there.  I think you have to switch those ands to &&s.  Sorry about
> > that.
> 
> Egad, I forget the parens around the \d{3} too.  Use Paul's solution.
> It's what I meant, minus about five mistakes.  I must be dumb today.

And you (and Paul) forgot to backslash the dots.

@results = grep { /192\.168\.0\.(\d{3})/ and $1 >= 192 and $1 <= 254 } @list;


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Is this possible? (file handles)

2004-03-31 Thread John W. Krahn
Jeff Westman wrote:
> 
> Hi,

Hello,

> I want to remove an empty file using the file handle and not a
> variable name or literal name referencing it.  Something like this:
> 
>  1  #!/bin/perl
>  2  use warnings;
>  3  use strict;
>  4  no strict 'subs';
>  5
>  6  open(F, "> abc") or die "cant create file: $!";
>  7  close(F) or die "cant close file: $!";
>  8
>  9  unlink(\*F) if -z (F);
> 
> But, in this case, I get an error:
> 
> $ runme.pl
> -z on closed filehandle F at ./x line 9.

unlink() requires the file name.  It won't work with the file handle.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Week Numbers lists

2004-03-31 Thread Mike Blezien
Thx's Paul,.. I caught the %0.2d change right away... thought it looked alittle 
weired :)

alot more elegant that what I original had in place,..works great! ;)

Appreciate the help.

--
MikeBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Paul Johnson wrote:
On Wed, Mar 31, 2004 at 11:38:56PM +0200, Paul Johnson wrote:

On Wed, Mar 31, 2004 at 03:23:49PM -0600, Mike Blezien wrote:


Hello,

I need to create a dropdown list of week numbers ranging from the current 
week number to week number 01. The week number would be obtain from a MySQL 
database, IE: select week(curdate()); this equals 13

and from this week#, then I need to generate a list from that week number, 
IE. 12,11,10,09,07,...etc.,  down to 01

What would be the best way in perl to do this ??
How about something like:

 @l = map sprintf("02d", $_), reverse 1 .. $curdate - 1;


Ha!  Now I'm doing it too ;-)

  @l = map sprintf("%02d", $_), reverse 1 .. $curdate - 1;

( Note the addition of a % )





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



RE: Week Numbers lists

2004-03-31 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Mike Blezien wrote:
> Hello,
> 
> I need to create a dropdown list of week numbers ranging from the
> current week number to week number 01. The week number would be
> obtain from a MySQL database, IE: select week(curdate()); this equals
> 13 
> 
> and from this week#, then I need to generate a list from that week
> number, IE. 12,11,10,09,07,...etc.,  down to 01
> 
> What would be the best way in perl to do this ??
> 

Are you to use the the current date and move back or if it is Wed then go back 
to your beginning of week ( Sun )?

Either way, it would be very simple with using localtime to generate from 
today's date back or from Sun or Mon, etc and back.
  Any questions and/or problems, please let me know.

  Thanks.

Wags ;)
Int: 9-8-002-2224
Ext: 408-323-4225x2224



**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Week Numbers lists

2004-03-31 Thread Paul Johnson
On Wed, Mar 31, 2004 at 11:38:56PM +0200, Paul Johnson wrote:
> On Wed, Mar 31, 2004 at 03:23:49PM -0600, Mike Blezien wrote:
> 
> > Hello,
> > 
> > I need to create a dropdown list of week numbers ranging from the current 
> > week number to week number 01. The week number would be obtain from a MySQL 
> > database, IE: select week(curdate()); this equals 13
> > 
> > and from this week#, then I need to generate a list from that week number, 
> > IE. 12,11,10,09,07,...etc.,  down to 01
> > 
> > What would be the best way in perl to do this ??
> 
> How about something like:
> 
>   @l = map sprintf("02d", $_), reverse 1 .. $curdate - 1;

Ha!  Now I'm doing it too ;-)

  @l = map sprintf("%02d", $_), reverse 1 .. $curdate - 1;

( Note the addition of a % )

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: A long time helper needs help

2004-03-31 Thread William.Ampeh




Hello Jenda,

Thanks for your response.  Now I can concentrate on how to hack the code.
What what is your take on how to represent the table entries (cells)?  What
is the most efficient way to associate each cell with its parent header?

That given is:

-

   -Domestic nonfinancial
sectors

-Nonfederal
  ---Households
Business
   Federal  Total  HomeConsumer
   Total  government  nonfederal  Total  mortgage   credit
Total  Corporate
_

1969 7.2-1.1 9.77.7   7.0   8.3
11.6   11.4


How can I efficiently TAG say the following:

 "7.2" with
"-Domestic nonfinancial sectors
",
and "Total"


 "-1.1" with
"-Domestic nonfinancial sectors
",
"Federal",
"government"


And so on?


Thanks for your time.

__

William Ampeh (x3939)
Federal Reserve Board


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Week Numbers lists

2004-03-31 Thread Paul Johnson
On Wed, Mar 31, 2004 at 03:23:49PM -0600, Mike Blezien wrote:

> Hello,
> 
> I need to create a dropdown list of week numbers ranging from the current 
> week number to week number 01. The week number would be obtain from a MySQL 
> database, IE: select week(curdate()); this equals 13
> 
> and from this week#, then I need to generate a list from that week number, 
> IE. 12,11,10,09,07,...etc.,  down to 01
> 
> What would be the best way in perl to do this ??

How about something like:

  @l = map sprintf("02d", $_), reverse 1 .. $curdate - 1;

Make sure you understand everything that is going on there.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Matching ranges of IP addresses

2004-03-31 Thread Smoot Carl-Mitchell
On Wed, 31 Mar 2004 23:09:28 +0200
Paul Johnson <[EMAIL PROTECTED]> wrote:

> On Wed, Mar 31, 2004 at 02:50:30PM -0600, Price, Jason (TLR Corp)
> wrote:
> 
> > I am working on a script that searches through a log file, looking
> > for IP matches based on several ranges of IPs.  I'm trying to find a
> > way to do something like this:
> > 
> > @results = grep /192.168.0.[192-254]/, @list
> > 
> > Which, obviously, doesn't work.  Is there any way to specify a range
> > of multi-digit numbers in a regular expression?
> 
> Does it really need to be a regular expression?

You might consider writing something using the Socket package. It
has a routine, inet_aton to convert an Internet address in dotted
decimal to its numeric representation. You can then convert your initial
address range to two numbers and then convert the dotted decimal
representation of each IP address to a number and do a direct
numeric comparison.

You might also take a look at the CPAN module Net::IP::Match. It looks
like it does what you want to do unless you really want to code up your
own solution from scratch.

-- 
Smoot Carl-Mitchell
Systems/Network Architect
email: [EMAIL PROTECTED]
cell: +1 602 421 9005
home: +1 480 922 7313

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Matching ranges of IP addresses

2004-03-31 Thread Price, Jason (TLR Corp)
Thanks to both James and Paul - that solution worked great.

Thanks!

Jason

-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 31, 2004 3:17 PM
To: Perl Beginners
Cc: Price, Jason (TLR Corp)
Subject: Re: Matching ranges of IP addresses



On Mar 31, 2004, at 3:09 PM, James Edward Gray II wrote:

> On Mar 31, 2004, at 3:02 PM, James Edward Gray II wrote:
>
>> On Mar 31, 2004, at 2:50 PM, Price, Jason (TLR Corp) wrote:
>>
>>> I am working on a script that searches through a log file, looking 
>>> for IP matches based on several ranges of IPs.  I'm trying to find a 
>>> way to do something like this:
>>>
>>> @results = grep /192.168.0.[192-254]/, @list
>>
>> @results = grep m/192.168.0.\d{3}/ and $1 >= 192 and $1 <= 254, @list;
>
> Sorry to reply to my own message, but I believe I made a mistake up 
> there.  I think you have to switch those ands to &&s.  Sorry about 
> that.

Egad, I forget the parens around the \d{3} too.  Use Paul's solution.  
It's what I meant, minus about five mistakes.  I must be dumb today.

James


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Week Numbers lists

2004-03-31 Thread Mike Blezien
Hello,

I need to create a dropdown list of week numbers ranging from the current week 
number to week number 01. The week number would be obtain from a MySQL database, 
IE: select week(curdate()); this equals 13

and from this week#, then I need to generate a list from that week number, IE. 
12,11,10,09,07,...etc.,  down to 01

What would be the best way in perl to do this ??

TIA
--
MikeBlezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Matching ranges of IP addresses

2004-03-31 Thread James Edward Gray II
On Mar 31, 2004, at 3:09 PM, James Edward Gray II wrote:

On Mar 31, 2004, at 3:02 PM, James Edward Gray II wrote:

On Mar 31, 2004, at 2:50 PM, Price, Jason (TLR Corp) wrote:

I am working on a script that searches through a log file, looking 
for IP matches based on several ranges of IPs.  I'm trying to find a 
way to do something like this:

@results = grep /192.168.0.[192-254]/, @list
@results = grep m/192.168.0.\d{3}/ and $1 >= 192 and $1 <= 254, @list;
Sorry to reply to my own message, but I believe I made a mistake up 
there.  I think you have to switch those ands to &&s.  Sorry about 
that.
Egad, I forget the parens around the \d{3} too.  Use Paul's solution.  
It's what I meant, minus about five mistakes.  I must be dumb today.

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Matching ranges of IP addresses

2004-03-31 Thread James Edward Gray II
On Mar 31, 2004, at 3:02 PM, James Edward Gray II wrote:

On Mar 31, 2004, at 2:50 PM, Price, Jason (TLR Corp) wrote:

I am working on a script that searches through a log file, looking 
for IP matches based on several ranges of IPs.  I'm trying to find a 
way to do something like this:

@results = grep /192.168.0.[192-254]/, @list
@results = grep m/192.168.0.\d{3}/ and $1 >= 192 and $1 <= 254, @list;
Sorry to reply to my own message, but I believe I made a mistake up 
there.  I think you have to switch those ands to &&s.  Sorry about 
that.

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Matching ranges of IP addresses

2004-03-31 Thread Paul Johnson
On Wed, Mar 31, 2004 at 02:50:30PM -0600, Price, Jason (TLR Corp) wrote:

> I am working on a script that searches through a log file, looking for
> IP matches based on several ranges of IPs.  I'm trying to find a way
> to do something like this:
> 
> @results = grep /192.168.0.[192-254]/, @list
> 
> Which, obviously, doesn't work.  Is there any way to specify a range
> of multi-digit numbers in a regular expression?

Does it really need to be a regular expression?

@results = grep /192.168.0.(\d+)/ && $1 >= 192 && $1 <= 254, @list;

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Matching ranges of IP addresses

2004-03-31 Thread James Edward Gray II
On Mar 31, 2004, at 2:50 PM, Price, Jason (TLR Corp) wrote:

I am working on a script that searches through a log file, looking for 
IP matches based on several ranges of IPs.  I'm trying to find a way 
to do something like this:

@results = grep /192.168.0.[192-254]/, @list
@results = grep m/192.168.0.\d{3}/ and $1 >= 192 and $1 <= 254, @list;

How's that?

Which, obviously, doesn't work.  Is there any way to specify a range 
of multi-digit numbers in a regular expression?
@results = grep m/192.168.0.(?:19[2-9]|2[0-4]\d|25[0-4])/, @list;

I think that works too, but I don't think it's as simple as the above.  
Season to taste.  ;)

James

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Matching ranges of IP addresses

2004-03-31 Thread Price, Jason (TLR Corp)
I am working on a script that searches through a log file, looking for IP matches 
based on several ranges of IPs.  I'm trying to find a way to do something like this:

@results = grep /192.168.0.[192-254]/, @list

Which, obviously, doesn't work.  Is there any way to specify a range of multi-digit 
numbers in a regular expression?

Thanks.

Jason

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: A long time helper needs help

2004-03-31 Thread Jenda Krynicky
From: <[EMAIL PROTECTED]>
> I have a set of tables that look similar to what I have pasted below:
> 
> (See attached file: page6.prn)(See attached file: page7.prn)
> 
> I am trying to organize the contents of these two files, so allow
> allows users to query the files.
>
> 
>
> PS:  My initial plan is to parse the contents of these files into a
> Perl DBI database, which could then be queried.

This definitely does look like the way to go.
If you do not want to have to install a separate database engine you 
might try DBD::SQLite.

Jenda
P.S.: A long time helper should be able to choose a better subject.
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Is this possible? (file handles)

2004-03-31 Thread Jeff Westman
Hi,

I want to remove an empty file using the file handle and not a
variable name or literal name referencing it.  Something like this:

 1  #!/bin/perl 
 2  use warnings;
 3  use strict;
 4  no strict 'subs';
 5
 6  open(F, "> abc") or die "cant create file: $!";
 7  close(F) or die "cant close file: $!";
 8
 9  unlink(\*F) if -z (F);

But, in this case, I get an error:

$ runme.pl
-z on closed filehandle F at ./x line 9.


TIA,

Jeff

__
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




A long time helper needs help

2004-03-31 Thread William.Ampeh




Hello,

I am currently struggling with this project.  I cannot even decide on the
best way to implement it, let alone start writing the code.

I have a set of tables that look similar to what I have pasted below:


(See attached file: page6.prn)(See attached file: page7.prn)

I am trying to organize the contents of these two files, so allow allows
users to query the files.

So a user can request the value of
"Domestic nonfinancial sectors", "Total", "1972"

which should then print out 10.0


The long term is to convert files of this structure to a "screen readable
HTML" format (508 compliant).

QUESTIONS:
1./ What is the best approach to implement this.  Also are there any
Perl-based programs that can be fine-tuned for this purpose?

2./  Can anyone offer to share a code he/she has written?

Any pointers will be very much appreciated.


PS:  My initial plan is to parse the contents of these files into a Perl
DBI database, which could then be queried.


===

CONTENTS of page6.prn and page7.prn:
===

6 Z.1, March 4, 2004
_
D.1 Debt Growth by Sector\203^G\202\201\205^K 1
In percent; quarterly figures are seasonally adjusted annual rates
-

   -Domestic nonfinancial
sectors

-Nonfederal
  ---Households
Business
   Federal  Total  HomeConsumer
   Total  government  nonfederal  Total  mortgage   credit
Total  Corporate
_

1969 7.2-1.1 9.77.7   7.0   8.3
11.6   11.4
1970 6.9 4.2 7.64.4   4.4   3.4
10.3   12.9
1971 9.5 8.3 9.89.2   8.5  11.7
10.17.8
197210.0 4.611.4   11.3  11.2  13.1
12.59.9
197310.7 2.012.9   12.4  11.7  13.3
14.7   17.5
1974 9.2 3.410.58.8   9.7   4.6
13.0   11.5
_




Z.1, March 4, 2003
7
_

F.206 Money Market Mutual Fund Shares
Billions of dollars; quarterly figures are seasonally adjusted annual rates
_

  20022003
-2002-  -2003-
   Q3
Q4  Q1
_

 1  FA63405  Net issues   -16.8  -207.8  -124.0
201.5  -394.2 1

 2  FA63405  Net purchases-16.8  -207.8  -124.0
201.5  -394.2 2

 3  FA153034005Household sector   -40.2   -90.282.1
-164.0  -185.3 3
 4  FA103034003Nonfinancial corporate bu   26.9   -52.7   -47.6
163.5   -38.5 4
 5  FA113034003Nonfarm noncorporate busi2.3-8.2-6.6
14.9-5.5 5

 6  FA603034003Bank personal trusts and 1.3-9.2 1.3
1.3-9.2 6
 7  FA543034003Life insurance companies   -13.5-8.3   -55.8
7.4   -28.2 7
 8  FA573034003Private pension funds2.8 2.9 2.8
2.8 2.9 8
 9  FA503034003Funding corporations 3.6   -42.1  -100.3
175.5  -130.3 9
_



___

William

page6.prn
Description: Binary data


page7.prn
Description: Binary data
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 


Re: (FOUO) PERL question ...

2004-03-31 Thread WC -Sx- Jones
Johnson, Michael wrote:
CLASSIFICATION: UNCLASSIFIED
SECURITY CONTROL MARKING: FOR OFFICIAL USE ONLY
Who offers the very best training in PERL ?

Thanks, Mike
http://stonehenge.com/
http://training.perl.com/ (Seems slow?)
There are MANY...

I would mainly say that you should just
read a lot at -
http://learn.perl.org/

Research at http://perlmonks.org/ or invite
your local http://pm.org/
HTH/Bill

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



(FOUO) PERL question ...

2004-03-31 Thread Johnson, Michael
CLASSIFICATION: UNCLASSIFIED
SECURITY CONTROL MARKING: FOR OFFICIAL USE ONLY

Who offers the very best training in PERL ?

Thanks, Mike

Classification: UNCLASSIFIED
Security Control Marking: FOR OFFICIAL USE ONLY


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: What is happening here

2004-03-31 Thread Jeff 'japhy' Pinyan
On Mar 30, R. Joseph Newton said:

>Jeff 'japhy' Pinyan wrote:
>
>> The main problem is the PRECEDENCE.  Your ? : line is run like so:
>>
>>   ((++$count) ? ($count += $count--) : $count) += $count++;
>
>Have you tested this?  I don't see the precedence issue happening here.
>Could you try duplicating these reults with code explicitly specifying
>the precedence you show?  I do not think you are going to find that the
>outer parentheses you show represent the actual precedence.  Remember
>that the ? and : are not different operators, but different parts of the
>same operator.  If the += operator has a higher precedence than ?, it
>will also have a higher precedence than :.

Yes, I have tested it, and it's documented.  ?: binds TIGHTER than +=.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
CPAN ID: PINYAN[Need a programmer?  If you like my work, let me know.]
 what does y/// stand for?   why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: gtk problem

2004-03-31 Thread Wiggins d Anconia
> 
> Hi Sir,
> 
> I have this problem regarding perl.
> 
> Cant figure this out. Hope ypu can help. Thanks.
> 
> 
> 
>  compile command ===
> 
> > [EMAIL PROTECTED] gtk]# perl -c enrollm.pl
> 
> > = error msg

> 
> > Can't locate Gtk.pm in @INC (@INC contains: 
> 
> > /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 
> 
> > /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi 
> 
> > /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl 
> 
> > /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi 
> 
> > /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl 
> 
> > /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at 
> 
> > enrollm.pl line 13.
> 
> > BEGIN failed--compilation aborted at enrollm.pl line 13.
> 

I don't know how much you know so don't take this the wrong way,  do you
have the Gtk Perl module installed?  If not, you will need to confirm
that you have 'make' and a c compiler as well as the gtk c libs
installed, and then install the Gtk module.

If you know that Gtk.pm is installed, come back and tell us where, we
can provide ways to get rid of your error...

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Regexp match question !

2004-03-31 Thread Wiggins d Anconia
> Hi everybody,
> 

> 
> Can someone give me a hint and maybe a source for more
> basic dokumentation about reg exp.
> 

perldoc perlretut
perldoc perlre

The first is in a tutorial style and should be an easier read than the
more reference like second.  You might also want to pickup "Learning
Perl" from O'Reilly, other than the excellent Perl information, it also
contains a beginners step into regexp.

Good luck,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: more on warn .. is next necessary

2004-03-31 Thread Jenda Krynicky
From: Harry Putnam <[EMAIL PROTECTED]>
> I wasn't able to really understand perldoc -f warn.
> 
> I'm doing
> use File::Find;
> open(FILE,"<$File::Find::name")or warn "blah blah: $!";
> 
> Two things I'm unsure of:
> 
> 1) is the `: $!' meaningfull here?
> 2) do I need a `next;' following to make `File::Find' go on to the
> next found file?
> 
> If so, how do I let the `next' know that open has failed?
> That is, how do I test exit status of open function?  Is it just as in
> shell programing ($?)? 

open(FILE,"<$File::Find::name")
or warn "blah blah: $!" and next;

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How to determine if STDIN has piped data?

2004-03-31 Thread Smoot Carl-Mitchell
On Tue, 30 Mar 2004 21:35:21 -0700
Bryan Harris <[EMAIL PROTECTED]> wrote:


> > Please keep in mind that doing this breaks the de facto Unix
> > standard for filters.  A simply command which is a filter (e.g takes
> > input from STDIN and sends output to STDOUT) is written without any
> > consideration whether the input is a terminal, pipe, socket or
> > otherwise. This makes it very simple to use the command in a
> > pipeline or standalone from the terminal.

> Strangely, I find that we almost always want our scripts to act this
> way. If any files or data is passed to the script, then it uses it. 
> Otherwise, it prints usage instructions (since we'd rather not have
> man pages for scripts, and I don't know how to build them anyway).
> 
> I mention this because I'm interested in hearing your thoughts on this
> methodology.

It really comes down to personal taste and what your users expect. My
usual convention for scripts is to use the '-h' or the '--help' flag to
display short help information. It is any easy and standard way to
display help info.

I find the ability of a script to also accept input from a terminal is a
useful learning tool and also lets a user easily see how a simple filter
works. It can be annoying to run a command and then have it seemingly do
nothing as it waits for user input. In those cases, for complex scripts
I have set up prompting when input is from a terminal.

I can certainly see the rationale for your methodology. If you are
comfortable with it and your users are comfortable with it, I would
stick to it.

> By the way, what's a socket?

Usually, a network protocol end-point which for most I/O purposes looks
like a file handle. Instead of reading or writing from a file, the
program reads or writes a socket which is typically connected to
another program via a network protocol which is either local or remote.
See perldoc -f socket.

-- 
Smoot Carl-Mitchell
Systems/Network Architect
email: [EMAIL PROTECTED]
cell: +1 602 421 9005
home: +1 480 922 7313

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How Random is Random?

2004-03-31 Thread John W. Krahn
Phil Schaechter wrote:
> 
> The documentation on "keys" and "each" says something like the following:
> 
> ---
> Returns a list consisting of all the keys of the named hash. (In scalar
> context, returns the number of keys.) The keys are returned in an apparently
> random order.
> ---
> 
> I have a database (>50,000 items) that I would like to select things from
> randomly.  I would like to "eventually" select all of the items from the
> database, but there are no time constraints.  The database is constantly
> being changed.
> 
> If I use keys to select 100 items to process, then come back at a later date
> and pick another 100, and so on, will I eventually hit "most" of the items?
> 
> My own experiments show this to be more or less true - but I'd like to know if
> anyone can explain to me how random is random.

You will note that the documentation says "apparently random order."  In
more recent versions of Perl (IIRC starting at 5.8.1) randomness was
added to hash keys for security reasons.  In previous versions the order
of the hash keys was determined by the hash function used which appeared
random because it was not the same order that the keys were entered.
As to your question, if the hash keys remain the same then the order
will remain the same.  However, if you add or delete keys then the order
may change.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Regexp match question !

2004-03-31 Thread John W. Krahn
Daniel Stellwagen wrote:
> 
> Hi everybody,

Hello,

> I am a beginner of programming ( so I am a beginner of perl programming
> too :-) ) and I have this very basic problem but cannot handle it.
> 
> I'm trying to match only a one single digit and wrote this code:
> 
> use strict;
> 
> my $number = 11;# two-digit number
> 
> if ( $number =~ /\d{1}\b/ ) {
> print "Match\n";
> } else {
> print "No Match\n";
> }
> 
> But I get a match !?
> I also tried:
> 
>$number =~ /\d?\b/
> because ? stands for no or one character
> 
> But that didn't work either.
> 
> Can someone give me a hint and maybe a source for more
> basic dokumentation about reg exp.

Your regular expression has a word boundary (\b) anchor after a single
digit character class (\d).  That will match the digit '7' in the
following examples: '  567  ', '567*&^%', '567', etc.  You have to
anchor both sides of the expression you want to match:

if ( $number =~ /\b\d\b/ ) {

Or more probably:

if ( $number =~ /\A\d\z/ ) {


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Regexp match question !

2004-03-31 Thread WC -Sx- Jones
Daniel Stellwagen wrote:
my $number = 11;# two-digit number


my $number;

while ($number < (5*11)) {
  ++$number =~ /(\d)(\d)?/;
  print "Seen $1 and $2 \tby looking at $number\n";
}
__END__

HTH/Sx

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: How to determine if STDIN has piped data?

2004-03-31 Thread WC -Sx- Jones
Bryan Harris wrote:

By the way, what's a socket?

Depends upon network type and OpSys

Basically a socket is a place to send
data and "not worry" too much about where
it went.  A pipe (usually a named
permanent connection) is set-up between
two sockets or two points.  You can encrypt
data traveling over a pipe by function of the
pipe - but you usually must encrypt data
before sending it to a socket.
A Socket is typically between
applications and  their data and
pipes are between applications.
An example is MySQL:

*.mysql  *.*  0 0 49152 0 LISTEN

30001558e50 stream-ord 300026159e0  /tmp/mysql.sock

This is a local Unix Socket where MySQL
awaits a connection.
man or perldoc -

IO::Handle
IO::Seekable
IO::File
IO::Pipe
IO::Socket
IO::Dir
HTH/Sx

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: How Random is Random?

2004-03-31 Thread Bram Mertens
On Tue, 2004-03-30 at 20:48, Phil Schaechter wrote:
[...]
> If I use keys to select 100 items to process, then come back at a later date 
> and pick another 100, and so on, will I eventually hit "most" of the items?
> 
> My own experiments show this to be more or less true - but I'd like to know if 
> anyone can explain to me how random is random.

I don't know much about "Perl's random" but random in a statistical or
mathematical context means that "over a large enough period of time" ALL
possible "answers" will occur.  But it also means that the same answer
could return 70 times before any other is returned.

However I suppose that theoretically if you keep altering the database,
the calculation of the random number changes as well which IMHO might
cause some records te be 'skipped'.  But that's more speculation than
knowledge...

HTH (a bit)

Bram
-- 
# Mertens Bram "M8ram"   <[EMAIL PROTECTED]>  Linux User #349737 #
# SuSE Linux 8.2 (i586) kernel 2.4.20-4GB  i686 256MB RAM #
# 11:30am  up 9 days 15:07,  11 users,  load average: 0.08, 0.02, 0.01 #


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




gtk problem

2004-03-31 Thread Philip Villamin
Hi Sir,

I have this problem regarding perl.

Cant figure this out. Hope ypu can help. Thanks.



 compile command ===

> [EMAIL PROTECTED] gtk]# perl -c enrollm.pl

> = error msg 

> Can't locate Gtk.pm in @INC (@INC contains: 

> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 

> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi 

> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl 

> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi 

> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl 

> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at 

> enrollm.pl line 13.

> BEGIN failed--compilation aborted at enrollm.pl line 13.

> 





Sincerely,

Philip Villamin



AW: gtk problem

2004-03-31 Thread Schell, Holger
Hi,
either u installed the module Gtk.pm wrong or u did not include it in your @INC path...
add the path where the Gtk.pm module is stored to your @INC to get the module...

BEGIN { unshift (@INC, #path of Gtk.pm); }



Best regards,

Holger Schell

SAP AG, 
68789 Rot (Germany) 
Non-ABAP Production Services
SAP Production
Student

Phone:  +49 6227 7- 66814
Fax:  +49 6227 78-38366
ROT15, CU.01

-Ursprüngliche Nachricht-
Von: Philip Villamin [mailto:[EMAIL PROTECTED] 
Gesendet: Mittwoch, 31. März 2004 20:52
An: [EMAIL PROTECTED]
Betreff: gtk problem

Hi Sir,

I have this problem regarding perl.

Cant figure this out. Hope ypu can help. Thanks.



 compile command ===

> [EMAIL PROTECTED] gtk]# perl -c enrollm.pl

> = error msg 

> Can't locate Gtk.pm in @INC (@INC contains: 

> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 

> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi 

> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl 

> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi 

> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl 

> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .) at 

> enrollm.pl line 13.

> BEGIN failed--compilation aborted at enrollm.pl line 13.

> 





Sincerely,

Philip Villamin


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




How Random is Random?

2004-03-31 Thread Phil Schaechter
The documentation on "keys" and "each" says something like the following:

---
Returns a list consisting of all the keys of the named hash. (In scalar 
context, returns the number of keys.) The keys are returned in an apparently 
random order.
---

I have a database (>50,000 items) that I would like to select things from 
randomly.  I would like to "eventually" select all of the items from the 
database, but there are no time constraints.  The database is constantly 
being changed.

If I use keys to select 100 items to process, then come back at a later date 
and pick another 100, and so on, will I eventually hit "most" of the items?

My own experiments show this to be more or less true - but I'd like to know if 
anyone can explain to me how random is random.

-Phil

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]