[16999] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4411 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 23 06:05:33 2000

Date: Sat, 23 Sep 2000 03:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <969703507-v9-i4411@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 23 Sep 2000     Volume: 9 Number: 4411

Today's topics:
    Re: /me bangs head agains't brick wall <darryl@work-thicker.co.uk>
        Bad http request? aap@gmx.net
    Re: basic question about an exercise in "Learning Perl" (Abigail)
    Re: Candidates for the top ten illiteracy list [OFF TOP <godzilla@stomp.stomp.tokyo>
    Re: Extra ^M in text file <ianmarsh@home.com>
    Re: getting images with LWP? (Mark-Jason Dominus)
    Re: Gunzip at Prohosting (Gwyn Judd)
    Re: Gunzip at Prohosting (BUCK NAKED1)
    Re: Gunzip at Prohosting (Gwyn Judd)
        Inserting one page inside another <jfunston@connect.ab.ca>
    Re: Inserting one page inside another (Abigail)
    Re: Inserting one page inside another <ter@my-deja.com>
        Levels of Perl Programmer <sxm124@po.cwru.edu>
    Re: Levels of Perl Programmer (Abigail)
        Local variable screws thing up? hiroshiishii@my-deja.com
    Re: Local variable screws thing up? <jeff@vpservices.com>
    Re: Local variable screws thing up? <darryl@work-thicker.co.uk>
    Re: Local variable screws thing up? (Martien Verbruggen)
    Re: MSXML.dll <jdb@wcoil.com>
    Re: Pattern Matching Question <jaap@stack.nl>
    Re: Question to the wise - Reading From File <darryl@work-thicker.co.uk>
    Re: Question to the wise - Reading From File <jaap@stack.nl>
        Remove blank lines <sxm124@po.cwru.edu>
    Re: Remove blank lines <godzilla@stomp.stomp.tokyo>
    Re: Remove blank lines (Abigail)
    Re: sending attachment not in body of email (Villy Kruse)
        vertical text renderer <richard@dragnet.com.tw>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 23 Sep 2000 10:17:46 +0000
From: "CJ Llewellyn" <darryl@work-thicker.co.uk>
Subject: Re: /me bangs head agains't brick wall
Message-Id: <osvhq8.p67.ln@paulweller>

In article <slrn8smqce.689.trammell@nitz.hep.umn.edu>,
trammell@nitz.hep.umn.edu (John J. Trammell) burped:
> On Fri, 22 Sep 2000 21:55:04 +0000, CJ Llewellyn
> <darryl@work-thicker.co.uk> wrote:
>>I'm having trouble with a script that recurses through directories. 
>>
> 
> perldoc DirHandle
> 

Thanks John,

What's the difference between a glob and the handle opendir creates ?

#!/usr/bin/perl -w

use DirHandle;

read_dir("/usr");

sub read_dir {
	my $dirname = $_[0];

	my $myDir = new DirHandle($dirname);
	if (defined $myDir){
		while( defined ($file = $myDir->read) ){
			chomp($filename = "$dirname/$file");
				# aviod following . .. and symbolic links
			if(! ($file eq '.' || $file eq '..' || -l $filename) ){
					# is it a directory
				if(-d $filename) {
					read_dir($filename);
				} else {
					print "$filename\n";
				}
			}
		}
		undef $myDir;
	} else {
	       	die "Unable to open directory : $dirname\n";
	}	
}

-- 
Regards,
CJ Llewellyn


------------------------------

Date: Sat, 23 Sep 2000 08:59:40 GMT
From: aap@gmx.net
Subject: Bad http request?
Message-Id: <8qhrdo$9ov$1@nnrp1.deja.com>

Hello,

my name is Mark. I am a programmer from Holland.
I am trying to build a kind of internetbrowser.
Just sending some http-request and getting a page in ASCII back is
enough.
But is doesn't work. The server I get connected with responds:

HTTP/1.1 400 Bad RequestServer: Netscape-Enterprise/3.6 SP3Via: 1.1
404.castel.nl (NetCache 4.1R5)Date: Sun, 17 Sep 2000 22:02:53 GMTYour
browser sent a message this server could not understand.

This is the trivial c-code that I use:

	i = connect(s, (struct sockaddr *)&a , sizeof(a));
	strcpy(cBuf,"GET / \r\n");
	strcat(cBuf,"HTTP 1.0 \r\n\r\n");
	send(s,cBuf,sizeof(cBuf),0);
	iRec = 1;
	while (iRec != 0)
	{
		iRec = recv(s,cBuf,1000,0);
		writenow(cBuf);
	}

Can you help me solving this ?

Regards,
Mark

mailto: aap at gmx.net


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 23 Sep 2000 04:42:08 GMT
From: abigail@foad.org (Abigail)
Subject: Re: basic question about an exercise in "Learning Perl"
Message-Id: <slrn8sod2n.5fq.abigail@alexandra.foad.org>

Mike Chao (myc1@nospam.earthlink.net) wrote on MMDLXXX September MCMXCIII
in <URL:news:ILVy5.16988$ks.674444@newsread1.prod.itd.earthlink.net>:
~~ hi all,
~~ 
~~ I am a perl newbie. The following is some code from the book "Learning
~~ Perl" 2nd ed. It's the exercise answer from Chapter 4, question 3.
~~ 
~~ 1 #!/usr/bin/perl
                    ^^^
Does the Llama really suggest you do *not* use -w here? If so, burn it
right now.

~~ 2 print "Enter a number (999 to quit): ";
~~ 3 chomp ($n = <STDIN>); 
~~ 4 while ($n =!
               ^^   Are you sure you don't mean != here? And why the newline?
~~ 5 999) {
~~ 6	$sum += $n;
~~ 7	print "Enter another number (999 to quit): "; 
~~ 8	chomp ($n = <STDIN>);
~~ 9 }
~~ 10 print "The sum is $sum.\n";
~~ 
~~ If I want to initialize the value of $sum so that it's not undef when I
~~ start out, I understand that I should do $sum = 0. However, if I put
~~ $sum = 0 between lines 2 and 3, the program runs fine. However, if 
~~ I put $sum = 0 between lines 3 and 4, I get the following errors:
~~ 
~~ syntax error at ./add.pl line 8, near "print"
~~ syntax error at ./add.pl. line 10, near  "}"
~~ 
~~ (not sure if the line numbers match 100%). I don't understand what
~~ is the difference?

I find this hard to believe. Yes, if you put '$sum = 0', exactly as quoted,
between lines 3 and 4, you do get errors:

    syntax error at foo.pl line 6, near ") {"
    syntax error at foo.pl line 10, near "}"

But, you would get errors as well if you put the same line between lines
2 and 3:

    syntax error at foo.pl line 4, near "chomp"
    Execution of foo.pl aborted due to compilation errors.

(Note that the line numbers perl gives you are 1 more than the numbering
 in your program; unlike you, perl counts the she-bang line as well.)


Now, if you would put '$sum = 0;' either between lines 2 and 3, or between
lines 3 and 4, your program runs.



Abigail
-- 
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];


------------------------------

Date: Fri, 22 Sep 2000 22:46:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Candidates for the top ten illiteracy list [OFF TOPIC]
Message-Id: <39CC43B0.26A3D4DE@stomp.stomp.tokyo>

Keith Calvert Ivey wrote:
 
> Russ Jones wrote:
> >Abigail wrote:
 
> > > However, in most cases, none of them are actually mistakes.

> > Oh boy, another one. "However, in most cases none of them IS actually
> > a mistake.
 
> What's the point of your message?  To be as offensive as
> possible?  It's off-topic, rude, and ill-informed.
 
> H.W. Fowler can hardly be called a permissive in matters of
> grammar, and here's what he had to say on the subject:
 
>     none.  1. It is a mistake to suppose that the pronoun is
>     singular only and must at all costs be followed by singular
>     verbs etc.; the OED explicitly states that the plural
>     construction is commoner.
 
> Can you find any usage guide that agrees with your condemnation,
> or are you just remembering something your junior-high English
> teacher said?  If you can, it's probably an obscure one, but in
> any case I don't think anybody in this newsgroup wants to hear
> about it.
 
> (By the way, the OED also has "seldomly" as an obsolete
> variation on "seldom", with citations from 1549 and 1620, so
> Abigail was obviously just trying to lend her prose an air of
> archaism.)
 

Try seldomness. With seldomness, none of you boys are never wrong.

* laughs *

Such a biting British Litotes!!!


None of you are right. Truthfully, I want none of this,
none of this is worth reading nor do I want it.

I agree flaming for spelling, grammar and similar, is
considered an activity reserved for blithering idiots.
Lots of blathering blithering idiots within newsgroups.

H.W. Fowler, I dunno. This use of "QED", if you are
quoting Fowler, is a violation of rules of language.
Abbreviations are _never_ to be used save for very
well recognized commoner abbreviations such as 
name antecedents and suffixes. So, Fowler, in this
discussion of English, violates an English rule, 
our rule of Clarity. 

Quite ironic.

Furthermore, "commoner" is way wrong! It is,

"more common" - "less common" - "amply common"

Our commoner is now considered antiquated,
archaic, much like whom is today. This is
not a question nor is whom a fancy expression
for Who's on first and, commoner is not just
another commoner.

A commoner is a common 'tater, you know, like a
Russet 'tater, an Idaho 'tater, an eye 'tater except
a common 'tater is a talking head on television.

Only commoners would say commoner. 

This H.W. Fowler is a Bozo of English.

* screams in delight *

Our word "none" has a context much like "zero" has.
It is appropriate to think of none as plural just
as it is appropriate to think of zero as plural,
although each indicate a quantity of nothing. This
is, of course, quite an oxymoronic rule. Nothing
is neither singular nor plural. None and Zero
are the blackholes of language; full of nothing.

In Abigail's defense, her use of none is quite the
Slippery Semantic. She is correct. Her "none" is
actually a quantity of more than one, thus is
oxymoronically, plural. I love this. In reality,
her "them" takes precedence for a singular versus
plural pseudo intransitive verb inflection decision.
Pseudo in that "are" is not a true verb but an
indicative inflection of both plural and first
person singular, presence tense of our intransitive
verb, "be". Within this sentence construct of hers,
'them' acts as an invisible modifier of 'none'
rendering it most plural! Her use of "are" is
most correct. Use of "is" is (ha ha) quite wrong.

Nonetheless, for common everyday usage, both
'are' and 'is' will suffice to convey an intended
message for the context presented. Thus, none of
you are right, none of you is right, none of them
are right and, none of them is right.

MUUUUHAHAHAHAHAHAHAAAA!!!!

* laughs her big butt off *

Ahh... if I could only laugh my big butt off,
I would have a tight teenage arse once again.

You boys best leave English Rules and, especially
Slippery Semantics, to this Queen of Straight Answers,
MOI!


Godzilla!
-- 
Dr. Kiralynne Schilitubi
Professor Of English
University Of California at Riverside


------------------------------

Date: Sat, 23 Sep 2000 05:10:52 GMT
From: Ian Marsh <ianmarsh@home.com>
Subject: Re: Extra ^M in text file
Message-Id: <39CC3CA4.ADC40500@home.com>

The ^M appears because DOS based Operating systems including WIndows
3.1/95/98/NT etc. use a pair of control characters in text files to show
newline. Commonly abreviated as CR/LF the first moves the cursor to the
start of the line and the second moves the cursor to the next line. Unix
based systems use only the CR and assume the line feed. Since it only
processes the CR, the LF is considered text and is displayed as ^M, the
CON response to ascii(0D).  You have to specify only a CR when
terminating a line and not rely on Windows OS services to do this.

jason wrote:
> 
> nkhan75@hotmail.com <nkhan75@hotmail.com> wrote ..
> >I am working with Perl/NT. Every time I create a text file from my
> >program, I find a ^M at the end of each line of the file.
> >
> >Does anyone know why this is happening?
> 
> everyone else is yacking on about FTP and UNIX vs Win32 file endings ..
> so maybe I'm completely confused here .. but your post says that you're
> creating these files from a Perl program
> 
> if this is the case .. then the likely cause of this problem is that
> you're outputting an extra ^M into your text file
> 
> this is correct
> 
>   open OUTPUT, '>outputfile' or die "Bad open: $!";
>   print OUTPUT "This line will have one ^M and one ^J on Win32\n";
>   close OUTPUT or die "Bad close: $!";
> 
> this is wrong
> 
>   open OUTPUT, '>outputfile' or die "Bad open: $!";
>   print OUTPUT "This line will have two ^Ms and one ^J on Win32\r\n";
>   close OUTPUT or die "Bad close: $!";
> 
> this is also correct (but only for Win32 text files)
> 
>   open OUTPUT, '>outputfile' or die "Bad open: $!";
>   binmode OUTPUT;
>   print OUTPUT "This line will have one ^Ms and one ^J on Win32\r\n";
>   close OUTPUT or die "Bad close: $!";
> 
> --
>   jason -- elephant@squirrelgroup.com --


------------------------------

Date: Sat, 23 Sep 2000 03:00:59 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: getting images with LWP?
Message-Id: <39cc4228.43c0$2a9@news.op.net>


In article <39CBF3D4.7342D497@mitre.org>,
Bruce Bowden  <bbowden@mitre.org> wrote:
>use LWP::Simple;
>$picfile="C:/somepath/image.jpg";
>$image=get('http://host.domain.com/dir/file.jpg');
>open(FILE, ">$picfile");
>binmode FILE; #ADDED FOR NT SERVER
>print FILE $image;
>close(FILE);

I think the next step is to isolate the problem better.  

Two things might be going wrong.  Perhaps the file is not coming over
the network properly.  Or perhaps you are getting the file from the
network, but something is going wrong when you try to save it.

To narrow down the problem, add the line

        print "Got ", length($image), " bytes from network.\n";

and see if it looks reasonable.  If it reports that you got zero bytes
from the network, you can rule out problems with the
open-binmode-print part of the program and concentrate on why the
'get' is not working.  If it reports that you got more than zero
bytes, then you can rule out problems with the 'get' and concentrate
on figuring out why the data did not go into the file.

Until you do this, it's premature to say 'problem getting images with
LWP' because you don't know that the problem is with LWP, and you
shouldn't say it, because you might fool yourself.  

Hmm, this reminds me of a passage in 'Zen and the Art of Motorcycle
Maintenance'.  You might want to have a look at that.





------------------------------

Date: Sat, 23 Sep 2000 05:13:44 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Gunzip at Prohosting
Message-Id: <slrn8sof7d.s5.tjla@thislove.dyndns.org>

I was shocked! How could BUCK NAKED1 <dennis100@webtv.net>
say such a terrible thing:
>[Still working on this 2 months later...sigh] 
>Why doesn't this work at http://www.freeprohosting.com? I get a global
>package error? How do I fix that?
>
>Do I have the perl paths for prohosting correct? #!/usr/bin/perl works
>there for all of my other scripts.
>
>Here's my coding:
>
>#!/usr/bin/perl

Standard stuff to type at the start of a script:

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

Standard CGI stuff:

use CGI qw/:standard/;
use CGI::Carp 'fatalsToBrowser';

print header;

>$file = usr/home1/discosco/html/lwp.tar.gz; 

You need to put this in quotes. It also probably needs to be an absolute
path rather than a relative path:

my $file = '/usr/home1/discosco/html/lwp.tar.gz';

>@response = `/usr/contrib/bin/gzcat $file | tar -xvf - 2>&1`;

my @response = blah blah;

>print "<pre>\n"; 
>foreach (@response) 
>{ 
>print; 
>}
>print "\n</pre>\n"; 

Did you know print expects a list?

print "<pre>\n", @response, "\n"</pre>\n";

>Also, do I have the path to my file at 
>
>$file = usr/home1/discosco/html/lwp.tar.gz;
>
>input correctly... or should I have input it like this: 
>
>$file = http://lightning.prohosting.com/~discosco/lwp.tar.gz; 

Do you think gzcat knows what to do with a URL? maybe you should install
a webserver on your own machine so you can try this stuff out a bit
closer to home before you put it on prohosting.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
If you have one foot in tomorrow and one foot in yesterday, you're bound
to find yourself pissing on today.


------------------------------

Date: Fri, 22 Sep 2000 23:49:13 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Gunzip at Prohosting
Message-Id: <26393-39CC3649-49@storefull-247.iap.bryant.webtv.net>

Try those modules and they didn't work.

Dennis



------------------------------

Date: Sat, 23 Sep 2000 05:40:42 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Gunzip at Prohosting
Message-Id: <slrn8sogpu.s5.tjla@thislove.dyndns.org>

I was shocked! How could BUCK NAKED1 <dennis100@webtv.net>
say such a terrible thing:
>Try those modules and they didn't work.

No english me

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The plural of spouse is spice.


------------------------------

Date: Thu, 21 Sep 2000 22:36:46 -0600
From: "Justin Funston" <jfunston@connect.ab.ca>
Subject: Inserting one page inside another
Message-Id: <39cae1c5$1_2@skylite.connect.ab.ca>

Hi everyone. What I want to do is insert one page into another. I have a
page which I want to have another page inlcuded right in it. I know of SSI,
but that won't work for me, because the page is partially generated by a CGI
script. Is there any other methods of doing this, such as Javascript, etc.
Please let me know. Or, possibly, could the CGI be edited to allow it
somehow. I just downloaded the CGI, and am fairly new to it. The files are
located at the following URL:
http://www.connect.ab.ca/~funston/dltemp/DLTempex.cgi?colorex
That uses the template:
http://www.connect.ab.ca/~funston/dltemp/html_tmp.html
The information to be inserted into the template from the CGI script is
obtained by the extension on the CGI (colorex), which is in three text
files. Access to the files is at:
http://www.connect.ab.ca/~funston/dltemp/

What I want to do is include like a SSI Include in the html_tmp.html file,
but it won't work, I guess, because it is processes by the cgi program?? If
you have any suggestions, please let me know.

Thanks,
Justin Funston.
jfunston@connect.ab.ca




------------------------------

Date: 23 Sep 2000 09:08:12 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Inserting one page inside another
Message-Id: <slrn8soslj.lo9.abigail@alexandra.foad.org>

Justin Funston (jfunston@connect.ab.ca) wrote on MMDLXXIX September
MCMXCIII in <URL:news:39cae1c5$1_2@skylite.connect.ab.ca>:
^^ Hi everyone. What I want to do is insert one page into another. I have a

Fine, but what does that have to do with Perl?

Please go to a more appropriate group, rec.arts.origami for instance.



Abigail
-- 
perl -wlne '}print$.;{' file  # Count the number of lines.
#    A pair of darting
#    carps. The Prince sighs under a
#    she-oak tree. The King.


------------------------------

Date: Sat, 23 Sep 2000 09:48:47 GMT
From: Tim Richardson <ter@my-deja.com>
Subject: Re: Inserting one page inside another
Message-Id: <8qhu9s$co4$1@nnrp1.deja.com>

In article <slrn8soslj.lo9.abigail@alexandra.foad.org>,
  abigail@foad.org wrote:
> Justin Funston (jfunston@connect.ab.ca) wrote on MMDLXXIX September
> MCMXCIII in <URL:news:39cae1c5$1_2@skylite.connect.ab.ca>:
> ^^ Hi everyone. What I want to do is insert one page into another. I
have a
>
> Fine, but what does that have to do with Perl?
>
> Please go to a more appropriate group, rec.arts.origami for instance.
>
> Abigail
>

I think it's a fair question. What's a portable version of Unix's cat?
Justin, you are right about the server side includes not working.

When I had to do this recently, I slurped the required file into a
variable and then printed it out at the right place in the file.

if (open (NAVBAR,$navbar_include)){ #don't care much if it fails
		#slurp the whole thing into a variable, could probably
use File::Copy for this
		@navbar = <NAVBAR>;
	}

Here is the synopsis fromt the File::Copy docs:

 use File::Copy;

        copy("file1","file2");
        copy("Copy.pm",\*STDOUT);'

so that looks interesting. I didn't bother about it too much, because
it's one file read either way, and my include file is small.

regards,
--
Tim Richardson
(search string: qweeblebeast)


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Sat, 23 Sep 2000 02:47:11 -0400
From: Sid Malhotra <sxm124@po.cwru.edu>
Subject: Levels of Perl Programmer
Message-Id: <39CC51EF.5E15CAFD@po.cwru.edu>

I am looking for an article (probably written by Tom Christiansen) on
the levels of a perl programmer.  I don't quite remember what exactly it
was but it listed the levels of a perl programmer and it's symptoms

examples:

Level One - you've heard of perl
2 - You know it as Practical Extraction and Report Language
 ...
Pathologically Eclectic Rubbish Lister

Some Level - You know of the $_ variable
Next Level - You know $_ and use it for everything.

 ...
Perl God - You know Larry's wife on a first name basis.
Level Before Last - Your first name is Tom or Randal
Last Level - Your first name is Larry.


If anyone can recognize the article I am trying to get to, could you
please let me know where I can find it.

Sid.



------------------------------

Date: 23 Sep 2000 09:09:14 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Levels of Perl Programmer
Message-Id: <slrn8sosnh.lo9.abigail@alexandra.foad.org>

Sid Malhotra (sxm124@po.cwru.edu) wrote on MMDLXXX September MCMXCIII in
<URL:news:39CC51EF.5E15CAFD@po.cwru.edu>:
?? I am looking for an article (probably written by Tom Christiansen) on
?? the levels of a perl programmer.


Try http://language.perl.com.



Abigail
-- 
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
          for (s;s;s;s;s;s;s;s;s;s;s;s)
              {s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'


------------------------------

Date: Sat, 23 Sep 2000 04:42:25 GMT
From: hiroshiishii@my-deja.com
Subject: Local variable screws thing up?
Message-Id: <8qhcbf$pk3$1@nnrp1.deja.com>

Hi everyone:

I cannot nake this simple script work.  Local declaration seems wrong.


---------------------------------
#!/usr/local/bin/perl5

# This list all files in a directory.

print "Which directory? \n";
$start_dir = <STDIN>;

&search($start_dir);

#***********
 sub search
#***********
{
	local $dir = @_;
	opendir(DIR, $dir);
	foreach $file (readdir(DIR))
	{
		print "$file\n";
	}
	closedir(DIR);
}

Thank you very much for your advice.



Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Fri, 22 Sep 2000 21:59:27 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Local variable screws thing up?
Message-Id: <39CC38AF.15C0887@vpservices.com>

hiroshiishii@my-deja.com wrote:
> 
> #!/usr/local/bin/perl5

Should have "-w" to turn on warnings.

Should have "use strict" to spot problems.

> # This list all files in a directory.
> 
> print "Which directory? \n";
> $start_dir = <STDIN>;

MUST chomp($start_dir) to remove the newline that gets inserted.

> &search($start_dir);
> 
> #***********
>  sub search
> #***********
> {
>         local $dir = @_;

Use "my" instead of "local".
@_ is a *list* of arguments.  If you want only the first argument, use
"shift" or $_[0].

>         opendir(DIR, $dir);

Check to see if your open succeeds:

          opendir(DIR,$dir) or die "Couldn't open $dir: $!";

-- 
Jeff


------------------------------

Date: Sat, 23 Sep 2000 08:50:55 +0100
From: "CJ Llewellyn" <darryl@work-thicker.co.uk>
Subject: Re: Local variable screws thing up?
Message-Id: <jrrhq8.dp6.ln@paulweller>


<hiroshiishii@my-deja.com> wrote in message
news:8qhcbf$pk3$1@nnrp1.deja.com...
> Hi everyone:
>
> I cannot nake this simple script work.  Local declaration seems wrong.
>
>
> ---------------------------------
> #!/usr/local/bin/perl5
>
> # This list all files in a directory.
>
> print "Which directory? \n";
> $start_dir = <STDIN>;
>
> &search($start_dir);
>
> #***********
>  sub search
> #***********
> {
> local $dir = @_;
> opendir(DIR, $dir);
> foreach $file (readdir(DIR))
> {
> print "$file\n";
> }
> closedir(DIR);
> }
>
> Thank you very much for your advice.


Heh wow, somebody with the same problem as me ! See /me bashes head agains't
brick wall thread.

--
Regards, CJ Llewellyn
http://www.cjll.uklinux.net/




------------------------------

Date: Sat, 23 Sep 2000 19:16:27 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Local variable screws thing up?
Message-Id: <slrn8sopmr.jr6.mgjv@martien.heliotrope.home>

On Sat, 23 Sep 2000 04:42:25 GMT,
	hiroshiishii@my-deja.com <hiroshiishii@my-deja.com> wrote:
> Hi everyone:
> 
> I cannot nake this simple script work.  Local declaration seems wrong.
> 
> 
> ---------------------------------
> #!/usr/local/bin/perl5

#!/usr/local/bin/perl5 -w
use strict;

> # This list all files in a directory.
> 
> print "Which directory? \n";
> $start_dir = <STDIN>;

my $start_dir = <STDIN>;
chomp $start_dir;

> &search($start_dir);

search($start_dir);

The & isn't necessary, and you should only use it if you really need its
semantics.

# perldoc perlsub

> #***********
>  sub search
> #***********
> {
> 	local $dir = @_;

Don't use local if you mean to use my. Also see the FAQ:

# perldoc -q 'local.*my'
Found in /opt/perl/lib/5.6.0/pod/perlfaq7.pod
       What's the difference between dynamic and lexical (static)
       scoping?  Between local() and my()?

Don't assign arrays to scalars. arrays in scalar context yield the
number of elements in the array.

Either of the following will do, in order of preference:

my $dir = shift;
my $dir = $_[0];
my ($dir) = @_;

> 	opendir(DIR, $dir);

opendir(DIR, $dir) or die "Cannot opendir $dir: $!";

> 	foreach $file (readdir(DIR))

If you are going to process the files one by one, then the following
would be better style:

while (my $file = readdir DIR)

But more idiomatic perl is to just get all the files in once, filtering
with grep, and transforming with map.

> 	{
> 		print "$file\n";
> 	}
> 	closedir(DIR);
> }
> 
> Thank you very much for your advice.

# perldoc -f chomp
# perldoc strict
# perldoc -f shift
# perldoc -f readdir
# perldoc -f grep
# perldoc -f map

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | System Administration is a dirty
Commercial Dynamics Pty. Ltd.   | job, but someone said I have to do
NSW, Australia                  | it.


------------------------------

Date: 23 Sep 2000 09:23:22 GMT
From: "Josiah" <jdb@wcoil.com>
Subject: Re: MSXML.dll
Message-Id: <8qhsqa$433$0@206.230.71.30>

I couldnt find Net-SSLeay on ActiveState either. However, one thing I did
find might be helpful. From the PPD:

    OpenSSL and SSLeay glue that provides LWP https support Joshua Chamas
<joshua@chamas.com

To install, from command line type

>    ppm install Crypt-SSLeay

and that will download and install to all the correct places.

hth,

--
Josiah <jdb@wcoil.com>

eval' use" :perl hacks by Josiah  "';
$@=$@=$@=reverse $@=$@=reverse $@=$@;
print map{substr($@,hex,1)}qw/3b 3c 3d 3e 3f 40 2c 06 01 07 03 06 04 02 0a
03 40 07 08 06 2d 07 08 14 06 40 04 34 35 07 08/;

IDBugM <idbugm@idbugm.com> wrote in message
news:8qh4au$h3r$1@nnrp1.deja.com...
> I've looked all over the place for Net::SSLeay for a Win32 system but
> all I've found is the Unix one that needs to be compiled.  I've pulled
> my hair out trying to get it to work on a Win32 system.  Where would I
> begin looking?  I didn't find it on activestate.com
>
>
> In article <8qh2l6$58j$1@slb6.atl.mindspring.net>,
>   ebohlman@netcom.com (Eric Bohlman) wrote:
> > IDBugM (idbugm@idbugm.com) wrote:
> > : I'm in a bit of a bind.  I'm trying to use Perl to post an XML
> string to
> > : a secure server.  Since I'm running this script on a Win32 system
> using
> > : Net::SSLeay would be very difficult to use.
> >
> > Are you aware that Net::SSLeay has been compiled for Win32 and is
> > available from ActiveState?
> >
> > : I've used the MSXML.DLL for ASP but I've never tried accessing the
> DLL's
> > : from Perl.  I've tried looking into all these groups for an answer
> but
> > : maybe I'm making it more difficult than it really is.  Here is the
> basic
> > : code I use in VB that I'm trying to convert into Perl.
> > :
> > : dim anXMLhttpObject, strResult
> > : Set anXMLhttpObject = Server.CreateObject("microsoft.XMLHttp")
> > : anXMLhttpObject.open "POST",TransactionURL,false
> > : anXMLhttpObject.setRequestHeader "Content-type", "text/xml"
> > : anXMLhttpObject.send RequestXMLstring
> > : strResult = anXMLhttpObject.responseText
> > :
> > : Anyone know how to convert this using the Win32::API module for
> Active
> > : State?  Please help if you know how to do this.  Thanks
> >
> > Since MSXML has a COM interface, you probably want to use Win32::OLE
> to
> > access it.
> >
> >
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




------------------------------

Date: Sat, 23 Sep 2000 09:30:43 GMT
From: "Jaap" <jaap@stack.nl>
Subject: Re: Pattern Matching Question
Message-Id: <7L_y5.263292$LX4.2293395@nlnews00.chello.com>

Ehmm... you could try to replace the /'s by \/'s first $string = s/\//\\\/g;

Or you could play with the options for regexps, maybe the 'o' option does
something




------------------------------

Date: Sat, 23 Sep 2000 10:31:22 +0000
From: "CJ Llewellyn" <darryl@work-thicker.co.uk>
Subject: Re: Question to the wise - Reading From File
Message-Id: <9m0iq8.297.ln@paulweller>

In article <MPG.143562f1a31ad25098adb7@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> burped:
> In article <aiegq8.ht.ln@paulweller> on Fri, 22 Sep 2000 20:15:53
> +0000,  CJ Llewellyn <darryl@work-thicker.co.uk> says...
>> In article <8qg2ck$8he$1@nnrp1.deja.com>, desertedge@my-deja.com
>> burped:
-snip-
>> while($line = <FILE>){
>>     print "$line";
> 
> The quotes are superfluous and misleading.  Why make an extra copy of 
> the variable before printing it

point taken.

-snip-

> More succinctly:
> 
>   print <FILE>;
> 

I'm assuming that the OP would want to do more than just print the file
to screen, otherwise 

'nix
cat file.txt

dos
type file.txt

from the CLI

-- 
Regards
CJ Llewellyn 



------------------------------

Date: Sat, 23 Sep 2000 09:30:42 GMT
From: "Jaap" <jaap@stack.nl>
Subject: Re: Question to the wise - Reading From File
Message-Id: <6L_y5.263291$LX4.2293395@nlnews00.chello.com>

replace $FILE by $_




------------------------------

Date: Sat, 23 Sep 2000 03:20:54 -0400
From: Sid Malhotra <sxm124@po.cwru.edu>
Subject: Remove blank lines
Message-Id: <39CC59D6.820EF279@po.cwru.edu>

I recently wrote a bunch of scripts to manage links on my website ...
yada yada .. I made and error and one of the scripts kept on adding an
extra '\n' fore every line that was already in the database.  Before I
knew it, a text file that's usually supposed to be 150 - 400 K was 25
megs.  (this was the largest increase, the others just doubled or
tripled in size due to the exponential growth in # of '\n''s) ... Anyway
I wrote a script to go through a file and get rid of blank lines.  There
are many ways of doing this (example below) but I wondered in the perl
spirit, what the most effiecient (most lazy) way was to remove blank
lines from a file.  Could anyone suggest better ways of doing it than I
did.  Or do it the perl way - from the command line perl -e ?

    With the script below, I keep getting segmentation errors when I run
it on large files (>100,000 lines).

Sid.

ps. I don't use use strict because my lazy webmaster won' t move to perl
5.  And yes I will change web services, but till then, could someone
help me out.
----
#!/usr/bin/perl -w

while ($filename = shift (@ARGV)) {
        @lines = ();
        print "Opening file $filename\n";
        open (FILE, "$filename") || die "can't open $filename : $!\n";
                foreach (<FILE>) {
                        push (@lines, $_) unless /^$/;
                }
        close (FILE);

        open (FILE, ">$filename") || die "can't open $filename : $!\n";
                foreach (@lines) {
                        print FILE;
                }
        close (FILE);
}

print "Done.\n";




------------------------------

Date: Sat, 23 Sep 2000 01:05:27 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Remove blank lines
Message-Id: <39CC6447.AD077C6@stomp.stomp.tokyo>

Sid Malhotra wrote:
 
> I recently wrote a bunch of scripts to manage links on my website ...
> yada yada .. I made and error and one of the scripts kept on adding an
> extra '\n' fore every line that was already in the database.

My presumption is you don't bother beta testing
your scripts before risking destroying valuable
data bases. This is highly illogical and, you
have earned your just deserves.


> Before I knew it, a text file that's usually supposed to be 
> 150 - 400 K was 25 megs.  

Another presumption I am making is, as a systems operator,
you don't bother checking your system nor your files on a 
daily basis. This is flat out stupid.


> (this was the largest increase, the others just doubled or
> tripled in size due to the exponential growth in # of '\n''s)

Others? You just indicated "a file" and now you are
indicating multiple files. Do you have a clue on what
you are doing at your server?


> ... Anyway

Boy I'll say.


> I wrote a script to go through a file and get rid of blank lines.

After looking over your code, my final presumption is
you are not familiar with imaginative use of chomp nor
familiar with index, substring and replace. This task 
could be accomplished in half a dozen lines of very 
simple basic Perl code, with no need for arrays and
all these other hula hoops, through which, you insist
upon leaping, likely without looking first.

Chomp each line imaginatively, index, substring and
replace, run a memory wasteful regex, whatever.

How challenging can this be to replace a string of
newline characters with one newline?

You could finish this task in the same amount of
time it took me to type this article, even at my
usual Mach One typing speed.


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


------------------------------

Date: 23 Sep 2000 09:32:44 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Remove blank lines
Message-Id: <slrn8sou3h.lo9.abigail@alexandra.foad.org>

Sid Malhotra (sxm124@po.cwru.edu) wrote on MMDLXXX September MCMXCIII in
<URL:news:39CC59D6.820EF279@po.cwru.edu>:
`` I recently wrote a bunch of scripts to manage links on my website ...
`` yada yada .. I made and error and one of the scripts kept on adding an
`` extra '\n' fore every line that was already in the database.  Before I
`` knew it, a text file that's usually supposed to be 150 - 400 K was 25
`` megs.  (this was the largest increase, the others just doubled or
`` tripled in size due to the exponential growth in # of '\n''s) ... Anyway
`` I wrote a script to go through a file and get rid of blank lines.  There
`` are many ways of doing this (example below) but I wondered in the perl
`` spirit, what the most effiecient (most lazy) way was to remove blank
`` lines from a file.  Could anyone suggest better ways of doing it than I
`` did.  Or do it the perl way - from the command line perl -e ?

Try this:

    perl -li -00pe0 your_file    # Hah! Beat this with golf!

That will remove blank lines. However, if you have many lines without
a blank line in between, or millions of blank lines in a row, you might
want to do:

    perl -i -ne'/./&&print' your_file

But that's a lot more code, and you spend more time in the dispatcher.

``     With the script below, I keep getting segmentation errors when I run
`` it on large files (>100,000 lines).
`` 
`` Sid.
`` 
`` ps. I don't use use strict because my lazy webmaster won' t move to perl
`` 5.  And yes I will change web services, but till then, could someone
`` help me out.

That's absurd. The last version of perl4 predates the eternal September
by more than half a year. Heck, perl5-alpha predates the eternal September.
Perl5 was out before more than 0.0000000000000001% of the people had even
heard of the web.

You, of course, should never have used that service.


I doubt the program I gave you will work on Perl 4. Perl 4 was a dead and
rotten carcas before I started looking at Perl. If the answers don't work
for your flea infested Perl, well, it sucks to be you.



Abigail
-- 
perl -wlpe '}$_=$.;{' file  # Count the number of lines.
#    Con Wei departs near
#    a dojo. A dragon walks.
#    A nesting raven.


------------------------------

Date: 23 Sep 2000 09:53:19 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: sending attachment not in body of email
Message-Id: <slrn8sovce.rlg.vek@pharmnl.ohout.pharmapartners.nl>

On Fri, 22 Sep 2000 17:47:04 +0800,
            Hugo Bouckaert <hugo@fractalgraphics.com.au> wrote:


>Hi All
>
>Anyway, as Gwyn's message states below, I tried the multipart/mixed,
>both for Type in the message
>body and attachment in order to have emails as attachments, not in the
>body of the mail message:  
>
>### Create a new multipart message:
>        $msg = MIME::Lite->build(
>                     From    =>'info@fractalgraphics.com.au',
>                     To      =>'hugo@fractalgraphics.com.au',
>                     Cc      =>'hugo@fractalgraphics.com.au',
>                     Subject =>'File Upload procedure',
>                     Type    =>'multipart/mixed',
>                     Data    =>$body
>                    );
>$msg->attach(Type     =>'multipart/mixed',
>                      Content-type =>'attachment',              
>                      FH    =>$att
>                     );
>
>I also tried it when specifying the html form in the html page, but when
>I do
>the latter, the attachment is no longer there. 
>
>Do you - or anyone alse who knows about this - mind being a bit more
>specific 
>- how do I alter the above code to have attachments not displayed in the
>body of the email? Your help will
>be greatly appreciated. 
>




To quote the FM.  If I do as shown in the example it works perfectly
for me.  Note that your text message in the MIME context becomes the
first MIME attachment and the second and following MIME attachment is
what mail readers conciders THE attachment(s).



NAME
       MIME::Lite - low-calorie MIME generator

SYNOPSIS
           use MIME::Lite;

       Create a single-part message:

           # Create a new single-part message, to send a GIF file:
           $msg = new MIME::Lite
                       From     =>'me@myhost.com',
                       To       =>'you@yourhost.com',
                       Cc       =>'some@other.com, some@more.com',
                       Subject  =>'Helloooooo, nurse!',
                       Type     =>'image/gif',
                       Encoding =>'base64',
                       Path     =>'hellonurse.gif';


       Create a multipart message (i.e., one with attachments):

           # Create a new multipart message:
           $msg = new MIME::Lite
                       From    =>'me@myhost.com',
                       To      =>'you@yourhost.com',
                       Cc      =>'some@other.com, some@more.com',
                       Subject =>'A message with 2 parts...',
                       Type    =>'multipart/mixed';

           # Add parts (each "attach" has same arguments as "new"):
           attach $msg
                       Type     =>'TEXT',
                       Data     =>"Here's the GIF file you wanted";
           attach $msg
                       Type     =>'image/gif',
                       Path     =>'aaa000123.gif',
                       Filename =>'logo.gif';






-- 
Villy


------------------------------

Date: Sat, 23 Sep 2000 17:31:16 +0800
From: Richard Ireland <richard@dragnet.com.tw>
Subject: vertical text renderer
Message-Id: <39CC7864.C5397724@dragnet.com.tw>

Does anyone know of a perl script that can accept a query string with a
text field and retrun a content-type: image/gif with the text rendered
vertically.

It might also accept other paramaters like bgcolor, font-color,
font-face, alignment, orientation, transparent etc (these would be
useful, but not essential).

I expect it will need some libaries like cgi-lib and gm etc.

I could write it myself, but there's no point re-inventing the wheel !!!
(unless someone wants to pay me to do it !!!!!!)

Richard Ireland

--


  D R A G N E T  -- solutions for your eBusiness --

  http://www.dragnet.com.tw

  Richard Ireland <richard@dragnet.com.tw>
  CEO, Dragnet International,
  3F, No.20, Alley 3, Lane 106, Min Chuan E. Rd., Sec.3,
  Taipei 105, Taiwan R.O.C.

  Cellular: +886 915 648 253
  Fax:      +886 2 8770 6387
  Work:     +886 2 8770 6386
  ICQ:      9046459


------------------------------------------------------------------------





------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4411
**************************************


home help back first fref pref prev next nref lref last post