Re: FW: How long can $_ be?
Hi Smiddy, you wrote: > This got me wondering. Is the behavior you see caused by limitations > for $_, or by limitations of the print function? You might try: > print strlen( $_ ), "\n"; My Perl doesn't know what strlen is. Is it part of a module? I don't think, it is a limitation of the print function. I am not able to find a string with a regular expression before I print something. Greetings, Anette -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: net::telnet and read eof error
On Wednesday 13 March 2002 10:30 am, Craig Williams wrote: > In my first attempt at telneting into sun box from win98, i've been > receiving the error message : pattern match read eof at scriptName.pl line > xx-- where xx is the login line. Unable to resolve that error > through the usual methods I tried executing the rainmaker sample in the > documentation at the end of the net::telnet module and received the same > error (this time at the "$t->waitfor('/continue:*$/);) line. I'm guessing > it's a setup error on my machine but haven't a clue where to look. Any > ideas? > > (sample from the net::telnet documentation that i ran) > > #!perl -w > > my ($forecast, $t); > > use Net::Telnet (); > $t = new Net::Telnet; > $t->open("rainmaker.wunderground.com"); > > ## Wait for first prompt and "hit return". > $t->waitfor('/continue:.*$/'); > $t->print(""); > > ## Wait for second prompt and respond with city code. > $t->waitfor('/city code.*$/'); > $t->print("BRD"); > > ## Read and print the first page of forecast. > ($forecast) = $t->waitfor('/[ \t]+press return to continue/i'); > print $forecast; > > exit; This may be a telnet client issue and not a perl problem. You might look at changing your Win98 telnet client to send a line feed instead of a carriage return. I'm not sure how to do this in win98 (also depends on the telnet client). >From my *BSD box I was able to run your provided sample code without a problem. Also, if you manually telnet to rainmaker.wunderground.com, you'll notice the following in the welcome message: **Note: If you cannot get past this opening screen, you must configure * your telnet program to send a line feed instead of just a carriage * return, or use a different telnet program that does so. Hope this helps. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: TAIL
I suggest: File::Tail if you are wanting to something like tail -f, though. Works like a champ. - Jim At 06:09 03.14.2002 +, Jonathan E. Paton wrote: > > Is there a perl function equivalent to the *nix command > > 'tail'? > >Here is a basic Perl implementation of tail: > >#!/usr/bin/perl >@a=<>;print@a[-10,-1]; > >IIRC there is a shorter way to do it, but that'd >mean going back over the FWP mailing list archives. > > > I don't mean like, a workaround through loops > > that will produce the same sort of result, just > > a function. > >sub tail (\@) { > my $array = shift; > return @$array[-10,-1]; >} > > > Also, what are the benefits of using the function > > grep? > >Lots, cross platform, NFA engine (not DFA) hence >backtracking and lookahead/lookbehinds etc. > > > Doing a system call to grep seems to run faster > > than the perl function! > >It probably will, since the system grep is built for >absolute speed in the small task it does. Perl is a >little more general, and the grep patterns are just >as powerful as any other regex in Perl. > >Platform independence springs to mind too... and also >if you already have data in memory (in Perl) writing >it out to disk is a pain that none of us bother with. > >Jonathan Paton > >__ >Do You Yahoo!? >Everything you'll ever need on one web page >from News and Sport to Email and Music Charts >http://uk.my.yahoo.com > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] -BEGIN PGP PUBLIC KEY BLOCK- Version: GnuPG v1.0.6 (MingW32) Comment: For info see http://www.gnupg.org - Jim Philosophy is for those who have nothing better to do than wonder why philosophy is for those who have nothing better to do than... mQGiBDxAonQRBACx+sz63XIeo5uTzc5n3Elf7Y13VVZGIM8Pilp3LpBu70/nGQPu anKYDB3aa1U5cfl+cTK5lOtUxN7Fu0a2Uv0ApIlC1qA8CjDZqlu7PDETFTVrpfGZ 007BHO+y2Y0bVsaMPXdnhbi0LAFSIkNYRhyzNWbAkeMsgA+i2k9hcnhvVwCgor7P nflXu7xWN9aWt3RJBzqdUR0EAK/1obJFUKQSK39cKTMPQ4u2UPflbS5dJ871naG5 xBAlQAjHAXT+f/fXE2ezrSyoQnlOD4kVbPN3gB5UT5mWoylPuf5W7WmupthVzUUN IsPDbmAT0YOwgALCfJVS+PrPCC8opmZhTjQBwgxCSY9MWULlzN3X2EEDqWIxluYb o5W/BACgHA+aFOO5F03QZBBScWn9YBS1ZH3sSlkQEK5RiwGXLmHJacOjn660SbOE MEKPDLDDJu/vt1fb3VRLc/fPB3aB7fi4XagfobaHbID9rx55slLhD94Q+5JuJSfg DyJ+vVSA1k+9/SynflPl0QY5zt0xSM+0CBg9mBg2bPyuGsDwXLQ5SmltIENvbm5l ciAoTmV3IEdQRyBLZXkgZm9yIFNuYWZ1WCkgPGpjb25uZXJAZW50ZXJpdC5jb20+ iFcEExECABcFAjxAonQFCwcKAwQDFQMCAxYCAQIXgAAKCRDmnFh04+r7ZdFiAKCh t8Vq7ZT6qvh9Dzn0lzZXRM4gywCfSLU/H5UHX7ZoxapfDs9pLxEEZeO5Ag0EPECj chAIAIsdwiPqW8IsumvpXu59qkfsi4H2nofxvbhMDiapEhgloydehNQOEiHwC/O1 a06PjUmNRLRdK88kjy99R84ILbWUJZUclQB2LcjlttnrIG/FzCMxoLTKOeOCJk8N ONswBdJdcf/XqbWJBTs/MXeNf4rmShYi6WJ5+jc1IE5PXGf4SR/9bz2r+/GESlrX tAoNtWl5a/NUxb6b0hR6zU9Y6oO1vpDDJNbcV9mafdYhsvoFYdD2c6JF+JoN+FHR tEP3k6leYwQ5P0kuUQNgWdWNWZfBq1tQDBfhg1/AV0JBzamyJfd0prFmtUEemKx4 haDsOoT4gLSPNTqSsyDt6TNLtGMAAwUIAINeot1FVpree5bvhy3xL+Pr1UGb++DM b8Qeer6ERkVQNx7YoU8hfpqOwvEQMyfb9s6HPfSWRUfQRF+g+9ohPgYkH+1nqH3V PtGSw1kgLOqxZQTVPEcAMhSflt9LSJETIQQByKKh1e5RvOuApwBFmQq3syRhzqv/ j2b6t3IqAB9WR5TnoYkdUtTWM9MGubiFl5B9uH5EHWAlFF8h760U7Xp9m1J3qTyH EJqjfGj2SP2DK5cisuWOWdPy5aSqT7ZKrcKeSTDUyiHclI1ygFHue8oO0HXqrs+k KjFdRqIKnzfY9gW/b/6gLHhBDV6BoA9w6+1Y9egOByRcVonE8zY/xMeIRgQYEQIA BgUCPECjcgAKCRDmnFh04+r7ZcyDAJ4ogYX7W4u8g+QJsksyL4Ld+dObCwCfU7hB 7I3ZgTsYwP6mr5RPjkH5PG8= =QOu8 -END PGP PUBLIC KEY BLOCK- __END__ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: TAIL
> Is there a perl function equivalent to the *nix command > 'tail'? Here is a basic Perl implementation of tail: #!/usr/bin/perl @a=<>;print@a[-10,-1]; IIRC there is a shorter way to do it, but that'd mean going back over the FWP mailing list archives. > I don't mean like, a workaround through loops > that will produce the same sort of result, just > a function. sub tail (\@) { my $array = shift; return @$array[-10,-1]; } > Also, what are the benefits of using the function > grep? Lots, cross platform, NFA engine (not DFA) hence backtracking and lookahead/lookbehinds etc. > Doing a system call to grep seems to run faster > than the perl function! It probably will, since the system grep is built for absolute speed in the small task it does. Perl is a little more general, and the grep patterns are just as powerful as any other regex in Perl. Platform independence springs to mind too... and also if you already have data in memory (in Perl) writing it out to disk is a pain that none of us bother with. Jonathan Paton __ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Reinitializing an Array
If you're having this kind of trouble, chances are you might not be properly scoping your array. Try declaring the array using my() inside of the scope you wish to use, for example inside of a loop. Then you won't have to worry about whether you remembered to undef your array. -Original Message- From: luke To: [EMAIL PROTECTED] Sent: 3/13/02 3:35 PM Subject: Re: Reinitializing an Array you can always set it to undef also: @an_array=undef; --- Luke Davison [EMAIL PROTECTED] - Original Message - From: "John W. Krahn" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 13, 2002 2:59 PM Subject: Re: Reinitializing an Array > Barry Kingsbury wrote: > > > > I have an array that I wish to reuse. Before I reuse it, I want to clear out all > > elements. Both of the following seem to work: > > > > @an_array = ""; > > This does not clear out all elements, it assigns one element to > @an_array with the value of "". > > > > and > > > > $#an_array = -1; > > This is one way to do it properly, another way is: > > @an_array = (); > > This assigns an empty list to @an_array. > > > > John > -- > use Perl; > program > fulfillment > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email may contain confidential and privileged material for the sole use of the intended recipient. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: extracting elements from arrays of arrays of arrays ;-)
At 06:38 PM 3/13/02 -0800, Simon K. Chan wrote: >Hiya All, > >I hope you'll forgive this oo perl rookie for asking a routine >question. I'm not new to perl, but >the bioperl module I'm working on is giving me a headache! ;-) > > >Let's say I have this: > >my @array = qw(12 56 41 23); > >my $array_ref = \@array; > ># where $var1, $var2, and $var3 are other array references. >my $ref = [$var1, $var2, $array_ref, $var3 ]; > >my @object = (); > >push @object, $ref; > >QUESTION: How do I obtain the array $array_ref refers to in this >situtation? Let's say I want to >give @new the values in @array. my @new = @{$object[0][2]}; -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tie/bless interactions?
At 02:19 AM 3/14/02 +0100, Jenda Krynicky wrote: > > 3) If I bless %self out of the "Tie::Hash" space and into the > > "APC::Event" space, are the "Tie::Hash" functions going to stop > > working? (I assume so.) > >You can't bless a hash, you can only bless a reference. > >What you end up with after your constructor is something like : > > APC::Event=HASH(0x1a7f148) reference >pointing to > a hash >tied to a > Tie::DBI=HASH(0x486454) reference >pointing to > whatever data Tie::DBI needs to store. > >Then > > $obj->Foo() > >calls the APC::Event::Foo() subroutine and > > $val = $obj->{foo} > >calls Tie::DBI::FETCH() subroutine with the >Tie::DBI=HASH(0x486454) reference and 'foo' parameters. Damian Conway's Regexp::Common module does more or less exactly this. I just finished reading the Perl Conference proceedings on it (yes, in places I am that far behind) and hope to make a full recovery :-) -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
extracting elements from arrays of arrays of arrays ;-)
Hiya All, I hope you'll forgive this oo perl rookie for asking a routine question. I'm not new to perl, but the bioperl module I'm working on is giving me a headache! ;-) Let's say I have this: my @array = qw(12 56 41 23); my $array_ref = \@array; # where $var1, $var2, and $var3 are other array references. my $ref = [$var1, $var2, $array_ref, $var3 ]; my @object = (); push @object, $ref; QUESTION: How do I obtain the array $array_ref refers to in this situtation? Let's say I want to give @new the values in @array. Thank many thanks for your time and help! = # Warmest Regards, Simon K. Chan - [EMAIL PROTECTED] "Great spirits have always encountered violent opposition from mediocre minds." - Albert Einstein __ Do You Yahoo!? Yahoo! Sports - live college hoops coverage http://sports.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: tie/bless interactions?
From: Dave Storrs <[EMAIL PROTECTED]> > I've got a class called APC::Event. The idea is that when you > instantiate one of these objects, you are signalling that a particular > event has happened; ergo, it takes the information you specified, > deduces a bunch more stuff, and logs all of it to a database. > Afterwards it sticks around and provides an interface to that record > (or the whole table, actually). > > I've just discovered the Tie::DBI modules, and they seem like exactly > what I want here, but I'm wondering if the following is going to get > me in trouble: > > > sub new { > my ($proto, %args) = @_; > > my %self; > my $database_handle =$args{ dbh } > || DBH(\%default_database_params, > {PrintError => 0, RaiseError => 1} > ); > tie %self, Tie::DBI, { db => $database_handle, >CLOBBER => 1, # Allow INSERT and >UPDATE, ># but not DELETE > }; > > > my $class =ref $proto# Are we being called as a class or > || $proto# instance method? > || 'APC::Event'; > > bless \%self, $class; > } I think this should be OK. > I haven't done that much with tie in the past, and I've never > done > anything where I tied an object and then blessed it, so I'm not quite > sure what the implications are. Specifically, > > 1) As I understand it, tie() uses bless() under the hood; is this > correct? Yes, but ... when you tie a variable the TIESCALAR/TIEARRAY/TIEHASH/TIEHANDLE subroutine constructs a data structure, creates a reference to that structure, bless()es the reference, returns the blessed reference and then perl ties the variable in question with that object. So it's not the variable, but the hidden reference that's blessed. > 2) I want the object to be an APC::Event, because there is more in the > class than just a constructor. Assuming that the answer to question 1 > is "yes", what happens when I rebless a reference? I believe it > "forgets" all about its original class, but I've never done it before > (actually, I've tried very hard to avoid it). Yes, if you rebless a reference it forgets about the original class and becomes an object of a different class. But this is not what happens at this time > 3) If I bless %self out of the "Tie::Hash" space and into the > "APC::Event" space, are the "Tie::Hash" functions going to stop > working? (I assume so.) You can't bless a hash, you can only bless a reference. What you end up with after your constructor is something like : APC::Event=HASH(0x1a7f148) reference pointing to a hash tied to a Tie::DBI=HASH(0x486454) reference pointing to whatever data Tie::DBI needs to store. Then $obj->Foo() calls the APC::Event::Foo() subroutine and $val = $obj->{foo} calls Tie::DBI::FETCH() subroutine with the Tie::DBI=HASH(0x486454) reference and 'foo' parameters. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reinitializing an Array
you can always set it to undef also: @an_array=undef; --- Luke Davison [EMAIL PROTECTED] - Original Message - From: "John W. Krahn" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 13, 2002 2:59 PM Subject: Re: Reinitializing an Array > Barry Kingsbury wrote: > > > > I have an array that I wish to reuse. Before I reuse it, I want to clear out all > > elements. Both of the following seem to work: > > > > @an_array = ""; > > This does not clear out all elements, it assigns one element to > @an_array with the value of "". > > > > and > > > > $#an_array = -1; > > This is one way to do it properly, another way is: > > @an_array = (); > > This assigns an empty list to @an_array. > > > > John > -- > use Perl; > program > fulfillment > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: write to an Excel document
The link is at: http://www-106.ibm.com/developerworks/linux/library/l-pexcel/ (l not I) "Tirthankar C. Patnaik" wrote: > > An excellent link for the task you have in mind, is: > > http://www-106..ibm.com/developerworks/linux/library/I-pexcel/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
HP-UX 10.2 Tk install error
I'm trying to install Tk (Tk800.024) but it fails with the text at the end of this e-mail. I looked and /usr/lib/X11R6 and /usr/lib/X11R6/libX11.2 both exist. So my question is what am I missing? Or what am I doing wrong? Thanks, John T. Shea jshea@cahp9>perl Makefile.PL perl is installed in /opt/perl5/lib/5.6.0/PA-RISC1.1 okay PPM for perl5.006 Test Compiling config/signedchar.c Test Compiling config/unsigned.c Test Compiling config/Ksprintf.c Test Compiling config/tod.c Generic gettimeofday() Using -L/usr/lib/X11R6 to find /usr/lib/X11R6/libX11.2 Cannot find X include files via /include Cannot find X include files anywhere at ./myConfig line 312. Compilation failed in require at Makefile.PL line 17. BEGIN failed--compilation aborted at Makefile.PL line 19. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
tie/bless interactions?
I've got a class called APC::Event. The idea is that when you instantiate one of these objects, you are signalling that a particular event has happened; ergo, it takes the information you specified, deduces a bunch more stuff, and logs all of it to a database. Afterwards it sticks around and provides an interface to that record (or the whole table, actually). I've just discovered the Tie::DBI modules, and they seem like exactly what I want here, but I'm wondering if the following is going to get me in trouble: sub new { my ($proto, %args) = @_; my %self; my $database_handle =$args{ dbh } || DBH(\%default_database_params, {PrintError => 0, RaiseError => 1} ); tie %self, Tie::DBI, { db => $database_handle, CLOBBER => 1, # Allow INSERT and UPDATE, # but not DELETE }; my $class =ref $proto# Are we being called as a class or || $proto# instance method? || 'APC::Event'; bless \%self, $class; } I haven't done that much with tie in the past, and I've never done anything where I tied an object and then blessed it, so I'm not quite sure what the implications are. Specifically, 1) As I understand it, tie() uses bless() under the hood; is this correct? 2) I want the object to be an APC::Event, because there is more in the class than just a constructor. Assuming that the answer to question 1 is "yes", what happens when I rebless a reference? I believe it "forgets" all about its original class, but I've never done it before (actually, I've tried very hard to avoid it). 3) If I bless %self out of the "Tie::Hash" space and into the "APC::Event" space, are the "Tie::Hash" functions going to stop working? (I assume so.) 4) If the answer to 3 is "yes", can I solve this by doing this: my $rh_self = \%self; unshift @{$rh_self->ISA}, 'APC::Event'; 5) Given the above constructor code, am I likely to have any problems with circular references? Thanks in advance, Dave Storrs PS If you wanted to rewrite the code snippet in question 4 without taking a reference, how would you do it? This doesn't seem right: unshift @self{ISA}, 'APC::Event'; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Reinitializing an Array
Barry Kingsbury wrote: > > I have an array that I wish to reuse. Before I reuse it, I want to clear out all > elements. Both of the following seem to work: > > @an_array = ""; This does not clear out all elements, it assigns one element to @an_array with the value of "". > and > > $#an_array = -1; This is one way to do it properly, another way is: @an_array = (); This assigns an empty list to @an_array. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: "Use of uninitialized value" error message
Jason Larson wrote: > > I'm still new to Perl myself, so I can't tell you exactly what's happening, > but it looks like $result_value1 is undef when it gets to the if statement. > I think a better way to accomplish what you're trying to do is simply: > > my $result_value1; > if ($result_value) { #$result_value1 is defined ^^ ^^^ This is _NOT_ testing whether $result_value1 is defined or not (in fact it is not testing $result_value1 at all :-), it is testing whether $result_value1 is true or false which is not the same thing. if ( defined $result_value1 ) { #$result_value1 is defined > $a= substr($result_value1, 0, 8); > $b= substr($result_value1, 8, 2); > $c= substr($result_value1, 10, 2); > } else { #$result_value1 is still undef > return (" ", " ", " "); > } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Microsoft Word Documents
Michael D. Risser [[EMAIL PROTECTED]] quoth: *>I have searched CPAN, but so far no luck. Does anyone know of a module or *>Perl script that can parse MS Word .doc files? *> *>I'm trying to add the ability to display these files in a web browser to a *>document managment system I found on the web. http://snake.cs.tu-berlin.de:8081/~schwartz/pmh/ Laola e. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: the scope of BEGIN {}
On Wed, Mar 13, 2002 at 01:27:08PM -0500, Nikola Janceski wrote: > Here is my question, $follow and $follow_skip I want to be a global variable > in the scope of the perl script I am running. > If I put a my in front of the declaration wouldn't it only be in the scope > of BEGIN or would it be in the scope of the entire script? How can I declare > it so that use strict; and use warnings; won't complain? If you put the declaration within the BEGIN block, yes, it would be scoped to just that block. So place the declaration outside of the BEGIN block. my($follow, $follow_skip); BEGIN { ... } Also, use strict is the only thing that complains about out-of-scope variable usage, and it's more than just a complaint. Michael -- Administrator www.shoebox.net Programmer, System Administrator www.gallanttech.com -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: TAIL
grep in perl doesn't work exactly same way as grep in *nix. It functions differently in perl, and has better uses in perl that the *nix's grep can't do. perldoc -f grep > -Original Message- > From: James Taylor [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, March 13, 2002 3:06 PM > To: [EMAIL PROTECTED] > Subject: TAIL > > > is there a perl function equivalent to the *nix command 'tail'? > I don't mean like, a workaround through loops that will > produce the same sort > of result, just a function. > > Also, what are the benefits of using the function grep? > Doing a system call > to grep seems to run faster than the perl function! > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Mail::Sender Timeout
From: [EMAIL PROTECTED] > Where in the Sender.pm file can I find the parameter for > timeout to the mail server? I need to increase this. I > keep getting a cannot connect error. > > Thanks > > Grant Sorry, there is no such parameter. I'm using plain socket()s with connect() and stuff, maybe you can change the timeouts of these, but I don't know how. But ... are you sure you want to connect to THAT server if your connection to it is so weak? You are supposed to pass the message to your LOCAL mailserver and leave the distribution and retries to the recipients' servers to it. Don't try to contact the recipients' mailservers, pass it to your own and forget about it. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Mail::Sender Timeout
Where in the Sender.pm file can I find the parameter for timeout to the mail server? I need to increase this. I keep getting a cannot connect error. Thanks Grant -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: :telnet and read eof error
solved my own problem reinstalled the net::telnet module, somebody screwed with the module code -Original Message- From: Craig Williams [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 12:31 PM To: Beginners@Perl. Org (E-mail) Subject: net::telnet and read eof error In my first attempt at telneting into sun box from win98, i've been receiving the error message : pattern match read eof at scriptName.pl line xx-- where xx is the login line. Unable to resolve that error through the usual methods I tried executing the rainmaker sample in the documentation at the end of the net::telnet module and received the same error (this time at the "$t->waitfor('/continue:*$/);) line. I'm guessing it's a setup error on my machine but haven't a clue where to look. Any ideas? (sample from the net::telnet documentation that i ran) #!perl -w my ($forecast, $t); use Net::Telnet (); $t = new Net::Telnet; $t->open("rainmaker.wunderground.com"); ## Wait for first prompt and "hit return". $t->waitfor('/continue:.*$/'); $t->print(""); ## Wait for second prompt and respond with city code. $t->waitfor('/city code.*$/'); $t->print("BRD"); ## Read and print the first page of forecast. ($forecast) = $t->waitfor('/[ \t]+press return to continue/i'); print $forecast; exit; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Microsoft Word Documents
I have searched CPAN, but so far no luck. Does anyone know of a module or Perl script that can parse MS Word .doc files? I'm trying to add the ability to display these files in a web browser to a document managment system I found on the web. Thanks in advance -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: the scope of BEGIN {}
> -Original Message- > From: Nikola Janceski [mailto:[EMAIL PROTECTED]] > Subject: the scope of BEGIN {} > > > BEGIN { > if ($^O =~ /^(ms)?(win|dos)(32|nt)?$/i){ > eval q{ > use lib "N:/xxx/perl_lib"; > use Win32::Process; > use Win32::Event 1.00 qw(wait_any); > > $follow = 0; # used in find command > $follow_skip = 0; # used in find command > } > > } else { > eval q{ > use lib "/xxx/perl_lib"; > > $follow = 1; # used in find command > $follow_skip = 2; # used in find command > } > } > } > > Here is my question, $follow and $follow_skip I want to be a > global variable > in the scope of the perl script I am running. > If I put a my in front of the declaration wouldn't it only be > in the scope > of BEGIN or would it be in the scope of the entire script? > How can I declare > it so that use strict; and use warnings; won't complain? > > (This has to be a global variable for I use it several > subroutines and is OS > dependent). I think you can do: use warnings; use strict; use vars qw($follow $follow_skip); Hope this helps... Jason CONFIDENTIALITY NOTICE: The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited.
PERL522 for Windows XP
Could someone help me with PERL522? Thank you in advance. Is there a certification process for PERL on supported platforms? We have PERL522 image on all our Clients (NT 4.0 with SP6, more than 8000 clients) and Servers (NT 4.0 with SP6a; HP, AIX). We are wondering if 522 is compatible/or certified for Windows XP (client), or if anyone has tested it on XP. If not compatible or certified, is there any plan in the near future? I understand that 522 is an older version. However, we can't upgrade PERL to 561 at this time due to organization merger/restructuring. Thanks
net::telnet and read eof error
In my first attempt at telneting into sun box from win98, i've been receiving the error message : pattern match read eof at scriptName.pl line xx-- where xx is the login line. Unable to resolve that error through the usual methods I tried executing the rainmaker sample in the documentation at the end of the net::telnet module and received the same error (this time at the "$t->waitfor('/continue:*$/);) line. I'm guessing it's a setup error on my machine but haven't a clue where to look. Any ideas? (sample from the net::telnet documentation that i ran) #!perl -w my ($forecast, $t); use Net::Telnet (); $t = new Net::Telnet; $t->open("rainmaker.wunderground.com"); ## Wait for first prompt and "hit return". $t->waitfor('/continue:.*$/'); $t->print(""); ## Wait for second prompt and respond with city code. $t->waitfor('/city code.*$/'); $t->print("BRD"); ## Read and print the first page of forecast. ($forecast) = $t->waitfor('/[ \t]+press return to continue/i'); print $forecast; exit; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
the scope of BEGIN {}
BEGIN { if ($^O =~ /^(ms)?(win|dos)(32|nt)?$/i){ eval q{ use lib "N:/xxx/perl_lib"; use Win32::Process; use Win32::Event 1.00 qw(wait_any); $follow = 0; # used in find command $follow_skip = 0; # used in find command } } else { eval q{ use lib "/xxx/perl_lib"; $follow = 1; # used in find command $follow_skip = 2; # used in find command } } } Here is my question, $follow and $follow_skip I want to be a global variable in the scope of the perl script I am running. If I put a my in front of the declaration wouldn't it only be in the scope of BEGIN or would it be in the scope of the entire script? How can I declare it so that use strict; and use warnings; won't complain? (This has to be a global variable for I use it several subroutines and is OS dependent). Nikola Janceski Too many of us look upon Americans as dollar chasers. This is a cruel libel, even if it is reiterated thoughtlessly by the Americans themselves. -- Albert Einstein (1879-1955) The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How long can $_ be?
I've seen this effect when using data I copied off the internet (using Explorer) into a text file in a Unix environment. In my case the problem was definitely a control character within the string causing a line return without a line feed. It didn't show up when I viewed the file with less or cat, or notepad on Windows, just when I manipulated it with perl, and printed the results to the screen. It really drove me crazy for a while. I don't remember exactly what crudgy solution I came up with, but it sounds like the same kind of problem. "Anette Seiler" To: [EMAIL PROTECTED] Subject: RE: How long can $_ be? 03/13/2002 06:51 AM Dear All, the script I'm using is really very simple: #!/usr/local/bin/perl -w use strict; while (<>) { chomp; print "\n\n$_\n\n"; } >From the command line I start the script with "perl script.pl". Now I have to enter some text. I just enter any text, either by typing or by cutting and pasting. I do not enter any strange characters or newlines. I just type in some text. I even take care to just use normal characters - no numbers, umlaute or anything else strange. As you can see, I did not play with $/. As I wrote in my initial mail, the answer I get is not the answer I expect. Whenever my input is more than 256 character, instead of printing everything I entered, it prints only the last part of what I entered, everything after character 256. The first part is chopped off. I experimented with that and had the following results: The first line I gave was 490 characters long, $_ contained the last 233 characters. The string was chopped off at character 257. The second line I gave was 462 characters long, $_ contained the last 205 characters. The string was chopped off at character 257. The third line I gave was 253 characters long, $_ contained the whole 253 characters. Nothing was chopped off. The fourth line I gave was 839 characters long, $_ contained the last 68 characters. The string was chopped off at character 771. Nikola asked: "Exactly how long/big are we talking of making $_?" The fourth line is already a very long line. I don't thing it will be more than a 1000 characters per line. The script above is the essence of the problem. I found the problem when I wrote a script that reads in a line at a time from a file. The script was supposed to find a url in each line with an regex, isolate the url and do something with it. The script did not find the url in lines that were longer than 256 characters, because it appeared more in the beginning. I then found out that it was not my regex that was wrong, but $_ did not give me what I wanted. Funny enough, I am able to find the url using index and substring. In this way I was able to do what I wanted to do, but it does not help solving the problem I have. The subroutine that worked was: open DATEI, "$_" or die "Kann die Datei $_ nicht öffnen ($!)\n"; foreach my $line () { chomp $line; if ($line =~ /\/i) { my $begin_url = index $line, "http"; my $end_url = index $line, "\" "; my $length = ($end_url - $begin_url) ; my $url = substr ($line, $begin_url, $length); and so on. I would be really grateful for an answer to the puzzle. Kind regards Anette > Perl 5.004_04 on my Solaris 5.6 machine had no problems making $_ of > length 178956970. Of course I have an elephant crap load of memory on > this sucker. > > Exactly how long/big are we talking of making $_? > > > -Original Message- > From: David Gray [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, March 12, 2002 9:06 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: How long can $_ be? > > > > Is there some limit in how long the contents of the variable $_ can > > be? > > Not that I'm aware of, no. > > > I encounter this problem on Solaris machines running Perl 5.005. On > > Windows with Perl 5.6.1. no such problem was encountered. > > > > What could cause the problem? > > I suppose it might be a a configuration problem of some sort, but I >
Re: Mail::Sender
From: [EMAIL PROTECTED] > I am using Mail::Sender on AIX 4.3.3 and encounter the > following error when running a script. > > Use of uninitialized value > at /usr/opt/perl5/lib/site_perl/5.005/Mail/Sender.pm > line 944, chunk 5. > Can't use an undefined value as filehandle reference > at /usr/opt/perl5/lib/site_perl/5.005/Mail/Sender.pm > line 944, chunk 5. > > I have used this on other sysystem without any > problems. Does anyone know if there are any issues with > Mail::Sender on AIX 4.3.3? It's not caused by the version of OS, but of perl. Sorry for this. Please install the 0.7.13 version uploaded to CPAN and http://Jenda.Krynicky.cz today. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
uploading multiple files over http
Can anyone help me - I am new to perl (and I love it) and I am trying to write a script that alows me to upload pictures for the web (.jpg and .gif) over http. Any advice would be greatly appreciated Thanks in advance Anadi _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: "Use of uninitialized value" error message
Hi Nikola/Jason Thanks for the help. The variable $result_value1 is declared within the subroutine and is never used outside the subroutine. I originally had the following piece of code (which I forgot to show you guys in the previous email): $result_value1 = $database1{$input_key1} But I changed the above code to the following and it worked ("Use of uninitialized value" error message" did not appear): $result_value1 = $database1{$input_key1} || " "; if ($result_value1 ne " ") { $a= substr($result_value1, 0, 8); $b= substr($result_value1, 8, 2); $c= substr($result_value1, 10, 2); return ($a, $b, $c); } else { return (" ", " ", " "); } Cheers Tony -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: 13 March 2002 17:16 To: 'Jason Larson'; 'Ho, Tony'; '[EMAIL PROTECTED]' Subject: RE: "Use of uninitialized value" error message that actually won't get rid of the warning. but you are right the declaration at the top of the script of the varible goes out of scope when it reaches the if. you are using -w or use warnings; in your script that is causing the warning. perhaps attaching the code would help but we can't tell where the varible goes out of scope. -Original Message- From: Jason Larson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 11:06 AM To: 'Ho, Tony'; '[EMAIL PROTECTED]' Subject: RE: "Use of uninitialized value" error message > -Original Message- > From: Ho, Tony [mailto:[EMAIL PROTECTED]] > Subject: "Use of uninitialized value" error message > > Hi guys > I was wondering if you could help me with the following problem. > > I am getting the following error message: > > Use of uninitialized value in string ne at > format_imsi_msisdn.pl line 257. > > line 257 and beyond consist of the following: > > if ($result_value1 ne " ") { > $a= substr($result_value1, 0, 8); > $b= substr($result_value1, 8, 2); > $c= substr($result_value1, 10, 2); > return ($a, $b, $c); > } > else { > return (" ", " ", " "); > } > > I declare the variable result_value1 at the begining of the method as > follows > > my $result_value1 =" "; > > Any ideas why ? I'm still new to Perl myself, so I can't tell you exactly what's happening, but it looks like $result_value1 is undef when it gets to the if statement. I think a better way to accomplish what you're trying to do is simply: my $result_value1; if ($result_value) { #$result_value1 is defined $a= substr($result_value1, 0, 8); $b= substr($result_value1, 8, 2); $c= substr($result_value1, 10, 2); } else { #$result_value1 is still undef return (" ", " ", " "); } Hope this helps... Jason CONFIDENTIALITY NOTICE: The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited. The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc.
Mail::Sender
I am using Mail::Sender on AIX 4.3.3 and encounter the following error when running a script. Use of uninitialized value at /usr/opt/perl5/lib/site_perl/5.005/Mail/Sender.pm line 944, chunk 5. Can't use an undefined value as filehandle reference at /usr/opt/perl5/lib/site_perl/5.005/Mail/Sender.pm line 944, chunk 5. I have used this on other sysystem without any problems. Does anyone know if there are any issues with Mail::Sender on AIX 4.3.3? Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: "Use of uninitialized value" error message
Original Message- From: Ho, Tony [mailto:[EMAIL PROTECTED]] Subject: RE: "Use of uninitialized value" error message Hi Nikola/Jason Thanks for the help. The variable $result_value1 is declared within the subroutine and is never used outside the subroutine. I originally had the following piece of code (which I forgot to show you guys in the previous email): $result_value1 = $database1{$input_key1} But I changed the above code to the following and it worked ("Use of uninitialized value" error message" did not appear): $result_value1 = $database1{$input_key1} || " "; ahh... that would do it, though I don't think that's the preferred way to solve your problem. You are getting the "Use of uninitialized value" warning message because $database1{$input_key1} is undef. You are simply bypassing that by making $result_value1 a " " if it would otherwise return undef. By using your original code ( $result_value1 = $database1{$input_key1}; ) with "if ($result_value1);" you do what you want and avoid the warning because you are now checking to see if $result_value1 is defined. I know that Nikola says you will still get the warning, but it always works for me... :) Hope this helps... Jason CONFIDENTIALITY NOTICE: The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited.
RE: Processing Large Files
One of the primodial reasons for me to chop the file and see it was to see what it looks like! Since it worked for you for a 1GB sized file, within a wink of the eye,I am sure that I have strong suspicion in the line length. I guess, it might be one large 300 MB file with a single line content! That explains it. Let me investigate and if that is what it turns out to be, I guess I should use read(), tell() functions. Thanks, Rex -Original Message- From: Nikola Janceski [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 11:29 AM To: '[EMAIL PROTECTED]'; [EMAIL PROTECTED] Subject: RE: Processing Large Files I cut and paste your code. Used a file 1070725103 (~1 Gb) bytes big with about 100 bytes per line. and it ran in split second. Are the lines in your file giant sized (>1Mb/line)? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 11:20 AM To: [EMAIL PROTECTED] Subject: Processing Large Files Friends, I need to process 300+ MB text files. I tried to open one such file; read 10 lines (line by line) and output those 10 lines to a new text file. Despite reading line by line, it was taking a very long time for processing. Is there anything that I can try to speed it up!! Here is my pronto code: ### #!/usr/bin/perl use strict; my $from= "humongous.txt"; open(INP, $from) or die "cannot open input file $!"; open(OUT, ">sample.txt") or die "cannot open input file $!"; print("trying to read input file\n"); while(){ print STDOUT; print OUT; last if($. >= 10); } close(INP); close(OUT); ## Thanks, Rex The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc.
RE: getOpt::long?
try $ perldoc Getopt No documentation found for "Getopt". However, try perldoc Getopt::Long perldoc Getopt::Std perldoc Getopt::Long.html perldoc Getopt::Std.html -Original Message- From: Jason Larson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 11:28 AM To: 'michael' Cc: [EMAIL PROTECTED] Subject: RE: getOpt::long? answers your questions, though running perldoc -f getopt didn't return anything for me, so you might have to check some of the other sources. Hope this helps... Jason CONFIDENTIALITY NOTICE: The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited. The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: getOpt::long?
> -Original Message- > From: michael [mailto:[EMAIL PROTECTED]] > Subject: Re: getOpt::long? > > > > > I am a true perl newbie. > > > > If you continue like this you will stay one. > > > :-) Thanks for all the feedback. I had intended to send the > assignment as an > attachment and ask about: > 1) Configuring my win2k box so that I could use the command > line to run a > perl program without having to type 'perl' before the name of > the program in > order to execute it, and All the information you should need about the AS install of Perl should be on your start menu as: Start | Programs | ActiveState ActivePerl 5.6 | Documentation. To answer your specific question, you can open the html file: file:///C:/Perl/html/faq/Windows/ActivePerl-Winfaq4.html and select "How do I associate Perl scripts with perl?" I'd detail the answer for you, but it's already been done, so it'll be easier for both of us if you read the documentation. > 2) How to access perl documentation. a) Start | Programs | ActiveState ActivePerl 5.6 | Documentation b) You can also go to C:\Perl\bin, and run perldoc from there (it is a batch file that emulates perldoc on Unix) c) http://www.perldoc.com d) Install cygwin > > C:\>cd perl > > C:\Perl>perldoc -f getopt > 'perldoc' is not recognized as an internal or external command, > operable program or batch file. Need to be in C:\Perl\bin directory > > C:\Perl>perl -v > 'perl' is not recognized as an internal or external command, > operable program or batch file. Need to be in C:\Perl\bin directory > > I have installed ActiveState Perl 5.6.1 build 631 on this > machine, some time > ago, and have previously written perl scripts on it ( small ones!). > > I also have this problem on my laptop. The aforementioned answers should resolve the issue on your laptop as well. > > So I installed Mandrake Linux 8.2 last night, and am even > able to find the > info on the getopt module. > > Now I just have to buy a supported printer so I can print it out! > > Sorry to have bothered. Understand that we are here to help. The feedback you got was based on the information that was sent. It was not meant to be degrading, but you have to look at it from our perspective. Now that you've re-posted, I hope this answers your questions, though running perldoc -f getopt didn't return anything for me, so you might have to check some of the other sources. Hope this helps... Jason CONFIDENTIALITY NOTICE: The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited.
Re: How long can $_ be?
Anette Seiler [[EMAIL PROTECTED]] quoth: *> *>>From the command line I start the script with "perl script.pl". Now I *>have to enter some text. I just enter any text, either by typing or by *>cutting and pasting. I do not enter any strange characters or *>newlines. I just type in some text. I even take care to just use *>normal characters - no numbers, umlaute or anything else strange. *>As you can see, I did not play with $/. *> *>As I wrote in my initial mail, the answer I get is not the answer I *>expect. Whenever my input is more than 256 character, instead of *>printing everything I entered, it prints only the last part of what I *>entered, everything after character 256. The first part is chopped off. I believe you :) It's a 'feature' of Sun's terminal driver which only allows lines of 256 characters. A workaround would be to force a linewrap at 74 chars or read $_ from a file. e. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: getOpt::long?
From: "michael" <[EMAIL PROTECTED]> > :-) Thanks for all the feedback. I had intended to send the assignment as an > attachment and ask about: > 1) Configuring my win2k box so that I could use the command line to run a > perl program without having to type 'perl' before the name of the program in > order to execute it, and Add .pl and whatever other extensions you want to the PATHEXT system variable (Rightclick "My Computer" and select Properties\Advanced\Environment Variables) You might need to set up the file extension mapping as well. > 2) How to access perl documentation. > > C:\>cd perl > > C:\Perl>perldoc -f getopt > 'perldoc' is not recognized as an internal or external command, > operable program or batch file. > > C:\Perl>perl -v > 'perl' is not recognized as an internal or external command, > operable program or batch file. The perldoc.bat and perl.exe are in c:\perl\bin. You should have this path in your PATH system variable. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Processing Large Files
I cut and paste your code. Used a file 1070725103 (~1 Gb) bytes big with about 100 bytes per line. and it ran in split second. Are the lines in your file giant sized (>1Mb/line)? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 11:20 AM To: [EMAIL PROTECTED] Subject: Processing Large Files Friends, I need to process 300+ MB text files. I tried to open one such file; read 10 lines (line by line) and output those 10 lines to a new text file. Despite reading line by line, it was taking a very long time for processing. Is there anything that I can try to speed it up!! Here is my pronto code: ### #!/usr/bin/perl use strict; my $from= "humongous.txt"; open(INP, $from) or die "cannot open input file $!"; open(OUT, ">sample.txt") or die "cannot open input file $!"; print("trying to read input file\n"); while(){ print STDOUT; print OUT; last if($. >= 10); } close(INP); close(OUT); ## Thanks, Rex The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Processing Large Files
Friends, I need to process 300+ MB text files. I tried to open one such file; read 10 lines (line by line) and output those 10 lines to a new text file. Despite reading line by line, it was taking a very long time for processing. Is there anything that I can try to speed it up!! Here is my pronto code: ### #!/usr/bin/perl use strict; my $from= "humongous.txt"; open(INP, $from) or die "cannot open input file $!"; open(OUT, ">sample.txt") or die "cannot open input file $!"; print("trying to read input file\n"); while(){ print STDOUT; print OUT; last if($. >= 10); } close(INP); close(OUT); ## Thanks, Rex
RE: "Use of uninitialized value" error message
that actually won't get rid of the warning. but you are right the declaration at the top of the script of the varible goes out of scope when it reaches the if. you are using -w or use warnings; in your script that is causing the warning. perhaps attaching the code would help but we can't tell where the varible goes out of scope. -Original Message- From: Jason Larson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 11:06 AM To: 'Ho, Tony'; '[EMAIL PROTECTED]' Subject: RE: "Use of uninitialized value" error message > -Original Message- > From: Ho, Tony [mailto:[EMAIL PROTECTED]] > Subject: "Use of uninitialized value" error message > > Hi guys > I was wondering if you could help me with the following problem. > > I am getting the following error message: > > Use of uninitialized value in string ne at > format_imsi_msisdn.pl line 257. > > line 257 and beyond consist of the following: > > if ($result_value1 ne " ") { > $a= substr($result_value1, 0, 8); > $b= substr($result_value1, 8, 2); > $c= substr($result_value1, 10, 2); > return ($a, $b, $c); > } > else { > return (" ", " ", " "); > } > > I declare the variable result_value1 at the begining of the method as > follows > > my $result_value1 =" "; > > Any ideas why ? I'm still new to Perl myself, so I can't tell you exactly what's happening, but it looks like $result_value1 is undef when it gets to the if statement. I think a better way to accomplish what you're trying to do is simply: my $result_value1; if ($result_value) { #$result_value1 is defined $a= substr($result_value1, 0, 8); $b= substr($result_value1, 8, 2); $c= substr($result_value1, 10, 2); } else { #$result_value1 is still undef return (" ", " ", " "); } Hope this helps... Jason CONFIDENTIALITY NOTICE: The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited. The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: "Use of uninitialized value" error message
> -Original Message- > From: Ho, Tony [mailto:[EMAIL PROTECTED]] > Subject: "Use of uninitialized value" error message > > Hi guys > I was wondering if you could help me with the following problem. > > I am getting the following error message: > > Use of uninitialized value in string ne at > format_imsi_msisdn.pl line 257. > > line 257 and beyond consist of the following: > > if ($result_value1 ne " ") { > $a= substr($result_value1, 0, 8); > $b= substr($result_value1, 8, 2); > $c= substr($result_value1, 10, 2); > return ($a, $b, $c); > } > else { > return (" ", " ", " "); > } > > I declare the variable result_value1 at the begining of the method as > follows > > my $result_value1 =" "; > > Any ideas why ? I'm still new to Perl myself, so I can't tell you exactly what's happening, but it looks like $result_value1 is undef when it gets to the if statement. I think a better way to accomplish what you're trying to do is simply: my $result_value1; if ($result_value) { #$result_value1 is defined $a= substr($result_value1, 0, 8); $b= substr($result_value1, 8, 2); $c= substr($result_value1, 10, 2); } else { #$result_value1 is still undef return (" ", " ", " "); } Hope this helps... Jason CONFIDENTIALITY NOTICE: The information contained in this ELECTRONIC MAIL transmission is confidential. It may also be privileged work product or proprietary information. This information is intended for the exclusive use of the addressee(s). If you are not the intended recipient, you are hereby notified that any use, disclosure, dissemination, distribution [other than to the addressee(s)], copying or taking of any action because of this information is strictly prohibited.
Re: getOpt::long?
- Original Message - From: "Jenda Krynicky" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, March 13, 2002 7:10 AM Subject: Re: getOpt::long? > From: Michael <[EMAIL PROTECTED]> > > > I am a true perl newbie. > > If you continue like this you will stay one. > :-) Thanks for all the feedback. I had intended to send the assignment as an attachment and ask about: 1) Configuring my win2k box so that I could use the command line to run a perl program without having to type 'perl' before the name of the program in order to execute it, and 2) How to access perl documentation. C:\>cd perl C:\Perl>perldoc -f getopt 'perldoc' is not recognized as an internal or external command, operable program or batch file. C:\Perl>perl -v 'perl' is not recognized as an internal or external command, operable program or batch file. I have installed ActiveState Perl 5.6.1 build 631 on this machine, some time ago, and have previously written perl scripts on it ( small ones!). I also have this problem on my laptop. So I installed Mandrake Linux 8.2 last night, and am even able to find the info on the getopt module. Now I just have to buy a supported printer so I can print it out! Sorry to have bothered. -michael- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Reinitializing an Array
proper way: @an_array = (); or undef @an_array; # doesn't really free up the memory it used but the array is uninitialized -Original Message- From: Barry Kingsbury [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 13, 2002 10:31 AM To: [EMAIL PROTECTED] Subject: Reinitializing an Array I have an array that I wish to reuse. Before I reuse it, I want to clear out all elements. Both of the following seem to work: @an_array = ""; and $#an_array = -1; I then go on to do something like: foreach (@foo_array) { push (@an_array, $_); } Neither seems completely correct although I like the second. Is the second legal and portable or did I just luck out? Is there a better way? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: How long can $_ be?
Hi Folks, This got me wondering. Is the behavior you see caused by limitations for $_, or by limitations of the print function? You might try: print strlen( $_ ), "\n"; Thanks, Smiddy -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Reinitializing an Array
I have an array that I wish to reuse. Before I reuse it, I want to clear out all elements. Both of the following seem to work: @an_array = ""; and $#an_array = -1; I then go on to do something like: foreach (@foo_array) { push (@an_array, $_); } Neither seems completely correct although I like the second. Is the second legal and portable or did I just luck out? Is there a better way? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Matching key values from more than one hash
--aplogies forgot Subject line Hi guys I am having trouble trying to figure out how to do a match between two hashes basically I have the $login and $gid from the passwd file and the $gid and $gname fields from the group file. (I got these from getpwent and getgrent) #!/util/perl5.static -w # Build phash %phash = (); $gid => $login @gid = keys( %phash ); # Build ghash %ghash = (); $gname => $gid # Match $login to $group foreach $gid (@gid) { if ($gid =~ / /; ) { #Build $login => $gname Hash } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
"Use of uninitialized value" error message
Hi guys I was wondering if you could help me with the following problem. I am getting the following error message: Use of uninitialized value in string ne at format_imsi_msisdn.pl line 257. line 257 and beyond consist of the following: if ($result_value1 ne " ") { $a= substr($result_value1, 0, 8); $b= substr($result_value1, 8, 2); $c= substr($result_value1, 10, 2); return ($a, $b, $c); } else { return (" ", " ", " "); } I declare the variable result_value1 at the begining of the method as follows my $result_value1 =" "; Any ideas why ? Thanks in advance Tony
FW:
Hi guys I am having trouble trying to figure out how to do a match between two hashes basically I have the $login and $gid from the passwd file and the $gid and $gname fields from the group file. (I got these from getpwent and getgrent) #!/util/perl5.static -w # Build phash %phash = (); $gid => $login @gid = keys( %phash ); # Build ghash %ghash = (); $gname => $gid # Match $login to $group foreach $gid (@gid) { if ($gid =~ / /; ) { #Build $login => $gname Hash } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: getOpt::long?
From: Michael <[EMAIL PROTECTED]> > I am a true perl newbie. If you continue like this you will stay one. > I am supposed to: > > Write a program that finds lines in an input file and copies them to an > output file . The program takes the following arguments: > >an input file name (a mandatory argument) >an output filename (an optional argument, set to STDOUT if omitted), >a starting position number that marks the beginning of the offset (an >optional argument, set to the beginning of the input file if omitted) >an ending position number that marks the end of the offset (an optional >argument, set to the end of the input file if omitted) > > If any mandatory argument is omitted or the command is followed by a help > switch, your program prints out a usage on the screen (Hint: use assert.pl to > verify the conditions). > ... But this is really cool. This guy's even too lazy to at least reword the request, he copies the whole homework assignment over here without changing a single word. I'm surprised he did not leave the name & email of his profesor at the end. Listen Michael, we don't do homeworks here. We are here to help people learn Perl, to help people finish their projects, but we are not here to do their work for them. How do you expect to learn anything if someone else does everything for you? Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how to pass 2 variables
Hi Jorge, It looks like you want to create a reference data structure to create your links from. I would suggest something like: # filename of link to create on disk my $path1 = "$RegValue\\InstallOXE.lnk"; # LINK attribute to set => value my %lnk1 = ( 'Path' => "$CMPath/Active_Perl/Bin/", 'WorkingDirectory' => "$CMPath/Active_Perl/Bin/", etc... ); And then: &createScut(\%lnk1,$path1); sub createScut { # I think this line works, haven't tested it my %link_info = %{$_[0]}; my $path = $_[1]; my $LINK = new Win32::Shortcut; for(keys %link_info) { $LINK->{$_} = $link_info{$_}; } $LINK->Save($path); $LINK->Close(); } Hope that helps, -dave > -Original Message- > From: Jorge Goncalvez [mailto:[EMAIL PROTECTED]] > Subject: RE:how to pass 2 variables > Hi, I have this but it is a bit repeating I wonder how to > pass 2 variables and > use only function createScut.My code: > my $path="$RegValue\\InstallOXE.lnk"; > &createScut($path); > my $path2="$RegValue\\remove.lnk"; > &createScut2($path2);I > > sub createScut() { > > my $CMPath = GetMyRegPath::GetCygwinMountsPath(); > my $lnkLocation = shift; > $LINK=new Win32::Shortcut(); > > $LINK->{'Path'}=qq($CMPath\\Active_Perl\\Bin\\); > $LINK->{'WorkingDirectory'}="$CMPath/Active_Perl/Bin/"; > $LINK->{'Description'}=" Serveur d'installation CS OXE "; > $LINK->{'ShowCmd'}=SW_SHOWMINNOACTIVE; > $LINK->{'IconLocation'}="$CMPath/Active_Perl/Bin/ras.ico"; > $LINK->Save($lnkLocation); > $LINK->Close(); > > } > > sub createScut2() { > > my $CMPath = GetMyRegPath::GetCygwinMountsPath(); > my $lnkLocation = shift; > $LINK=new Win32::Shortcut(); > > $LINK->{'Path'}=qq($CMPath\\); > $LINK->{'WorkingDirectory'}="$CMPath"; > $LINK->{'Description'}=" Désinstallation de cygwin "; > $LINK->{'ShowCmd'}=SW_SHOWMINNOACTIVE; > $LINK->{'IconLocation'}="$CMPath/Active_Perl/Bin/cygwin.ico"; > $LINK->Save($lnkLocation); > $LINK->Close(); > > } > > > Thanks. > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
FW: Perldoc question
If new to unix and you want to find perldoc (or any module), try this: find . -name perldoc* -print That will locate perldoc and show you the path to it. You could also try: whence perldoc That may also work (works for me under ksh) Hope that helps, Joe -Original Message- From: Tyler Longren [mailto:[EMAIL PROTECTED]] Sent: Tuesday, March 12, 2002 2:24 PM To: Joe Echavarria; Hanson, Robert; [EMAIL PROTECTED] Subject: Re: Perldoc question type this at your command line: echo $PATH That should display a few folders (/usr/local/bin, /usr/bin, etc...). your perldoc executable should be located in a folder listed in your $PATH. Good luck, Tyler - Original Message - From: "Joe Echavarria" <[EMAIL PROTECTED]> To: "Hanson, Robert" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, March 12, 2002 1:15 PM Subject: RE: Perldoc question > I really don ' t understand what you mean. I am new to > Unix and Perl. > Please help me out here. What i should to ?, read or > what ? > > Thanks. > >Joe. > --- "Hanson, Robert" <[EMAIL PROTECTED]> wrote: > > perldoc isn't in your path most likely. > > > > Check your path environment variable (echo $PATH), > > and make sure that > > perldoc is in one of those directories. If I had to > > guess you probably have > > a symlink to the perl executable in your path, but > > not the actual bin/ > > directory of perl. > > > > Rob > > > > -Original Message- > > From: Joe Echavarria > > [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, March 12, 2002 1:48 PM > > To: [EMAIL PROTECTED] > > Subject: Perldoc question > > > > > > hi there, > > > > On my unix box when i try to get perl help from > > the > > command line using "perldoc print" or "perlfunc" i > > get > > these errores. > > > > perlfunc: not found > > perldoc: not found > > > > How can i fix this problem ? > > > > Thanks. > > > > Joe. > > > __ > Do You Yahoo!? > Try FREE Yahoo! Mail - the world's greatest free email! > http://mail.yahoo.com/ > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE:how to pass 2 variables
Hi, I have this but it is a bit repeating I wonder how to pass 2 variables and use only function createScut.My code: my $path="$RegValue\\InstallOXE.lnk"; &createScut($path); my $path2="$RegValue\\remove.lnk"; &createScut2($path2);I sub createScut() { my $CMPath = GetMyRegPath::GetCygwinMountsPath(); my $lnkLocation = shift; $LINK=new Win32::Shortcut(); $LINK->{'Path'}=qq($CMPath\\Active_Perl\\Bin\\); $LINK->{'WorkingDirectory'}="$CMPath/Active_Perl/Bin/"; $LINK->{'Description'}=" Serveur d'installation CS OXE "; $LINK->{'ShowCmd'}=SW_SHOWMINNOACTIVE; $LINK->{'IconLocation'}="$CMPath/Active_Perl/Bin/ras.ico"; $LINK->Save($lnkLocation); $LINK->Close(); } sub createScut2() { my $CMPath = GetMyRegPath::GetCygwinMountsPath(); my $lnkLocation = shift; $LINK=new Win32::Shortcut(); $LINK->{'Path'}=qq($CMPath\\); $LINK->{'WorkingDirectory'}="$CMPath"; $LINK->{'Description'}=" Désinstallation de cygwin "; $LINK->{'ShowCmd'}=SW_SHOWMINNOACTIVE; $LINK->{'IconLocation'}="$CMPath/Active_Perl/Bin/cygwin.ico"; $LINK->Save($lnkLocation); $LINK->Close(); } Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How long can $_ be?
Dear All, the script I'm using is really very simple: #!/usr/local/bin/perl -w use strict; while (<>) { chomp; print "\n\n$_\n\n"; } >From the command line I start the script with "perl script.pl". Now I have to enter some text. I just enter any text, either by typing or by cutting and pasting. I do not enter any strange characters or newlines. I just type in some text. I even take care to just use normal characters - no numbers, umlaute or anything else strange. As you can see, I did not play with $/. As I wrote in my initial mail, the answer I get is not the answer I expect. Whenever my input is more than 256 character, instead of printing everything I entered, it prints only the last part of what I entered, everything after character 256. The first part is chopped off. I experimented with that and had the following results: The first line I gave was 490 characters long, $_ contained the last 233 characters. The string was chopped off at character 257. The second line I gave was 462 characters long, $_ contained the last 205 characters. The string was chopped off at character 257. The third line I gave was 253 characters long, $_ contained the whole 253 characters. Nothing was chopped off. The fourth line I gave was 839 characters long, $_ contained the last 68 characters. The string was chopped off at character 771. Nikola asked: "Exactly how long/big are we talking of making $_?" The fourth line is already a very long line. I don't thing it will be more than a 1000 characters per line. The script above is the essence of the problem. I found the problem when I wrote a script that reads in a line at a time from a file. The script was supposed to find a url in each line with an regex, isolate the url and do something with it. The script did not find the url in lines that were longer than 256 characters, because it appeared more in the beginning. I then found out that it was not my regex that was wrong, but $_ did not give me what I wanted. Funny enough, I am able to find the url using index and substring. In this way I was able to do what I wanted to do, but it does not help solving the problem I have. The subroutine that worked was: open DATEI, "$_" or die "Kann die Datei $_ nicht öffnen ($!)\n"; foreach my $line () { chomp $line; if ($line =~ /\/i) { my $begin_url = index $line, "http"; my $end_url = index $line, "\" "; my $length = ($end_url - $begin_url) ; my $url = substr ($line, $begin_url, $length); and so on. I would be really grateful for an answer to the puzzle. Kind regards Anette > Perl 5.004_04 on my Solaris 5.6 machine had no problems making $_ of > length 178956970. Of course I have an elephant crap load of memory on > this sucker. > > Exactly how long/big are we talking of making $_? > > > -Original Message- > From: David Gray [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, March 12, 2002 9:06 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: RE: How long can $_ be? > > > > Is there some limit in how long the contents of the variable $_ can > > be? > > Not that I'm aware of, no. > > > I encounter this problem on Solaris machines running Perl 5.005. On > > Windows with Perl 5.6.1. no such problem was encountered. > > > > What could cause the problem? > > I suppose it might be a a configuration problem of some sort, but I > doubt that. Could you show us the exact code you're using to load the > lines from your file into $_ ? > > -dave > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- > -- The views and opinions expressed in this > email message are the sender's own, and do not necessarily represent > the views and opinions of Summit Systems Inc. > Mit freundlichen Grüßen Anette Seiler HBZ-NRW Geschäftsbereich Digitale Bibliothek Tel.: +49-221-40075-196 Fax: +49-221-40075-190 www.hbz-nrw.de email: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Save image to disk
You probably don't need a perl script for this, there's this command call wget in linux which you can use to mirror a site, and using the -A option you can make it download file with specified extention (gif, jpg..etc). Tor. Gary Hawkins wrote: > Would like to save images to disk using their URL's. Hoping someone can give > me a jump start on it. > > Gary > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Save image to disk
Would like to save images to disk using their URL's. Hoping someone can give me a jump start on it. Gary -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex question
Hi Martin, > > > i have a long text file. in this text file several strings of the form: > ### filename.jpg ### are embedded. > > how should a regex look that takes following: > > ### filename.jpg ### > > and returns > try this. s/### (\w+\.jpg) ###//; the filename is in $1 > > > and the filename.jpg saved in a $ > > :o) > > martin -- cu boris Wenn ich nur mehr Zeit gehabt hätte, hätte ich Dir einen kürzeren Brief geschrieben. -- Pascal -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: regex question
Try this regexp. s/###.*?###//g; [EMAIL PROTECTED] wrote: > hi > > i have a long text file. in this text file several strings of the form: ### >filename.jpg ### are embedded. > > how should a regex look that takes following: > > ### filename.jpg ### > > and returns > > > > and the filename.jpg saved in a $ > > :o) > > martin > -- > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
regex question
hi i have a long text file. in this text file several strings of the form: ### filename.jpg ### are embedded. how should a regex look that takes following: ### filename.jpg ### and returns and the filename.jpg saved in a $ :o) martin -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE:Win32::Shortcut
Hi, I use Win32::Shortcut with a perl /tk apllication to make a shortcut on the windows Desktop it works but when I double click my icon my application get a littele time to come and I wonder it is possible to add a hourglass when i double click my icon to make waiting the user. thanks . -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]