RE: Calling a Method...
I hope I'm explaining this right. I am including a package: use Net::Telnet::Cisco that includes another package Net::Telnet How do I call a method from Net::Telnet? Do I have the use it explicitly? When I try something like: $x = Net::Telnet::Cisco-new( Host = $_[0] ); $fh = x-input_log('input.log'); #input_log from Net::Telnet I get: Can't locate object method input_log via package x (perhaps you forgot to load x?) at ./telnettest line 38. -- You have a syntax error, since you have not added a '$' in front of x, Perl believes you are perhaps refering to a package (named x). Try this instead: $fh = $x-input_log('input.log'); #input_log from Net::Telnet However, if 'input_log' in a method of Net::Telnet only, then you must make sure that Net::Telnet::Cisco inherit from Net::Telnet or else it will not be found. See the documentation on Net::Telnet::Cisco as I have never used it. -Robin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: problem with concatenation
Here is an extract of my code: 1$chaine2=; 2$chaine3=; 3$chaine4=; 4for($i=0;$i$cpt;$i++) 5{ 6$chaine2=bra href=\#sujet$i\bfont face='verdana, arial' SIZE=2 COLOR=#FF8C52\n; 7$chaine3=$titre[$i]; 8$chaine4 = $chaine2.$chaine3; 9print TEMP $chaine4; 10} There is a problem with line 8; the message is :Use of uninitialized value in concatenation (.) or string at copy.pl line 50. Well, this means that either $chaine2 or $chaine3 is undefined. If you look at $chaine2, you define it before. So $chaine3 is undefined, which means that $titre[$i] is undefined at certain point in your loop. Either check your loop construct (what value does $cpt have?) or check if you are properly filling the @titre array. We cannot help more with only this part of the code. -Robin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Multi-unix hop logins
Hello, I need to perform multiple logins in a hop scheme on Unix machines in order to retrieve a file. If I were to do this manually, I would have to do: rlogin -l username hostname type password if asked rlogin -l username secondmachinename typepassword if asked Then, either rcp or ftp the file back to the first machine. Then get back on the first machine and ftp it back on the original machine (where my script resides). I CANNOT access the last machine without accessing the intermediate one before. What would be the best way to attack this problem ? I've been thinking about using the Expect module, and IO::Telnet. Are there any cool CPAN module that already do this ? I don't want this to be over-complicated by having to parse a bunch of made for human shell interactions... Thanks ! -Robin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: multiple entry/exit points
-Original Message- From: Mooney Christophe-CMOONEY1 [SMTP:[EMAIL PROTECTED]] Sent: Thursday, July 12, 2001 3:33 PM To: 'Rogirio Brito'; [EMAIL PROTECTED] Subject: RE: multiple entry/exit points Personally, i am very liberal with my lasts/breaks/returns/gotos. There is definitely something to be said for strictness. From a theoretical point of view, the code flows better. For example, it is easier to diagram and easier to debug. If i write code for the company i work for, i follow their rules, which usually means only one return statement in a sub/function and no lasts/breaks in my loops. The word 'goto' is considered profane. Then how do you break out of multinested loop? You set a flag and check for that flag in the outer nested loops ? last label and break label are there for that purpose. In C that is the only way of breaking out of multinested loop without using a goto. -Robin -- To unsubscribe, e-mail: -unsubscribe@ For additional commands, e-mail: -help@
FW: Win32 fork(), parent then child
Hi, I tested with a while loop. They do change after a while. This probably has to do with how the output is done on the same terminal in windows and how it handle timesharing. Fork does work correctly with my version of ActivePerl on Win32... -Robin -Original Message- From: Paul Murphy [SMTP:[EMAIL PROTECTED]] Sent: Friday, June 29, 2001 11:22 AM To: [EMAIL PROTECTED] Subject: Win32 fork(), parent then child Hey everyone: Anyone using fork() in Win32 ActivePerl? Consider the following code: code use FileHandle; STDOUT-autoflush(1); $kidpid = fork(); print pid = $$ kidpid = $kidpid\n; print pid = $$ kidpid = $kidpid\n; print pid = $$ kidpid = $kidpid\n; print pid = $$ kidpid = $kidpid\n; print pid = $$ kidpid = $kidpid\n; print pid = $$ kidpid = $kidpid\n; print pid = $$ kidpid = $kidpid\n; print pid = $$ kidpid = $kidpid\n; print pid = $$ kidpid = $kidpid\n; /code I would have thought that the child and parent output would be intermingled. But they don't, the child code gets executed after the parent code is complete. Which kinda defeats the purpose. I have even put in a while() after this that bails when I tell it. The child code gets executed once I let the parent process terminate, or at least the output arrives after the output of the first is complete. But I have stdout autoflushed. Am I missing something here? Paul. -- - CRESTCo Ltd. The views expressed above are not necessarily those 33 Cannon Street.held by CRESTCo Limited. London EC4M 5SB (UK) +44 (020) 7849 http://www.crestco.co.uk -- -
RE: Converting Unix paths to windows
As a side note, you can still use forward slash / instead of \ in Windows. They are compatible with all internal Windows API. Reasons for this is the history prior to MS-DOS being born. -Robin -Original Message- From: Aaron Craig [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, June 27, 2001 11:50 AM To: [EMAIL PROTECTED] Subject: Re: Converting Unix paths to windows At 10:22 27.06.2001 -0500, Daryl Hoyt wrote: Hi, I am writing a script to be used on Windows and many different flavors of Unix. I am looking for a good way to convert Unix paths to Windows. Any Ideas? What do you mean exactly. If you just mean converting \ to / and getting rid of the drive you can do this: my $sPath = C:\\foo\\bar; $sPath =~ s/^[a-z]+://i; $sPath =~ s/\\/\//g; print $sPath; Aaron Craig Programming iSoftitler.com
RE: Unexplainable behavior
-Original Message- From: Charles Lu [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, June 13, 2001 10:53 AM To: [EMAIL PROTECTED] Subject: Unexplainable behavior The following snippet of code doesn't behave the way I want it to. Yet i cannot see why? $hash{s} = T; if(exists($hash{s}) and $hash{s} ne T or $hash{s} ne F) { print inside\n; } else{ print outside\n; } This is a logic problem and can be explained by De Morgan's Law. Basically, if we analyze the if statement, it contains 3 parts. exists($hash{s}) -- true $hash{s} ne T -- false $hash{s} ne F -- true Hence, $hash{s} ne T or $hash{s} ne F -- true And 'true' and 'true' -- true, so it goes 'inside'. So you meant to only go inside if it does not equal T or does not equal F. This can be done by doing: if(exists($hash{s}) and $hash{s} ne T and $hash{s} ne F). -Robin
Variable scope behavior in foreach loop
Hi, I have a small conceptual problem. I have been told that doing: my $item; foreach $item (@arr) { ... } is more efficient than: foreach my $item (@arr) { ... } Because it does not reallocate memory each time. This means that the scope of $item in the second example is actually after the { }. Right ? Then can someone explains why the following code: #---Begin Code--- use strict; my $par=50; print $par\n; my @arr = ('first', 'second', 'third'); foreach $par (@arr) { print $par\n; } print $par\n; #---End Code- produces the following output: 50 first second third 50 This means that the $par in the foreach loop is NOT the same as the $par outside of the loop. However, I use strict and I do not even do a my $par. How can this be possible ? However, when I use the print \$par, I see that it allocates a different address on each iteration of the loop, even without the par. So what does on anyway ? -Robin
Licensing
Hi people, Has anyone been able to conceive some kind of licencing scheme in Perl ? That is, I want to deploy a Perl program that the customer will only be able to use for 30-60-90-30n days. This causes great problem to implement in Perl since the customer could simply comment-out the line that does the check (no matter what kind of check that is). I could use obsufucation technique, but that seems annoying. Anyone has a suggestion ? -Robin
RE: Email question
-Original Message- From: Gross, Stephan [SMTP:[EMAIL PROTECTED]] Sent: Wednesday, May 30, 2001 1:12 PM To: 'Beginner Perl' Subject: Email question I'd like to a write a program that would tell me, for several specific accounts/mailboxes on a Microsoft Exchange server, how many emails are there. I can use either POP3 or IMAP protocols. Any suggestions or pointers? I had success with the Mail::IMAPClient module. For the number of emails in a mailbox, look at the function message_count(). -Robin
Dynamic regular expressions
Hi people, I need to match string against regular expressions that are only known at run-time. I'm having problems doing it so I made a small test script like the following : #!/net/tcmvega35/data1/automation/perl/bin/perl -w use strict; die test.pl [string] [regex] unless $#ARGV == 1; if ($ARGV[0] =~ $ARGV[1]) { print $ARGV[0] matches $ARGV[1]\n; } else { print $ARGV[0] does not match $ARGV[1]\n; } On the command lines, the following happend allo al = match allo /al/ = no match (should match, no ?) allo lo$= match allo ^al= match allo ^ao$ = no match (should match, no ?) Questions : - Why don't I need the regular expression delimiters (/), is it implicit when using variables ? - If I don't add them (/), will it still work for all cases ? - Why doesn't the last case work ? Thanks ! -Robin