[18713] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 881 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 12 00:10:36 2001

Date: Fri, 11 May 2001 21:10:13 -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: <989640613-v10-i881@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 11 May 2001     Volume: 10 Number: 881

Today's topics:
    Re: if ($x in @a) equivalent in perl? (Dave Bailey)
    Re: if ($x in @a) equivalent in perl? <godzilla@stomp.stomp.tokyo>
    Re: if ($x in @a) equivalent in perl? (Dave Bailey)
    Re: if ($x in @a) equivalent in perl? (Alan Barclay)
    Re: if ($x in @a) equivalent in perl? <godzilla@stomp.stomp.tokyo>
    Re: if ($x in @a) equivalent in perl? (Dave Bailey)
    Re: if ($x in @a) equivalent in perl? <godzilla@stomp.stomp.tokyo>
    Re: if ($x in @a) equivalent in perl? <godzilla@stomp.stomp.tokyo>
    Re: if ($x in @a) equivalent in perl? <aqumsieh@hyperchip.com>
    Re: if ($x in @a) equivalent in perl? (Dave Bailey)
    Re: If statement question (Abigail)
    Re: If statement question (Craig Berry)
        Is this possible with Perl?? <proteus@cgiparadise.com>
    Re: Is this possible with Perl?? (Eric Bohlman)
    Re: Is this possible with Perl?? <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: need a simple script created please (R.S.)
    Re: Removing blank lines at beginng/end of a file (Abigail)
    Re: Removing blank lines at beginng/end of a file (Craig Berry)
    Re: Removing blank lines at beginng/end of a file <joe+usenet@sunstarsys.com>
    Re: Removing blank lines at beginng/end of a file <aqumsieh@hyperchip.com>
        Sendmail problem <shaun.collins@orange.net>
    Re: Sendmail problem <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: setting environment variables <fredridv@ifi.uio.no>
        USENIX 2001 Annual Technical Conference <tiffany@usenix.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 May 2001 00:00:07 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <slrn9fol0a.dgc.dave@sydney.daveb.net>

On Fri, 11 May 2001 13:18:25 -0700, Godzilla! 
<godzilla@stomp.stomp.tokyo> wrote:

>I use two methods for this. This test script below
>my signature includes both of these methods. My 
>first method is a standard grep methodology. My
>second, a transliteration methodolgy.
>
>You will discover for very tiny arrays, there is no
>significant difference in efficiency between the two.
>For arrays any larger than what I use in my test script,
>my second method is more efficient and, becomes more
>efficient than grep as array size increases.
[...]

[second method]

>@Array = qw (a b c d e f g h x);
>$string = "@Array";
>if ($string =~ tr/x//)
> { $found = "true"; }

This method does not work and is always slower than using grep,
sometimes drastically slower.  Don't use it.

--
Dave Bailey
davidb54@yahoo.com


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

Date: Fri, 11 May 2001 18:03:02 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <3AFC8BC6.5B989213@stomp.stomp.tokyo>

Dave Bailey wrote:
 
>  Godzilla! wrote:
 
> >I use two methods for this. This test script below
> >my signature includes both of these methods. My
> >first method is a standard grep methodology. My
> >second, a transliteration methodolgy.

> >You will discover for very tiny arrays, there is no
> >significant difference in efficiency between the two.
> >For arrays any larger than what I use in my test script,
> >my second method is more efficient and, becomes more
> >efficient than grep as array size increases.
> [...]
 
> [second method]
 
> >@Array = qw (a b c d e f g h x);
> >$string = "@Array";
> >if ($string =~ tr/x//)
> > { $found = "true"; }
 
> This method does not work and is always slower than using grep,
> sometimes drastically slower.  Don't use it.


This is a joke, right?

Godzilla!


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

Date: 12 May 2001 01:14:03 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <slrn9fopau.dsi.dave@sydney.daveb.net>

On Fri, 11 May 2001 18:03:02 -0700, Godzilla! 
<godzilla@stomp.stomp.tokyo> wrote:
>Dave Bailey wrote:
> 
>>  Godzilla! wrote:
> 
>> >I use two methods for this. This test script below
>> >my signature includes both of these methods. My
>> >first method is a standard grep methodology. My
>> >second, a transliteration methodolgy.
[...]
>> >@Array = qw (a b c d e f g h x);
>> >$string = "@Array";
>> >if ($string =~ tr/x//)
>> > { $found = "true"; }
> 
>> This method does not work and is always slower than using grep,
>> sometimes drastically slower.  Don't use it.
>
>This is a joke, right?

No.  The time required to create $string from @Array exceeds the
time saved using tr instead of grep.  Furthermore, counting 
occurrences of x in $string using tr returns substring matches
as well as equality matches.  What if @Array = qw(xx y) instead?

--
Dave Bailey
davidb54@yahoo.com


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

Date: 12 May 2001 00:35:05 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <989627667.654017@elaine.furryape.com>

In article <xris-F9136F.16235811052001@news.evergo.net>,
xris  <xris@dont.send.spam> wrote:
>In article <tfogp2ov3fhg74@corp.supernews.com>,
> Chris Stith <mischief@velma.motion.net> wrote:
>
>> Yes, it's using a hash. Perhaps you should too if you
>> need to quickly check for existence of an element. ;-)
>
>which is what I do most of the time.  however, there seems to be no way 
>to define the elements of a hash in a specific order (the compiler moves 
>them around on its own, after I define the hash).

If you want a hash with a presciped order, look into the IxHash module.
>
>I think the grep() solution will work, whever I need it (I was just 
>curious, didn't have a real application for it at the moment).
>
>Thanks,
>
>Chris
>




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

Date: Fri, 11 May 2001 18:41:44 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <3AFC94D8.19F063@stomp.stomp.tokyo>

Dave Bailey wrote:

> Godzilla! wrote:
> >Dave Bailey wrote:
> >>  Godzilla! wrote:

(snipped)

> >> >@Array = qw (a b c d e f g h x);
> >> >$string = "@Array";
> >> >if ($string =~ tr/x//)
> >> > { $found = "true"; }

> >> This method does not work and is always slower than using grep,
> >> sometimes drastically slower.  Don't use it.

> >This is a joke, right?
 
> No.  The time required to create $string from @Array exceeds the
> time saved using tr instead of grep.  Furthermore, counting
> occurrences of x in $string using tr returns substring matches
> as well as equality matches.  What if @Array = qw(xx y) instead?
 

What if a double hump camel mounted by a deranged terrorist
trekking across the Sahara, what if this camel sneezes tossing
his wild eyed rider upon the blistering sand, whereupon hitting 
this scorching sand, he screams and shoots up into our atmosphere 
trailing smoke from his burning butt, strikes a rogue Iraqi jet,
sending it plummeting into a oil rich sheik's tent just as he is
porking one of his belly dancers. What if he becomes angry and 
sends elderly Rhodesian seasoned mercenaries to America to nuke
Wally World and, they do, which in turns knocks down your electrical
power grid causing your computer to crash and burn and, subsequently, 
your Perl program?

What if the Bird of Paradise flew up your nose?

Well, what if?


This method I displayed is seven-hundred percent more efficient
than grep for simply running through the alphabet. Rest assured,
grep is almost always a lousy choice, regardless of what ifs,
almost as lousy of a troll as you are.

Godzilla!
--

#!perl

print "Content-type: text/plain\n\n";

use Benchmark;

print "Run One:\n\n";
&Time;

print "\n\nRun Two:\n\n";
&Time;

print "\n\nRun Three:\n\n";
&Time;


sub Time
 {
  timethese (100000,
  {
  'name1' =>
  '$found ="false";
   @Array = (a .. z);
   if (grep {x eq $_} @Array)
   { $found = "true"; }',

  'name2' =>
  '$found ="false";
   @Array = qw (a .. z);
   $string = "@Array";
   if ($string =~ tr/x//)
    { $found = "true"; }',
   } );
 }

exit;


PRINTED RESULTS:
________________

Run One:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  7 wallclock secs ( 6.92 usr +  0.00 sys =  6.92 CPU) @ 14450.87/s
 name2:  1 wallclock secs ( 1.10 usr +  0.00 sys =  1.10 CPU) @ 90909.09/s


Run Two:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  7 wallclock secs ( 6.97 usr +  0.00 sys =  6.97 CPU) @ 14347.20/s
 name2:  1 wallclock secs ( 1.10 usr +  0.00 sys =  1.10 CPU) @ 90909.09/s


Run Three:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  7 wallclock secs ( 7.03 usr +  0.00 sys =  7.03 CPU) @ 14224.75/s
 name2:  2 wallclock secs ( 1.15 usr +  0.00 sys =  1.15 CPU) @ 86956.52/s


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

Date: 12 May 2001 01:49:54 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <slrn9fore5.dun.dave@sydney.daveb.net>

On Fri, 11 May 2001 18:41:44 -0700, Godzilla! 
<godzilla@stomp.stomp.tokyo> wrote:
>Dave Bailey wrote:
[...]
>> No.  The time required to create $string from @Array exceeds the
>> time saved using tr instead of grep.  Furthermore, counting
>> occurrences of x in $string using tr returns substring matches
>> as well as equality matches.  What if @Array = qw(xx y) instead?
[...]
>This method I displayed is seven-hundred percent more efficient
>than grep for simply running through the alphabet. Rest assured,
>grep is almost always a lousy choice, regardless of what ifs,
>almost as lousy of a troll as you are.
[...]
>sub Time
> {
>  timethese (100000,
>  {
>  'name1' =>
>  '$found ="false";
>   @Array = (a .. z);
>   if (grep {x eq $_} @Array)
>   { $found = "true"; }',
>
>  'name2' =>
>  '$found ="false";
>   @Array = qw (a .. z);
>   $string = "@Array";
>   if ($string =~ tr/x//)
>    { $found = "true"; }',
>   } );
> }

Wrong again.  Try rerunning your benchmark with @Array = qw(a..z)
for both tests instead of using @Array = (a..z) for the tr test 
and @Array = qw(a..z) for the grep test.

--
Dave Bailey
davidb54@yahoo.com


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

Date: Fri, 11 May 2001 18:56:08 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <3AFC9838.FF84FA21@stomp.stomp.tokyo>

Godzilla! wrote:
 
> Dave Bailey wrote:
 
> > Godzilla! wrote:
> > >Dave Bailey wrote:
> > > >  Godzilla! wrote:

(snipped)

> This method I displayed is seven-hundred percent more efficient
> than grep for simply running through the alphabet. Rest assured,
> grep is almost always a lousy choice, regardless of what ifs,
> almost as lousy of a troll as you are.

For those not paying close attention, I must amend my claim
of seven-hundred percent faster, previously made. I neglected
to remove qw quote word syntax from my test script, second
code snippet. I am wrong. My method is only slightly faster
for running through the alphabet, than is grep.

How this for honesty?

Godzilla!
--

#!perl

print "Content-type: text/plain\n\n";

use Benchmark;

print "Run One:\n\n";
&Time;

print "\n\nRun Two:\n\n";
&Time;

print "\n\nRun Three:\n\n";
&Time;


sub Time
 {
  timethese (100000,
  {
  'name1' =>
  '$found ="false";
   @Array = (a .. z);
   if (grep {x eq $_} @Array)
   { $found = "true"; }',

  'name2' =>
  '$found ="false";
   @Array = (a .. z);
   $string = "@Array";
   if ($string =~ tr/x//)
    { $found = "true"; }',
   } );
 }

exit;

PRINTED RESULTS:
________________

Run One:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  7 wallclock secs ( 7.03 usr +  0.00 sys =  7.03 CPU) @ 14224.75/s
 name2:  7 wallclock secs ( 6.27 usr +  0.00 sys =  6.27 CPU) @ 15948.96/s


Run Two:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  7 wallclock secs ( 7.03 usr +  0.00 sys =  7.03 CPU) @ 14224.75/s
 name2:  7 wallclock secs ( 6.26 usr +  0.00 sys =  6.26 CPU) @ 15974.44/s


Run Three:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  7 wallclock secs ( 7.14 usr +  0.00 sys =  7.14 CPU) @ 14005.60/s
 name2:  6 wallclock secs ( 6.31 usr +  0.00 sys =  6.31 CPU) @ 15847.86/s


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

Date: Fri, 11 May 2001 19:21:34 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <3AFC9E2E.73F1E9C3@stomp.stomp.tokyo>

Dave Bailey wrote:

> Godzilla wrote:
> >Dave Bailey wrote:
> > >  Godzilla! wrote:

> > I use two methods for this. This test script below
> > my signature includes both of these methods. My
> > first method is a standard grep methodology. My
> > second, a transliteration methodolgy.

(snipped)

> What if @Array = qw(xx y) instead?

To satiate your need to stroke your own ego at the
expense of another, I have run some tests which are
outside my set parameters, your annoying what if.
For multiple instances, grep is slightly faster
under the parameters I set for these tests and
slightly slower for my original parameters.


Next time, approach me politely and, don't annoy me
by cowardly hiding behind a fake yahoo email address.

What if you step out of those cowardly shadows and
show everyone who you are really? Is this too tough
of a what if for you?


I am honest and, I never hide who I am. Doing this
would offend both my dignity and ethics.

Godzilla!
--

#!perl

print "Content-type: text/plain\n\n";

use Benchmark;

print "Run One:\n\n";
&Time;

print "\n\nRun Two:\n\n";
&Time;

print "\n\nRun Three:\n\n";
&Time;


sub Time
 {
  timethese (100000,
  {
  'name1' =>
  '$found ="false";
   @Array = qw (godzilla rocks and rolls);
   if (grep {o eq $_} @Array)
   { $found = "true"; }',

  'name2' =>
  '$found ="false";
   @Array = qw (godzilla rocks and rolls);
   $string = "@Array";
   if ($string =~ tr/o//)
    { $found = "true"; }',
   } );
 }

exit;

PRINTED RESULTS:
----------------

Run One:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  2 wallclock secs ( 1.15 usr +  0.00 sys =  1.15 CPU) @ 86956.52/s
 name2:  1 wallclock secs ( 1.54 usr +  0.00 sys =  1.54 CPU) @ 64935.06/s


Run Two:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  0 wallclock secs ( 1.15 usr +  0.00 sys =  1.15 CPU) @ 86956.52/s
 name2:  2 wallclock secs ( 1.54 usr +  0.00 sys =  1.54 CPU) @ 64935.06/s


Run Three:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  1 wallclock secs ( 1.15 usr +  0.00 sys =  1.15 CPU) @ 86956.52/s
 name2:  2 wallclock secs ( 1.54 usr +  0.00 sys =  1.54 CPU) @ 64935.06/s


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

Date: Sat, 12 May 2001 02:39:50 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <m34rur70j3.fsf@alquds.qumsieh.homeip.net>


> In article <tfogp2ov3fhg74@corp.supernews.com>,
>  Chris Stith <mischief@velma.motion.net> wrote:
> 
> I think the grep() solution will work, whever I need it (I was just 
> curious, didn't have a real application for it at the moment).

Note that if the element you're looking for is the first one in your
array, and your array is a million elements long, then the grep() will
go through ALL elements of your array.

I'd rather do it less elegantly and save on execution time:

	my $found = 0;
	for my $item (@array) {
		if ($item eq $x) {
			$found = 1;
			last;
		}
	}

	if ($found) {
		# found it.
	}

Of course, you can package this into a subroutine called in(), but you'd
have to call it like so:

	if (in($x, \@array)) {  # or similar
	}

--Ala


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

Date: 12 May 2001 02:47:36 GMT
From: dave@sydney.daveb.net (Dave Bailey)
Subject: Re: if ($x in @a) equivalent in perl?
Message-Id: <slrn9fouqb.e05.dave@sydney.daveb.net>

On Fri, 11 May 2001 18:56:08 -0700, Godzilla! 
<godzilla@stomp.stomp.tokyo> wrote:
>Godzilla! wrote:

>For those not paying close attention, I must amend my claim
>of seven-hundred percent faster, previously made. I neglected
>to remove qw quote word syntax from my test script, second
>code snippet. I am wrong. My method is only slightly faster
>for running through the alphabet, than is grep.
>
>How this for honesty?

It's an excellent start.  However, you've neglected one final
thing, which I've saved for last.  Take note of the subject 
of this thread:

 "if ($x in @a) equivalent in perl?"

In particular, note the "$x" part.  This means that the poster
needs a method which allows the use of variables, not just 
barewords.  Unfortunately for you, tr does not do this unless
you wrap it inside an eval.  Wrapping tr inside the eval, as 
you must do in order to use variables, slows it down dramatically.

There is also the matter of tr returning substring matches as
well as equality matches, of course.  That fact alone should 
have rendered the rest of this discussion moot.

--
Dave Bailey
davidb54@yahoo.com


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

Date: Fri, 11 May 2001 22:09:34 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: If statement question
Message-Id: <slrn9fooou.q7g.abigail@tsathoggua.rlyeh.net>

Rudolf Polzer (eins@durchnull.de) wrote on MMDCCCX September MCMXCIII in
<URL:news:slrn9fou5g.ra2.eins@www42.t-offline.de>:
##  
##  Is there a Perl way to say (C):
##  
##  for (;/*ever*/;) { ... }

That boils down to: 

    for (;;) { ... }

which does the same in C as in Perl...

##  for (;'ever';) { ... }
##  
##  works, but is 'ever' optimized away as a '1' constant?

I don't understand your question. First of all, 'ever' isn't identical
to 1; if you want to make it identical to a number, it should be 0.
Furthermore, why do you think 1 is more optimized than 'ever'?



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: Fri, 11 May 2001 22:27:49 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: If statement question
Message-Id: <tfopr57vn1lsfc@corp.supernews.com>

nobull@mail.com wrote:
: Of course it would be more conventional to write this as:
: 
: unless (open (FILE, "file.txt")) {
:   print "what do you want to do instead:  ";
: }

Or just use the same logical connective style normally suggested for 'open
or die trying':

  open FILE, 'file.txt' or print "Oops.\n";

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Fri, 11 May 2001 22:31:48 GMT
From: "David Tsai" <proteus@cgiparadise.com>
Subject: Is this possible with Perl??
Message-Id: <oLZK6.2298$N23.207191@newsread1.prod.itd.earthlink.net>


Usually when you open a flat text file that reads line by line you go..

open(FILE,"file.txt");
while($line =<FILE>) {
    # do stuff here
}
close(FILE);

Instead of opening files like that, I want to create a standard sub routine
or module so I can open files something like this..

use MyModule;
$file = new MyModule("file.txt");
while($line = $file->fetchrow()) {
    # Do stuff here
}

My question is.. how do I program the fetchrow() sub routine to return the
specific line of the file that it is currently on.  I can think of some ways
of accomplishing this, but it would be extremely inefficient (such as
storing the entire file in an array when the object is created).  Is there a
way to seek or stream the data through the function as if I just used the
standard Perl method for reading files so that the only data that is stored
in memory is the current line.

The reason why I want to accomplish this is because I want to create a
module that mimics the DBI module to be used on text databases.  I want to
create a module that understands all the basic SQL commands and has the
fetchhash and fetchrow commands that DBI has.  This way I can create the
front end of a program and easily port it to use mySQL or flat-file
databases with little or no modification.




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

Date: 12 May 2001 01:26:24 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Is this possible with Perl??
Message-Id: <9di3g0$16j$1@bob.news.rcn.net>

David Tsai <proteus@cgiparadise.com> wrote:
> The reason why I want to accomplish this is because I want to create a
> module that mimics the DBI module to be used on text databases.  I want to
> create a module that understands all the basic SQL commands and has the
> fetchhash and fetchrow commands that DBI has.  This way I can create the
> front end of a program and easily port it to use mySQL or flat-file
> databases with little or no modification.


That particular wheel has been invented at least three times.  Go to CPAN 
and look at DBD::CSV, DBD::RAM, and DBD::Sprite.



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

Date: 12 May 2001 01:45:21 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Is this possible with Perl??
Message-Id: <86heyre3wu.fsf@jon_ericson.jpl.nasa.gov>

"David Tsai" <proteus@cgiparadise.com> writes:

> The reason why I want to accomplish this is because I want to create a
> module that mimics the DBI module to be used on text databases.  I want to
> create a module that understands all the basic SQL commands and has the
> fetchhash and fetchrow commands that DBI has.  This way I can create the
> front end of a program and easily port it to use mySQL or flat-file
> databases with little or no modification.

Don't reinvent the wheel - use CPAN!  DBD::RAM (or DBD::CVS) is what
you want.

Jon


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

Date: Sat, 12 May 2001 01:40:54 GMT
From: rastacey@roadrunner.nf.net (R.S.)
Subject: Re: need a simple script created please
Message-Id: <3afc9356.207002774@news.thezone.net>

On Fri, 11 May 2001 17:05:58 -0400, Lou Moran <lmoran@wtsg.com> wrote:
Hi. My name is Bob Stacey and I do small contract jobs in several
platforms.

The script shouldn't be too big a problem. I have a few general
questions about your requirements.
How far advanced are you with your server? Have you ever run cgi
scripts before?  What kind of budget do you have to work with?
Let me know and we should be able to work something out to get this
done for you.
Bob Stacey
>On Fri, 11 May 2001 14:34:59 -0700, Donald Dahlman
><druid@eoe-magical.org> wrote wonderful things about sparkplugs:
>
>>I need a perl script
>>that allows a user to fill in some information
>>select a local file on there machine a jpg or gif only
>>click a button and have the contents added to an html file
>>and have the graphic file added to a separate directory.
>>when the html file is opened the links will also show the photos
>>have a little money can some one help. I can do a little of the work
>>like creating the basic html headers and footers
>>druid@nift.net
>>
>
>
>you need a programmer...
>
>you could *possibly* try www.freeperlcode.com although your specs are
>a little specific.
>
>--
>print "\x{263a}" 



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

Date: Fri, 11 May 2001 22:21:33 +0000 (UTC)
From: abigail@foad.org (Abigail)
Subject: Re: Removing blank lines at beginng/end of a file
Message-Id: <slrn9fopfd.q7g.abigail@tsathoggua.rlyeh.net>

John W. Krahn (krahnj@acm.org) wrote on MMDCCCX September MCMXCIII in
<URL:news:3AFC60DF.FA5A40FC@acm.org>:
//  Kenneth Eide wrote:
// > 
// > Hello!
// > 
// > How would I remove ALL blank lines at the beginning, and at the end of a
// > file?
// > I've searched for help on this but I haven't found anything unfortunatly.
// > Hope some of you guys could help me out.
//  
//  perl -0777 -pi.bak -e 's/^\s+//; s/\s+$//' yourfile


That might take a lot of memory if the file is big.


perl -niwle '$a ? do {length ? do {for (1 .. $b) {print ""}; $b = 0; print}
                             : $b ++}
                : length and print and $a ++' yourfile


If you consider a file consisting of just spaces and tabs to be a
blank line, change "length" to /\S/ (both times).

You will lose the spaces on "blank lines" then though.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: Fri, 11 May 2001 22:35:57 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Removing blank lines at beginng/end of a file
Message-Id: <tfoqad7n3d2fc9@corp.supernews.com>

Kenneth Eide (js@hotmail.com) wrote:
: How would I remove ALL blank lines at the beginning, and at the
: end of a file?

For files small enough to fit in memory:

#!/usr/bin/perl -w
# blstrip - strips blank lines at the beginning and end of input.
#   NOTE:  Will choke on files too large to fit in memory.
# Craig Berry (20010511)

use strict;

my $text = do { local $/; <> };

$text =~ s/\A\n+//;
$text =~ s/\n{2,}\Z/\n/;

print $text;


-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: 11 May 2001 20:48:14 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Removing blank lines at beginng/end of a file
Message-Id: <m3d79ffl4h.fsf@mumonkan.sunstarsys.com>

abigail@foad.org (Abigail) writes:

> John W. Krahn (krahnj@acm.org) wrote on MMDCCCX September MCMXCIII in
> <URL:news:3AFC60DF.FA5A40FC@acm.org>:
> //  perl -0777 -pi.bak -e 's/^\s+//; s/\s+$//' yourfile

[...]

> perl -niwle '$a ? do {length ? do {for (1 .. $b) {print ""}; $b = 0; print}
>                              : $b ++}
>                 : length and print and $a ++' yourfile
> 
> 
> If you consider a file consisting of just spaces and tabs to be a
> blank line, change "length" to /\S/ (both times).
> 
> You will lose the spaces on "blank lines" then though.

I'm not sure what you expect this to do, but it sure is an 
interesting puzzle.

Anyway, here's what I came up with-

  % perl -pi.bak -we 'for($_=<> until /\S/..0 or eof; !/\S/; $_.=<>) { 
                      if (eof) { $_=""; last } }' filename 

This treats lines without non-space characters as blank.

Joe Schaefer
-- 
Quintessential Williams: generate clicks-and-mortar models 


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

Date: 11 May 2001 22:07:50 -0400
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Removing blank lines at beginng/end of a file
Message-Id: <m37kzn7215.fsf@alquds.qumsieh.homeip.net>


> John W. Krahn (krahnj@acm.org) wrote on MMDCCCX September MCMXCIII in
> <URL:news:3AFC60DF.FA5A40FC@acm.org>:
> //  Kenneth Eide wrote:
> // > 
> // > Hello!
> // > 
> // > How would I remove ALL blank lines at the beginning, and at the end of a
> // > file?
> // > I've searched for help on this but I haven't found anything unfortunatly.
> // > Hope some of you guys could help me out.
> //  
> //  perl -0777 -pi.bak -e 's/^\s+//; s/\s+$//' yourfile
> 
> 
> That might take a lot of memory if the file is big.
> 
> 
> perl -niwle '$a ? do {length ? do {for (1 .. $b) {print ""}; $b = 0; print}
>                              : $b ++}
>                 : length and print and $a ++' yourfile

You haven't tested your code, have you?

% perl -niwle '$a ? do {length ? do {for (1 .. $b) \
  {print ""}; $b = 0; print} : $b ++} : length and \
  print and $a ++' test.file
Can't open perl script "$a ? do {length ? do {for (1 .. $b) {print ""}; $b = 0; print} : $b ++} : length and print and $a ++": No such file or directory


Of course, you need a space after the -i:

% perl -ni -wle '$a ? do {length ? do {for (1 .. $b) \
  {print ""}; $b = 0; print} : $b ++} : length and \
  print and $a ++' test.file
Warning: Use of "length" without parens is ambiguous at -e line 1.
Search pattern not terminated at -e line 1.


I'm not sure what you're code is supposed to do, so I can't fix it.

--Ala


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

Date: Sat, 12 May 2001 01:20:15 +0100
From: "Shaun" <shaun.collins@orange.net>
Subject: Sendmail problem
Message-Id: <3afc74c5$0$15026$cc9e4d1f@news.dial.pipex.com>

We're using windoze and Outlook connected to a ms postoffice, to send mail
to the internet.
Currently Outlook sends mail to the postoffice using MHS.

Is there a way of sending mail using MHS? preferebly direct to the ms
postoffice.
I have tried to find info on this problem but to no avail.

Thanks very much.





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

Date: 12 May 2001 01:31:06 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Sendmail problem
Message-Id: <86lmo3s691.fsf@jon_ericson.jpl.nasa.gov>

"Shaun" <shaun.collins@orange.net> writes:

> We're using windoze and Outlook connected to a ms postoffice, to
> send mail to the internet.  Currently Outlook sends mail to the
> postoffice using MHS.
> 
> Is there a way of sending mail using MHS? preferebly direct to the
> ms postoffice.  I have tried to find info on this problem but to no
> avail.

Did you realize you posted this to a _perl_ newsgroup?  Perhaps you
would do better to consult your sysadmin or documentation, FAQs and
forums about MHS (whatever that is).

Jon


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

Date: Sat, 12 May 2001 05:54:32 +0200
From: Fredrik De Vibe <fredridv@ifi.uio.no>
Subject: Re: setting environment variables
Message-Id: <Pine.GSO.4.21.0105120551010.29841-100000@tyrfing.ifi.uio.no>

Hi

hvtuml
On 10 May 2001, Anno Siegel wrote:
> That's a faq, and "perldoc -q environment" takes you there.  The short
> answer is, you can't make it "permanent".

I couldn't get that to work. "man perldoc" only gave me the alternatives
h, v, t, u, m and l and "perldoc environment" didn't give me anything. Any
idea why and/or to what I can do?


--Fredrik



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

Date: Fri, 11 May 2001 16:55:06 -0700
From: Tiffany Peoples <tiffany@usenix.org>
Subject: USENIX 2001 Annual Technical Conference
Message-Id: <tiffany-B4C151.16550611052001@reader.news.uu.net>
Keywords: USENIX, FREENIX, technical conference, research, system administration, security, Unix, Linux, Windows NT, Open Source, Tutorials, training, Invited talks, Refereed Papers, Distributed caching, embedded systems, Extensible operating, storage, kernel, BSD, resource management, virtual memory, personal digital assistants, device driver, LDAP, high availability, Perl, wireless networking, ubiquitous messaging, remote access, Web technologies, network administration, Java, Perl, scalability, Programming tools, Portability, Client-server design development, Sendmail, DNS, GUI builders, CGI, free software, Operating systems design, Robotics and automation, e-commerce, electronic commerce, CORBA, Tcl/tk, Intranet, Extranet, 0bject oriented, POSIX, ActiveX, software, hardware, Apache, GNOME, Samba, FreeBSD, GNU, design, development

2001 USENIX Annual Technical Conference
June 25-30, 2001 
Marriott Copley Place Hotel
Boston, Massachusetts, USA
http://www.usenix.org/events/usenix01/

==============================================
REGISTER BY May 25, 2001 and Save up to $200!
==============================================

Join peers, research and industry leaders in Boston at the USENIX Annual 
Technical Conference. 

FEATURING THIRTY professional-level tutorials, SEVENTEEN brand-new!
Herešs a sampling:
Running Web Servers Securely     Internet Security for Linux Sys Admins
Network Security Profiles        UNIX Network Programming
Network Programming with Perl    Inside the Linux Kernel
Building Linux Applications         Large Heterogeneous Networks
Practical Wireless IP Security         Exploring the Potential of LDAP
Wireless Networking Fundamentals    Configuring & Administering Samba 
Servers

* KEYNOTE ADDRESS by Daniel D. Frye, Director of IBM Linux Technology 
Center.

* INVITED TALKS on WAP, IP Wireless Networking, Security Aspects of 
Napster and Gnutella, Security For E-voting in Public Elections, Virtual 
Machines, Online Privacy, Active Content and Secure DNS

*NEWLY ADDED CLOSING SESSION with Cynthia Breazeal, researcher from the 
MIT media lab, currently developing robots that can duplicate human 
facial emotions.

*VENDOR EXHIBITION featuring innovative companies, products and 
services. 
For more information on exhibiting, please contact Dana Geffner at 
dana@bgiassociates.com.

For more information and to register, visit: 
http://www.usenix.org/events/usenix01/

=====================================================================
The 2001 USENIX Annual Technical Conference is sponsored by 
USENIX, the Advanced Computing Systems Association.   www.usenix.org
=====================================================================


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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 V10 Issue 881
**************************************


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