Re[2]: Code clean up help ---- PLEASE

2002-01-11 Thread Maxim Berlin

Hello Ronald,

Friday, January 11, 2002, Yacketta, Ronald [EMAIL PROTECTED] wrote:

YR No takers on my minor request for help from the guru's?

don't know about gurus, but i feel something very strange about your code.
please show rest of your code and tell, what this code should do for
you. i'm afraid, that more professional version of your script
should be completely rewritten.

 I have finally made my way to the final stage of the script..
 execution of
 the test.. I have the following (be for warned it is 
 POS/FUGLY code!!! ) sub
 that needs to be cleaned up. I am not to sure on how todo 
 this... I have
 ideas etc.. but would like info as to a cleaner more professional way.



Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re[2]: Best perl on windows?

2002-01-04 Thread Maxim Berlin

Hello Gary,

Friday, January 04, 2002, Gary Hawkins [EMAIL PROTECTED] wrote:

GH So then the only differences that come to mind are (1) paths (below), and (2)
GH you only need #! in the first line, although you need perl there to use -w.
GH It can be #!/usr/local/bin/perl -w and that works.  Yes it can be an incorrect
GH location of perl, like #!zz:\perl.exe -w, just as long as perl is there
GH somewhere.  #!perl -w works.  And #!perl.exe -w works.  #!test -w doesn't work.
GH But #!testperltesting -w works.  ActivePerl reads the location of perl.exe from
GH the registry.  Perl56.dll is the magic that does most of the translating on a
GH Windows system.

GH Paths:  Just use '/' instead of '\' in directory paths.  Or '\\'.

GH Except for those two things, practically no differences.

just for your information: you can avoid these two things - http://cygwin.com/
with cygwin you can run, for examples, Xfree server on windows
computer.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: Computer connected to the internet?

2002-01-04 Thread Maxim Berlin

Hello Gary,

Friday, January 04, 2002, Gary Hawkins [EMAIL PROTECTED] wrote:

GH How can I check whether the system is connected?

GH Want to pause the script if connection is lost.  
your OS? and your connection type?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: UUCP and perl (or any alternatives)

2002-01-04 Thread Maxim Berlin

Hello Dermot,

Friday, January 04, 2002, Dermot Paikkos [EMAIL PROTECTED] wrote:

DP Hi Gurus,
DP I need to create a script to copy files from one server to another. 
DP Both servers are UNIX (Tru64). My 1st thought was to use a system 
DP to uucp to the other server but this is proving problematic.

DP Are there any lightweight alternatives? Has anyone got a better way 
DP to do this than uucp or had trouble getting this to work? 

hmmm... what about [t]ftp?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re[2]: Computer connected to the internet?

2002-01-04 Thread Maxim Berlin

Hello Gary,

Friday, January 04, 2002, Gary Hawkins [EMAIL PROTECTED] wrote:

 GH How can I check whether the system is connected?

 your OS? and your connection type?

GH Well, everything in the world preferably (I'm only asking for the world), if
GH others are going to be able to run it, but W2K and DSL for humble starters.

GH Maybe check whether a particular port is open?
unfortunatelly, there is no simple and universal answer. providers and
administrators does many specific things, which valid only for their
clients. for example, for a typical client it's enough to make an http
protocol up and running.
second, your connected is a very common thing. is your system
connected, if your connect to provider is ok, but provider's network
lies down? or provider lost connection to europe or US?
basically, take a look at modules at
http://search.cpan.org/search?mode=modulequery=ping

Things, which shows you, that system is NOT connected:
1. you can not reach your default gateway
2. you can not operate with your provider's DNS server(s)
addresses of gateway and DNS servers you can obtain by running
'ipconfig /all' command on Win* boxes.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: REGEXP Help on Linux

2002-01-04 Thread Maxim Berlin

Hello Daryl,

Saturday, January 05, 2002, Daryl J. Hoyt [EMAIL PROTECTED] wrote:

DJH Hi,
DJH I am trying to use the net::telnet module, and I keep timing out.  I
DJH believe it is because I do not have the right prompt.  My prompt looks like
DJH [sqa1@duke:~]$.  I do not know why this doesn't work: Prompt =
DJH '/\[$::username\@$::machine\]\$$/'.
because you do not understand difference between
'/\[$::username\@$::machine\]\$$/' and /\[$::username\@$::machine\]\$$/

try

print '/\[$::username\@$::machine\]\$$/';
print /\[$::username\@$::machine\]\$$/;

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: AdminMisc::GetHostName Question

2002-01-04 Thread Maxim Berlin

Hello Dean,

Saturday, January 05, 2002, Dean Theophilou [EMAIL PROTECTED] wrote:

DT Can someone tell me if the GetHostName function is a reliable way of
DT determining if a particular machine is up or down?  Thanks.
no. gethostname/gethostbyname deals with only one computer - DNS
server.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re[2]: add text to the end of a word. HELP!!

2002-01-01 Thread Maxim Berlin

Hello Leon,

Tuesday, January 01, 2002, Leon [EMAIL PROTECTED] wrote:

 Can you open a file for reading and writing as the same time?
yes.

L I have asked the question of can I read and write to the same file
L simultaneously, such as this :-
L open FILE, 'myfile.txt' or die $!\n;
L open FILE2, 'myfile.txt' or die $!\n;
L while (FILE){
L # do some changes to $_;
L print FILE2 $_;
L };

L but I did not get any response. Therefore I dont think we can do that.
check
perldoc -f open
for +, ,  modifiers.
and, may be you should check 'seek' function.
perldoc -f seek

You  can't usually use either read-write mode for
updating  textfiles,  since they have variable length records. See the
-i switch in the perlrun manpage for a better approach. - you are warned.

as usual, you can use temporary files as a i/o buffer.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: Making Cygwin and Apache and Perl Play Nice

2001-12-31 Thread Maxim Berlin

Hello Richard,

Monday, December 31, 2001, Richard S. Crawford [EMAIL PROTECTED] wrote:

RSC Here's the problem.  When I run Perl scripts under win2k, I have to include
RSC this as the first line of each CGI script:

RSC  #! c:/perl/bin/Perl.exe

RSC But when I run them under Linux, I have to include this:

RSC  #!/usr/bin/perl

RSC Is there any way that anyone knows of to map my Perl interpreter under 
RSC Windows to the Cygwin installation, so that I don't have to change the 
RSC first line of my Perl CGI scripts when I switch operating systems?
sure, use cygwin's mount.
C:\mount
Device  Directory   Type Flags
D:\CYGNUS\USR   /usruser textmode
C:  /   user textmode
C:\ls /usr
BIN  INCLUDE  LIB  LOCALSBIN
DOC  INFO LIBEXEC  MAN  SHARE

RSC   Is this 
RSC something I can change under Apache (I'm running 1.3)?
hmmm... no.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re[2]: Data through the parallel port

2001-12-20 Thread Maxim Berlin

Hello Stanislav,

Thursday, December 20, 2001, Stanislav Zahariev [EMAIL PROTECTED] wrote:

 hi.
 in last month , i send data through port but not with laser.
 i am working in ISP and send and receive data through port
 and routhr.
SZ So, how ? :)) With perl or without? I can manage it working with C, but i
SZ was just wondering is there a way doing it with perl too:)) Everyone is
SZ saying that Perl is all-purpose programming language.

perl itself does not have builtin low-level input/output commands.
you can see list of Perl builtin functions by running
'perldoc perlfunc'.
If you really need interface to lpt port, write your own module (in C, you
call it library), in C and use them. see
'perldoc perlxs'
for more details.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: help with DBD error

2001-12-20 Thread Maxim Berlin

Hello JIM-CONT,

Thursday, December 20, 2001, FLAHERTY, JIM-CONT [EMAIL PROTECTED] wrote:


FJC hello, I have redhat 7.1 and perl is loaded with mysql , I have several
FJC scripts with perl , DBI, DBD and mysql working fine , so If think I have
FJC everything set up properly 

FJC But I get an error :

FJC DBD::mysql::st execute failed: Duplicate entry '204' for key 1 at
FJC /var/www/cgi-bin/sobt/chstatus2.cgi line 107.

looks like you trying to insert record into your database with the
primary key, which already exists.

FJC  unable to execute query  at /var/www/cgi-bin/sobt/chstatus2.cgi line 107.
FJC Issuing rollback() for database handle being DESTROY'd without explicit
FJC disconnect().

FJC this is the section of code ( with line numbers)  

FJC  97  $dbh2 = DBI -connect($data_source, $username, $password);

FJC  98my $sth2 = $dbh2 - prepare(select title from media1 where num 
='$num');
FJC  99 
FJC 100$sth2 - execute or die  unable to execute query ;
FJC 101 
FJC 102 
FJC 103  $dbh2 =DBI -connect($data_source, $username, $password);
FJC 104   my $sth2 = $dbh2 - prepare(insert into 
history(num,title,date,user1)values('$num','$date1','$date1','$name'));
FJC 105 
FJC 106 
FJC 107   $sth2 - execute or die  unable to execute query ;
FJC 108 
FJC 109 
FJC 110 



Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: creating web interface for .forward on linux

2001-12-14 Thread Maxim Berlin

Hello KeN,

Friday, December 14, 2001, KeN ClarK [EMAIL PROTECTED] wrote:

KC i've looked through 'learning perl' 2nd edition, and am confused. much. i 
KC want to create an interface for system users to update their .forward 
KC files in their $HOME directories.

KC I want this to be a web-based interface. The webmail program I am using is 
KC openwebmail, and doesn't have this functionality, yet. 

KC I can't be any more of a beginner. I am concerned heavily about security 
KC also. What I envision is a page with a username and password submit 
KC fields. If the user exists, and if the password is correct, then it will 
KC let a field that user fills in their [EMAIL PROTECTED] and that writes to 
KC their own $HOME/.forward. Also, if they clear the field, and submit, it 
KC will write over any existing .forward, to disable .forwarding.

KC If I can figure out the perl side of checking writing over the .forward, 
KC I'd like to add this to openwebmail. 

KC Ask away if you've question.

no questions, but it's usually admnistrator job, not cgi beginner...
1. http daemon usually runs on servers with uid=nobody and
group=nogroup. In correctly designed sites, httpd haven't any access to
users home files.
2. if you really want to do this, you should reconfigure your http
daemon. if your daemon is apache, read http://httpd.apache.org/docs-2.0/suexec.html

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: client-server communication

2001-12-14 Thread Maxim Berlin

Hello Michael,

Wednesday, December 12, 2001, Michael McQuarrie [EMAIL PROTECTED] wrote:

MM I  am  trying to get a client to communicate with a server located
MM on  another  host.  I can get the 2 to connect, the server to send
MM data,  and  the  client to receive the data on the other end but I
MM can  not  get the client to respond to the server. I am a beginner
MM with  this  so  I  don't  really know where the problem would lie,
MM hopefully one of you do. I got most of this from examples. Here is
MM the server piece followed by the client. Thanks in advance.
unfortunatelly, you've got bad examples...
take a look at
perldoc perlipc
, which contains working client/server samples.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: shifting scalars ??

2001-12-08 Thread Maxim Berlin

Hello Craig,

Saturday, December 08, 2001, Craig Inman [EMAIL PROTECTED] wrote:

CI As I'm new to perl, I'm more or less trying to write a 'nested while
CI read' loop (atleast that is what my attempts come out to look like so
CI far).

CI trying something like

CI open (A, $list1) or die .
my $a,$b;

CI while(A)
CI chomp;
CI  {
CI print  $_\n;#just so I know that it's there
$a=$_;
CI  }

CI open(B, $list2) or die 

CI while(B)
CI chomp;

CI if $_ =~ ?   # this is where I'm getting lost, want to
CI compare $_ from above   (A) to $_ from (B)
$b=$_;
if $b =~ $a 

CI then I'm just printing my diffs so I can correc the necessary files.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: calling a server via http

2001-12-08 Thread Maxim Berlin

Hello rory,

Saturday, December 08, 2001, rory o'connor [EMAIL PROTECTED] wrote:

roc I'm not sure if perl is best suited for this project - but I bet it is!  I 
roc need to call a server (perhaps via lynx?) in a cron'd script and then time 
roc how long it takes for the page to load. 

roc The reason is that sometimes the remote server stops loading pages due to 
roc some unknown problem (this is nt4.0, mind you).  while we try to figure it 
roc out, i need to be alerted via email when it hasn't finished loading the page 
roc in say, 20 seconds - because the server needs to be restarted.

take a look at sample in
perldoc -f alarm

to load page from http server, you can use lynx, of course, but i
suggest you to use perl module 'LWP'.
perldoc LWP::Simple
perldoc LWP



Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: PERL MySQL DBI

2001-12-06 Thread Maxim Berlin

Hello Aaron,

Friday, December 07, 2001, Aaron Shurts [EMAIL PROTECTED] wrote:

AS Okay, I was the one that asked the crazy question about the weird join,
AS but I got that figured out.  Now I have a problem.

AS while( ($login, $existingemail, $areacode, $prefix, $rest) =
$sth-fetchrow_array ())
AS {
something like this ?:
$existingemail=NO EMAIL PROVIDED if ($existingemail eq  );

AS print $login,$existingemail,$areacode-$prefix-$rest\n;
AS }

AS That code is inside my foreach statement, but existingemail is an
AS optional field.  If there is no email address given, I would like to
AS print out NO EMAIL PROVIDED.  How do I do this within my while loop.
AS When this report is run, it is piped to a csv file so that it can easily
AS be imported into Excel.  Thanks in advance for the help.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: Simpler....

2001-12-05 Thread Maxim Berlin

Hello Daniel,

Wednesday, December 05, 2001, Daniel Falkenberg [EMAIL PROTECTED] wrote:
DF Please don't stree to much over this one but, is there an easier way of
DF writing this?

DF while(1){
DF   if ($status == 1) {
DF #Do this sub...
DF sub();
DF   elsif ($status == 1) {
DF #Do this other sub...
DF sub2();
DF   } else {
DF #Continue while loop...
DF   }
DF }

DF Can I make it smaller.  I want to know this to improve my Perl skills.

perldoc -q switch


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Does Perl have an equivalent of C's #include

2001-12-05 Thread Maxim Berlin

Hello Andrew,

Wednesday, December 05, 2001, Andrew Clark [EMAIL PROTECTED] wrote:

AC The subject says it all.

AC R,

AC AJFC

AC Please CC replys, I'm not on the list.

perldoc -f require
perldoc -f use

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: Simpler....

2001-12-05 Thread Maxim Berlin

Hello Sandeep,

Wednesday, December 05, 2001, Shinagare, Sandeep [EMAIL PROTECTED] 
wrote:

SS Hi All,
SS I am trying to learn Perl and want to begin with getting an interpreter for
SS the Windows OS (NT).
SS Which are the good ones around for download?
http://www.perl.com/pub/a/language/info/software.html
http://www.activestate.com/
SS Also, any pointers for basic tutorials?
http://perl.oreilly.com/
http://learn.perl.org/
http://www.perl.org/

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Pattern match woos

2001-12-05 Thread Maxim Berlin

Hello Dermot,

Wednesday, December 05, 2001, Dermot Paikkos [EMAIL PROTECTED] wrote:

DP Hi there, 
DP This is both frustrating and embarrassing. I can't capture the 
DP following data into a variable. The line I want is:
DP DL.CODGIAZUC00/DL.COD

DP I have tried a multitude of Regex, none seems to be working. Here's 
DP my last attempt:

DP   open(F,$i);
DP   while (defined( $p = F)) {
DP chomp($p);
DP($code)  = ( $p =~ /^\DL\.COD\(\w\d+)/ );
DP   }
DP print $code\t $i\n;

DP Most of my attempts have been trying to Esc the , but I am not 
DP sure these are metacharacters.
you don't need to escape '' and '' symbols in regexps.
your regexp should looks like
($code)  = ( $p =~ /^DL\.COD(\w+)/ );
, if you want to store 'GIAZUC00' into $code.
\w is [a-zA-Z0-9_]
if you want to separate letters and digits, you need something like
this:
($code,$num)  = ( $p =~ /^DL\.COD([a-zA-Z]+)(\d+)/ );



Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: q as an argument

2001-12-05 Thread Maxim Berlin

Hello Michael,

Wednesday, December 05, 2001, Michael McQuarrie [EMAIL PROTECTED] wrote:


MM I am defining a sub that takes only specific options:

MM sub error_notify
MM {
MM   my $ERR_USAGE = error_notify (e,p,x, \Message Text\)\n;

MM   foreach (@_)
MM   {
MM if(/^e$/)  { push @ERR_OPTS, email; }
MM elsif (/^p$/)  { push @ERR_OPTS, page;  }
MM elsif (/^x$/)  { push @ERR_OPTS, exit;  }
MM elsif (/^\w$/) { print Invalid error_notify Option\n$ERR_USAGE;}
MM else   { $MESSAGE = $_; }
MM   }
MM   bla bla bla...

MM This sub is supposed to be called like this:
MM error_notify(e,p,x,This is the error message that will be sent out);
bad syntax. you should use ' or  for character variables.
'e','p','x'

MM The  problem  that  I  am running into is that whenever q (which
MM isn't  a  valid option) is supplied as an argument to the sub like
MM this:
MM error_notify(q,Whatever);
normally, you can not use this syntax. you should get
Can't find string terminator , anywhere before EOF
error from perl. use
error_notify(q,Whatever);
MM I get an error because the q is interpreted as a quote operator.
MM I  am  using a \w to try and match all invalid options but \w will
MM not  match  the  q. Anyone know a way around this? I would like to
MM keep the same syntax for calling the sub.
i suggest you to put
use strict;
line at the top of your source and run
perl -c yoursource
to check syntax.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[4]: q as an argument

2001-12-05 Thread Maxim Berlin

Hello Michael,

Wednesday, December 05, 2001, Michael McQuarrie [EMAIL PROTECTED] wrote:

MM Maxim,
MM Correction:
MM The use strict; requires the arguments to all be quoted.
yes.

MM In  the real script I am only using use strict 'vars';. This way
MM I  can keep the syntax of calling the sub the same as I originally
MM had.  I  would  like  to keep the error_notify(e,p,x,Message);
MM syntax.  The q is the only character that is causing me problems
MM with this.

how do you want to use reserved perl word as an argument, without
quotes? it's impossible.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: Can Perl work like Expect?

2001-12-04 Thread Maxim Berlin

Hello Ahmed,

Tuesday, December 04, 2001, Ahmed Moustafa [EMAIL PROTECTED] wrote:

AM Thanks a lot. Where can I find exmaples for using Expect.pm, please?

http://search.cpan.org/search?mode=modulequery=expect
but, for telnet and ftp you can use Net::Telnet and Net::FTP modules.
http://search.cpan.org/doc/JROGERS/Net-Telnet-3.02/lib/Net/Telnet.pm
http://search.cpan.org/doc/GBARR/libnet-1.09/Net/FTP.pm

AM Brett W. McCoy wrote:


I used to use Expect http://expect.nist.gov/ for dealing with
interactive programs i.e. Telnet and FTP.

Expect lets you interact with running process as if it was a file.

Does Perl have something like that i.e. writing a Perl script which
interacts with another process?

Your help will be appreciated so much.

 
 Yep -- there's a module on CPAN called Expect.pm.  It works as you would
 expect. :-)



Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re[2]: What's wrong with unlink?

2001-12-04 Thread Maxim Berlin

Hello Tirthankar,

Tuesday, December 04, 2001, Tirthankar C. Patnaik [EMAIL PROTECTED] wrote:

TCP You might want to check the permissions of those files. 

TCP The command works fine here. 
TCP But I guess the mistake is that you're working on Windows, and there you have
TCP a back-slash ( \ ) instead of a slash ( / ). 
TCP Try this: 

TCP my ($_path) = c:\EventLogs;
TCP unlink $_path/* if -r $_path;

TCP This should work. 
no :) you forgot to escape backslash. but there is no difference
between \ and / slashes in path names in perl for windows.
second, unlink $_path/* does not works.
can be
my $_path = c:/EventLogs;
if( -d $_path )
{
chdir $_path;
unlink * or die $!;
}

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: Can Perl work like Expect?

2001-12-04 Thread Maxim Berlin

Hello Ahmed,

Tuesday, December 04, 2001, Ahmed Moustafa [EMAIL PROTECTED] wrote:

AM Actually, I need to interact with a Secure FTP (SFTP) client. Is there 
AM some module for that?
Ahmed, i've already show you the way. ask search.cpan.org, ok?
http://search.cpan.org/search?mode=modulequery=sftp

AM By the way, Are these modules installed by default on the Perl 
AM distributions?
by default - no.
AM Or, how can I tell if a module is installed or not?
something like
perl -e use Net::FTP;
if module is not installed, you'll recieve error.
AM Thanks,

AM Maxim Berlin wrote:

 Hello Ahmed,
 
 Tuesday, December 04, 2001, Ahmed Moustafa [EMAIL PROTECTED] wrote:
 
 AM Thanks a lot. Where can I find exmaples for using Expect.pm, please?
 
 http://search.cpan.org/search?mode=modulequery=expect
 but, for telnet and ftp you can use Net::Telnet and Net::FTP modules.
 http://search.cpan.org/doc/JROGERS/Net-Telnet-3.02/lib/Net/Telnet.pm
 http://search.cpan.org/doc/GBARR/libnet-1.09/Net/FTP.pm



Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: UID's

2001-12-04 Thread Maxim Berlin

Hello Christo,

Tuesday, December 04, 2001, Christo Rademeyer [EMAIL PROTECTED] wrote:

CR Hi how can I do this in perl ? srdof the same thing?
CR tail -n5 /etc/passwd | cut -d: -f3

CR -
= -
CR 23
CR 77
CR 100
CR 501
CR 501
for example, you can write
my @uids=`tail -n5 /etc/passwd | cut -d: -f3`;

what do you need, exactly? trying to parse /etc/passwd?
take a look at sample in
perldoc -f split

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: problem executing linux command in perl

2001-12-04 Thread Maxim Berlin

Hello Rahul,

Tuesday, December 04, 2001, Rahul Garg [EMAIL PROTECTED] wrote:

RG Also, the script is working fine if i am changing permissions manually .it
RG is fetching and appending  data to $r_file
RG Any suggestions..
'no such file or directory' means, that your $r_file does not exists.
looking at
RG error :Cannot chmod : no such file or directory
produced by
RG die Cannot chmod $r_file: $!;
i can see, that your $r_file does not contain anything.

RG - Original Message -
RG From: Rahul Garg [EMAIL PROTECTED]
RG To: [EMAIL PROTECTED]; John W. Krahn [EMAIL PROTECTED]
RG Sent: Tuesday, December 04, 2001 6:57 PM
RG Subject: Re: problem executing linux command in perl


RG chmod 0777, $r_file or die Cannot chmod $r_file: $!;
RG giving error :
RG error :Cannot chmod : no such file or directory


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: UID's

2001-12-04 Thread Maxim Berlin

Hello Christo,

Tuesday, December 04, 2001, Christo Rademeyer [EMAIL PROTECTED] wrote:

CR Thanks
CR got mine like this.
CR open (TFH,/etc/passwd);
CR @data = TFH;
CR foreach $line(@data) {
CR ($user,$pass,$uid,$gid,$info,$home,$type) = split /:/, $line;
CR }

CR $a = ($uid +  1);

CR bit shitty if your pass files get's to long.

so what?
open (TFH,/etc/passwd);
while( $line = TFH ) {
 ($user,$pass,$uid,$gid,$info,$home,$type) = split /:/, $line;
}

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[4]: What's wrong with unlink?

2001-12-04 Thread Maxim Berlin

Hello Tirthankar,

Tuesday, December 04, 2001, Tirthankar C. Patnaik [EMAIL PROTECTED] wrote:


TCP Hi Maxim, 

 no :) you forgot to escape backslash. but there is no difference
 between \ and / slashes in path names in perl for windows.

TCP Thanks for this. I use perl on a Linux box, and there I use a /. 

 second, unlink $_path/* does not works.

TCP No. here's a small perl prog I wrote to test this: 

TCP #!/usr/bin/perl -w
 
TCP $_dir = /tmp/dummy/;
TCP unlink $_dir/* if -r $_dir;
TCP exit;

TCP This prog worked on  v5.6.1 built for i386-linux. 
we're talking of windows versions, btw :)

i'm not sure, but may be this behavior depends of perl version. your
sample works with cygnus perl 5.6.1 and does not with old windows perl
5.005_02. chdir helps.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: CPAN usage

2001-11-30 Thread Maxim Berlin

Hello Martin,

Friday, November 30, 2001, Martin Pfeffer [EMAIL PROTECTED] wrote:

MP 1. I has no internet connection at home and so i want to make a local
MP copy of cpan Modules on my Fileserver. Where or why can i download
MP this? 
take a look at
http://www.cpan.org/misc/cpan-faq.html#How_mirror_CPAN

MP 2. The downloaded mirror should be used with the cpan module where
MP must i define the path to local mirror or how can i work with cpan and
MP local mirror

for cpan module, you can define custom site(s), like
  'urllist' = [q[ftp://your.cpan.site/CPAN/] ],

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: a beginners challenge

2001-11-30 Thread Maxim Berlin

Hello Roiy,

Friday, November 30, 2001, Zysman, Roiy [EMAIL PROTECTED] wrote:

 Hi All,
 Why not make a little challenge ..
 Lets see who can write the most lean ,mean , elegant , powerful, poetic
 (but most important)  _Shortest_, script that cleans from a directory
 files that are at least 3 days old.
 Good luck all,
 You're welcome to pick who you think is the winner.

you already has solution. do you want it especially in perl?
ok ;)
@result= `find . -newerct \'3 days ago\' -maxdepth 1 -exec rm \{\} \\;`;


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: a beginners challenge

2001-11-30 Thread Maxim Berlin

Hello Shawn,

Friday, November 30, 2001, Shawn [EMAIL PROTECTED] wrote:

 @result= `find . -newerct \'3 days ago\' -maxdepth 1 -exec rm \{\} \\;`;

S I guess I have to ask, what is this command?  -newerct?  I get the following
S when running this line:
S find: -newerct: unknown option

it depends of your find. this very far prom perl, but...
man find:

 -newerXY file
 True if the current file has a more recent last access time
 (X=a), change time (X=c), or modification time (X=m) than the
 last access time (Y=a), change time (Y=c), or modification time
 (Y=m) of file.  In addition, if Y=t, then file is instead inter-
 preted as a direct date specification of the form understood by
 cvs(1).  Note that -newermm is equivalent to -newer.


if you need more, please contact me, not [EMAIL PROTECTED]

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: shadow file

2001-11-22 Thread Maxim Berlin

Hello nafiseh,

Thursday, November 22, 2001, nafiseh saberi [EMAIL PROTECTED] wrote:

ns hi.
ns I find one source code about  crypt function.
ns I put it in my source code,but
ns it gives this error to me :

ns   useradd: unable to lock password file .

ns i want to add user from web in shadow file,
ns with useradd function.

ns would you help me ??

your script (mostly, http daemon) haven't sufficient privileges to
create user. this question is very far from perl, so consult your
system/web administrator. If your http daemon is apache, you can read
http://httpd.apache.org/docs-2.0/suexec.html
too.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: REGEX or Parse a text file

2001-11-14 Thread Maxim Berlin

Hello Dermot,

Wednesday, November 14, 2001, Dermot Paikkos [EMAIL PROTECTED] wrote:

DP I am having trouble getting the data I want out of a text file: The file has
DP this sturcture:

DP File Name: m:\a\a084099.jpg
DP   Width x Height: 2480 x 2062
DP   Number of Colours: True Colour (24 bits)
DP   Dots per inch: 300 x 300
DP   Image size (inches): 8.27 x 6.87
DP   Raw size: 15341280  Actual size: 1203289   (Compression ratio: 12.8:1)

DP There a thousand or so entries. Each entry is separated by a blank new line.
DP I want to get just the file name and the last line. My troulbe is I can't
DP manage to parse it correctly. The best I have been able to get is:
DP m:\a\a084100.jpg  Uncompressed Size: 15341280  Actual size: 1203289
DP m:\a\a084100.jpg  Uncompressed Size: 15341280  Actual size: 1203289
DP m:\a\a084100.jpg  Uncompressed Size: 15341280  Actual size: 1203289
DP m:\a\a084100.jpg  Uncompressed Size: 15341280  Actual size: 1203289
DP m:\a\a084100.jpg  Uncompressed Size: 15341280  Actual size: 1203289
DP m:\a\a084100.jpg  Uncompressed Size: 15006480  Actual size: 1251205
DP m:\a\a084100.jpg  Uncompressed Size: 15006480  Actual size: 1251205

DP The lines get repeated 7 times before getting the next entry. I used:

DP while (REPORT) {
DP if (/File/gc) {# I tried with or without gc but it made no 
difference.
/gc useless here. why not use
 if (/File Name: /) {
DP  $name = $';
, and remove 2 next lines?
DP chomp($name);
DP  ($file = $name) =~ s/ Name: //;
DP }
DP if (/Raw/) {
DP  $size = $';
DP  chomp($size);
DP  ($foo = $size) =~ s/\((Compression...*)//;
DP  ($bar = $foo) =~ s/size/Uncompressed Size/;
DP }

DP print OUTPUT $file $bar \n;
move your print inside if (/Raw/) { } to avoid useless repetitions.

while (REPORT) {
chomp;
if (/File Name: /) {
$name = $';
}
if (/Raw/) {
 $size = $';
 $size =~ s/\((Compression...*)//;
 $size =~ s/size/Uncompressed Size/;
 print OUTPUT $name $size \n;
}
}


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: [Socket] Question

2001-11-09 Thread Maxim Berlin

Hello RArul,

Friday, November 09, 2001, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Rnc Thanks John. The purpose was not to send email. I was just trying to see if
Rnc I am able to do a conversation with some server using a socket, as I am just
Rnc learning to program a socket.
well, try to
select(TO_SERVER); $| = 1; select(STDOUT);
then.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Off-Topic (200%) - Where are you from?

2001-11-09 Thread Maxim Berlin

Hello,

looks like i'm only one from Russia (Moscow) here...

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re[2]: merging two hashes together?

2001-11-03 Thread Maxim Berlin

Hello Wagner-David,

Saturday, November 03, 2001, Wagner-David [EMAIL PROTECTED] wrote:

WD Here is one shot, though I changed some of the constants:

WD #!perl -w

my %h1  = (one = 1, two = 2, three = 3);
my %h2  = (four = 4, five = 5, six = 6);
WD my %h3  = ();

WD mergehash( \%h1, \%h2, \%h3);


WD sub mergehash {
WD my ( $h1, $h2, $h3) = @_;
WD foreach my $MyKey1 ( keys %{$h1} ) {
WD $h3-{$MyKey1} = $h1-{$MyKey1};
WD  }

[...]

jfyi (just for your information): think about
%h3=(%h1,%h2);


Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: Global Variables

2001-11-02 Thread Maxim Berlin

Hello jason,

Friday, November 02, 2001, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

jwc Need some help.
 
jwc  I think that I need to be using global variables.  Unless Someone has a 
jwc better solution.
 
jwc  What I am trying to do is.  I want to set a variable for such things as  
 
jwc  FONT_COLOR=00
jwc  BACKGROUND_COLOR=55
 
 
jwc  For example:  So that I do not have to go through every file and set that
jwc  on
jwc  ever line that I would like to use it on.  I would like to set global
jwc  variable so that if I change (in this case) the colors than I only have to
jwc  change it in one place and be done with it.
 
jwc  Which brings me to my question. Unless you know a better way of doing it.
jwc  How do I set global variables

take a look at
perldoc -f use
perldoc -f require


Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re[2]: Outputting shell command to a browser

2001-11-02 Thread Maxim Berlin

Hello Robert,

Friday, November 02, 2001, Robert Thompson [EMAIL PROTECTED] wrote:

RT The  overall  problem  is  not  if  grep works or not, but why the
RT output  from the backticks does not show up in the cgi. I only put
RT the  grep in there to make the code read easier. $results does not
RT have  anything  in  the cgi with or without the grep. Below is the
RT code again. Am I not using the backticks correctly?

You are using backticks correctly. the problem is not in
perl, your script works fine under my apache/freebsd. you should
look at your server|system logs and configuration.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: gethostbyname and getnetbyname

2001-11-02 Thread Maxim Berlin

Hello Nathaniel,

Friday, November 02, 2001, Wert, Nathaniel [EMAIL PROTECTED] wrote:

WN 1)   I   can   get   gethostbyname   to   work   in  this  format:
WN gethostbyname('node.foo.com').  I need it to work in the following
WN format: gethostbyname($nodename). Is this not set up for that?
$nodename='node.foo.com';
$ent=gethostbyname($nodename);
where is your problem?

example:
use Socket;
use Net::hostent;
$h = gethostbyname(www.perl.com);
print name:, $h-name, address:,inet_ntoa($h-addr),\n,

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re[2]: gethostbyname and getnetbyname

2001-11-02 Thread Maxim Berlin

Hello Nathaniel,

Saturday, November 03, 2001, Wert, Nathaniel [EMAIL PROTECTED] wrote:

WN Maybe it comes in the statement before that:

WN $nodename = STDIN;
:) you forgot
chomp $nodename;
here. $nodename contains '\n' at the end.

WN $iaddr = gethostbyname($nodename);
WN ($a,$b,$c,$d) = unpack('C4',$iaddr);
WN $ipaddress = $a.$b.$c.$d;
WN print $ipaddress;

WN I have debugged this numerous times and I can't seem to understand
WN why gethostbyname does not return anything. I have tried with both
WN the  hostname  and  the  hostname.foo.com notation and it does not
WN work.

WN It  does  work  when I replace $nodename with 'node.foo.com' but I
WN can't get the imputed variable to work?
perldoc -f chomp

Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: terminating input

2001-11-02 Thread Maxim Berlin

Hello Jason,

Saturday, November 03, 2001, Jason Cruces [EMAIL PROTECTED] wrote:

JC Hello all,
JC Probably are really simple one but haven't found the
JC answer yet. In an interactive program, where a user is
JC prompted to enter more than one value, I would use

JC chomp(@values = STDIN);

JC And to terminate the input, enter Ctrl-D (or Ctrl-Z on
JC windows).
JC My question is, how would I change the terminating
JC characters (Ctrl-D) to the user just hitting the enter
JC key (or any other character)?
JC I tried a do/until statement like
here is a couple of errors in your program:

JC do{
JC $i=0;
1. your $i always is 0.
JC chomp($value[$i] = STDIN).
2. '.' at the end of string causes trouble. replace it with ';'.
JC $i++;
JC }until (! $value[$i]);
3. your $value[$i] always undefined in until condition, because $i
changed after input.

JC but still not having much luck. Any ideas?
something like

$i=-1;
do{
$i++;
chomp($value[$i] = STDIN);
} until (!$value[$i]);


Best wishes,
 Maximmailto:[EMAIL PROTECTED]


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




Re: Search and replace using a variable

2001-09-13 Thread Maxim Berlin

Hello Jimson,

Thursday, September 13, 2001, Jimson Lee [EMAIL PROTECTED] wrote:

[..]
JL Being new to perl, I know how to search for strings.  I know how to
JL explicitly search and replace a string.
you always can use variable instead of exact string.

JL   What I don't know how to do is
JL search for a string,
in array - grep, as you wrote below.
in string - match, see
perldoc -f m

JL  make that string a variable,
grep function return array of results.
my @results = grep /OAM/i, @lines;

JL  and then use that
JL variable in a search and replace statement so that I can run this script
JL at all my sites.
see
perldoc -f grep
(grep can do replace for you), or
perldoc -f s
perldoc perlop
JL Here's what I'm using to search for a string...

JL open FILE, config.cfg or die can't open config.cfg: $!;
JL my @lines = FILE;
JL print grep /OAM/i, @lines;

JL When I run this against config.cfg, it gives me the string OAM...  Can I
JL make that a variable?
yes :)

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: '' and

2001-09-12 Thread Maxim Berlin

Hello Matija,

Tuesday, September 11, 2001, Matija Papec [EMAIL PROTECTED] wrote:


MP Is there a reason why '' should be preferred over  when using static
MP expressions? My guess is that  takes a little longer at compile time for
at run time. inside loop, for example.
MP perl to see if variables resides inside quotes, but don't know if this is
MP significant to bother with single quotes.

personally, i prefer '' in next case:
my $a = \$\@\^;
my $a = '$@^';

MP ps. I've always used  but now my boss tells me that this is a bad thing :)

it depends :)

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: line end problems - help #2

2001-09-12 Thread Maxim Berlin

Hello Ron,

Wednesday, September 12, 2001, Ron Woodall [EMAIL PROTECTED] wrote:
RW I asked a similar question before and got no response. I guess I didn't
RW explain myself.

RW Here's the problem. I'm using a perl script to create an html page. The 
RW editor is located on a Windows '98 machine and the file resides on a Linux 
RW machine. The file is edited across the network. Part of the script contains 
RW a heredoc that contains the head of the page. The remainder of the page is 
RW made up of lines added to the buffer and subsequently written to the output 
RW file. I've tried \r\n and \n as line ends both in the heredoc and the 
RW output array.

[..]
RW I'm open to any suggestions as to why and what I can do about it.
If you use FTP to transfer file between windows and linux, switch your
ftp client to 'ascii' mode.
If not, tell your editor to save output file in unix format.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: line end problems - help #2

2001-09-12 Thread Maxim Berlin

Hello Ron,

Thursday, September 13, 2001, Ron Woodall [EMAIL PROTECTED] wrote:

If you use FTP to transfer file between windows and linux, switch your
ftp client to 'ascii' mode.
If not, tell your editor to save output file in unix format.

RW  I store the file directly to the Linux machine and tried setting 
RW the editor to save in unix format.
what do you mean - 'directly'? it's impossible. you should use samba
on linux or ftp - there is no other solutions, afaik.

RW  No resolution. I haven't tried FTP yet 
RW but that might be worth it when I get to the production end of the run. Any 
RW other solutions? I'm using NoteTab Light 4.85 (Freeware version) by Eric 
RW G.V. Fookes.
1. change your editor. i prefer me (www.multiedit.com), correctly handles
many problems, but, i'm afraid, not a beginners tool.

2. you can use
perl -p -i -e 's/\r//g' filename# dos-unix
perl -p -i -e 's/\n/\r\n/g' filename# unix-dos
on your linux.

3. you can setup X server on your windows computer, and run linux
editor's (emacs, nvi, ... ) from linux. this is a long song, but i
can sing, if anyone is interested :)

RW  Thanks but no cigar yet ;-)
no smoking:) want to die at full health :) (sort of humor)

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: line end problems - help #2

2001-09-12 Thread Maxim Berlin

Hello Curtis,

Thursday, September 13, 2001, Curtis Poe [EMAIL PROTECTED] wrote:

CP That will show non-printing characters (-v) and the end of line will be indicated 
with a dollar
CP sign (-E).  If you see a ^M before the end of line, you have saved the file in DOS 
mode.  To fix
CP it, use an inplace edit:

CP perl -pi -e 's/\r//g' somescript.pl

CP Just be sure to back up the file first!

-i does backup for you ?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: timestr (benhcmark)

2001-09-10 Thread Maxim Berlin

Hello Ronald,

Monday, September 10, 2001, Yacketta, Ronald [EMAIL PROTECTED] wrote:
YR I have the following benchmark line in my perl code
 
YR my  $etime = timeit(1, \get_errors);
YR more code
YR printf OFN egrep\t: %s\n, timestr($etime);
 
YR is there a way to manipulate the timestr output? The function it calls has
YR 4 5 second delays within it, I would like the timestr output to no report
YR those delay's. Is there a way to take $etime and subtract 20 seconds from
YR it to get the actual time the function took - the delays?
Well... afaik, no.
but - what delays?
sub timestr does not call anything heavy, look into Benchmark.pm
although, you can use timediff or you can modify benchmark values by
yourself.

  DB1 x$t
0  Benchmark=ARRAY(0x656060)
   0  0
   1  0.22
   2  0
   3  0
   4  0
   5  0
  DB2 n
main::(t.pl:6): print loops took:,timestr($t),\n;
  DB2 n
loops took: 0 wallclock secs ( 0.22 usr +  0.00 sys =  0.22 CPU)


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Interpolating function call in here documents causes out-of-order execution

2001-09-01 Thread Maxim Berlin

Hello Yusuf,

Thursday, August 30, 2001, Yusuf Goolamabbas [EMAIL PROTECTED] wrote:

YG The following test program

YG #!/usr/bin/perl

YG sub main() {
YG $key = 5 ;
YG print TARGET ;
YG Foobar
YG Snafu
YG ${\(interp($key))}
YG TARGET
YG }

YG sub interp {
YG  my ($arg) = @_ ;
YG  print Hello World, $arg \n ;
YG  return;
YG }

YG main();

YG gives the following output
YG --
YG Hello World 5
YG Foobar
YG Snafu

YG --

YG I am stumped at this out-of-order execution path, Am I doing something
YG wrong ?
no.
your 'print TARGET' prints TARGET _after_ constructing all TARGET
content. try

sub interp {
 my ($arg) = @_ ;
 return Hello World, $arg \n ;
}

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Reading backwards

2001-09-01 Thread Maxim Berlin

Hello Louis-Philippe,

Friday, August 31, 2001, Louis-Philippe Dextraze [EMAIL PROTECTED] wrote:

LPD Hi everyone,
LPD I'm trying to read throu a 200meg+ error log
LPD file. (I have no administrative rights on this server,
LPD you see i'm just a programmer why would my boss think
LPD i'd need access to a error log not as if it would make
LPD my life easyer or anything...ok this rant is over)

LPD I'm trying to read it throu a cgi...but if I try and
LPD open the whole thing up. my browser crashes under the
LPD memory needs.

LPD The solution i'm using now is this.
LPD is dirty and hogs much of the servers power when it
LPD runs but at the moment it's the only way for me
LPD to have access to this file.

LPD CODE

LPD open FICMSG, $logfile or print problem opening log file.;

LPD $i=0;
LPD while(!(eof FICMSG))
LPD {
LPD $msg[$i] = FICMSG;
LPD $_ = $msg[$i];
LPD if ($i  40)
LPD {
LPD $i++;
LPD }
LPD else
LPD {
LPD $i=0;
LPD }
LPD }
1. you do not need $_ = $msg[$i]; string, becouse you do not use $_
variable.
2. you can shorten your code:
open FICMSG, $logfile or print problem opening log file.;

$i=0;
while($msg[$i] = FICMSG)
{
if ($i  40)
{
$i++;
}
else
{
$i=0;
}
 }

3. please do not use that approach :)

LPD for($i = 0; $i = $#msg; $i++)
LPD {
LPD print bError $i:/bbr$msg[$i]\nbrbr;
LPD }

LPD /CODE


LPD My question is...can we read the file backwards.
LPD If I could set the reading pointer to the end
LPD of the file and then work my way back 40 entries.
LPD and print...now that would make my day.

LPD anyone know of a way?
yes. you can simply write
my @msg = `tail -40 $logfile`;

if you really want to read file from end to begin by yourself,
you should be familiar with system calls like seek (perldoc -f seek)
and tell (perldoc -f tell).

here is sample(taken from fido7.ru.perl, author Dmitriy Goldobin ):
sub PrintReverse
{
open FILE, shift; binmode FILE; seek FILE, 0, 2;
my $chunk = ;
for( my $pos = tell(FILE)  ~2047; $pos = 0; $pos -= 2048 ) {
my $buf; seek FILE, $pos, 0; read FILE, $buf, 2048;
@_ = split /^/, $buf.$chunk;
$chunk = shift if $pos;
print pop while( @_ );
}
}

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: adding element to array if a match found

2001-09-01 Thread Maxim Berlin

Hello Jeremy,

Saturday, September 01, 2001, Jeremy Lomas [EMAIL PROTECTED] wrote:

JL I have a file that I'm reading into an array. The file will be 3 colon
JL delimited fields

JL field1:field2:field3

JL I then read  in another file that has an optional 4th field, and will be
JL noted by matching the first field of this array with the first field of
JL the first array

JL field4:field5

JL I want to see if field4 = field1 (it'll be numeric) if they match, I
JL want to append field5 to the end of the record

JL field1:field2:field3:field5

JL am I crazy for saying I could do this?
no.

JL Until  today I considered myself a novice Perl programmer, but now
JL I'm not so sure. Any help would be greatly appreciated!
please show us your code?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Need help on setuid script.

2001-09-01 Thread Maxim Berlin

Hello Matthew,

Thursday, August 30, 2001, Matthew Sorenson [EMAIL PROTECTED] wrote:

[...]
MS I get the error: Insecure dependency in kill while running setuid at
MS /dev/fd/3.

MS Is there something I can do to satisfy this security condition which will
MS allow perl to complete the action, or am I out of luck, stuck kluging the
MS script in ksh.
if you have apache web server, take a look at suexec.
http://www.apache.org/docs-2.0/suexec.html

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Help with Recursive script on Large Directory

2001-08-28 Thread Maxim Berlin

Hello James,

Tuesday, August 28, 2001, Kipp, James [EMAIL PROTECTED] wrote:

KJ I have this script that recursed through a directory on a network drive and
KJ it's subdirs flagging files based on a couple of params.

KJ Firstly, I know this will be resource intensive. Is there a better way to do
KJ this that is maybe not even a Perl solution?

KJ Secondly, the script is failing to recurse! It just goes a couple of levels
KJ and stops!! It changes to the top-level dir ok and opens it ok but that is
KJ it.
KJ I know about file find but I do not want to use it.

KJ I am running NT Workstation, the mapped network drive is on a Novell Server.
KJ Thanks for any help on this.
KJ Here is the script:
KJ 
KJ # script will recurse through specified directory logging files that have
KJ # not been modified in 60 days and are over 50MB.

KJ # use strict;
KJ use Cwd;
KJ use File::Spec;

KJ # system ('h:') or die can't get to h:\n;
KJ $log = 'c:\\temp\\chk_space.txt';
KJ $path = 'dbm\\marketing_database_II';

open(LOG, $log) or die Can't open $log: $!;
KJ print LOG These files are over 60 days old and over 50MB\n\n;

KJ ScanDir($path);

ScanDir($path);

KJ sub ScanDir
KJ {
KJ my ($workdir) = shift;
KJ my ($start) = File::Spec-curdir();
your $start='.' here.
my ($start) = cwd;

KJ my @stuff;
KJ # my ($age, $size); 
KJ system(h:); #this fails to for some reason, so I have to manually do
#system(h:); #this fails to for some reason, so I have to manually do
chdir does that for you.

KJ chdir($workdir) or die Can't cd to $workdir: $!\n;
KJ opendir(DIR, .) or die Can't open directory $path: $!\n;
KJ @stuff = grep (!/^\.\.?$/ , readdir(DIR));
KJ closedir(DIR);

KJ foreach my $file (@stuff) {
KJ # next if $file =~ /^\.\.?$/;
KJ next if $file =~ /mediaCreate/;
KJ if (-d $file)   {
KJ ScanDir($file);
ScanDir($file);
KJ next;
KJ }


KJ if(((-M $file)  60)  ((-s $file)  1024 ** 2 * 50 )) {
KJ print LOG $workdir/$file\n;
KJ }
KJ chdir($start) or die Unable to CD to $start: $!\n;
you don not want this here. it's algorythmical error.
#chdir($start) or die Unable to CD to $start: $!\n;
KJ }
chdir($start) or die Unable to CD to $start: $!\n;
KJ }


KJ close LOG;  


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: Writing a log file?

2001-08-28 Thread Maxim Berlin

Hello John,

Tuesday, August 28, 2001, Michael Fowler [EMAIL PROTECTED] wrote:

MF On Tue, Aug 28, 2001 at 02:42:58PM -0400, John Way wrote:
 Does anyone know how to get a perl script to write out each line of code to
 an output (log) file as it performs each line? (Other than a print
 statement after everyline) I've looked in the perlrun documentation, but
 could not find anything.

MF I do not know of such a feature.  The Perl debugger gets close, but it's
MF interactive; perhaps you could get it to log to a file, I don't know.
yes, it's possible via perl debugger and $ENV{PERLDB_OPT}.

perldoc perldebug
search for UsageOnly

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: Help with Recursive script on Large Directory

2001-08-28 Thread Maxim Berlin

Hello James,

Tuesday, August 28, 2001, Kipp, James [EMAIL PROTECTED] wrote:
KJ Thanks so much for your help. Is this how the code should be before I test
KJ it again.

It depends of your needs. for example, in your log file you miss full
name of files.
a good example or educational purpose, but in real life, please use
File::Find.

KJ use Cwd;

KJ $log = 'c:\\temp\\chk_space.txt';
KJ $path = 'dbm\\marketing_database_II';

open(LOG, $log) or die Can't open $log: $!;
KJ print LOG These files are over 60 days old and over 50MB\n\n;

KJ ScanDir($path);
KJ ## why not ScanDir($path)??
see perldoc perlsub for detailed explanation about differences between
(example from perlsub)
   foo(1,2,3);# pass three arguments
   foo(1,2,3); # the same

   foo();  # pass a null list
   foo(); # the same

   foo;   # foo() get current args, like foo(@_) !!
   foo;# like foo() IFF sub foo predeclared, else foo

you do not need that , so don't use it, it's dangerous.
example:

sub a
{
print sub\n;
}

print test
a;

i've missed ';' after 'print test', and now i got

print test  a;

construction. very difficult to find.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[10]: Stripping line breaks

2001-08-26 Thread Maxim Berlin

Hello Christopher,

Sunday, August 26, 2001, Christopher Solomon [EMAIL PROTECTED] wrote:
[]
 CS or am I misunderstanding you?
 
 may be.
 example:
 
 $regex=STDIN; chomp $regex;
 $variable=STDIN; chomp $variable;
 $a =~ s!$variable!$regex!;
 

CS Well, in this case, I don't see a problem.  The contents of $variable (and
sorry, my mistake. in that case regex works correctly.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Getting the time

2001-08-25 Thread Maxim Berlin

Hello Rory,

Saturday, August 25, 2001, Rory O'Connor [EMAIL PROTECTED] wrote:

ROC All I need to do is find out how to get the current date and time from
ROC the server so that I can write it to a logfile I'm creating.  How can I
ROC do that?

which server do you mean? NTP? or you need local time from your
computer? see
perldoc -f localtime

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Stripping line breaks

2001-08-25 Thread Maxim Berlin

Hello Rory,

Saturday, August 25, 2001, Rory O'Connor [EMAIL PROTECTED] wrote:

ROC Another quick one - how can I easily strip line break characters from a
ROC variable?

see
perldoc -f chomp

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: Stripping line breaks

2001-08-25 Thread Maxim Berlin

Hello Rory,

Saturday, August 25, 2001, Rory O'Connor [EMAIL PROTECTED] wrote:

ROC thanks all for your help.  It is my understanding that chomp($var); will
ROC only strip the \n from the end of a string.  I'm dealing with strings
ROC that could potentially be littered with newline characters.
well... then you have multiple strings stored in one variable? yes,
chomp won't help you here.
ROC   I have an
ROC o'reilly perl book, but it's not super clear on how to strip *all*
ROC newline characters out of a string, no matter where they are.  am i
ROC right in assuming regex needed for this?
in perl way, yes. something like

$a=a\nb\nc\nd\n\n\n;
$b=$/;
$a =~ s/$b//g;

alternativelly, you can take a look at
perldoc -f substr

Best wishes,
 Maximmailto:[EMAIL PROTECTED]

p.s. does anyone know, why i can not write $a =~ s/$///g; ?



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




Re[4]: Stripping line breaks

2001-08-25 Thread Maxim Berlin

Hello Christopher,

Saturday, August 25, 2001, Christopher Solomon [EMAIL PROTECTED] wrote:
 p.s. does anyone know, why i can not write $a =~ s/$///g; ?

CS You can. 

CS $a =~ s!$/!!g;

CS Perl just gets confused with the /'s, you have to use alternate
CS delimiters.
ok, what about $! ? use @? what about $@?
and so on...

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[6]: Stripping line breaks

2001-08-25 Thread Maxim Berlin

Hello Christopher,

Sunday, August 26, 2001, Christopher Solomon [EMAIL PROTECTED] wrote:

  p.s. does anyone know, why i can not write $a =~ s/$///g; ?
 
 CS You can. 
 
 CS $a =~ s!$/!!g;
 
 CS Perl just gets confused with the /'s, you have to use alternate
 CS delimiters.
 ok, what about $! ? use @? what about $@?
 and so on...

CS I guess just use whatever delimiters won't get caught up in the variable
CS name.  You can use (I believe) any non-alphanumeric character as a regex
CS delimiter.  I like !, /, ^, and {} personally.
:) what if i don't know variable name?

$! is $OS_ERROR, $ERRNO
$/ is $INPUT_RECORD_SEPARATOR, $RS
$^ is $FORMAT_TOP_NAME

well, ${ unassigned now...

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[8]: Stripping line breaks

2001-08-25 Thread Maxim Berlin

Hello Christopher,

Sunday, August 26, 2001, Christopher Solomon [EMAIL PROTECTED] wrote:

   p.s. does anyone know, why i can not write $a =~ s/$///g; ?
  
  CS You can. 
  
  CS $a =~ s!$/!!g;
  
  CS Perl just gets confused with the /'s, you have to use alternate
  CS delimiters.
  ok, what about $! ? use @? what about $@?
  and so on...
 
 CS I guess just use whatever delimiters won't get caught up in the variable
 CS name.  You can use (I believe) any non-alphanumeric character as a regex
 CS delimiter.  I like !, /, ^, and {} personally.
 :) what if i don't know variable name?
 
 $! is $OS_ERROR, $ERRNO
 $/ is $INPUT_RECORD_SEPARATOR, $RS
 $^ is $FORMAT_TOP_NAME
 

CS If you're using a regex, like above, I can't really imagine a situation
CS where you wouldn't know the variable name. Know what I mean?
yes.

CS if you are using s!variable!!g, then surely you will know what  
CS variable will be, even if you don't know the contents of that variable.
no.

CS or am I misunderstanding you?

may be.
example:

$regex=STDIN; chomp $regex;
$variable=STDIN; chomp $variable;
$a =~ s!$variable!$regex!;

any ideas?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: [ sort ]

2001-08-24 Thread Maxim Berlin

Hello Mellotto,

Thursday, August 23, 2001, Mellotto [EMAIL PROTECTED] wrote:

M I've tried to sort hash values. The following file shows my problem:
M 
M #!/opt/perl5/bin/perl
M %map = (
M 1  = 1,
M 2  = 10,
M 3  = 200,
M 4  = 2,
M 5  = 5,
M 6  = 150,
M 7  = 45,
M 9  = 12,
M 8  = 30,
M 10 = 13,
M );
M for  (sort {$map{$a} = $map{$b} || sort $b } keys %map) {
M printf(%d;%d\n, $_, $map{$_});
M }
M 
M The output for this script:
M 1;1
M 4;2
M 5;5
M 2;10
M 9;12
M 10;13
M 8;30
M 7;45
M 6;150
M 3;200

M I need to sort numerically by first column. I've written it
M in many ways, but it still sorting by second column.

M Could you help me solve this problem?

for  (sort {$a = $b} keys %map) {
printf(%d;%d\n, $_, $map{$_});
}


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: a1.a2.a3.a4 - integer

2001-08-23 Thread Maxim Berlin

Hello P,

Friday, August 24, 2001, P lerenard [EMAIL PROTECTED] wrote:

Pl I can transform an ip a1.a2.a3.a4 to an integer using
Pl b1=a1  24
Pl b2=a2  16
Pl b3=a3  8
Pl int =b1+b2+b3+a4
Pl now I want to do the opposite.
Pl how can I get a1.a2.a3.a4 from this integer?
Pl ok I get a1, but I start to have a headeach to get the rest
if you interested in ip addresses conversions, you can use
use Socket;

sub ip2ul {
return inet_aton($_[0]);
}

sub ul2ip {
return inet_ntoa($_[0]);
}

or something like this:
sub ip2ul {
   return unpack( 'N', pack( 'C4', split( /\./, shift ) ) );
}
sub ul2ip {
   return join( '.', unpack( 'C4', pack( 'N', shift ) ) );
}

(receipts stolen from russian fido7.ru.perl group)

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: redirecting print output to a variable

2001-08-23 Thread Maxim Berlin

Hello Bas,

Thursday, August 23, 2001, Bas Bloemsaat [EMAIL PROTECTED] wrote:

BB I've got this code:

BB #Example of generated code. I have little influence over the actual code in
BB the variable. It's generated from a template.
BB $generatedCode = '$test = some result; print test is: $test;';

open MYFILE, somefile;
BB select(MYFILE);
BB my $testvar = eval $generatedCode;
BB select(STDOUT);
BB close MYFILE;

BB this prints the result of the generated code in a file called somefile. Is
BB there any way in which I can store the output from the
BB eval $generatedCode;
BB in a variable, be it a string or an array, instead of in a file? I have to
BB do this a lot , and having a file in between slows the code quite a bit.
i'm not sure, that have correctly understand you.
may be you need this?
$generatedCode = '$test = some result; print test is: $test;';
$generatedCode =~ s/print /return /;
my $testvar = eval $generatedCode;
print testvar=$testvar;

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: is this sub called correctly? am I missing something?

2001-08-23 Thread Maxim Berlin

Hello Birgit,

Thursday, August 23, 2001, Birgit Kellner [EMAIL PROTECTED] wrote:

BK my ($db_key, %rec);
BK # %orderhash contains numeric keys and values, like ('43' = '5', '20' = 
BK '17'); I want to call the sub get_record for each of these keys.
BK # NOTE: this works perfectly, with the same syntax, in other parts of the 
BK same file.
BK # might the problem be that I'm embedding the call to the sub in a foreach 
BK loop here?

BK foreach (keys %orderhash) {
BK $db_key = $_;
BK print Database key: $db_key; #this works fine, so $db_key HAS a 
numeric 
BK value
BK %rec = get_record($db_key); # here's the problem: %rec doesn't 
get 
BK returned
BK print Number: $rec{'number'}; # ouch, no value.
BK }

BK # this is the called sub, contained in another file that we're requiring.
BK # other file also runs under use strict - no errors reported. all variables 
BK not declared in the sub are declared globally.
BK # I won't give all explanations about what this does just yet - hoping that 
BK this is a simple logic error which I'm too blind to see ...

BK sub get_record {
BK # 
BK # Given an ID as input, get_record returns a hash of the
BK # requested record or undefined if not found.

BK my ($key, $found, $line, @data, $field, $restricted, $i, %rec);
BK $key = $_[0];   
BK $found = 0;
BK ($restricted = 1) if ($auth_modify_own and !$per_admin);

BK open (DB, $db_file_name) or cgierr(error in get_records. unable to 
BK open db file: $db_file_name.\nReason: $!);
BK if ($db_use_flock) { flock(DB, 1); }
BK LINE: while (DB) {
BK (/^#/)  and next LINE;
BK (/^\s*$/)   and next LINE;
BK $line = $_; chomp ($line);  
BK @data = split_decode($line);
BK next LINE if ($restricted and ($db_userid ne 
$data[$auth_user_field]));
BK if ($data[$db_key_pos] eq $key) {
BK $found = 1;
BK for ($i = 0; $i = $#db_cols; $i++) {  # Map the array 
columns to a hash.

Unfortunatelly, my telepathic abilities still seriously broken :)
please put
print key = $db_cols[$i], value = $data[$i];
here and show us output.
BK $rec{$db_cols[$i]} = $data[$i];
BK }
BK last LINE;
BK }
BK }
BK close DB;   
BK $found ?
BK (return %rec) :
BK (return undef);
BK }

Birgit, please, provide as more information as possible with your question, not only
piece of code. it's very hard to understand, what can be wrong.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Having a problem with sendmail

2001-08-21 Thread Maxim Berlin

Hello Craig,

Wednesday, August 22, 2001, Craig S Monroe [EMAIL PROTECTED] wrote:

CSM The script completes, but the mail is never sent.
CSM I do not receive any errors..

CSM #! /usr/bin/perl -w

CSM use strict;

CSM my $from = mailer\@testsite\.com;
CSM my $email = cmonroe11\@mediaone\.net;
CSM my $subject = This is a test mail;
CSM my $messagebody = ;
CSM my $mail_program;

CSM #  Initiate the email to the user.
CSM sub send_mail {
CSM my ($from, $email, $subject, $messagebody) = @_;
CSM my $flags = -t;  # -odq would add it to the queue
CSM $mail_program = '/bin/sendmail';
CSM $mail_program .=  $flags;
CSM open (MAIL, |$mail_program) || die Could Not Open Mail Program: $!;
CSM print MAIL __END_OF_MAIL__;
CSM To: $email
CSM From: $from
CSM Reply-to: $from
CSM Subject: $subject
CSM Content-Type: text/plain;
CSM $messagebody
CSM __END_OF_MAIL__
CSM close (MAIL);
CSM } # End of send_mail


CSM print Content-type: text/html\n\n;
CSM print EOF;
CSM html
CSM body
CSM Sent email:
CSM $from
CSM $email
CSM $subject
CSM $messagebody
CSM /body
CSM /html
CSM EOF
CSM 
CSM Sorry remedial question, but whew this one is getting to me...

well... sorry for a stupid question, but i can not see - where did you call
send_mail() sub?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: dynamic table help

2001-08-20 Thread Maxim Berlin

Hello Keith,

Monday, August 20, 2001, Keith  Rachel Murphy [EMAIL PROTECTED] wrote:

KRM Need  a little help. I have a problem that I have been banging my
KRM head  on  all  weekend  and  I  am more than a little frustrated.
KRM Basically,  I want to pull data from a database and display it in
KRM the  form  of  a table, with a row in the table for each row from
KRM the  database. What happens is each row from the database ends up
KRM as  its  own  seperate  table.  The  current  code  portion is as
KRM follows:


KRM #!/usr/bin/perl -w
KRM #
KRM #

KRM use CGI qw(:all);
use CGI qw/:all *table/;

KRM use DBI;


KRM blah,blah,blah..



KRM ## fetch results and print
print start_table({-border=5});

KRM while ( my @row = $sth-fetchrow_array() ) {

KRM ($id,$first_name, $last_name, $phone_number, $street_address, $city, $state, 
$zip, $email) = @row;
printTr({-valign=CENTER},
KRM [
KRM td(['First Name', $first_name]),
KRM td(['Last Name', $last_name]),
KRM td(['Phone Number', $phone_number]),
KRM td(['Street Address', $street_address]),
KRM td(['City', $city]),
KRM td(['State', $state]),
KRM td(['Zip', $zip]),
KRM td(['E-Mail', $email]) 
KRM ]
);
KRM }
print end_table();



Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: chomp list

2001-08-20 Thread Maxim Berlin

Hello Jennifer,

Tuesday, August 21, 2001, Jennifer Pan [EMAIL PROTECTED] wrote:

JP I have a file :
JP #myfile.txt
JP a   b   c   d
JP a   c   s   g
JP g   o   y   g
JP _END_

JP I wrote a perl script to put each line into a list;

JP #/usr/bin/perl -w
JP open (FH, myfile.txt) ;
JP while ($LINE = FH) {
JP chomp $LINE;
JP push @list, $LINE;
JP }
JP close FH;

JP print $_ for (@list);

JP _END_

JP I expect to get 
JP a   b   c   da  c   s   gg  o   y
JP g
JP instead I got
JP a   b   c   d
JP a   c   s   g
JP g   o   y   g

JP why didn't chomp work??!!
chomp removes part of your string, defined in '$/' variable.

JP any insight is appreciated
what is your environment?
you can get above result if, for example, you have created myfile.txt in
windows ($/=\r\n), tranfers myfile.txt to unix-like OS ($/=\n) in binary mode,
and then run your script in unix.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: k-shell case statement

2001-08-20 Thread Maxim Berlin

Hello Robert,

Tuesday, August 21, 2001, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Ric What is the best perl example of a k-shell case statement as follows:

Ric case $VAR1
Ric in

take a look at Basic BLOCKs and Switch Statements in
perldoc perlsyn

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: SMTO Socket Connection

2001-08-13 Thread Maxim Berlin

Hello Joel,

Monday, August 13, 2001, Joel Divekar [EMAIL PROTECTED] wrote:

JD Hi Friends

JD Friday evening I heard a New that there is a change of MTA on our 
JD WebServer. And then all my Perl scripts running on our WebServer refuse to 
JD send me any stats / logs by email. And this gave me a jolt on Saturday 
JD morning. I requested our Admin to send me docs related to our new MTA and 
JD got the copy odf the same immediately. I opened my general purpose 
JD sub-routine file modified mail sending part accordingly and again all my 
JD scripts started sending me mails again. WOW but what happens if there is 
JD change of MTA again and again and again.
JD So I decided to write a simple SMTP program which makes a socket connection 
JD to the specified port and send mail irrespective of a MTA.

JD I started with the following code.

JD ===
JD # Please note my system runs Win2k + Activestate Perl
JD # And My Server Red Hat 6.2
JD ===

JD #!/usr/bin/perl -w

JD # use packages
JD use strict;
JD use IO::Socket;

JD # Data Variables
JD my ($SMTP_Server) = 10.10.10.10;
JD my ($SMTP_Port) = 25;
JD my ($CR) = \r\n;
JD my $Socket;

JD # Mail Related Data
JD my $from = joel\@testlinux.net;
JD my $to = joel\@testlinux.net;

JD # Open Socket - SMTP Connection
JD $Socket = IO::Socket::INET-new(PeerAddr = $SMTP_Server,
JD  PeerPort = smtp($SMTP_Port),
JD  Proto= tcp,
JD  Type = SOCK_STREAM)
JDor die Error : Cannot Open SMTP Socket. Reason : $!;

JD # set buffering off or autoflush
JD $|=1;

JD # say hello the mail host
JD # print $Socket HELO $SMTP_Server . $CR;

JD # Send Mail Command

JD # mail from
JD print $Socket MAIL FROM: $from . $CR;

JD # mail to
JD print $Socket RCPT TO: $to . $CR;

JD # Data command
JD print $Socket DATA . $CR;

JD # test message
JD print $Socket Test Message . $CR;
JD print $Socket . . $CR;

JD #quit SMTP Session
JD print $Socket QUIT . $CR;

JD # Close Connection
JD close $Socket;

JD # Print Socket Close
JD print SMTP Socket Closed . $CR;

JD ===

JD Problem : and the mail is received by me immediately
JD but it gives To: as undisclosed-recipients

JD Help : a) Where did I go wrong in my code ?
nothing wrong in your code. just add
print $Socket To: $to\n;
after DATA command.

JDb) Any guideline on how to improve my code
perldoc Net::SMTP

   use Net::SMTP;

   $smtp = Net::SMTP-new('mailhost');

   $smtp-mail($ENV{USER});
   $smtp-to('postmaster');

   $smtp-data();
   $smtp-datasend(To: postmaster\n);
   $smtp-datasend(\n);
   $smtp-datasend(A simple test message\n);
   $smtp-dataend();

   $smtp-quit;

JDc) Any guidelines on attaching file(s)
http://search.cpan.org/doc/ERYQ/MIME-Lite-2.111/lib/MIME/Lite.pm

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Not working in Netscape, working in IE

2001-08-13 Thread Maxim Berlin

Hello Rahul,

Monday, August 13, 2001, Rahul Garg [EMAIL PROTECTED] wrote:
RG The problem goes like this-

RG value of $mailids is coming from previous perl script 
RG if($emailids eq ' ' || $emailids eq '@' || $emailids eq '.' || $emailids !~ /..+/ )
RG {
RG print enter;
RG Content-type : text/html
RG html
RG headtitleSearch/title/head
RG body

RG #invokes the same perl script with the error message ..not
RG working  in  Netscape  but  working  in IEinstead it gives the
RG complete HTML code in Netscape...any solution

RG /body
RG /html

just add empty line after
Content-type : text/html

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Recursive file copy

2001-08-09 Thread Maxim Berlin

Hello perl newbie,

Thursday, August 09, 2001, perl newbie [EMAIL PROTECTED] wrote:


pn I am using the following code to do two things:

pn 1) create a unique directory name using @ARGV, and
pn 2) recursively copy the contents of a source directory
pn into the target directories.

[..]

pn I would appreciate help with the following questions:

pn 1) what am I possibly doing wrong ?
see below.

pn 2) Is there a problem with my usage of the foreach
pn loop in this case.
no.
pn 3) Is there a better way to accomplish what I am doing
pn ?
depends of your needs. may be you want File::Copy?

pn PS:  Here is the source code:

pn - Perl Source Code 

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

pn ##
pn ###MAIN PROGRAM###
pn ##


pn # set environment variables.

pn $ENV{WORK_AREA} = /tmp/regr_tests;

$ENV{'WORK_AREA'} = /tmp/regr_tests;

pn # forward declarations, required due to the use
pn # of the strict pragma.

pn # variable declarations
pn my $dir_name;
pn my $cal_date = POSIX::strftime(%m%d%Y,localtime());
pn my $proc_id = getpid();

pn # function declarations
pn sub myMkDir;

pn # loop through the command line arguments and
pn # check for the existence of the named directories.
pn # Create new directories ONLY if they are not already
pn # existing.

pnforeach $dir_name (@ARGV){

pn # create unique directory names per each run.
pn$dir_name= $dir_name . _. $cal_date . _ .
pn $proc_id ;
if you really need random number, do not use process id.
look at perldoc -f rand.
pn myMkDir $ENV{WORK_AREA}/$dir_name;
myMkDir $ENV{'WORK_AREA'}/$dir_name;

pn # recursively copy files from DB area to TEST area.
pn system(/usr/bin/cp -rf \$HOME/samples \$ENV{WORK_AREA}/\$dir_name);

you should not escape $ sign on variables; try
print /usr/bin/cp -rf \$HOME/samples \$ENV{WORK_AREA}/\$dir_name;
to feel difference.

and your $HOME undefined. may be you mean
system(/usr/bin/cp -rf $ENV{'HOME'}/samples $ENV{'WORK_AREA'}/$dir_name);

pn }

pn ### end of main

pn ##
pn   Sub myMkDir 
pn ##

pn sub myMkDir {
pn   my $dir = shift;

pn   if (-e $dir) {
pn if (!(-d $dir)) {
pn   # Exist, but not a directory, it's a file
pn   die Error: can't create directory $dir, a file
pn of that name already exist
pn s\n; }
pn  else { die Error: can't create directory $dir, a
pn directory of that name al
pn ready exists\n; }
pn   } else {
pn mkdir $dir, 0755;
pn   }
pn }


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: antispam or something

2001-08-08 Thread Maxim Berlin

Hello Morgan,

Wednesday, August 08, 2001, Morgan Norell [EMAIL PROTECTED] wrote:

MN in the mailform

MN require log.pl

MN and in the log.pl

MN #!/usr/bin/perl -wT

MN $location = unknown;
MN if ($ENV{'REMOTE_ADDR'}) {
MN   $location = $ENV{REMOTE_ADDR};
   $location = $ENV{'REMOTE_ADDR'};
MN }
MN if ($ENV{REMOTE_HOST}) {
if ($ENV{'REMOTE_HOST'}) {
MN  $location = $ENV{REMOTE_HOST};
 $location = $ENV{'REMOTE_HOST'};
MN }

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Compare large files memory error

2001-08-07 Thread Maxim Berlin

Hello Mbedish,

Tuesday, August 07, 2001, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

Mac Is  there  a better way to compare large files than this snippet,
Mac which runs out of memory if files  30mb.

Mac It is also slow, about the same speed as comparing in a text editor!

Mac Thank you.

Mac __SNIP__

Mac @file1 =  (IN1);
Mac @file2 =  (IN2);
first, it is a very bad practice to read entire file into memory.  for
example, if file size is bigger than free memory, you'll have unpredictable
result.
second, the slowest operation in your example is file I/O. your files
may have differences in second string, so you do not need to read rest of
file.


Mac $are_equal = compare_arrays(\@file1, \@file2);

Mac if ($are_equal) {

Mac print Files are IDENTICAL \n;
Mac }

Mac else

Mac {

Mac print Files are DIFFERENT \n;
Mac }

Mac sub compare_arrays {
Macmy ($first, $second) = @_;
Mac#no warnings;  # silence spurious -w undef complaints
third, you compare your arrays two times

first pass:
Macreturn 0 unless @$first == @$second;
second pass:
Macfor (my $i = 0; $i  @$first; $i++) {
Macreturn 0 if $first-[$i] ne $second-[$i];
Mac}

Macreturn 1;
Mac}

Mac __SNIP__
so, i can recommend something like
$retval=1;
while( $a=IN1 )
{
$b=IN2;
if ($a ne $b)
{
$retval=0; last;
}
}
close IN1; close IN2;
return $retval;

at the beginning, you can compare files size (perldoc -f stat).


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: perl interpreter

2001-08-01 Thread Maxim Berlin

Hello Sascha,

Wednesday, August 01, 2001, Sascha Kersken [EMAIL PROTECTED] wrote:

SK You just CAN'T.
SK What you have to do is install a Perl interpreter on each computer you want
SK to run Perl scripts on.
can not agree with you because of laziness.
(The three principal virtues of a programmer are Laziness, Impatience,
and Hubris)

s/programmer/sysadmin/;
:)

SK The best - and most easily to install - distribution for Windows systems is
SK ActivePerl which can be downloaded at www.activestate.com


 Sorry, I am an absolut beginner, started with perl on Saturday ;) !

 Can anybody tell me if - and how - it is possible to start my perl-scripts on
 computers without a perl interpreter, without an installed perl - on
 windows-computers of my coworkers?
to Matthias:

it depends...
you need perl, that uses config files, not windows registry (activeperl
can not help you there).
then simply install perl on network drive, share them and add to path
on coworkers computers ( drive letter should be the same ).

take a look at http://www.cpan.org/ports/index.html, or you can take
Perl-5.00502 at http://www.mysql.com/downloads/os-win32.html. he is
very old, but still works. But, here you will have problems with new
modules which you will install - you will need win32 C compiler.
decision is yours.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: readdir

2001-07-27 Thread Maxim Berlin

Hello COLLINEAU,

Friday, July 27, 2001, COLLINEAU Franck FTRD/DMI/TAM 
[EMAIL PROTECTED] wrote:

CFFDT I have a problem with my code:

CFFDT #!/usr/bin/perl -w

CFFDT opendir (LMI,lmi) || die impossible d'ouvrir lmi: $!;
CFFDT $chaine=BEGIN PAPIER;
CFFDT while($fichier=readdir LMI)
CFFDT {
first, you should not open . and ..
next if ($fichier eq '.' or $fichier eq '..');
CFFDT open (FICHIER,lmi/$fichier) || die impossible d'ouvrir $fichier:
CFFDT !$\n;
CFFDT open(TEMP,temp.htm)|| die impossible d'ouvrir temp.htm: $!\n;
CFFDT print TEMP
CFFDT !-\n;
CFFDT $trouve=0;
CFFDT while($fichier)
second, you have endless loop here. $fichier always true.
may be you mean
while($fichier=FICHIER)
or
while(FICHIER)
if you use $_?
CFFDT {
CFFDT $trouve = 1 if($_=~m/$chaine/);
CFFDT if ($trouve) 

CFFDT {
CFFDT (print TEMP $_)|| die écriture impossible dans
CFFDT temp.htm $!\n;
CFFDT }
CFFDT if (/DATA\/unnoir.gif/) {last};

CFFDT }
CFFDT close(FICHIER); 
CFFDT close(TEMP);
CFFDT }



CFFDT closedir LMI;


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: newlines

2001-07-26 Thread Maxim Berlin

Hello Sergio,

Thursday, July 26, 2001, Sergio Gonzalez [EMAIL PROTECTED] wrote:


SG Hi,

SG I'm wondering how to make sure that when my data is written to a file, a
SG proper end of line is in place after ea. intended line.

it's not your job. leave it to operating system.

SG code:

SG ...

SG # now loop and append the data to the file 

SG # Loop thru hash and write data 
SG foreach $value(values %cgidata) {  
SG  if ($debug  0) { print Writing Values: \$value\,BR\n;   }
SG  print FILEHANDLE \$value\,; # PRINT all data
   
SG  }  

SG #  Here is were my question is #

SG print FILEHANDLE \n;  # PRINT end of line 

that's enough.

SG ... more code ...

SG should i use something like # print FILEHANDLE \r 
NO.

SG basically i want my data to output as comma delimited, but i want the end
SG of lines to be in place when i ftp the file over to a win system.

again, it's not your job. you should switch ftp to ascii mode, and
then transfer your text files.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Arrays as subroutines arguments

2001-07-26 Thread Maxim Berlin

Hello Diego,

Thursday, July 26, 2001, Diego Riaño [EMAIL PROTECTED] wrote:

DR How can I pass two arrays as subroutine arguments?
passing arrays as arguments is bad idea; you should use references.

my_sub(\@array1, \@array2);
sub my_sub
{
my ($ref1,$ref2) = @_;
print $$ref1[0], $$ref2[0];
}

see perldoc perlref for more.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Reading binary files

2001-07-26 Thread Maxim Berlin

Hello Sambamoorthy,

Thursday, July 26, 2001, Sambamoorthy Jayaraman [EMAIL PROTECTED] wrote:

SJ How do I read a binary file?? From this file, I need to read 16 bit values.
SJ I have attached a sample binary file alongwith. When you are reading this 
SJ file, enable `hex edit mode'.
perldoc -f binmode

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: if in a list

2001-07-26 Thread Maxim Berlin

Hello Jennifer,

Thursday, July 26, 2001, Maxim Berlin [EMAIL PROTECTED] wrote:

MB $boolean = grep /AF1/,@mylist;
sorry, incorrect sample. should be:
$boolean = grep /^AF1$/,@mylist;
with first regexp you catch every string, that contain 'AF1'.

thanks to Mooney Christophe.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: if in a list

2001-07-26 Thread Maxim Berlin

Hello Jennifer,

Thursday, July 26, 2001, Jennifer Pan [EMAIL PROTECTED] wrote:

JP I want to test if AF1 is in my list @mylist;

JP I did: 

JP foreach $LIST (@mylist) {
JP if ($LIST = AF1) 
JP $boolean = 1;
JP else 
JP $boolean = 0;
JP }

JP is there a more elegant way to do it?

$boolean = grep /AF1/,@mylist;

perldoc -f grep

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: split

2001-07-21 Thread Maxim Berlin

Hello Greg,

Sunday, July 22, 2001, Greg [EMAIL PROTECTED] wrote:

G I need to split an array up. I need to split on colons and spaces.  I appear
G to be successful splitting on a colon, but am having difficulty doing both.
G Any advice would be appreciated.

G # existing...
G @_ = ($hour, $minute, $second, $frame, $crap1, $crap2, $crap3, $crap4) =
G split(/:/,$line);
(if i correctly understand you) try
split(/[: ]/,$line);

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: help with email submit

2001-07-21 Thread Maxim Berlin

Hello ken,

Saturday, July 21, 2001, ken clark [EMAIL PROTECTED] wrote:

kc Help. I am very new. I am using this script to create a guestbook entry; 
kc however I want it to ALSO email the results to me. I am willing to figure 
kc this out myself if someone can point me in the right direction.
if you need to send email(s), take a look at Net::SMTP module.
perldoc Net::SMTP
if you have it already installed, or
http://search.cpan.org/doc/GBARR/libnet-1.0703/Net/SMTP.pm
otherwise.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: How to send a notification mail from Windows/NT?

2001-07-20 Thread Maxim Berlin

Hello David,

Friday, July 20, 2001, Nazary, David [EMAIL PROTECTED] wrote:

ND Hi,

ND When I use the following script to send mail: 

[...]
ND I get this error message. Any ideas how I can resolve this?

C:\CM\utilsc:\perl\bin\perl  smtp_mailer2.pl
ND The system cannot find the path specified.
ND Use of uninitialized value in scalar assignment at
ND c:/Perl/site/lib/Net/Domain.pm line 191.
ND Use of uninitialized value in scalar assignment at
ND c:/Perl/site/lib/Net/Domain.pm line 191.
ND Use of uninitialized value in pattern match (m//) at
ND c:/Perl/site/lib/Net/Domain.pm line 215.
ND Use of uninitialized value in split at c:/Perl/site/lib/Net/Domain.pm line
ND 219.

looks like your perl installation damaged. try to reinstall.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: module question

2001-07-20 Thread Maxim Berlin

Hello Jerry,

Friday, July 20, 2001, Jerry Preston [EMAIL PROTECTED] wrote:


JP My program to test out my module is:

JP #!/usr/local/bin/perl

JP   use CGI;
JP   use CGI::Carp qw(fatalsToBrowser);
JP   use KI;

JP   $ki = new KI();
JP   $query=new CGI;

JP   print $query-header();
JP   print $query-start_html( -title  = 'test' );
JP   print $query-startform(  -method = 'POST', -name = 'test' );

JP%wdf = $ki-test;

according to your module:
$wdf = $ki-test;

JP   print name *$wdf{ 'name' }*br;

and:
print name *$$wdf{ 'name' }*br;

JP   print $query-end_form();


JP I am not sure what I am doing wrong.  The module test will print out my name, but 
I cannot get
JP my script to print out my name.

JP Any ideas?
do
use strict;
in your scripts.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: module question

2001-07-20 Thread Maxim Berlin

Hello Jerry,

Friday, July 20, 2001, Jerry Preston [EMAIL PROTECTED] wrote:

JP I  tried  $$  and  still no output. What in the module did I do to
JP make you think the $$ would work?

do you replace
%wdf = $ki-test;
with
$wdf = $ki-test;
too?
your module returns a reference(\%wdf), so you should use pointer.

see
perldoc perlref
for more information.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: Warnings

2001-07-17 Thread Maxim Berlin

Hello paul,

Tuesday, July 17, 2001, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:


pzcu So I am finally tightening up my code using strict and -w.
[...]
pzcu Produces the warning:

pzcu Use of uninitialized value in string ne at logisys.pl line 139, FILE line 3

pzcu Even though the initialise line is there.

pzcu Any ideas?
please show full source;
your part has succesfully checked by my perl.

use strict;
my ($reason2, @theline, %headers, $s_port);
$reason2= @theline[$headers{reason\:}];
$s_port = @theline[$headers{s_port}];
if(($reason2 ne unknown established TCP packet) and ($s_port ne nameserver))
{
}

D:\tempperl -cw t.pl
t.pl syntax OK



Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re[2]: Help pls %

2001-07-13 Thread Maxim Berlin

Hello Govinderjit,

Friday, July 13, 2001, Govinderjit Dhinsa [EMAIL PROTECTED] wrote:

GD How do I please get the fields to start from the positions I want
GD them to please;
GD For example I want;

GD $fields[0],  (which is 7 characters long to start from position
GD 0).
GD $fields[1],  (which is 10 characters long to start from position
GD 10).
GD $fields[2],  (which is 35 characters long to start from position
GD 25).
GD $fields[3];  (which is 15 characters long to start from  position
GD 65).

read perldoc perlform, it may be helpful.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: Log::LogLite -- Returning references to log objects

2001-07-13 Thread Maxim Berlin

Hello Michael,

Saturday, July 14, 2001, Michael Dube [EMAIL PROTECTED] wrote:

MD I am using the Log::LogLite module to facilitate application logging in my
MD script.

[...]
MD I so far have been unsuccessful at doing this.  Whenever I return $log, it
MD is undefined in the calling module.

MD Any suggestions???

please show your source.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: date

2001-07-13 Thread Maxim Berlin

Hello F.H,

Friday, July 13, 2001, F.H [EMAIL PROTECTED] wrote:

FH Does anyone know how to get a difference between 2 dates. For instance
FH something like (07/12/01 - 07/13/01) that would get me 1.
which date format has your input? in most common case i can recommend
convert dates to unixtime (see time::local and localtime), then
substract, and then convert result back to date.

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




Re: open FILE problem

2001-07-12 Thread Maxim Berlin

Hello Jennifer,

Thursday, July 12, 2001, Jennifer Pan [EMAIL PROTECTED] wrote:

JP Hello all,  I came across this problem opening up files that are fed in
JP from command line using ls. I do not know why this script did not
JP work. Appreciated any input. 

[...]
JP at prompt I typed
JP ls *.txt | perl format.pl

JP it never worked
what OS do you use? script works well on my freebsd.

JP  it always die cannot open $LINE.
please show me output, exactly how your script produced.

JP  I don't understand why
me too :)

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: to double or to single quotes? that's the question

2001-07-12 Thread Maxim Berlin

Hello Silvio,

Thursday, July 12, 2001, Silvio Luis Leite Santana [EMAIL PROTECTED] wrote:

SLLS Just to confirm some thoughts I had...

SLLS Since double quotes need to be searched for variable interpolation,
SLLS while single quotes don't, I should always (whenever possible) prefer
SLLS single quotes instead of double quotes in my programs, because:

SLLS print 'hi all';

SLLS would be faster than

SLLS print hi all;

SLLS Am I correct?

customize and check this for youself:

use Benchmark;

timethese( 1e7, {
'one' = sub { my $a = 'hi all';  },
'two' = sub { my $a = hi all;  },
});


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: to double or to single quotes? that's the question

2001-07-12 Thread Maxim Berlin

Hello Silvio,

Thursday, July 12, 2001, Silvio Luis Leite Santana [EMAIL PROTECTED] wrote:

SLLS Just to confirm some thoughts I had...

SLLS Since double quotes need to be searched for variable interpolation,
SLLS while single quotes don't, I should always (whenever possible) prefer
SLLS single quotes instead of double quotes in my programs, because:

SLLS print 'hi all';

SLLS would be faster than

SLLS print hi all;

SLLS Am I correct?

customize and check this for youself:

use Benchmark;

timethese( 1e7, {
'one' = sub { my $a = 'hi all';  },
'two' = sub { my $a = hi all;  },
});


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re[2]: test script

2001-07-11 Thread Maxim Berlin

Hello Bradley,

Wednesday, July 11, 2001, Bradley M. Handy [EMAIL PROTECTED] wrote:

BMH #!/path/to/perl

BMH use CGI;

print CGI-param();
BMH print I'm Working;


BMH I believe the above lines of code should work just fine.

your script does not print content/type, so it produces error as CGI
script.

#!/usr/bin/perl

use CGI qw(:standard);

print header;
print I'm Working;


 Can anyone tell me what is the most basic script that I can load onto a 
 server to test that it is working?


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: syntax checking module

2001-07-11 Thread Maxim Berlin

Hello Rizwan,

Wednesday, July 11, 2001, Rizwan [EMAIL PROTECTED] wrote:

R I am looking for a module that checks the syntax of a perl script.
hm. why don't you use perl itself? or, may be, eval()?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re[2]: cgi help

2001-07-05 Thread Maxim Berlin

Hello Michael,

Sunday, June 24, 2001, Michael P. Carel [EMAIL PROTECTED] wrote:

 MPC Hi there, Is there any one who can help with my problem regarding
MPC perl
 MPC cgi's.
 MPC I've encountering problemwith my webpages when i execute my cgi prog,
MPC heres
 MPC my error messages in my page:
 [...]
 MPC More information about this error may be available
 MPC in the server error log.

 MPC Please help me.

 so, do you look at server error log?
MPC yes ! but it looks weird even some simple cgi script  that will show message
MPC hello doesnt work.

MPC here's my server error log:
MPC [error] (8)Exec format error: exec of /home/httpd/cgi-bin/test.cgi
MPC [error]premature end of script headers: /home/httpd/cgi-bin/test.cgi


MPC and heres my samplecgi file config (/home/httpd/cgi-bin/test.cgi):

MPC#!/usr/bin/perl

MPCprint Content-type: text/html\n\n;
MPCprint Hello World!!\n;

MPCexit;
1. is your script executable?
2. do you have perl installed in /usr/bin ?

from command line, type:

/home/httpd/cgi-bin/test.cgi

and show us, what happened.


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: Parent and Current Directories

2001-07-05 Thread Maxim Berlin

Hello SAWMaster,

Thursday, July 05, 2001, SAWMaster [EMAIL PROTECTED] wrote:

S Hello group!

S I'm  trying to list all files in a directory EXCEPT the current and
S the parent directories.

S ie.

S .
S ..
S file1
S file2
S file3

S Is not what I want.  I only want:

S file1
S file2
S file3

S I thought I had the right code, but I don't.

S while($i  ($#filelist))
S {
S if ((@filelist[$i] ne '.') || (@filelist[$i] ne '..'))

try $filelist[$i]

S {
S print @filelist[$i];
S print BR\n;
S $i++;
S }
S }

S I was thinking, maybe it's not equal to . and .. because of a newline at the end of 
. and .. ?

S But I tried a chop, or chomp and it just took off the last letter of all files, 
problem unsolved.

S Can someone steer a newbie in the right direction again?

Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re[2]: Parent and Current Directories

2001-07-05 Thread Maxim Berlin

Hello SAWMaster,
Thursday, July 05, 2001, Maxim Berlin [EMAIL PROTECTED] wrote:

S I'm  trying to list all files in a directory EXCEPT the current and
S the parent directories.

S ie.

S .
S ..
S file1
S file2
S file3

S Is not what I want.  I only want:

S file1
S file2
S file3

S I thought I had the right code, but I don't.

S while($i  ($#filelist))
S {
S if ((@filelist[$i] ne '.') || (@filelist[$i] ne '..'))

MB try $filelist[$i]
1. and, what the strange if condition? it is always true.


S {
S print @filelist[$i];
S print BR\n;
S $i++;
S }
2. you have endless loop here. $i never increment, if 'if
condition' wrong.

S }


Best wishes,
 Maximmailto:[EMAIL PROTECTED]





Re: How to convert hexadecimal number in decimal ?

2001-07-04 Thread Maxim Berlin

Hello Jean-Paul,

Wednesday, July 04, 2001, Jean-Paul Miéville [EMAIL PROTECTED] wrote:


JPM Can you explain me how can I convert an hexadecimal number in decimal ?


unfortunatelly, i do not remember where i got this :(

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));
 
Best wishes,
 Maximmailto:[EMAIL PROTECTED]





  1   2   >