Re: "1;"?
R. Joseph Newton wrote: > Rob Richardson wrote: > >> Greetings! >> >> Dan Muey's stumpy.lib file, quoted below, ends with a statement >> consisting of a single contstant value: "1;". This is the second >> time >> I've seen this today. What is its purpose? > > It's pretty much a standard for modules, but not strictly necessary. > For instance, I just changed the last line in one of my pm files to: > "Toodle-oo!"; As long as the module returns 'true' it'll work fine. That's anything apart from 'undef', zero or an empty string. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using HTML::Parser question
Dan Muey wrote: > For clarity sake with all of the code and changes and stuff here is > the code that works mostly the way I want A virtue that - faith, hope and clarity. Sorry, /R -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How do I test a variable to see if it is a scalar or a hash?
On Thursday, January 23, 2003, at 11:43 AM, Ken Lehman wrote: How do I test a variable to see what type of variable it is(scalar, array, hash, etc...)? What I am trying to accomplish is I have a hash and some values are scalar data and some values are nested hashes and I need a way to tell the difference. You don't actually have nested hashes, you have hashes whose values are references to more hashes. Perhaps you can test to see if the value for a particular key is a reference? If not, it is "just" a regular scalar value. Take care, Chris -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
improvements to code
Hi all, I want to grap the: last first middle(if any) email from a text file sometimes there is a middle intital, sometimes there isn't sample data: Smith, Mary [EMAIL PROTECTED] Jones, Tommy Lee [EMAIL PROTECTED] can someone suggest improvements to the code below? #!/usr/bin/perl -w my ($first, $last, $middle, @fields); open(IN, "text.txt") or die("nope: $!\n"); while($line = ){ chomp($line); @fields=split(/ /, $line); #an array in scalar context returns number of elements $number = @fields; print("number: $number\n"); #if there is no remainder, there are 3 elements if($number % 3 == 0){ $first = $fields[0]; $last = $fields[1]; $email= $fields[2]; } #if there is no remainder, there are 4 elements elsif($number % 4 == 0){ $first = $fields[0]; $last = $fields[1]; $middle= $fields[2]; $email= $fields[3]; } print("first: $first\n"); print("last: $last\n"); print("middle: $middle\n"); print("email: $email\n"); } close(IN); thanks in advance, Pam -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: For loop aliasing AND changing an array within a loop.
While stepping through the code I wrote, I distinctly noted that the substitution on $_ did NOT affect the array and vice versa. If anyone insists on adding or deleting elements of an array from within a loop, you can ... you just have to update either $_ or what $_ is aliased to, like the original code I posted. Thanks, John, for reminding me of glob. It does exactly what I need. Perl has so many parts, it is easy to forget many of them. Thanks. -Original Message- From: Paul Johnson [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 22, 2003 5:24 PM To: John W. Krahn Cc: [EMAIL PROTECTED] Subject: Re: For loop aliasing AND changing an array within a loop. On Wed, Jan 22, 2003 at 02:10:34PM -0800, John W. Krahn wrote: > Zeus Odin wrote: > > I think I read somewhere that you should NOT delete array elements from > > within a loop. However, the following works very well. > > I think that you are thinking of hashes. From perlsyn: If any part of LIST is an array, "foreach" will get very confused if you add or remove elements within the loop body, for example with "splice". So don't do that. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Probably a simple hash question
> Here's the setup: > I have set up a hash %categories where the key is one number and the value > is another > i.e. $categories('1094') = 100049-0220-14 I assume you meant (note braces and quotes): $categories{1094} = '100049-0220-14' otherwise the value will be 100049-0220-14 = -99. > So, further on down, I'm trying to do a lookup in %categories to see if a > value is there. (I can > swap the key and the value in the setup if it will make this next step > easier) > and I had a while loop to search through each of the keys & values, but > the problem is > that it doesn't break out of the while loop, and the wrong value gets set > as $myID; There are two ways I can think of: (1) you can copy and reverse the hash or (2) you can loop through the values until you find a match. -- # remember, hashes are not in key order # note () NOT {} %categories = ( 1094 => '100049-0220-14', 1095 => '100059-5220-54', 1096 => '100669-6620-660004', 1097 => '100779-7720-770004', ); $value = '100779-7720-770004'; # (1) %reversed = reverse %categories; print "$reversed{$value}\n"; # (2) foreach $key(keys %categories){ print "Loop ", ++$x, "\n"; if($categories{$key} eq $value){ print "$key\n"; print "Exiting within loop $x\n"; last; } } -- > #until ($value == $ccid) Data are text not numeric ($value eq $ccid). See above. > #}## Need to break out of the while loop here once find it. last; > So, here's the question: > Where can I find information on how to use variables as the keys in a > hash? I hope this answers your question. If %categories is not that large OR if you have a fast computer OR if you have a lotta memory, I would opt for (1) above because there is no looping--ie, less code to maintain, that is always good. If you no longer need the original %categories, you can also do %categories = reverse %categories; Otherwise, opt for (2). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[ANN] splits2d.pl
Uh-oh. Newbie code ahead. You have been warned. Thank you all for helping me with my questions! splits2d.pl can be used to split one or more HTML files of links, or bookmarks, into a set of HTML files of links, or bookmarks, by category. As currently written, splits2d prefers two types of HTML as input: bookmark files and splits2d's own output. It has not been extensively tested with other types of HTML. Output files are overwritten without warning. If you run it, please read the included documentation, which I tried to make fairly thorough. Uh-oh, I forgot to add 2 more bugs to it: it expects the template to be in the current directory; and output files always go to the current directory and they are always named page1.html, page2.html, etc. Make that 3 bugs. Unfortunately, this perl script has only been tested on Windows, and I decided to put the script and supporting files in a zip file. However, the script was saved in Unix format. Any feedback is welcome. It uses widely available modules but I couldn't find anything out there that did this exactly. The scripts that I found didn't preserve the link descriptions as defined by tags, and I tend to save bookmarks in Yahoo and export to Netscape bookmark files which have those descriptions. Also I wanted splits2d.pl to be able to read its own output as input (and it does). splits2d.pl requires the following modules (some of these are core modules): File:Basename, G (thanks Jenda), HTML::TokeParser, HTMLTMPL, Getopt::Long, Pod::Usage, Time::HiRes splits2d.zip, which contains splits2d.pl and supporting files (including a sample input file bookmarks.html to play with), can be found at this link if anyone's interested: URL:http://www.webneed.net/~heydave/work-in-progress/ Dave Sometimes it really is the messenger's fault. Sometimes you really did miss a spot. -- myself -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple use of same module question
R. Joseph Newton said: >> And that finally explains why in some of my scripts using the >> Win32::Lanman >> module I have to do a 'require Win32;' instead of a 'use Win32' if I >> don't >> want to get warning messages about conflicting constants. > > I*t sems to me that this is sort of a shortcoming, if you have to worry > about that at all. In C/C++, one of the standards for writing any header > file is to always surround the entirety with an inclusion guard to prevent > the precompiler from redefining classes or redeclarating other constants > and prototypes. Usually it took the form of: > > #ifndef STDIO_H > #define STDIO_H > ... All code in header > ... > #endif /* STDIO_H */ > > Which effectively prevents such problems--although it does not prevent > deadlock from circular includes. > > I assume that most Perl modules have similar structures built in. No. This is taken care of by perl itself using %INC. The module author does not need to do anything to stop the module being included more than once. It sounds like something is broken in the Win32 import sub (I have never used or looked at Win32.pm), or that there is some other problem, but import guards are not the solution. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
SGI::FAM Module gives errors
Hi I receive the following error when runnung the 'monitor' perl script after installing SGI::FAM via CPAN. (I have installed it manually as well -> same error). 'Your vendor has not defined SGI::FAM macro new at ./monitor line 6' The script snippet is pasted below: #!/usr/bin/perl use SGI::FAM qw(); use autouse Pod::Usage => qw(pod2usage); pod2usage(VERBOSE => 1) unless @ARGV; my ($fam)=SGI::FAM->new(); fam works fine and the SGI::FAM module installed without errors (in all cases). What's missing? Thnx for any suggestions Bernd Hinrichsen Network Admin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to use com components in perl
Hi - > -Original Message- > From: Pankaj Kapare [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 23, 2003 1:15 AM > To: [EMAIL PROTECTED] > Subject: How to use com components in perl > > > Hi > Can anybody tell me how to use com components developed in c++ > in perl script.If provided with sample code it will be great help. > thanks. > Pankaj > I really haven't done this, but I would advise you to start your quest with the CPAN Win32::OLE module (and it's siblings). Aloha => Beau. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: one line perl
Hi, I am trying to get the following one liner to work, but the figure from the subtraction is printed after column 6 and column 7 and 8 are discarded. What I am trying to do is create an extra column after column 6 for the subtraction and retain the last two columns: perl -F'\t' -lane 'print join("\t", @F[0..8], $F[6] - $F[5])' * input data: 68152 922949 639F510 100 150245 870 46735 985967 649A600 90 110 344 915 Please tell me which piece I am missing Cheers parkerd -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: improvements to code
On Thu, 23 Jan 2003, Pam Derks wrote: > Hi all, > > I want to grap the: > last first middle(if any) email > from a text file > > sometimes there is a middle intital, sometimes there isn't > > sample data: > Smith, Mary [EMAIL PROTECTED] > Jones, Tommy Lee [EMAIL PROTECTED] > > can someone suggest improvements to the code below? Does it always come in the same order?? If it does, then: I've also removed a trailing "," from all the names (if any) #!/usr/bin/perl -w my ($first, $middle, $last, $email); open(IN, "text.txt") or die("nope: $!\n"); while(my $ln = ) { chomp $ln; ($last, $first, $email) = split / +/, $ln, 3; ($email, $middle) = reverse split(/ +/, $email); ($first, $middle, $last) = map { $_ = '' if (!defined $_); s/ *,$/; $_;} ($first, $middle, $last); print("first: $first\n"); print("last: $last\n"); print("middle: $middle\n"); print("email: $email\n"); } close IN; > > #!/usr/bin/perl -w > > my ($first, $last, $middle, @fields); > > open(IN, "text.txt") or die("nope: $!\n"); > while($line = ){ > > chomp($line); > > @fields=split(/ /, $line); > #an array in scalar context returns number of elements > $number = @fields; > print("number: $number\n"); > > #if there is no remainder, there are 3 elements > if($number % 3 == 0){ > $first = $fields[0]; > $last = $fields[1]; > $email= $fields[2]; > } > > #if there is no remainder, there are 4 elements > elsif($number % 4 == 0){ > $first = $fields[0]; > $last = $fields[1]; > $middle= $fields[2]; > $email= $fields[3]; > } > > print("first: $first\n"); > print("last: $last\n"); > print("middle: $middle\n"); > print("email: $email\n"); > } > > close(IN); > > thanks in advance, > > Pam > > -- > 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]
MS Word question
I'm running Perl on Cygwin on top of Windows 2000. I have a lot of ascii text files that someone has thoughfully saved as Microsoft Word documents. If I open them in a text editor, I can see the ascii text, but there is some junk at the top and bottom. Testing the files with -T tells me they're not text. grep seems able to search through the text in the files, but I'd like to strip the junk out and save them as simple text files. I tried a few things in Perl, but didnt' get anywhere. I'd be grateful if someone were able to provide some pointers. Many thanks, Harry. Harry Southworth, TE2A/4 Parklands, Alderley Park, Cheshire, SK10 4TG, UK Tel.: +44 1625 518327 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Pairs have minimum difference
Hi, ALL, I thought there should be a solution/algorithm already to this problem and would like to check here first. The problem: To return all the pairs (one number from each array, one number can only be in one pair) that have the smallest sum of absolute differences from two arrays. For example my @xa=(8765,6000,4765,3000,1530,1500,1465,1234,1000); my @xb=(8675,6000,4567,3100,3000,1545,1515,1485,1324,1005); to return: diffnum_1 num_2 0 30003000 0 60006000 5 10001005 15 15001515 15 15301545 20 14651485 -90 87658675 90 12341324 -19847654567 . 3100 Notice that |1500-1485|=|1500-1515|. Many thanks! Nengbing -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Pairs have minimum difference
Hi - I'll pass - this looks like HOMEWORK! Please put on your thinking cap and try it... > -Original Message- > From: Nengbing Tao [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 24, 2003 3:00 AM > To: [EMAIL PROTECTED] > Subject: Pairs have minimum difference > > > Hi, ALL, > > I thought there should be a solution/algorithm already to > this problem > and would like to check here first. > > > The problem: To return all the pairs (one number from each array, one > number can only be in one pair) that have the smallest sum of absolute > differences from two arrays. > > For example > > my @xa=(8765,6000,4765,3000,1530,1500,1465,1234,1000); > my @xb=(8675,6000,4567,3100,3000,1545,1515,1485,1324,1005); > > to return: > diff num_1 num_2 > 0 30003000 > 0 60006000 > 5 10001005 > 1515001515 > 1515301545 > 2014651485 > -90 87658675 > 9012341324 > -198 47654567 > . 3100 > > Notice that |1500-1485|=|1500-1515|. > > > Many thanks! > > > Nengbing > > > > -- > 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: improvements to code
Pam Derks wrote: > > Hi all, Hello, > I want to grap the: > last first middle(if any) email > from a text file > > sometimes there is a middle intital, sometimes there isn't > > sample data: > Smith, Mary [EMAIL PROTECTED] > Jones, Tommy Lee [EMAIL PROTECTED] > > can someone suggest improvements to the code below? > > #!/usr/bin/perl -w use strict; > my ($first, $last, $middle, @fields); You should define these variables in the smallest possible scope instead of at the top of the program. > open(IN, "text.txt") or die("nope: $!\n"); > while($line = ){ while ( my $line = ) { > chomp($line); > > @fields=split(/ /, $line); split / / will split using a single space, it is more efficient to use the default. my @fields = split ' ', $line; > #an array in scalar context returns number of elements > $number = @fields; > print("number: $number\n"); > > #if there is no remainder, there are 3 elements > if($number % 3 == 0){ Why use modulus, just use == 3. if ( @fields == 3 ) { > $first = $fields[0]; > $last = $fields[1]; > $email= $fields[2]; According to your explaination at the beginning the order of the names is "last first middle(if any)". So is that the correct order or is it really "first last"? Also, since you declared $middle outside of the loop, the value in $middle will not be changed here. If the previous record had a middle name that middle name will show up in subsequent records that have no middle name. > } > > #if there is no remainder, there are 4 elements > elsif($number % 4 == 0){ elsif ( @fields == 4 ) { > $first = $fields[0]; > $last = $fields[1]; > $middle= $fields[2]; > $email= $fields[3]; > } > > print("first: $first\n"); > print("last: $last\n"); > print("middle: $middle\n"); > print("email: $email\n"); > } > > close(IN); This is the way I would do it: #!/usr/bin/perl -w use strict; open IN, 'text.txt' or die "Cannot open 'text.txt' $!"; while ( ) { # split removes ALL whitespace so chomp isn't required my @fields = split; print 'number: ' . @fields . "\n"; my $email = pop @fields || ''; my $last = shift @fields || ''; my $first = shift @fields || ''; my $middle = shift @fields || ''; print "first: $first\n"; print "last: $last\n"; print "middle: $middle\n"; print "email: $email\n"; } close IN; __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple use of same module question
From: "Paul Johnson" <[EMAIL PROTECTED]> > R. Joseph Newton said: > > worry about that at all. In C/C++, one of the standards for writing > > any header file is to always surround the entirety with an inclusion > > guard to prevent the precompiler from redefining classes or > > redeclarating other constants and prototypes. Usually it took the > > form of: > > > > #ifndef STDIO_H > > #define STDIO_H > > ... All code in header > > ... > > #endif /* STDIO_H */ > > > > Which effectively prevents such problems--although it does not > > prevent deadlock from circular includes. > > > > I assume that most Perl modules have similar structures built in. > > No. This is taken care of by perl itself using %INC. The module > author does not need to do anything to stop the module being included > more than once. > > It sounds like something is broken in the Win32 import sub (I have > never used or looked at Win32.pm), or that there is some other > problem, but import guards are not the solution. No there is nothing broken. The modules ARE compiled just once (and you are right it's thank to %INC), but the import() function gets called for each use statement. Otherwise use Module::Name qw(Foo Bar); use Module::Name qw(Baz); would not work. And it behaves exactly the same on any OS. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
NewbieQuestion Deleting the first 5 lines of a file
Hello, I have over 1000 files that I need to delete the first five lines of text from. This needed to be done, like yesterday. I started writting an Applescript to do this but ran into a bug with Folder Actions and attached scripts that stopped my progress dead. Would someone please show me how this is done with perl. Thanks, Jeff -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Pairs have minimum difference
Hi, ALL, I thought there should be a solution/algorithm already to this problem and would like to check here first. The problem: To return all the pairs (one number from each array, one number can only be in one pair) that have the smallest sum of absolute differences from two arrays. For example my @xa=(8765,6000,4765,3000,1530,1500,1465,1234,1000); my @xb=(8675,6000,4567,3100,3000,1545,1515,1485,1324,1005); to return: diffnum_1 num_2 0 30003000 0 60006000 5 10001005 15 15001515 15 15301545 20 14651485 -90 87658675 90 12341324 -19847654567 . . 3100 Notice that |1500-1485|=|1500-1515|. Many thanks! Nengbing -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [ANN] splits2d.pl
David Eason wrote: > > [snip] > > Any feedback is welcome. > > [snip] > > splits2d.zip, which contains splits2d.pl and supporting files (including a > sample input file bookmarks.html to play with), can be found at this link if > anyone's interested: > URL:http://www.webneed.net/~heydave/work-in-progress/ The code looks pretty good over all, just a couple of minor nits. :-) 1) You should test your code with warnings and strict enabled. $ perl -wc splits2d.pl "my" variable $header_text masks earlier declaration in same scope at splits2d.pl line 127. 122 sub read_html_files() 123 { 124 my $link_per_target_count; 125 my $header_text = $opts{suggest_category}; ^^^ 126 my $p; 127 my ($header_text, $dd_text, $got_dd_text, $href_val, $a_text, $tok, $tag); 2) You should declare lexical variables where you define them or in the smallest possible scope. 18 my ($tick, $tock, $time_elapsed); [snip] 269 # start elapsed time measurement 270 $tick = [gettimeofday]; 271 272 parse_args(); 273 read_html_files(); 274 write_html_files(); 275 276 # end elapsed time measurement 277 $tock = [gettimeofday]; 278 $time_elapsed = tv_interval $tick, $tock; These three variables are declared 251 lines away from where they are actually used. 218 sub write_html_files() { 219 220 my ($category, $i, $link, $page); These variables are declared at the top of the sub instead of where they are used so you haven't noticed that $i is no longer used in this sub. Also, it is more efficient to declare and define them at the same time. 122 sub read_html_files() 123 { 124 my $link_per_target_count; 156 ++$link_per_target_count; It doesn't look like you need this variable. 129 my $doc; 130 foreach $doc (@ARGV) Would be better as: foreach my $doc (@ARGV) 32 my $app_name = basename $0; $app_name is not used anywhere. 3) You are using sprintf when concatenation would do. 230 $write_file = sprintf ("$target_base%d$target_ext", $target_count); Could be written as: $write_file = "$target_base$target_count$target_ext"; 236 linkToPrev(sprintf ("$target_base%d$target_ext", $target_count - 1)); Could be written as: linkToPrev( $target_base . $target_count - 1 . $target_ext ); 240 linkToNext(sprintf ("$target_base%d$target_ext", $target_count + 1)); Could be written as: linkToNext( $target_base . $target_count + 1 . $target_ext ); HTH John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Pairs have minimum difference
> > Hi, ALL, > > I thought there should be a solution/algorithm already > to this problem and would like to check here first. > > > The problem: To return all the pairs (one number from each > array, one number can only be in one pair) that have the > smallest sum of absolute differences from two arrays. > > For example > > my @xa=(8765,6000,4765,3000,1530,1500,1465,1234,1000); > my @xb=(8675,6000,4567,3100,3000,1545,1515,1485,1324,1005); > Why not put them in a hash and loop over the key/value pairs? my %nums = ( 3000 => 3005, 2000 => 4678 ); foreack $k(keys %nums) { if($k > $nums{$k}) { my $diff = $k - $nums{$k}; } else { my $diff = $nums{$k} - $k; } print "Diff : $diff N1 :$k N2 : $nums{$k}"; } > to return: > diff num_1 num_2 > 0 30003000 > 0 60006000 > 5 10001005 > 1515001515 > 1515301545 > 2014651485 > -90 87658675 > 9012341324 > -198 47654567 > . . 3100 > > Notice that |1500-1485|=|1500-1515|. Is that a problem? > > > Many thanks! > > > Nengbing > > -- > 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: Multiple use of same module question
Jenda Krynicky said: > From: "Paul Johnson" <[EMAIL PROTECTED]> >> It sounds like something is broken in the Win32 import sub (I have >> never used or looked at Win32.pm), or that there is some other >> problem, but import guards are not the solution. > > No there is nothing broken. The modules ARE compiled just once (and > you are right it's thank to %INC), but the import() function gets > called for each use statement. Otherwise > use Module::Name qw(Foo Bar); > use Module::Name qw(Baz); > would not work. As I recall, someone (Timothy Johnson?) said they got errors from using Win32 more than once and resorted to requiring it to silence the errors. I don't think we ever saw the error messages or the code. This prompted me to write the first paragraph above. As I am sure you know, require does not call the import sub, hence my rash diagnosis on flimsy evidence, complete with self evident disclaimer. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NewbieQuestion Deleting the first 5 lines of a file
> Hello, > > I have over 1000 files that I need to delete the first five > lines of text from. > This needed to be done, like yesterday. I started writting an > Applescript to do > this but ran into a bug with Folder Actions and attached > scripts that stopped my > progress dead. Would someone please show me how this is done > with perl. > first question: will these files be in one directory? or from various places? what type of files ? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple use of same module question
From: "Paul Johnson" <[EMAIL PROTECTED]> > As I recall, someone (Timothy Johnson?) said they got errors from > using Win32 more than once and resorted to requiring it to silence the > errors. I don't think we ever saw the error messages or the code. > This prompted me to write the first paragraph above. The problem in that case was that two different modules exported by default the same constants. And therefore perl -w issued warnings about redefining constants/subroutines. Most probably the "correct" solution would be to use Win32 qw(); to instruct Win32.pm not to export the constants. But of course this all is not related to the Windows as an OS. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Using HTML::Parser question
Perfect Thank you so much for the enlightenment! I will study that until I have it down pat! Thanks a million!!! Today you receive the genius award (Sorry Rob :P) Dan > > Dan Muey wrote: > > > > > print "body text: @body\n"; # this needs to keep the tags were they > > are** > > > > that' fairly easy to do: > > #!/usr/bin/perl -w > use strict; > > use HTMP::Parser; > > my $text = < > HI Title > heaD STUFF > > > keep the I tag > hI HERE'S CONTENT i WANT > IMaGE > > > > i DON'T WANT THIS SCRIPT EITHER > > Hello world > > > > HTML > > my $body = 0; > my $title = 0; > my @body; > my @title; > my %body_attr; > > my $html = HTML::Parser->new(api_version => 3, > text_h => [\&text,'dtext'], > start_h => [\&open_tag, > 'tagname,attr'], > end_h => [\&close_tag, 'tagname']); > $html->ignore_elements(qw(script comment)); > $html->parse($text); $html->eof; > > print "title is:\n@title\n\n"; > print "body text:\n@body\n\n"; > print "body attr:\n"; > while(my($k,$v) = each %body_attr){ > print "$k=$v\n"; > } > > sub text{ > > my $text = shift; > > return unless($text =~ /\w/); > > if($title){ > push(@title,$text); > }elsif($body){ > push(@body,$text); > } > } > > sub open_tag{ > > my $tagname = shift; > my $attr= shift; > > $title = 1 if($tagname eq 'title'); > > if($tagname eq 'body'){ > $body = 1; > while(my($key,$value) = each %{$attr}){ > $body_attr{$key} = "'$value'"; > } > }elsif($body){ > my $t = ''; > while(my($key,$value) = each %{$attr}){ > $t .= "$key='$value' "; > } > $t =~ s/\s$//; > push(@body,"<$tagname" . ($t ? " $t>" : '>')); > } > } > > sub close_tag{ > > my $tagname = shift; > > $title = 0 if($tagname eq 'title'); > $body = 0 if($tagname eq 'body'); > > push(@body,"") if($body); > } > > __END__ > > prints: > > title is: > HI Title > > body text: > keep the I tag > hI HERE'S CONTENT i WANT >IMaGE >Hello world > > body attr.: > bodytag='attributes' > > david > > -- > 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: one line perl
Aimal Pashtoonmal wrote: > > Hi, Hello, > I am trying to get the following one liner to work, but the figure > from the subtraction is printed after column 6 and column 7 and 8 are > discarded. What I am trying to do is create an extra column > after column 6 for the subtraction and retain the last two columns: > > perl -F'\t' -lane 'print join("\t", @F[0..8], $F[6] - $F[5])' * > > input data: > 68152 922949 639F510 100 150245 870 > 46735 985967 649A600 90 110 344 915 When you say column 6 are you counting from one or zero? Do you actually have whitespace at the beginning of the input data or is that an email formatting thing? See if this works: perl -lane'splice @F, 6, 0, $F[6] - $F[5]; print join "\t", @F' * John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: NewbieQuestion Deleting the first 5 lines of a file
Jeff Thomas wrote: > > Hello, Hello, > I have over 1000 files that I need to delete the first five lines of text from. > This needed to be done, like yesterday. I started writting an Applescript to do > this but ran into a bug with Folder Actions and attached scripts that stopped my > progress dead. Would someone please show me how this is done with perl. #!/usr/bin/perl -w use strict; use Tie::File; for my $file ( @ARGV ) { tie my @array, 'Tie::File', $file or die "Cannot open $file: $!"; splice @array, 0, 5; untie @array; } __END__ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Tk with Perl
>Trying it now from the Command Prompt.seems to be just 'sitting' >there. Hi Tony, If you're still having trouble getting the package, it could be a firewall issue. I have to download packages, then install from my local box because of corporate B()[[S][|~!. I believe this is the correct URL (though I always have a hard time finding it): http://ppm.activestate.com/PPMPackages/zips/5xx-builds-only/TK.zip download, unzip, move to that dir at command line and install, `ppm install --location=current_directory Tk` should do it IIRC. `Perldoc ppm` should answer any install questions. I'm using ActiveState Perl 5.6.1 build 663 and did have to install this module separately. But you can try `ppm query` to see what's installed. Mine has this line for TK: Tk [800.023] A Graphical User Interface Toolkit Enjoy, Peter -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Easiest way to disable the ENTER key on a from
I would like to disable the RETURN key on my form so users cannot accidentally submit it before they are finished. I have if statements that check to see if all the fields have input, but many users will complain since they are used to hitting RETURN instead of TAB. The submit button will need to only work with a mouse click. Thanks Sander -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: MS Word question
Hi Harry, You might want to check out catdoc @ http://www.ice.ru/~vitus/catdoc/. I use this with Ht://Dig (http://htdig.org) for indexing Word docs on one of our webservers. Also take a look at laola (http://user.cs.tu-berlin.de/~schwartz/pmh/index.html), particularly lhalw portions. HTH! Bill Akins, CNE Sr. OSA Emory Healthcare (404) 712-2879 - Office 12674 - PIC [EMAIL PROTECTED] >>> "Southworth, Harry" <[EMAIL PROTECTED]> 01/24/03 06:38AM >>> I'm running Perl on Cygwin on top of Windows 2000. I have a lot of ascii text files that someone has thoughfully saved as Microsoft Word documents. If I open them in a text editor, I can see the ascii text, but there is some junk at the top and bottom. Testing the files with -T tells me they're not text. grep seems able to search through the text in the files, but I'd like to strip the junk out and save them as simple text files. I tried a few things in Perl, but didnt' get anywhere. I'd be grateful if someone were able to provide some pointers. Many thanks, Harry. Harry Southworth, TE2A/4 Parklands, Alderley Park, Cheshire, SK10 4TG, UK Tel.: +44 1625 518327 [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: free web hosting with full CGI service?
Can you clarify "full" CGI service? Can we assume that, since you ask on a Perl list you are looking for Perl capabilities? www.netfirms.com offers Perl CGI scripting for free and only puts a modest banner on the top (no popups or other annoying garbage). -r -Original Message- From: MJ [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 22, 2003 11:30 PM To: [EMAIL PROTECTED] Subject: free web hosting with full CGI service? Hi, I am looking for some free webhosting services where there is full support for CGI. Though, I checked out few that offer free hosting service, there is a limitation in cgi script support only till some extent. I may not need much of free space but require full cgi support. Can one suggest me few proven sites... Mike __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Easiest way to disable the ENTER key on a from
On Fri, 24 Jan 2003 09:13:32 -0600, "Liebert, Sander" <[EMAIL PROTECTED]> wrote: > I would like to disable the RETURN key on my form so users cannot > accidentally submit it before they are finished. I have if statements that > check to see if all the fields have input, but many users will complain > since they are used to hitting RETURN instead of TAB. The submit button will > need to only work with a mouse click. > This has to be handled client side, you need to look into Javascript or some other client side language. I am assuming you're asking this list, because you are using CGI which is written in Perl. CGI is server side. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Multiple use of same module question
Jenda Krynicky said: > From: "Paul Johnson" <[EMAIL PROTECTED]> >> As I recall, someone (Timothy Johnson?) said they got errors from >> using Win32 more than once and resorted to requiring it to silence the >> errors. I don't think we ever saw the error messages or the code. >> This prompted me to write the first paragraph above. > > The problem in that case was that two different modules exported by > default the same constants. And therefore perl -w issued warnings > about redefining constants/subroutines. Ah, OK. I missed that important bit of information. But to make this little thread useful I can use this example to warn against the antisocial use of @EXPORT where @EXPORT_OK or even %EXPORT_TAGS might be better. > Most probably the "correct" solution would be to > use Win32 qw(); which is the same as use Win32 (); which is (almost) the same as require Win32; which is where we came in. So now we can all relax and enjoy our weekends, safe in the knowledge that this little conundrum has been put to rest. Thanks, Jenda. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NewbieQuestion Deleting the first 5 lines of a file
[EMAIL PROTECTED] wrote: > Hello, > > I have over 1000 files that I need to delete the first five lines of > text from. This needed to be done, like yesterday. I started writting > an Applescript to do this but ran into a bug with Folder Actions and > attached scripts that stopped my progress dead. Would someone please > show me how this is done with perl. perl -i.bak -ne 'print if $.>5; close ARGV if eof' *.txt -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NewbieQuestion Deleting the first 5 lines of a file
All files will be in the same directory. The files are Postscript. They all have a proprietary header with comments above the %!PS line so they all fail to print. At 24/01/2003 14:48:47, "Kipp, James" <[EMAIL PROTECTED]> wrote: > > Hello, > > > > I have over 1000 files that I need to delete the first five > > lines of text from. > > This needed to be done, like yesterday. I started writting an > > Applescript to do > > this but ran into a bug with Folder Actions and attached > > scripts that stopped my > > progress dead. Would someone please show me how this is done > > with perl. > > > > first question: will these files be in one directory? or from various > places? what type of files ? > > > -- > 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]
unicode problem (?)
Hello, I have program that reads in text from an excel spreadsheet (using the Spreadsheet-ParseExcel module) that works great until... one of the cells has text that contains a tilda. It then appears that the program goes ape-s**t and starts printing out unicode (or multi-byte characters). Can anyone explain why and what I can do to disable that 'feature'. I have tried (unsuccessfully) using pack/unpack, the "use bytes" pragma, etc, but their ineffectiveness may be (is probably) due to pilot error. Any help *MUCH* appreciated. either reply to list or directly to me: [EMAIL PROTECTED] thanks!
IMAGES ANALYSIS PROBLEM
hi to all, i have to perform a quantitavie analysis of confocal microscopy images. these images have black pixel for background and green or red pixel in foreground (cellular structures stained with specific antibody). the intensity of each pixel may be from 0 to 255 (8 bit images in pseudocolors). i'm loking for a package to manage the .tif or jpg files and to perform statistical analysis in terms of intensity/number of pixel. have you any idea to this challenge??? thankyou very mch and good work. bye Dario Greco IIGB - Institute of Genetics and Biophysics, "Adriano Buzzati-Traverso" - CNR Via P.Castellino, 111 80131 Napoli (Italy) tel +39 081 6132 367 fax +39 081 6132 350 e-mail: [EMAIL PROTECTED]; [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ANOTHER IMAGE ANALYSIS PROBLEM
hi to all and thanks to your suggests for my last problem. i've another challenge: i must quantify the length of neurites and the branching of dendrites in fluorescence microscopy images of neurons stained with specific antibodies. have you any suggest for me? thanks very much Dario Greco IIGB - Institute of Genetics and Biophysics, "Adriano Buzzati-Traverso" - CNR Via P.Castellino, 111 80131 Napoli (Italy) tel +39 081 6132 367 fax +39 081 6132 350 e-mail: [EMAIL PROTECTED]; [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Hash of Hashes of Arrays?
Hey folks, Although I'm getting pretty good at using newsgroups and assorted perl references(including this one!)to find answers to my questions, I can't seem to solve this one. This is what I've got: I have a list of inspection stations in a data file which is comma-separated. It contains the following data, in order: Station Name, Address 1, Address Line 2, City, State, Zip, Phone Number I have no problem reading each of the lines and assigning variables from the output of the split(/,/, $line); This is what I need to do: I believe I need a hash of hashes of arrays... I am creating output in the format of inspection pages which list all inspection stations in each town (some towns have only one, others have several). I need to group the lines (of address information) by city and get a count of the number of stations in a given city. The best Perl reference of this I could find was in the Perl Cookbook, but it was very poorly explained. Thanks in advance! Glenn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: For loop aliasing AND changing an array within a loop.
Hi Michael. Michael Hooten wrote: > While stepping through the code I wrote, I distinctly noted that the > substitution on $_ did NOT affect the array and vice versa. If you watch carefully what Perl is doing, it aliases correctly _until_ you choose to modify the array. After this the correct value from the original 'foreach' list is used, but aliasing is no longer meaningful and $_ is independent of the new array. It is effectively iterating over a temporary copy of the original array. Looking at your first algorithm: > FIRST TRY-- > $x=0; > for (@dir){ ># Remove each array element that is NOT a directory name ># OR remove ":\s+" from the end of dir name. >if ( s/^(.*):\s+$/$1/ ){ > $dir[$x] = $_;# substitution changes $_ but not @dir >} else { # shouldn't the substitution change both? > splice @dir, $x, 1; > $_ = $dir[$x];# splice changes @dir but not $_ > redo; >} >$x++; > } Since the assignment to $_ in your 'else' clause has no effect on the execution, and because of your modification of the array within the loop, the following code is equivalent: my $x=0; my @temp = @dir; foreach (@temp) { if ( $_ =~ s/^(.*):\s+$/$1/ ){ $dir[$x] = $1; $x++; } else { splice @dir, $x, 1; } } where it is obvious that you wouldn't expect @dir to change with $_. Similarly your second try: > SECOND TRY- > START: @dir = `ls mosfet* | grep ^mosfet`; > $x=0; > for (@dir){# substitution now changes @dir but NOT $_ >unless( $dir[$x] =~ s/^(.*):\s+$/$1/ ){ > splice @dir, $x, 1; > $_ = $dir[$x]; > redo; >} >$x++; > } is equivalent to this: my $x=0; my @temp = @dir; foreach (@temp) { unless ($dir[$x] =~ s/^(.*):\s+$/$1/) { splice @dir, $x, 1; } else { $x++; } } In both cases you can see that the value of $_ is unnecessary, and is used only in the first case as an implicit parameter to the substitution operator. The second case may therefore be more appropriately written as: my $x = 0; while ($x < @dir) { : } since you are using 'foreach' only to execute the body of the loop the correct number of times. > If anyone insists on adding or deleting elements of an array from > within a loop, you can ... ...expect to have problems. Remember that you are doing something that perldoc itself explicitly says not to do. It is very unlikely that you know better, and certainly what you are doing is unsupported. Even if it appears that you have a work-around then it will not be a general solution, and is likely not to withstand alterations to the related code. Gradu diverso, via una. Cheers Michael, and happy Perling. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NewbieQuestion Deleting the first 5 lines of a file
[EMAIL PROTECTED] wrote: > Subject: RE: NewbieQuestion Deleting the first 5 lines of a file > At 24/01/2003 15:29:27, Bob Showalter > <[EMAIL PROTECTED]> wrote: > > [EMAIL PROTECTED] wrote: > > > Hello, > > > > > > I have over 1000 files that I need to delete the first five lines > > > of text from. This needed to be done, like yesterday. I started > > > writting an Applescript to do this but ran into a bug with Folder > > > Actions and attached scripts that stopped my progress dead. Would > > > someone please show me how this is done with perl. > > > > perl -i.bak -ne 'print if $.>5; close ARGV if eof' *.txt > > Hmmm... This leaves me with a backup file and a totally empty > original file. I tested this before posting and tested it again just now, and it works fine. My platform is FreeBSD. > Is print sending everything to STDOUT instead of > writing it to file? No, the -i option arranges for the print to go to the file. The close(ARGV) resets the $. line number between files. See perldoc -f eof for details. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash of Hashes of Arrays?
I'd be tempted to use a hash of hash of hashes, storing it like this: $hash{$city}{$station}{add1}=$address1 $hash{$city}{$station}{add2}=$address2 $hash{$city}{$station}{state}=$state $hash{$city}{$station}{zip}=$zip $hash{$city}{$station}{phone}=$phone So my loop would look like this: foreach my $city (sort keys %hash) { print 'There are ', scalar (keys %{$hash{$city}}), " station(s) in $city. They are:\n"; foreach my $station (sort keys %{$hash{$city}}) { print " $station\n"; print " $hash{$city}{$station}{add1}\n"; print " $hash{$city}{$station}{add2}\n"; # etc. etc. } } but here's how I did it, because you asked for arrays... $line='station1,stat1add1,stat1add2,city1,ST,01234,555-1212'; ($station, $add1, $add2, $city, $state, $zip, $phone)=split(/,/, $line); push @{$hash{$city}{$station}}, $add1; push @{$hash{$city}{$station}}, $add2; push @{$hash{$city}{$station}}, $state; push @{$hash{$city}{$station}}, $zip; push @{$hash{$city}{$station}}, $phone; foreach my $city (sort keys %hash) { print 'There are ', scalar (keys %{$hash{$city}}), " station(s) in $city. They are:\n"; foreach my $station (sort keys %{$hash{$city}}) { print " $station\n"; # using arrays here, might as well loop foreach (@{$hash{$city}{$station}}) { print " $_\n"; } } } On Fri, 24 Jan 2003, Glenn Tremblay wrote: > This is what I need to do: > I believe I need a hash of hashes of arrays... > I am creating output in the format of inspection pages which list all > inspection stations in each town (some towns have only one, others have > several). > I need to group the lines (of address information) by city and get a count > of the number of stations in a given city. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash of Hashes of Arrays?
>I have a list of inspection stations in a data file which is >comma-separated. It contains the following data, in order: >Station Name, Address 1, Address Line 2, City, State, Zip, Phone Number > >I need to group the lines (of address information) by city and get a count >of the number of stations in a given city. OK, I didn't actually test this exact code, but it should present the idea of storing this information in an array of arrays: open IN, yourfile; while (){ chomp; push @arr, \[split /,/]; } close IN; @arr = sort ${$arr[$a]}[3] <=> ${$arr[$b]}[3] @arr; # sort by city How do you picture using a hash of hashes of arrays? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NewbieQuestion Deleting the first 5 lines of a file
At 24/01/2003 15:29:27, Bob Showalter <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Hello, > > > > I have over 1000 files that I need to delete the first five lines of > > text from. This needed to be done, like yesterday. I started writting > > an Applescript to do this but ran into a bug with Folder Actions and > > attached scripts that stopped my progress dead. Would someone please > > show me how this is done with perl. > > perl -i.bak -ne 'print if $.>5; close ARGV if eof' *.txt Hmmm... This leaves me with a backup file and a totally empty original file. Is print sending everything to STDOUT instead of writing it to file? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash of Hashes of Arrays?
Hello folks, I am having a problem of embedding the html tag http://www.cnn.com >Click here in a perl script. Could someone please help . Thanks. Deepa >>> <[EMAIL PROTECTED]> 01/24/03 01:01PM >>> >I have a list of inspection stations in a data file which is >comma-separated. It contains the following data, in order: >Station Name, Address 1, Address Line 2, City, State, Zip, Phone Number > >I need to group the lines (of address information) by city and get a count >of the number of stations in a given city. OK, I didn't actually test this exact code, but it should present the idea of storing this information in an array of arrays: open IN, yourfile; while (){ chomp; push @arr, \[split /,/]; } close IN; @arr = sort ${$arr[$a]}[3] <=> ${$arr[$b]}[3] @arr; # sort by city How do you picture using a hash of hashes of arrays? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NewbieQuestion Deleting the first 5 lines of a file
> > > > > > perl -i.bak -ne 'print if $.>5; close ARGV if eof' *.txt > > Bob I have been trying to figure out a different solution then using the -i arg. Is there a simple way to just open each file, delete the 5 lines in place and close it(with no backup file), without getting into sysread, truncate, etc... something like this: @files = glob("*.ps"); foreach $file (@files) { open (IN, "$file") or die "can't open $!\n"; while ($line = ) { $line =~ s/.*\n// if $. <= 5; } close IN; - I can't seem to delete the lines in place, without using -i, I was able to do it easily with a shells script using sed: cd dir_with_the_files for file in `ls .` do sed '1,5d' $file > $file done -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: improvements to code
Hi Pam. Some peripheral comments, now that others have done all of the hard work :) John W. Krahn wrote: > Pam Derks wrote: >> I want to grap the: >> last first middle(if any) email >> from a text file >> >> sample data: >> Smith, Mary [EMAIL PROTECTED] >> Jones, Tommy Lee [EMAIL PROTECTED] >> >> can someone suggest improvements to the code below? >> >> #!/usr/bin/perl -w > > use strict; > > >> my ($first, $last, $middle, @fields); > > You should define these variables in the smallest possible scope > instead of at the top of the program. > >> open(IN, "text.txt") or die("nope: $!\n"); Putting a \n on the end of the 'die' string stops Perl from putting the source line number and data input line number on the end. ... or die $!; is better for debugging. >> while($line = ){ > > while ( my $line = ) { You might think about using: while () where the file records are placed in $_, which can be used as an implicit parameter for most built-in functions. >> chomp($line); >> >> @fields=split(/ /, $line); > > split / / will split using a single space, it is more efficient to use > the default. > > my @fields = split ' ', $line; For instance, this would be: my @fields = split; with the above form of while(). >> #an array in scalar context returns number of elements >> $number = @fields; >> print("number: $number\n"); >> >> #if there is no remainder, there are 3 elements >> if($number % 3 == 0){ > > Why use modulus, just use == 3. > > if ( @fields == 3 ) { > > >> $first = $fields[0]; >> $last = $fields[1]; >> $email= $fields[2]; $first and $last are always fields [0] and [1] (whichever way round!, and you can index from the end of an array with negative numbers, so: $last = $fields[0]; $first = $fields[1]; $email = $fields[-1]; $middle is either field [2] or blank, depending on the size of the array: $middle = (@fields > 3 ? $fields[2] : ''); Apart from that, everything I an think of has been said. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Link in perl
> > Hello folks, > I am having a problem of embedding the html tag > http://www.cnn.com >Click here in a perl script. > Could someone please help . Always change the subject when you're doinhg a new post. What problem are you having? First off make the thml correct: http://www.cnn.com";>Click here Second : print 'http://www.cnn.com";>Click here'; # with single quotes print "http://www.cnn.com\";>Click here"; # with double quotes Notice the backslashes in front of the double quotes in the double quoted string That escapes them, or treats them as literl " instead of seeing them as how perl is using them for a print statement EG doing this : print "http://www.cnn.com";>Click here"; Is just the same as doing : print "http://www.cnn.com ">Click here"; Firstline is missing an ending ';' Second line is a bareword Third line has nothing to tell it what todo with the "" string > > Thanks. > Deepa > > >>> <[EMAIL PROTECTED]> 01/24/03 01:01PM >>> > > >I have a list of inspection stations in a data file which is > >comma-separated. It contains the following data, in order: Station > >Name, Address 1, Address Line 2, City, State, Zip, Phone > Number > > > >I need to group the lines (of address information) by city and get a > count > > >of the number of stations in a given city. > > OK, I didn't actually test this exact code, but it should > present the idea of storing this information in an array of arrays: > > open IN, yourfile; > while (){ > chomp; > push @arr, \[split /,/]; > } > close IN; > @arr = sort ${$arr[$a]}[3] <=> ${$arr[$b]}[3] @arr; # sort by > city > > How do you picture using a hash of hashes of arrays? > > > > > > -- > 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: Pairs have minimum difference
Nengbing Tao wrote: > -90 87658675 > 9012341324 > -198 47654567 > > Notice that |1500-1485|=|1500-1515|. > how can you have negative if they are abs? anyway, have you try: #!/usr/bin/perl -w use strict; my @xa=(8765,6000,4765,3000,1530,1500,1465,1234,1000); my @xb=(8675,6000,4567,3100,3000,1545,1515,1485,1324,1005); my %hash; for my $i (@xa){for my $j (@xb){push(@{$hash{abs($i-$j)}},"$i\t$j")}}; for my $diff (sort {$a <=> $b} keys %hash){ print "$diff\t$_\n" for(@{$hash{$diff}}); } __END__ prints: 0 60006000 0 30003000 5 10001005 15 15301545 15 15301515 15 15001515 15 15001485 20 14651485 45 15301485 45 15001545 50 14651515 80 14651545 ... etc not sure if that's what you want... david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Link in perl
Hi Dan, I did as you suggested. print "http://www.cnn.com\";>Click here"; I don't get any compilation error, email goes fine to my groupwise mailbox. When I open hte mail, I see the raw html. http://www.cnn.com>Click here>> "Dan Muey" <[EMAIL PROTECTED]> 01/24/03 01:26PM >>> > > Hello folks, > I am having a problem of embedding the html tag > http://www.cnn.com >Click here in a perl script. > Could someone please help . Always change the subject when you're doinhg a new post. What problem are you having? First off make the thml correct: http://www.cnn.com";>Click here Second : print 'http://www.cnn.com";>Click here'; # with single quotes print "http://www.cnn.com\";>Click here"; # with double quotes Notice the backslashes in front of the double quotes in the double quoted string That escapes them, or treats them as literl " instead of seeing them as how perl is using them for a print statement EG doing this : print "http://www.cnn.com";>Click here"; Is just the same as doing : print "http://www.cnn.com ">Click here"; Firstline is missing an ending ';' Second line is a bareword Third line has nothing to tell it what todo with the "" string > > Thanks. > Deepa > > >>> <[EMAIL PROTECTED]> 01/24/03 01:01PM >>> > > >I have a list of inspection stations in a data file which is > >comma-separated. It contains the following data, in order: Station > >Name, Address 1, Address Line 2, City, State, Zip, Phone > Number > > > >I need to group the lines (of address information) by city and get a > count > > >of the number of stations in a given city. > > OK, I didn't actually test this exact code, but it should > present the idea of storing this information in an array of arrays: > > open IN, yourfile; > while (){ > chomp; > push @arr, \[split /,/]; > } > close IN; > @arr = sort ${$arr[$a]}[3] <=> ${$arr[$b]}[3] @arr; # sort by > city > > How do you picture using a hash of hashes of arrays? > > > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: Hash of Hashes of Arrays?
Glenn Tremblay wrote: > > This is what I need to do: > I believe I need a hash of hashes of arrays... > I am creating output in the format of inspection pages which list all > inspection stations in each town (some towns have only one, others have > several). > I need to group the lines (of address information) by city and get a count > of the number of stations in a given city. > if you really just want to group by city, you don't need that nested structure. i am sure you really mean group by state and city right? #!/usr/bin/perl -w use strict; my %hash; push(@{$hash{(split(/,/))[3,4]}},$_) while(); for(keys %hash){ print "$_ has ",scalar @{$hash{$_}}," stations and they are:\n"; print join('',@{$hash{$_}}); } __DATA__ Cat,1234 main, street,sf,ca,94124,123-4567 Dog,3456 main, street,sf,ca,94131,999-1234 Fish,9123 main, road,oa,wa,97541,431-4312 Bird,3456 main, street,sf,wa,94131,999-1234 prints: ca has 2 stations and they are: Cat,1234 main, street,sf,ca,94124,123-4567 Dog,3456 main, street,sf,ca,94131,999-1234 wa has 2 stations and they are: Fish,9123 main, road,oa,wa,97541,431-4312 Bird,3456 main, street,sf,wa,94131,999-1234 david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash of Hashes of Arrays?
On Fri, 24 Jan 2003, david wrote: > Glenn Tremblay wrote: > > > > > This is what I need to do: > > I believe I need a hash of hashes of arrays... > > I am creating output in the format of inspection pages which list all > > inspection stations in each town (some towns have only one, others have > > several). > > I need to group the lines (of address information) by city and get a count > > of the number of stations in a given city. > > > > if you really just want to group by city, you don't need that nested > structure. i am sure you really mean group by state and city right? Actually, the funny part of all this is that every station will be in the same state. I need to include the state information regardless. The output needs to allow me to loop through each city, somehow, and print out the address data for each station in that city. > > #!/usr/bin/perl -w > use strict; > > my %hash; > > push(@{$hash{(split(/,/))[3,4]}},$_) while(); > > for(keys %hash){ > print "$_ has ",scalar @{$hash{$_}}," stations and they are:\n"; > print join('',@{$hash{$_}}); > } > > __DATA__ > Cat,1234 main, street,sf,ca,94124,123-4567 > Dog,3456 main, street,sf,ca,94131,999-1234 > Fish,9123 main, road,oa,wa,97541,431-4312 > Bird,3456 main, street,sf,wa,94131,999-1234 > > prints: > > ca has 2 stations and they are: > Cat,1234 main, street,sf,ca,94124,123-4567 > Dog,3456 main, street,sf,ca,94131,999-1234 > wa has 2 stations and they are: > Fish,9123 main, road,oa,wa,97541,431-4312 > Bird,3456 main, street,sf,wa,94131,999-1234 > > david > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Link in perl
> > Hi Dan, > I did as you suggested. > print "http://www.cnn.com\";>Click here"; > I don't get any compilation error, email goes fine to my > groupwise mailbox. When I open hte mail, I see the raw html. > http://www.cnn.com>Click here But I wanted only the "Click here" to be in the mail instead > of the link. Well you didn't say it was an email your formatting! Remember , when you post to a list, most of us can't read minds so you need to explain more what you are trying to do, how you've tried to do it, etc... Read this, and you'll probably get better help faster and be able to help better also : http://www.tuxedo.org/~esr/faqs/smart-questions.html Any hoo onto your question... Are you adding a header to the mail that tells it that it's an html email? If not then you're just sending some text that happens to look a lot like html. How do you do that you ask? Depends on how your making the mail. Are you using modules? Which one(s)? How about the code you're using? Have you look at cpan and searched for 'email' and read any documentation/examples? Most of the time I can find answers to my problems by trying that first, then if there's something I don't understand I'll post to a list and show them what I tried and what I need to do. > >>> "Dan Muey" <[EMAIL PROTECTED]> 01/24/03 01:26PM >>> > > > > > Hello folks, > > I am having a problem of embedding the html tag > > http://www.cnn.com >Click here in a perl script. > > Could someone please help . > > Always change the subject when you're doinhg a new post. > > What problem are you having? > First off make the thml correct: > http://www.cnn.com";>Click here > Second : > > print 'http://www.cnn.com";>Click here'; # with > single quotes print "http://www.cnn.com\";>Click > here"; # with double quotes Notice the backslashes in > front of the double quotes in the double quoted string That > escapes them, or treats them as literl " instead of seeing > them as how perl is using them for a print statement > > EG doing this : > print "http://www.cnn.com";>Click here"; > Is just the same as doing : > > > print "http://www.cnn.com > ">Click here"; > > Firstline is missing an ending ';' > Second line is a bareword > Third line has nothing to tell it what todo with the "" string > > > > > > Thanks. > > Deepa > > > > >>> <[EMAIL PROTECTED]> 01/24/03 01:01PM >>> > > > > >I have a list of inspection stations in a data file which is > > >comma-separated. It contains the following data, in order: Station > > >Name, Address 1, Address Line 2, City, State, Zip, Phone > > Number > > > > > >I need to group the lines (of address information) by city and get > a > > count > > > > >of the number of stations in a given city. > > > > OK, I didn't actually test this exact code, but it should > > present the idea of storing this information in an array of arrays: > > > > open IN, yourfile; > > while (){ > > chomp; > > push @arr, \[split /,/]; > > } > > close IN; > > @arr = sort ${$arr[$a]}[3] <=> ${$arr[$b]}[3] @arr; # sort > by > > city > > > > How do you picture using a hash of hashes of arrays? > > > > > > > > > > > > -- > > 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: NewbieQuestion Deleting the first 5 lines of a file
Kipp, James wrote: > > > > perl -i.bak -ne 'print if $.>5; close ARGV if eof' *.txt > > > > > Bob > I have been trying to figure out a different solution then using the > -i arg. Is there a simple way to just open each file, delete the 5 > lines in place and close it(with no backup file), without getting > into sysread, truncate, etc... Not really. What's the problem with using -i? > > something like this: > > @files = glob("*.ps"); > foreach $file (@files) { > open (IN, "$file") or die "can't open $!\n"; > while ($line = ) { > $line =~ s/.*\n// if $. <= 5; > } > close IN; > > - > I can't seem to delete the lines in place, without using -i, I was > able to do it easily with a shells script using sed: > > cd dir_with_the_files > for file in `ls .` > do > sed '1,5d' $file > $file > done Really? did you actually try that? The shell will clobber the file before sed gets a chance to open it. I don't see how you could wind up with anything but an empty file. FWIW, FreeBSD's sed has a -i option a la Perl's. Maybe Linux and other newer Unices have that as well? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NewbieQuestion Deleting the first 5 lines of a file
have been trying to figure out a different solution then using the > > -i arg. Is there a simple way to just open each file, delete the 5 > > lines in place and close it(with no backup file), without getting > > into sysread, truncate, etc... > > Not really. What's the problem with using -i? nothing really, just curiosity > > > > > cd dir_with_the_files > > for file in `ls .` > > do > > sed '1,5d' $file > $file > > done > > Really? did you actually try that? The shell will clobber the > file before > sed gets a chance to open it. I don't see how you could wind up with > anything but an empty file. oops, you are correct, should be: sed '1,5d' $file > $file.new but we still have not changed the original file, have we :-) Thanks Jim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Hash of Hashes of Arrays?
On Fri, 24 Jan 2003, david wrote: > Glenn Tremblay wrote: > > > > Actually, the funny part of all this is that every station will be in the > > same state. I need to include the state information regardless. > > > > The output needs to allow me to loop through each city, somehow, and print > > out the address data for each station in that city. > > > > in that case, this should do it: > > #!/usr/bin/perl -w > use strict; > > my %hash; > > while(){ > my @fields = chomp && split(/,/); > push(@{$hash{$fields[3]}},\@fields); > } > > > for(keys %hash){ > print "$_ has ",scalar @{$hash{$_}}," stations and they are:\n"; > for(@{$hash{$_}}){ > print < Name: $_->[0] > Street 1: $_->[1] > Street 2: $_->[2] > City: i $_->[3] > State:$_->[4] > Zip: $_->[5] > Phone:$_->[6] > > INFO > } > } > > __DATA__ > david > > Cool! Thanks for your help, folks. It works!! -Glenn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: NewbieQuestion Deleting the first 5 lines of a file
James Kipp wrote: > have been trying to figure out a different solution then using the >>> -i arg. Is there a simple way to just open each file, delete the 5 >>> lines in place and close it(with no backup file), without getting >>> into sysread, truncate, etc... >> >> Not really. What's the problem with using -i? > > nothing really, just curiosity > [snip] > > but we still have not changed the original file, have we :-) There isn't a way to edit a text file anywhere except the end without copying the data. Deleting from the beginning requires that all data after the deletion are moved up to the start of the file. You could do it within a buffer and write that back to the same file, but the file would still need to be truncated to empty it before the data was rewritten. You may as well just write it to a new file and rename them, which the -i qualifier does transparently. Cheers, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
used sendmail to send an attachment
I use $mailprog = '/usr/lib/sendmail'; to send e-mail with. Can I use this to send an attachment? Thanks, Jerry
RE: used sendmail to send an attachment
On Fri, 24 Jan 2003 14:50:02 -0600, "Jerry Preston" <[EMAIL PROTECTED]> wrote: > I use $mailprog = '/usr/lib/sendmail'; to send e-mail with. Can I use > this to send an attachment? > Yes, but you should avoid it if at all possible. Have you considered using one of the many modules from CPAN for this sort of thing and determined that they will not work? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: used sendmail to send an attachment
> > I use $mailprog = '/usr/lib/sendmail'; to send e-mail with. > Can I use > this to send an attachment? Yes sendmail handles attachments. Read this, you'll have an easier time after you do : http://www.tuxedo.org/~esr/faqs/smart-questions.html Now if I was a jerk I'd stop there and let you stew a bit but I'm not ( at least not today ;) ) Is your question actually "Can I use perl to send an email attachment via sendmail?" If so yes but you'll have an easier time doing it with a module. Go search cpan for some mail modules and try some of the examples. Those works mostly straight up without much modification. > > Thanks, > > Jerry > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: NewbieQuestion Deleting the first 5 lines of a file
> [snip] > > > > but we still have not changed the original file, have we :-) > > There isn't a way to edit a text file anywhere except the end > without copying the data. Deleting from the beginning requires > that all data after the deletion are moved up to the start of the > file. You could do it within a buffer and write that back to the > same file, but the file would still need to be truncated to empty > it before the data was rewritten. You may as well just write it > to a new file and rename them, which the -i qualifier does > transparently. Thanks Rob. I was not aware of this. > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: used sendmail to send an attachment
Yes I realize that link isn't the question page. But if you read what it says, namely, This site has moved change 'tuxedo' to 'catb' then you might deduce that the actual url is Going to be http://www.catb.org/~esr/faqs/smart-questions.html It changed since the last time I used it, so sorry if it gave anyone a headache. > > > > I use $mailprog = '/usr/lib/sendmail'; to send e-mail with. > > Can I use > > this to send an attachment? > > Yes sendmail handles attachments. > Read this, you'll have an easier time after you do : http://www.tuxedo.org/~esr/faqs/smart-questions.html Now if I was a jerk I'd stop there and let you stew a bit but I'm not ( at least not today ;) ) Is your question actually "Can I use perl to send an email attachment via sendmail?" If so yes but you'll have an easier time doing it with a module. Go search cpan for some mail modules and try some of the examples. Those works mostly straight up without much modification. > > Thanks, > > Jerry > > -- 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: used sendmail to send an attachment
Wow, this is kinda freaky Usually my perl email goes directly into a "perl" mail directory, but your two emails just popped into my work-inbox. I was just now starting to test a script for sending mail that works perfectly on a unix machine, but isn't working correctly on an NT server. That's why I thought --at first-- that Dan and Jerry's email was an error message that my company's NT server sent me. Are you saying that to send a command to send email, you just type the command $mailprog? $mailprog = ''; *** Here's what I have that works on my UNIX box: $command="/usr/usb/mail -s 'Calendar $datestamp' dscott\@ti.com< email.txt"; system($command); ** I was told that the path for the NT box is something like this: N:/SENDMAIL/sendmail.exe ** So I just changed the script to $command="N:/SENDMAIL/sendmail.exe -s 'Calendar $datestamp' dscott\@ti.com< email.txt"; system($command); *** I get the following error message back can't open syslog log! No such file or directory -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: used sendmail to send an attachment
[snip] >I haven't used sendmail. Then what was ""I use $mailprog = '/usr/lib/sendmail'; to send e-mail with."" all about? >I have used SMTP server to send mail in groupwise environment. >Where should I look at in the 'catb' website. I'll even give you an anchor : 1 - Click here http://www.catb.org/~esr/faqs/smart-questions.html#intro 2 - Study everything from there all the way until the end of the document. I really love this page! [snip] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Email function question
I asked this before, but I probably made the question too long and confusing to follow. How do I send an email using perl? The path for the sendmail program is: h:/blah/blah/SENDMAIL/sendmail.exe I want it to open the contents of a particular file. Then send the contents of the file as an email to [EMAIL PROTECTED] Thanks, --Deborah -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Email function question
Don't use sendmail. Use one of the perl modules designed to communicate with SMTP servers like Mail::Sender or Mail::Sendmail (which, confusingly enough has nothing to do with the sendmail program). The documentation that comes with these modules should be more than enough to get you going. - Johnathan Scott, Deborah wrote: I asked this before, but I probably made the question too long and confusing to follow. How do I send an email using perl? The path for the sendmail program is: h:/blah/blah/SENDMAIL/sendmail.exe I want it to open the contents of a particular file. Then send the contents of the file as an email to [EMAIL PROTECTED] Thanks, --Deborah -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Email function question
On Fri, 2003-01-24 at 15:35, Scott, Deborah wrote: > I asked this before, but I probably made the question too long and confusing > to follow. > > How do I send an email using perl? > The path for the sendmail program is: > h:/blah/blah/SENDMAIL/sendmail.exe > > I want it to open the contents of a particular file. Then send the contents > of the file as an email to > [EMAIL PROTECTED] > > > Thanks, > --Deborah > if your file is a text file #! /usr/bin/perl -w $file = "/suidbin/sendmail -t"; $var = "the_file.txt"; open(FILE, "$var") || die "cant open text file"; @file = ; close(FILE); ##open pipe to sendmail open(MAIL, "|$file") || die "cant open sendmail"; print MAIL "To: blah\@devnull.bz\n" ; print MAIL "From: blah\@cyberspace.org\n" ; print MAIL "Subject: Fresh\n\n" ; foreach(@file){ print MAIL; } close ( MAIL ) ; -- jd [EMAIL PROTECTED] Bad spellers of the world untie! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Email function question
On Fri, 2003-01-24 at 14:20, jdavis wrote: > On Fri, 2003-01-24 at 15:35, Scott, Deborah wrote: > > I asked this before, but I probably made the question too long and confusing > > to follow. > > > > How do I send an email using perl? > > The path for the sendmail program is: > > h:/blah/blah/SENDMAIL/sendmail.exe > > > > I want it to open the contents of a particular file. Then send the contents > > of the file as an email to > > [EMAIL PROTECTED] > > > > > > Thanks, > > --Deborah > > > > > > if your file is a text file > > #! /usr/bin/perl -w > > $file = "/suidbin/sendmail -t"; > $var = "the_file.txt"; > > open(FILE, "$var") || die "cant open text file"; > @file = ; > close(FILE); > > ##open pipe to sendmail > open(MAIL, "|$file") || die "cant open sendmail"; > print MAIL "To: blah\@devnull.bz\n" ; > print MAIL "From: blah\@cyberspace.org\n" ; > print MAIL "Subject: Fresh\n\n" ; > foreach(@file){ > print MAIL; > } > close ( MAIL ) ; > > > -- > jd > [EMAIL PROTECTED] > > Bad spellers of the world untie! oops... forgot to adjust the path and stuff for windoz -- jd [EMAIL PROTECTED] Bad spellers of the world untie! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Modules
Got 2 modules and a driver script that uses both. Both modules require Exporter and export their functions. However in my driver script I have to fully qualify the function names of the SECOND module(module->function), while the functions of the first module become part of my main:: package namespace and are called without any mention of the module name. I know the modules are good since I have no problems calling their methods if I use them individually. But whenever I use both in my driver script one of them has to have its functions proceeded by the module name. There is no name clashing in variables or function names. I can provide code if necessary. Just wondering if this is some common oversight on my part... Ismar Dupanovic WHI 847-964-7872
ATL COM
Hi, Can anybody help me? Problem is like this: I have one com component namely ValidateLogin.In this component i have one interface namely Login. Under this Interface I have One method Validate,which takes two parameters and returns the result .Now I want to create the instance of this component and want to pass the parameters to Validate method and collect the result in the variable to use it further.I am using WIN32::OLE but i am not able to successfully run the script. I have written the script as follows: #!/usr/local/bin/perl print "Content-type: text/html\n\n"; BEGIN { push(@INC,'E:/PerlInstall/site/lib/;E:/PerlInstall/lib/,F:/ATL/practise/debug') } use Win32::OLE $Object = Win32::OLE->new('{0x0073C45B,0xE00A,0x4B1B,{0x9C,0xB6,0x97,0x33,0xDD,0x01,0x18,0xB6}}') or die "Can not create Object\n"; $Result=$Object->Login->Invoke('Validate','Pankaj','Kapare'); print "$Result"; undef $Object; So please check the script and tell what r mistakes ? what should be the parameter of the above new method.?Should it be dll or lib file or ? Please mail me the answer as early as possible? Thanks in advance Pankaj.
changing backgorund color error
The below given part of code from a cgi script is working fine but when I try to change the back ground color to print "\n"; I get an internal server error. What is the problem or how do I change the background color sub return_html { print "Content-type: text/html\n\n"; print "\n"; print " \n Results of Search\n \n"; print "\n"; print " \n Results of Search in $title\n \n"; print "Below are the results of your Search in no particular order:$ print "\n"; foreach $key (keys %include) { if ($include{$key} eq 'yes') { print "$titles{$key}\n"; } } print "\n"; print "\n"; print "Search Information:\n"; print "\n"; print "Terms: "; $i = 0; foreach $term (@terms) { print "$term"; $i++; if (!($i == @terms)) { print "\n"; foreach $key (keys %include) { if ($include{$key} eq 'yes') { print "$titles{$key}\n"; } } print "\n"; print "\n"; print "Search Information:\n"; print "\n"; print "Terms: "; $i = 0; foreach $term (@terms) { print "$term"; $i++; if (!($i == @terms)) { print ", "; } } print "\n"; print "Boolean Used: $FORM{'boolean'}\n"; print "Case $FORM{'case'}\n"; print "\n"; print "\nBack to Search Page\n"; print "$title\n"; print "\n"; print "\n"; print "\n\n"; } __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]