Re: Finding IP address connected to your http server.

2003-01-17 Thread Gary Stainburn
On Friday 17 Jan 2003 7:18 am, simran wrote:
> if (you are looking for connections that have come in over time) then
>   look in the log file
> else if i you are looking for the ip that is current connecting to the cgi
> script you can usually find that info in the environment variable
> REMOTE_ADDR - $ENV{'REMOTE_ADDR'} else
>   there is probably a way to get the remote ip in javascript as well, if
> that is what you want endif
>
> On Fri, 2003-01-17 at 17:50, [EMAIL PROTECTED] wrote:
> > Hey,
> >
> > My friend is doing some web programming with perl, and wanted me to help
> > him do something. He wants to create a script that will show all the IPs
> > that are connected to the http server. I have looked on through several
> > sites, and even a couple fo books I own. Yet I have failed to find a
> > solution for this. If you can come up with some tips or help, please send
> > them to [EMAIL PROTECTED]
> >
> > Thank you for your time,
> >
> > Tyler Mace
> > Application Programmer
> > Sunergize, Inc.

Please bear in mind that this IP address is in all probability NOT the IP 
adress of the browser, but that of some cache in between.  If you want this - 
as I did, to enable reverse connections to be made, then this will be no good 
(one of my machines on a dial-up with dynamic IP contacting my web server 
with a 'here-I-am' message, and then the web server making an outbount ssh 
connection).  

There is no direct method of doing this other than getting the browser to pass 
it's IP address, probably as someone said, by using a javascript.

Although this is probably completely useless to you, I got round the problem 
by having my dial-up box use wget to call a CGI and from the ip-up script, 
passing the local IP as an argument.


-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


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




Re: ppm: No suitable installation target for package G

2003-01-17 Thread David Eason
It installs now, thanks so much for your help!



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




Re: [CiRT] Finding IP address connected to your http server.

2003-01-17 Thread Jonathan Gill
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Are you looking for someway to process the log files from the web server or do 
you want to see what is _directly_ connected at the time?

If you are looking for ways to process logs, then check the perl cookbook 
(oreilly) that has some examples in the back of how to do this.  

Else you will need to write some sort of module for the web server that will 
record the connection, either that or maybe proces the output of "netstat | 
grep 80" as a guess.

HTH

- -- 
Jonathan Gill 
SecureCiRT, A SBU of Z-Vance Pte Ltd
http://www.securecirt.com/
PGP : 315C 314D CD36 CBFF 728E F167 FCD8 15B7 0287
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+J6wV/Nj+exW3AocRAiT5AJ9orptoqnpJ/A/kt300R3KYrdLuUgCgj8TV
ZKGOME/GhoHTplAsNYId4HQ=
=jond
-END PGP SIGNATURE-


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




doubt in mysql

2003-01-17 Thread kasi ramanathen

i'm to update a pearl programme using mysql, i know only less of the latter. i come 
across a statement 

$ver=$dbh->prepare(SELECT jobid, pid from jobs where exectime


Re: Finding IP address connected to your http server.

2003-01-17 Thread Victor Tsang
Maybe we should bring this discussion out to a more appropiate list, but
anyways,  have a look into this doc.

http://dev.zope.org/Wikis/DevSite/Proposals/RemoteAddrAndAccelerators

This is not perfertly reliable, but you might want to consider it.

Tor.


> 
> Please bear in mind that this IP address is in all probability NOT the IP
> adress of the browser, but that of some cache in between.  If you want this -
> as I did, to enable reverse connections to be made, then this will be no good
> (one of my machines on a dial-up with dynamic IP contacting my web server
> with a 'here-I-am' message, and then the web server making an outbount ssh
> connection).
> 
> There is no direct method of doing this other than getting the browser to pass
> it's IP address, probably as someone said, by using a javascript.
> 
> Although this is probably completely useless to you, I got round the problem
> by having my dial-up box use wget to call a CGI and from the ip-up script,
> passing the local IP as an argument.
> 
> --
> Gary Stainburn
> 
> This email does not contain private or confidential material as it
> may be snooped on by interested government parties for unknown
> and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
> 
> --
> 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]




Re: determining location of character in array....

2003-01-17 Thread Rob Dixon
Mike Liss wrote:
> Hello,
>
> Is there an easy way to get the location of a specific instance of a
> character
> in an array?
>
> for example:
>
> $MyArray = "This is the test";
>
> I would like to know the index of the first occurence of the letter
> "h" ( 1 )

Hi Mike

I thought you may be interested in an alternative.

$str =~ m/\Q$substr/g;
print pos($str) - length($substr), "\n";

which is similar to 'print index $str, $substr, "\n"' but has the
advantage that it works on a regular expression. It can also be put into
a loop without troubling to use index's third 'position' parameter.

while ( $str =~ m/\Q$substr/g )
{
print pos($str) - length($substr), "\n";
}

Cheers,

Rob




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




[perl #20364] How to use com components in perl

2003-01-17 Thread Pankaj Kapare
Sir,
I want know how to  use com components developed in c++  within perl script.
Thanking you!
pankaj.




Length of String

2003-01-17 Thread Ho, Tony
Hi guys
Do you know whether there is a function in perl to find the size of a string
?
For example, "06" would be size 2.

Cheers
Tony



RE: Length of String

2003-01-17 Thread NYIMI Jose (BMB)
C:\>perl -e "print length('06')";
2
C:\>

See 
perldoc -f length

José.

> -Original Message-
> From: HO Tony (CSG) 
> Sent: Friday, January 17, 2003 12:08 PM
> To: '[EMAIL PROTECTED]'
> Subject: Length of String
> 
> 
> Hi guys
> Do you know whether there is a function in perl to find the 
> size of a string ? For example, "06" would be size 2.
> 
> Cheers
> Tony
> 


 DISCLAIMER 

"This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer".

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




RE: [perl #20364] How to use com components in perl

2003-01-17 Thread Beau E. Cox
Hi -

> -Original Message-
> From: Pankaj Kapare [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 17, 2003 1:04 PM
> To: [EMAIL PROTECTED]
> Subject: [perl #20364] How to use com components in perl
> 
> 
> Sir,
> I want know how to  use com components developed in c++  within 
> perl script.
> Thanking you!
> pankaj.
> 
> 

I really haven't done this, but I think a good
starting point would be the CPAN module Win32::OLE.

Aloha => Beau;


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




RE: Perl book

2003-01-17 Thread Dylan Boudreau
Thanks to everyone for all their advice on what book to go with next.  I
think I am going to go with the Perl Black Book for now but I am sure I
will eventually buy Perl Cookbook and Programming Perl.  I can't really
wait a couple of months because I hate my job and the learning of Perl
is key to getting a new one :-)

Cheers,

Dylan

-Original Message-
From: Randal L. Schwartz [mailto:[EMAIL PROTECTED]] 
Sent: January 15, 2003 11:23 PM
To: [EMAIL PROTECTED]
Subject: Re: Perl book


> "Dylan" == Dylan Boudreau <[EMAIL PROTECTED]> writes:

Dylan> I have already read Learning Perl and am looking to get another 
Dylan> book to learn more what would people recommend?

If you liked Learning Perl, and can wait a few months, I might be able
to recommend another book that would fit quite nicely.  :-)

print "Just another Perl [book] hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095 <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See
PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!

-- 
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]




Re: doubt in mysql

2003-01-17 Thread Jenda Krynicky
From: kasi ramanathen <[EMAIL PROTECTED]>
> i'm to update a pearl programme using mysql, i know only less of the
> latter. i come across a statement 
> 
> $ver=$dbh->prepare(SELECT jobid, pid from jobs where exectime 
> now i want to know the perpose of " statement

The < is just a less than. Nothing special about it. The ? is a so-
called placeholder. It means "the parameter will be inserted here".

This allows you to do:

$ver=$dbh->prepare('SELECT jobid, pid from jobs where exectime < 
?');
...
$RS = $ver->execute('2003-1-13');

and it will execute the
SELECT jobid, pid from jobs where exectime < '2003-1-13'
statement and return the rows.

You should use ->prepare() and ->execute() if you plan to use the 
same statement many times and all you need is to change a few 
parameters.
This will allow the SQL server to "compile" the statement and prepare 
the "execution plan" just once and then reuse it.

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]




help in lwp

2003-01-17 Thread kasi ramanathen

use LWP::Simple;
getprint("http://www.yahoo.com/";);

this code will print the whole yahoo page as html output in your system.

but instud of using simple i want to use UserAgent. shall you give me the code so that 
i can cut and past and run the program. please response quickly

Catch all the cricket action. Download Yahoo! Score tracker


Re: Script that runs on my Win98 box and the Unix server

2003-01-17 Thread Rob Richardson
Joe,

Maybe this is a difference between ActivePerl and IndigoPerl.  I'm
using Indigo, although I also have ActivePerl on my machine.  

But I created a folder named c:\usr\bin and copied perl.exe into it,
and it's working.

RobR

--- "R. Joseph Newton" <[EMAIL PROTECTED]> wrote:
> "...Is there any way I can have two different paths to the Perl
> executable,
> and let my script decide which to use?"  Rob
> 
> Hi Rob,
> 
> You shouldn't need to, probably.  At least on Win 2K, ActiveState
> Perl ignores the comment line completely.  If you have it properly
> installed, the paths should alredy be set, and *.pl should be
> r3egistered for the Perl executable.  If not, you should re-install
> with the latest version.  You will have to configure for perl CGIs in
> IIS, if you are using the native web services.
> 
> Joseph
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




RE: help:how to hex2bin,bin2hex,bin2dec,dec2bin

2003-01-17 Thread murphy, daniel (BMC Eng)
I remember seeing this awhile ago on this list and saved it:



bin2dec:
 
  $out = unpack("N", pack("B32", substr("0" x 32 . $in, -32))); 
 
bin2hex:
 
  $out = unpack("H8", pack("B32", substr("0" x 32 . $in, -32))); 
 
bin2oct:
 
  $out = sprintf "%o", unpack("N", pack("B32", substr("0" x 32 . $in,
-32))); 
 
dec2bin:
 
  $out = unpack("B*", pack("N", $in));
 
dec2hex:
 
  $out = unpack("H8", pack("N", $in));
 
dec2oct:
 
  $out = sprintf "%o", $in;
 
hex2bin:
 
  $out = unpack("B32", pack("N", hex $in));
 
hex2dec:
 
  $out = hex $in;
 
hex2oct:
 
  $out = sprintf "%o", hex $in;
 
oct2bin:
 
  $out = unpack("B32", pack("N", oct $in));
 
oct2dec:
 
  $out = oct $in;
 
oct2hex:
 
  $out = unpack("H8", pack("N", oct $in));
 



-Original Message-
From: billy [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 16, 2038 8:55 PM
To: [EMAIL PROTECTED]
Subject: help:how to hex2bin,bin2hex,bin2dec,dec2bin


are there some commands or function?
thanks for your response.

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




write to file

2003-01-17 Thread Thomas Browner
How do I use perl to write to a file?

 

Thomas 

 




Re: baffling script behavior- root loses files

2003-01-17 Thread zentara
On Thu, 16 Jan 2003 22:34:53 +0100, [EMAIL PROTECTED] (Jenda Krynicky)
wrote:

>> are missing, seemingly random:
>
>Ahh the usual mistake.
>
>The readdir() returns just the file and subdirectory names, not 
>complete paths.
>
>Therefore if you opendir() some other directory than '.' you have to 
>prepend that directory to the filenames before you do the tests.
>Otherwise you are looking at the files in the current directory.
>
>Try
>   foreach (@files){push @movem,$_ if -f "$homedir/$_"}

Thanks guys. It makes sense now. I guess I should have taken a clue
from the fact that it worked until I switched directories. 
I guess I was thrown off by the fact that I did get some output, but
not the full output. I guess this is one of those areas where Perl
will do something unpredictable?



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




Re: Length of String

2003-01-17 Thread Bill Akins
perldoc -f length

#!/usr/local/bin/perl -w
use strict;
my $foo = "This is 10";
my $i = (length $foo);
print "The string is $i charecters long!\n";


>>> "Ho, Tony" <[EMAIL PROTECTED]> 01/17/03 06:08AM >>>
Hi guys
Do you know whether there is a function in perl to find the size of a string
?
For example, "06" would be size 2.

Cheers
Tony


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




RE: write to file

2003-01-17 Thread Dylan Boudreau
open FILEHANDLE, "> output.txt" or die "$!";
print FILEHANDLE "Some text\n";
print FILEHANDLE "Some more text\n";
close FILEHANDLE;


Dylan


-Original Message-
From: Thomas Browner [mailto:[EMAIL PROTECTED]] 
Sent: January 17, 2003 10:22 AM
To: [EMAIL PROTECTED]
Subject: write to file


How do I use perl to write to a file?

 

Thomas 

 




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




Re: help in lwp(I GOT ANSWER)

2003-01-17 Thread kasi ramanathen

i was waiting for answer but nune came i myself found solution. if it is useful to 
someone just cut and paste this programe and see the output

use LWP::UserAgent;
$ua=LWP::UserAgent->new;
#$ua->agent("Mozilla/3.0");
$req=new HTTP::Request(GET=>"http://www.yahoo.com";);
$res=$ua->request($req);
print $res->content;


 kasi ramanathen <[EMAIL PROTECTED]> wrote:


use LWP::Simple;
getprint("http://www.yahoo.com/";);

this code will print the whole yahoo page as html output in your system.

but instud of using simple i want to use UserAgent. shall you give me the code so that 
i can cut and past and run the program. please response quickly

Catch all the cricket action. Download Yahoo! Score tracker

kasi 

perl programmer 

at stringinfo, india

Catch all the cricket action. Download Yahoo! Score tracker


passing arguments to a subroutine to try and match two fields in a text file

2003-01-17 Thread Le Blanc, Kerry (Kerry)
I think I am getting close. With much help I have been able to tweek my original code 
down quite a bit. For the most part, everything is working as it should. What is 
stumping me right now is, how do I make sure that both the part number and the rev 
match before printing out the record. The part number is in $fields[0], the rev is in 
$fields[1]. The two fields are seperated by a pipe. I am attempting to send both 
inputs to the subroutine as arguments. thanks for any hints towards the right 
direction.
 
 
#!/usr/bin/perl -w
 
use strict;
use Data::Dumper;
 

print "Enter the Part Number you wish to search for: ";
my $part = ;
chomp($part);

print "Enter the Revison for ($part): ";
my $rev = ;
   chomp($rev);
 
my $searchresult = &search(part => $part, rev => $rev);
 

if (defined $searchresult) {
 print "Located Part Number $part: $$searchresult[1]\n";<-- How can I print all the 
fields without typing in each field
}else {   individually?
 print "Your Part Number ($part) could not be found...\n";
}
 
# This routine will accept a part number and rev as anonymous
# hashes, and search thru a text file returning the entire
# record (pipe delineated) of the 1st occurence
 
sub search {
 my %args = @_;
 my $retval;
 
 local *FH;
 open (FH, './fai.txt') || die "Cannot open file: ($!)";
 my @parts = ;
 my @rev = ;
 foreach my $line (@parts, @rev) {
  my @fields = split(/\|/, $line);
  if ($args{part} eq $fields[0], $fields[1]) { <-- this is as close as I have gotten 
so far
   $retval = \@fields;
   last;
  }
 }
 close FH;
 return $retval;
}

Kerry LeBlanc 
Materials Auditor 
Process Owner 
75 Perseverence Way 
Hyannis, MA. 02601 
1-508-862-3082 
http://www.vsf.cape.com/~bismark   

 



Re:perl confusion/ and passwd

2003-01-17 Thread RF
> 2) Since 5.6.1 is installed right now, can I install
> 5.8.0 over it without uninstalling 5.6.1? (Btw,
> I'm running Slackware Linux 8.0).

You may want to look at the latest issue of the Perl Journal
(www.tpj.com).  It has an excellent article by Matthew O. Persico
entitled: Juggling Perl Versions.  It has advice and scripts to help you
maintain multiple versions of Perl.

Best of luck.

Rashid




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




RE: passing arguments to a subroutine to try and match two fields in a text file

2003-01-17 Thread wiggins
See inline.


On Fri, 17 Jan 2003 11:01:58 -0500, "Le Blanc, Kerry (Kerry)" <[EMAIL PROTECTED]> 
wrote:

> I think I am getting close. With much help I have been able to tweek my original 
>code down quite a bit. For the most part, everything is working as it should. What is 
>stumping me right now is, how do I make sure that both the part number and the rev 
>match before printing out the record. The part number is in $fields[0], the rev is in 
>$fields[1]. The two fields are seperated by a pipe. I am attempting to send both 
>inputs to the subroutine as arguments. thanks for any hints towards the right 
>direction.
>  
>  
> #!/usr/bin/perl -w
>  
> use strict;
> use Data::Dumper;
>  
> 
> print "Enter the Part Number you wish to search for: ";
> my $part = ;
> chomp($part);
> 
> print "Enter the Revison for ($part): ";
> my $rev = ;
>chomp($rev);
>  
> my $searchresult = &search(part => $part, rev => $rev);
>  
> 
> if (defined $searchresult) {
>  print "Located Part Number $part: $$searchresult[1]\n";<-- How can I print all the 
>fields without typing in each field
> }else {   individually?
>  print "Your Part Number ($part) could not be found...\n";
> }
>  
> # This routine will accept a part number and rev as anonymous
> # hashes, and search thru a text file returning the entire
> # record (pipe delineated) of the 1st occurence
>  

Actually it is just accepting a list, which it is automagically turning into a hash 
(plain not anonymous) for you.

> sub search {
>  my %args = @_;
>  my $retval;
>  
>  local *FH;
>  open (FH, './fai.txt') || die "Cannot open file: ($!)";
>  my @parts = ;
>  my @rev = ;

This stores two copies of the file in memory, do you need two copies?

>  foreach my $line (@parts, @rev) {

This (I believe) is going to combine @parts and @rev so you will step through the file 
twice.  Are you expecting alternating lines in the file?

>   my @fields = split(/\|/, $line);
>   if ($args{part} eq $fields[0], $fields[1]) { 

if (($args{'part'} eq $fields[0]) && ($args{'rev'} eq $fields[1])) {

>$retval = \@fields;
>last;
>   }
>  }
>  close FH;
>  return $retval;
> }
> 

http://danconia.org

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




using if(0) statements

2003-01-17 Thread Johnson, Shaunn
Howdy:

I am not familiar with using 'if' in a script and I have
come across a list of new scripts that I now
have to learn / maintain.  In most of the scripts,
there are things that begins with if (0).

Say, for example:

--[code]

if (0) {
$path="$dest/new_local";
makepath ($path);
&first(1);
}

--[/code]

I'm not clear on a few things.  First, with  'if (0)',
is this expecting that the commands BEFORE 
this returns a true / competed successful
value before it runs through this part of the
code?  Or, is this another way of saying
'while true; do ...  ; done' ?

Also, is 'makepath' an ACTUAL command?  I've never
seen that before.

Thanks!

-X



Re: using if(0) statements

2003-01-17 Thread Jenda Krynicky
From: "Johnson, Shaunn" <[EMAIL PROTECTED]>
> I am not familiar with using 'if' in a script and I have
> come across a list of new scripts that I now
> have to learn / maintain.  In most of the scripts,
> there are things that begins with if (0).
> 
> Say, for example:
> 
> --[code]
> 
> if (0) {
> $path="$dest/new_local";
> makepath ($path);
> &first(1);
> }
> 
> --[/code]

This is basicaly just a comment. if(0) {...} will be removed from the 
script by the optimizer. 
 
> Also, is 'makepath' an ACTUAL command?  I've never
> seen that before.

Well File::Path contains mkpath(), but I don't know this. Are you 
sure it's not defined elsewhere in the script or any of the modules 
it uses?

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: using if(0) statements

2003-01-17 Thread Ben Siders
Since it's commented out, it could be that somebody removed that 
function in previous maintenance.
Jenda Krynicky wrote:

From: "Johnson, Shaunn" <[EMAIL PROTECTED]>
 

I am not familiar with using 'if' in a script and I have
come across a list of new scripts that I now
have to learn / maintain.  In most of the scripts,
there are things that begins with if (0).

Say, for example:

--[code]

if (0) {
$path="$dest/new_local";
makepath ($path);
&first(1);
}

--[/code]
   


This is basicaly just a comment. if(0) {...} will be removed from the 
script by the optimizer. 

 

Also, is 'makepath' an ACTUAL command?  I've never
seen that before.
   


Well File::Path contains mkpath(), but I don't know this. Are you 
sure it's not defined elsewhere in the script or any of the modules 
it uses?

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


 


--
Benjamin J. Siders
Software Engineer




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




Re: passing arguments to a subroutine to try and match two fields in a text file

2003-01-17 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
>>  open (FH, './fai.txt') || die "Cannot open file: ($!)";
>>  my @parts = ;
>>  my @rev = ;
>
> This stores two copies of the file in memory, do you need two copies?
>

It doesn't actually. The first assignment leaves you at end-of-file so
subsequent reads fail. @parts will contain all of the file records and
@rev will be empty.

Also need to chomp @parts, otherwise the last field will have a trailing
"\n".

And @parts is a misconception - should be @records or something.

>>  foreach my $line (@parts, @rev) {
>
> This (I believe) is going to combine @parts and @rev so you will step
> through the file twice.  Are you expecting alternating lines in the
> file?

Yes and no, in that order! @rev is empty as I said, so this is the same
as

while (my $line = ) {

without the above array reads. This is the preferable way to do it,
although it's probably worth declaring

our @lines =  unless @lines;
chomp @lines;

to keep a persistent copy of the file for multiple calls to the routine.
(But let's get it working first :)

>
>>   my @fields = split(/\|/, $line);
>>   if ($args{part} eq $fields[0], $fields[1]) {
>
> if (($args{'part'} eq $fields[0]) && ($args{'rev'} eq $fields[1]))
{

(No need for quotes or internal parentheses, for what it's worth)

>
>>$retval = \@fields;
>>last;

It's more concise if you just close the file and 'return' out of the
loop at this level:

close FH;
return \@fields;

>>   }
>>  }
>>  close FH;
>>  return $retval;

Just:

return undef;

>> }

I hope that's fairly clear. It's getting a bit of a mess :-/

Rob




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




RE: passing arguments to a subroutine to try and match two fields in a text file

2003-01-17 Thread Le Blanc, Kerry (Kerry)
I made some changes. Now I get an error message.

The message says "Can't use string ("") as an ARRAY ref while "strict refs" in use"

Here is the code as it stands now, with changes.



#!/usr/bin/perl -w

use strict;
use Data::Dumper;
use diagnostics -verbose;


print "Enter the Part Number you wish to search for: ";
my $part = ;
   chomp($part);
   
print "Enter the Revison for ($part): ";
my $rev = ;
   chomp($rev);

my $searchresult = &search(part => $part, rev => $rev);


if (defined $searchresult) {
print "Located Part Number $part: $$searchresult[1..7]\n";

}else {
print "Your Part Number ($part) Rev ($rev) could not be found...\n";
}


# This routine will accept a part number as an anonymous
# hash, and search thru a text file returning the entire
# record (pipe delineated) of the 1st occurence

sub search {
my %args = @_;
my $retval;

local *FH;
open (FH, './fai.txt') || die "Cannot open file: ($!)";
my @records = ;
chomp (@records);
   foreach my $line (@records){

my @fields = split(/\|/, $line);
if ($args{part} eq $fields[0] && $args{rev} eq $fields[1]){
$retval = \@fields;
last;

close FH;
return \@fields;
}
}

}

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




Re: passing arguments to a subroutine to try and match two fields in a text file

2003-01-17 Thread Rob Dixon
Le Blanc wrote:
> I made some changes. Now I get an error message.
>
> The message says "Can't use string ("") as an ARRAY ref while "strict
> refs" in use"
>
> Here is the code as it stands now, with changes.
>
> #!/usr/bin/perl -w
> use strict;
> use Data::Dumper;
> use diagnostics -verbose;
>
> print "Enter the Part Number you wish to search for: ";
> my $part = ;
>chomp($part);
>
> print "Enter the Revison for ($part): ";
> my $rev = ;
>chomp($rev);
>
> my $searchresult = &search(part => $part, rev => $rev);
>
>
> if (defined $searchresult) {
> print "Located Part Number $part: $$searchresult[1..7]\n";
>

print "Located Part Number $part: @$searchresult\n";

>
> }else {
> print "Your Part Number ($part) Rev ($rev) could not be found...\n";
> }
>
>
> # This routine will accept a part number as an anonymous
> # hash, and search thru a text file returning the entire
> # record (pipe delineated) of the 1st occurence
>
> sub search {
> my %args = @_;
> my $retval;
>
> local *FH;
> open (FH, './fai.txt') || die "Cannot open file: ($!)";
> my @records = ;

close FH;

> chomp (@records);
>foreach my $line (@records){
>
> my @fields = split(/\|/, $line);
> if ($args{part} eq $fields[0] && $args{rev} eq $fields[1]){
> $retval = \@fields;# DELETE
> last; # DELETE
>
> close FH;# DELETE
> return \@fields;# This is all you need
> }
> }
>
> }

Nearly there!

Rob




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




Telnet using IO:Socket module

2003-01-17 Thread pankajwarade
Hi,

I am tring to use IO::Socket module in order to execute the commands on
remote server. Perl script connects remote server on port 23, and waits for
login prompt forever.  It recieves non-printable characters instead of login
prompt.
-
#!/usr/bin/perl

use IO::Socket;

my $sock = new IO::Socket::INET (
Proto   => 'tcp',
PeerAddr=> 10.38.3.3,
PeerPort=> 23,
) or

die "Could not create socket: $!\n" unless $sock;

while(<$sock>)
{
print;
}
--


I userstand, I can use Net::Telnet module also for the same.But, tring to
make it work with IO:Socket.

Any input on this will really be appreciated.


Thanks!
Pankaj



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




Re: baffling script behavior- root loses files

2003-01-17 Thread David T-G
zentara --

...and then zentara said...
% 
...
% I guess I was thrown off by the fact that I did get some output, but
% not the full output. I guess this is one of those areas where Perl
% will do something unpredictable?

It depends on what you expect perl to do ;-)  It wasn't unpredictable for
*some* folks...


HTH & HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!




msg36825/pgp0.pgp
Description: PGP signature


Re: Telnet using IO:Socket module

2003-01-17 Thread david
Pankajwarade wrote:

> my $sock = new IO::Socket::INET (
> Proto   => 'tcp',
> PeerAddr=> 10.38.3.3,
> PeerPort=> 23,
> ) or
> 
> die "Could not create socket: $!\n" unless $sock;

[snip]

> I userstand, I can use Net::Telnet module also for the same.But, tring to
> make it work with IO:Socket.
> 
> Any input on this will really be appreciated.
> 

you are trying to connect 10.38.3.3 using port 23 which the server is 
probably listening for Telnet connection. Telent doesn't use the tcp 
protocol, it uses TELNET.

david

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




Multiple aliases for same sub

2003-01-17 Thread Oblak, Sasha
Hello

I defined on sub (say 'foo'), and I have defined 2 alias that point to foo
(say 'boo' and 'zoo').  When I call the either function boo or zoo, I really
enter foo.  Is there any way to find out which sub was really called either
'boo' or 'zoo'?  I tried using caller, but caller returns foo.

sub foo {
print "here " . (caller[0])[3] . "\n";
}

*{boo} = \&foo;
*{zoo} = \&foo;

boo();
zoo();


here main::foo
here main::foo


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




Re: Telnet using IO:Socket module

2003-01-17 Thread kevin reynolds
The argument 'tcp' is the correct use.  Telnet is implemented over the tcp 
protocol.  The proto field is looking for tcp, udp etc.  I believe the 
problem may be at the beginning of the script.  Try

use IO::Socket::INET;  (you may have to get it from cpan)

instead of use IO::Socket;.  That might work.

http://search.cpan.org/author/RSE/lcwa-1.0.0/lib/io/IO/Socket/INET.pm



Kevin


From: david <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Re: Telnet using IO:Socket module
Date: Fri, 17 Jan 2003 13:54:23 -0800

Pankajwarade wrote:

> my $sock = new IO::Socket::INET (
> Proto   => 'tcp',
> PeerAddr=> 10.38.3.3,
> PeerPort=> 23,
> ) or
>
> die "Could not create socket: $!\n" unless $sock;

[snip]

> I userstand, I can use Net::Telnet module also for the same.But, tring 
to
> make it work with IO:Socket.
>
> Any input on this will really be appreciated.
>

you are trying to connect 10.38.3.3 using port 23 which the server is
probably listening for Telnet connection. Telent doesn't use the tcp
protocol, it uses TELNET.

david

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


_
Help STOP SPAM: Try the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


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



Test

2003-01-17 Thread lielie meimei
 
 

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




a small script in which a dbm hash fails to work right

2003-01-17 Thread willy

i have a vexing problem for you

the following does work fine:::

#dbmopen(%CARDREC, "testbase22", 0664)||
#die "can't dbmopen testbase with mode 0664";

open (IN, "test.in")||
die "can't open test.in";


$index=0;
foreach (){   $index++;
   ($index=1) if ($index>10);
   chomp();
   push(@card,$_) if ($index<10);

if ($index==10){
$CARDREC{$card[0]} = [@card];
print "$CARDREC{$card[0]}[0]\n\n";
print "@{$CARDREC{$card[0]}}\n\n";
@card=();}}

#dbmclose(%CARDREC);

the output is as follows::

line one

line one line two line three line four line five line sixe line seven line 
8 line 9

l11

l11 l12 l13 l14 l15 l16 l17 l18 l19




but, when i uncomment for DBM statemnents as shown here:::

#!/usr/bin/perl -w

dbmopen(%CARDREC, "testbase22", 0664)||
die "can't dbmopen testbase with mode 0664";

open (IN, "test.in")||
die "can't open test.in";

$index=0;
foreach (){   $index++;
   ($index=1) if ($index>10);
   chomp();
   push(@card,$_) if ($index<10);

if ($index==10){
$CARDREC{$card[0]} = [@card];
print "$CARDREC{$card[0]}[0]\n\n";
print "@{$CARDREC{$card[0]}}\n\n";
@card=();}}

dbmclose(%CARDREC);


i get the following output::



Use of uninitialized value in concatenation (.) or string at 
./cardbase-0.1.0.pl line 14,  line 21.




Use of uninitialized value in concatenation (.) or string at 
./cardbase-0.1.0.pl line 14,  line 21.



after a lot of playing around... i think that my dbm syntax is
right... so i am just plain confused :(


--
thanks :)
willy

-- 
Bill Gates is a man who loves EULAs,
If you break his contract he'll just sue ya',
If you do any sharing,
He'll set you to swearing,
So use GPL and shout 'booya'!!

-
This mail sent through IMP: http://horde.org/imp/

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




Re: a small script in which a dbm hash fails to work right

2003-01-17 Thread John W. Krahn
Willy wrote:
> 
> i have a vexing problem for you
> the following does work fine:::
> 
> [snip]
> 
> the output is as follows::
> 
> line one
> 
> line one line two line three line four line five line sixe line seven line
> 8 line 9
> 
> l11
> 
> l11 l12 l13 l14 l15 l16 l17 l18 l19

Are you discarding every tenth line on purpose or is this a bug in your
code?


> 
> 
> but, when i uncomment for DBM statemnents as shown here:::
> 
> #!/usr/bin/perl -w

You should use strict as well as warnings while developing your code.

use strict;


> dbmopen(%CARDREC, "testbase22", 0664)||
> die "can't dbmopen testbase with mode 0664";

perldoc -f dbmopen
   dbmopen HASH,DBNAME,MASK
   [This function has been largely superseded by the
   `tie' function.]

You should probably be learning to use tie instead of dbmopen.


> open (IN, "test.in")||
> die "can't open test.in";

You should include the $! variable in the error message so you know why
it failed.

open IN, 'test.in' or die "can't open 'test.in' $!";


> $index=0;
> foreach (){   $index++;

foreach reads the entire file at once into a list.  The normal way is to
read a line at a time with a while loop.  Using a while loop also gives
you access to the $. variable which means that you don't need the $index
variable.

>($index=1) if ($index>10);
>chomp();
>push(@card,$_) if ($index<10);
> 
> if ($index==10){
> $CARDREC{$card[0]} = [@card];
> print "$CARDREC{$card[0]}[0]\n\n";
> print "@{$CARDREC{$card[0]}}\n\n";
> @card=();}}
> 
> dbmclose(%CARDREC);
> 
> i get the following output::
> 
> 
> Use of uninitialized value in concatenation (.) or string at
> ./cardbase-0.1.0.pl line 14,  line 21.
> 
> Use of uninitialized value in concatenation (.) or string at
> ./cardbase-0.1.0.pl line 14,  line 21.
> 
> 
> 
> after a lot of playing around... i think that my dbm syntax is
> right... so i am just plain confused :(

You are trying to store an array reference [ARRAY(0x12345678)] to a file
which changes the reference to a string, and once it becomes a string
can't be changed back to a reference.  You need to use a module like
Storable or join the values into a single string like this:

#!/usr/bin/perl -w
use strict;

dbmopen %CARDREC, 'testbase22', 0664
or die "can't dbmopen testbase with mode 0664 $!";
open IN, 'test.in'
or die "can't open 'test.in' $!";

my @card;
while (  ) {
chomp;
push @card, $_ if $. % 10;

unless ( $. % 10 ) {
$CARDREC{ $card[ 0 ] } = join "\0", @card;
print "$card[0]\n\n";
print "@{[ split /\0/, $CARDREC{$card[0]} ]}\n\n";
@card = ();
}
}

dbmclose %CARDREC;

__END__



John
-- 
use Perl;
program
fulfillment

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