Re: print $var =~ s/\s+\).$/)./g;
On Fri, 2008-11-21 at 15:13 -0800, [EMAIL PROTECTED] wrote: > Is there any way I can get rid of that pesky number and just have the > $var string printed? No. Substitution returns the number of substitutions made. Only match will return the matches. -- Just my 0.0002 million dollars worth, Shawn The map is not the territory, the dossier is not the person, the model is not reality, and the universe is indifferent to your beliefs. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Attempting to use SFTP between Windows and Linux box
I have a couple of processes that run one on a production box and another on a test box. The production box script checks that a particular file is never more than 40 minutes old while on the test box, this checks that the actual polling processes ( in this case three pollers ) also are never more that 40 mminutes old. Each poller does it's work and then the last action it does is open a file as output and closes. This has worked very over the last few years, but now with the movement to Linux, they want secure checking and uncertain what I am doing wrong ( or even right for that matter ). I am running under XP SP 2, AS 5.8.8(build 824). I am attempting login via SFTP to pull up the file so I can check it's stats. What I get in my output log is: IT2ua815132X: Reading configuration data C:/Documents and Settings/drw6386/.ssh/config IT2ua815132X: Reading configuration data /etc/ssh_config IT2ua815132X: Connecting to dhprltest.hro.freight.fedex.com, port 22. IT2ua815132X: Remote version string: SSH-1.99-OpenSSH_3.6.1p2 IT2ua815132X: Remote protocol version 1.99, remote software version OpenSSH_3.6.1p2 Math::BigInt: couldn't load specified math lib(s),fallback to Math::BigInt::FastCalc at C:/Perl/site/lib/Crypt/DH.pm line 6 IT2ua815132X: Net::SSH::Perl Version 1.30, protocol version 2.0. IT2ua815132X: No compat match: OpenSSH_3.6.1p2. I have checked both locations ( PC and Linux ) and neither of those configuration files exist. Obviously I am trying to do this in batch/monitoring mode ( no interaction ). Any insights or thoughts on how one approach this would be greatly appreciated? Note: This is a working poller for FTP and not something new. Only trying to get secure processing is new. If you have any questions and/or problems, please let me know. Thanks. Wags ;) David R. Wagner Senior Programmer Analyst FedEx Freight 1.408.323.4225x2224 TEL 1.408.323.4449 FAX http://fedex.com/us -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
print $var =~ s/\s+\).$/)./g;
I would like to print the result of a $var that has been s///'ed. Sure, I can do this: $var =~ s/\s+\).$/)./g; print "$var\n"; but I was thinking more like this: print $var =~ s/\s+\).$/)./g; However, I get a "1" returned (to term), probably b/c one match is found. Is there any way I can get rid of that pesky number and just have the $var string printed? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: removing files in unix or linux using glob?
On Fri, Nov 21, 2008 at 16:38, Richard Lee <[EMAIL PROTECTED]> wrote: > Richard Lee wrote: >> >> Richard Lee wrote: >>> >>> stion on this.. suppose there is 3 files in temp directory >>> >>> /tmp/yahoo1 >>> /tmp/yahoo2 >>> /tmp/yahoo3 >>> >>> and I wanted to take the last file that was created.. would this work? >>> >>> my $filename = shift; >>> >>> my @file_1 = ; >>> my $file_1 = $file_1[-1]; >>> push @files, $file_1; >> >> i am not 100% sure if this logic is correct or not. >> >> my %big_hash; >> for (@file_1) { >>$big_hash{$_} = (stat($_))[9]; >> } >> >> my @keys = sort { $big_hash{$a} <=> $big_hash{b} } keys %big_hash; >> my $file_1 = $keys[-1]; >> push @files, $file_1; >> > I am missing a $ in $big_hash{b}.. and i see that this method works.. but is > there easier and better(correct) way to do this ??? If the number of files is fewer than a two hundred this is fine, but if it is more then you really want to use a min routine rather than sort to find the oldest file: #FIXME: if two files are the oldest, we can't predict which one will be deleted my $oldest_name; my $oldest_date = 0; for my $file () { if ($oldest_date >= (stat $file)[8]) { # _ is used here to get the cached info # from the last stat call $oldest_date = (stat _)[8]; last stat call $oldest_name = $file; } } die "no files found" unless defined $oldest_name; print "the oldest file is $oldest_name\n"; -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: removing files in unix or linux using glob?
Richard Lee wrote: Richard Lee wrote: stion on this.. suppose there is 3 files in temp directory /tmp/yahoo1 /tmp/yahoo2 /tmp/yahoo3 and I wanted to take the last file that was created.. would this work? my $filename = shift; my @file_1 = ; my $file_1 = $file_1[-1]; push @files, $file_1; i am not 100% sure if this logic is correct or not. my %big_hash; for (@file_1) { $big_hash{$_} = (stat($_))[9]; } my @keys = sort { $big_hash{$a} <=> $big_hash{b} } keys %big_hash; my $file_1 = $keys[-1]; push @files, $file_1; I am missing a $ in $big_hash{b}.. and i see that this method works.. but is there easier and better(correct) way to do this ??? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: removing files in unix or linux using glob?
Richard Lee wrote: stion on this.. suppose there is 3 files in temp directory /tmp/yahoo1 /tmp/yahoo2 /tmp/yahoo3 and I wanted to take the last file that was created.. would this work? my $filename = shift; my @file_1 = ; my $file_1 = $file_1[-1]; push @files, $file_1; i am not 100% sure if this logic is correct or not. my %big_hash; for (@file_1) { $big_hash{$_} = (stat($_))[9]; } my @keys = sort { $big_hash{$a} <=> $big_hash{b} } keys %big_hash; my $file_1 = $keys[-1]; push @files, $file_1; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: removing files in unix or linux using glob?
Mr. Shawn H. Corey wrote: See: * perldoc -f unlink * perldoc -f glob * perldoc perlfunc and search for -f under "Alphabetical Listing of Perl Functions" one more question on this.. suppose there is 3 files in temp directory /tmp/yahoo1 /tmp/yahoo2 /tmp/yahoo3 and I wanted to take the last file that was created.. would this work? my $filename = shift; my @file_1 = ; my $file_1 = $file_1[-1]; push @files, $file_1; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Adding Very Large Numbers and Display
On Fri, 2008-11-21 at 11:02 -0800, [EMAIL PROTECTED] wrote: > Hello > > I have a perl script that is working fine. The script involves creating an > array of numbers. The values of these numbers in the is quite large (12 > integer digits or more). I can easily display the numbers with a simple print > statement. I want to display the contents with one element per line and > format it so that it lines up vertically. This is where I am running into > issues. I tried to use a sprintf statement with a format of "%15u" so that > I did not get a negative number. However the value displayed is much smaller > than what the actual value. What is the best way to fix this display issue? Try "%15s" instead; "%15u" seems to cut-off the numbers. #!/usr/bin/perl use strict; use warnings; my $n = 1; for my $i ( 1 .. 15 ){ $n = $n * 10 + $i; printf "%15s\n", $n; } __END__ -- Just my 0.0002 million dollars worth, Shawn The map is not the territory, the dossier is not the person, the model is not reality, and the universe is indifferent to your beliefs. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Adding Very Large Numbers and Display
Hello I have a perl script that is working fine. The script involves creating an array of numbers. The values of these numbers in the is quite large (12 integer digits or more). I can easily display the numbers with a simple print statement. I want to display the contents with one element per line and format it so that it lines up vertically. This is where I am running into issues. I tried to use a sprintf statement with a format of "%15u" so that I did not get a negative number. However the value displayed is much smaller than what the actual value. What is the best way to fix this display issue? Thanks, Andrew -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
RE: need help with SpreadSheet::Parse perl module
> -Original Message- > From: Chas. Owens [mailto:[EMAIL PROTECTED] > Sent: 21 November 2008 13:13 > To: Manasi Bopardikar > Cc: beginners@perl.org > Subject: Re: need help with SpreadSheet::Parse perl module > > On Fri, Nov 21, 2008 at 07:33, Manasi Bopardikar > <[EMAIL PROTECTED]> wrote: > snip > > in the above code I get the max row count of my sheet by reading it > using > > the Spreadsheet::ParseExcel::Workbook module of cpan. > > > > then I want to open the same tablle2sheet.xls for writing.but currently > I am > > not able to find any module which allows me to do that. > snip > > I don't believe there is a module that allows arbitrary editing of an > Excel spreadsheet (but I have not done an exhaustive search of CPAN > for one in a while). Spreadsheet::ParseExcel allows you to read an > existing file and Spreadsheet::WriteExcel allows you yo write a new > file. The only way I know of to create the illusion of an arbitrary > edit is to use both together to copy the data from the old file to a > new file making changes as needed, unlink'ing the old file, and > rename'ing the new file to the old file's name. > > Well, that isn't 100% true; if you are on a Windows machine that has > Excel installed you can use Win32::OLE to make Excel make your changes > for you. > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > You can use Spreadsheet::WriteExcel to generate an Excel workbook. It has methods to add sheets and cell data and also lots of methods for formatting etc. The CPAN documentation is very clear and you will be able to use examples straight off the docs for a prototype. HTH Stu Information in this email including any attachments may be privileged, confidential and is intended exclusively for the addressee. The views expressed may not be official policy, but the personal views of the originator. If you have received it in error, please notify the sender by return e-mail and delete it from your system. You should not reproduce, distribute, store, retransmit, use or disclose its contents to anyone. Please note we reserve the right to monitor all e-mail communication through our internal and external networks. SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and are used under licence. British Sky Broadcasting Limited (Registration No. 2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited (Registration No. 2340150) are direct or indirect subsidiaries of British Sky Broadcasting Group plc (Registration No. 2247735). All of the companies mentioned in this paragraph are incorporated in England and Wales and share the same registered office at Grant Way, Isleworth, Middlesex TW7 5QD. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: no output Net::SSH2
On Thu, Nov 20, 2008 at 15:09, monnappa appaiah <[EMAIL PROTECTED]> wrote: > Hi, > > As per you suggestion i removed the last line of the code and the > replaced with the code, now the code looks like this > -- > > #!/usr/bin/perl -w > use strict; > use Net::SSH2; > > my $ssh2 = Net::SSH2->new(); > $ssh2->connect('sys5') or die "Unable to connect host $@ \n"; > $ssh2->auth_password('xyz','mypass'); > my $chan = $ssh2->channel(); > $chan->exec('ls -la'); > while (<$chan>) {print} > my $buflen = 1; > my $buf1 = '0' x $buflen; > $chan->read($buf1, $buflen); >print "BUF1:\n", $buf1,"\n"; > -- It looks to me like you did not remove the last line (i.e. the one that says while (<$chan>) {print}). -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Perl Call from Java dumps core while making a FTP connection
On Thu, Nov 20, 2008 at 21:43, <[EMAIL PROTECTED]> wrote: > I need help with an issue with executing a perl program from java. I > have a perl script that does a FTP. The perl program works well when I > run it from command line or on a cron job. > > The same command I am also running from a Java program, it used to run > fine on Solaris 8 and Perl 5.8.0. When we moved to Solaris 10 now, > perl version being the same but this java to perl call results in a > core dump. We did an initial core read, it points to an error like > "Can't find LocalCfg.pm in the path @INC". > > Is this a right error message or does it point to some perl module not > being installed correctly in the new environment. I do not even see > any LocalCfg as a perl module in our install tree. snip Hmm. How are you executing the Perl script from Java? Also, what are the values of the environment variables $PERL5LIB and $PERLLIB. We would also benefit from seeing the script itself (after you sanitize it, of course). Baring that, what modules and pragmas are being used by the script? -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: need help with SpreadSheet::Parse perl module
On Fri, Nov 21, 2008 at 07:33, Manasi Bopardikar <[EMAIL PROTECTED]> wrote: snip > in the above code I get the max row count of my sheet by reading it using > the Spreadsheet::ParseExcel::Workbook module of cpan. > > then I want to open the same tablle2sheet.xls for writing.but currently I am > not able to find any module which allows me to do that. snip I don't believe there is a module that allows arbitrary editing of an Excel spreadsheet (but I have not done an exhaustive search of CPAN for one in a while). Spreadsheet::ParseExcel allows you to read an existing file and Spreadsheet::WriteExcel allows you yo write a new file. The only way I know of to create the illusion of an arbitrary edit is to use both together to copy the data from the old file to a new file making changes as needed, unlink'ing the old file, and rename'ing the new file to the old file's name. Well, that isn't 100% true; if you are on a Windows machine that has Excel installed you can use Win32::OLE to make Excel make your changes for you. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: help me in rearranging line numbers in a file
Gowri Chandra Sekhar Barla, TLS, Chennai wrote: > > Please help me in rearranging line numbers in a file > > Example" > > File.txt > 1 ghghjghjg > 2 1hjkhkjh > 3 > 4 .macro TTT offset > 5 TTT 200 > 6 TTT 300 > 7 fghfghf > 8 hjhjkhjkh > 9 kgghjgg > > Output should be > > File.txt > 1 ghghjghjg > 2 1hjkhkjh > 3 > .macro TTT offset > TTT 200 > TTT 300 > 4 fghfghf > 5 hjhjkhjkh > 6 kgghjgg That is an dreadful definition of your problem. Please tell us exactly what lines should become unnumbered and what program solutions you have tried. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
need help with SpreadSheet::Parse perl module
Hi, Following is the piece of code my $parser = Spreadsheet::ParseExcel::Workbook->Parse('tablle2sheet.xls');; #parseexcel method that would open the file for writing my $sheet= $parser->Worksheet($Worksheet); my $rw=$sheet->{MaxRow}+1; print "rowcount:$rw\n"; something like-sheet3->write(0,0,'xyz'); doesn't work here in the above code I get the max row count of my sheet by reading it using the Spreadsheet::ParseExcel::Workbook module of cpan. then I want to open the same tablle2sheet.xls for writing.but currently I am not able to find any module which allows me to do that. Can someone help/ Thanks and Regards, Manasi Bopardikar s/w Engineer Persistent SystemsLtd (+91)(020)(30234497)|9371059891 [EMAIL PROTECTED] DISCLAIMER == This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.
Re: help me in rearranging line numbers in a file
Is this your homework??? On Fri, Nov 21, 2008 at 5:19 PM, Gowri Chandra Sekhar Barla, TLS, Chennai < [EMAIL PROTECTED]> wrote: > > Hi all > > Please help me in rearranging line numbers in a file > > Example" > > File.txt > 1 ghghjghjg > 2 1hjkhkjh > 3 > 4 .macro TTT offset > 5 TTT 200 > 6 TTT 300 > 7 fghfghf > 8 hjhjkhjkh > 9 kgghjgg > > Output should be > > File.txt > 1 ghghjghjg > 2 1hjkhkjh > 3 > .macro TTT offset > TTT 200 > TTT 300 > 4 fghfghf > 5 hjhjkhjkh > 6 kgghjgg > > > Thanks and regards > Gowri > > DISCLAIMER: > > --- > > The contents of this e-mail and any attachment(s) are confidential and > intended for the named recipient(s) only. > It shall not attach any liability on the originator or HCL or its > affiliates. Any views or opinions presented in > this email are solely those of the author and may not necessarily reflect > the opinions of HCL or its affiliates. > Any form of reproduction, dissemination, copying, disclosure, modification, > distribution and / or publication of > this message without the prior written consent of the author of this e-mail > is strictly prohibited. If you have > received this email in error please delete it and notify the sender > immediately. Before opening any mail and > attachments please check them for viruses and defect. > > > --- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > >
help me in rearranging line numbers in a file
Hi all Please help me in rearranging line numbers in a file Example" File.txt 1 ghghjghjg 2 1hjkhkjh 3 4 .macro TTT offset 5 TTT 200 6 TTT 300 7 fghfghf 8 hjhjkhjkh 9 kgghjgg Output should be File.txt 1 ghghjghjg 2 1hjkhkjh 3 .macro TTT offset TTT 200 TTT 300 4 fghfghf 5 hjhjkhjkh 6 kgghjgg Thanks and regards Gowri DISCLAIMER: --- The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. Before opening any mail and attachments please check them for viruses and defect. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: perl compilation issue - using global variable
I am using perlcc to compile perl script On Thu, Nov 20, 2008 at 8:25 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Thu, Nov 20, 2008 at 00:05, ashish nainwal <[EMAIL PROTECTED]> > wrote: > > Thanks for the info. I will be using my perl script for AIX but I am not > > able to find a supporting IBM official doc which says that AIX comes with > > perl by default. > snip > > What are you using to create the binary? PAR::Packer? perlcc? > > -- > Chas. Owens > wonkden.net > The most important skill a programmer can have is the ability to read. > -- Ashish Nainwal "Goodwill wishes are a state of our mind.Have a great day!' http://wrappedinapolythene.blogspot.com/
Perl Call from Java dumps core while making a FTP connection
I need help with an issue with executing a perl program from java. I have a perl script that does a FTP. The perl program works well when I run it from command line or on a cron job. The same command I am also running from a Java program, it used to run fine on Solaris 8 and Perl 5.8.0. When we moved to Solaris 10 now, perl version being the same but this java to perl call results in a core dump. We did an initial core read, it points to an error like "Can't find LocalCfg.pm in the path @INC". Is this a right error message or does it point to some perl module not being installed correctly in the new environment. I do not even see any LocalCfg as a perl module in our install tree. Please help! Thank you, Srinivasan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/