[12542] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6142 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 27 05:07:12 1999

Date: Sun, 27 Jun 99 02:00:16 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 27 Jun 1999     Volume: 8 Number: 6142

Today's topics:
    Re: "Learning Perl" exercises (Casey R Tweten)
        Apologies for multiple posts <mdichirico@lamotionpictures.com>
    Re: Command line parameters / Wildcard characters / Rec (Ronald J Kimball)
    Re: deleting part of a string (Ronald J Kimball)
        Explination of a be <bie@connect.ab.ca>
    Re: Free New Job/Resume Site! (Ronald J Kimball)
        grep variants? (William Herrera)
    Re: grep variants? (Bart Lateur)
    Re: How to store hashes <thummel@junior-net.de>
    Re: Index of an array-item (Ronald J Kimball)
    Re: Learning Perl exercises using reverse <swiftkid@bigfoot.com>
        learning perl asdfasdfwertwert@my-deja.com
    Re: offline testing of Perl/CGI's <swiftkid@bigfoot.com>
    Re: Statistics for comp.lang.perl.misc (Bart Lateur)
    Re: Unlink == delete files? Why (on earth) is it called (Ronald J Kimball)
    Re: weirdness with Netcom (Greg Andrews)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sun, 27 Jun 1999 06:20:00 GMT
From: crt@highvision.com (Casey R Tweten)
Subject: Re: "Learning Perl" exercises
Message-Id: <3775c220.145175659@news.kiski.net>

On Sun, 27 Jun 1999 04:58:15 GMT, Mike Dichirico
<mdichirico@lamotionpictures.com> wrote:

:I'm reading "Learning Perl" and trying the exercises in them.  I'm
:using my Win98 computer as my platform.
:
:On page 57, exercise #1, it says to wrte a program that reads a list of
:strings on seperate lines and prints out the list in reverse order.
:
:Appendix A of the book gives the following code as one of the possible
:answers to the exercise:
:
:print "Enter the list of strings:\n";
:@list = <STDIN>;
:@reverselist = reverse @list;
:print @reverselist;
:
:When I run the program, it asks for me to enter a string like it's
:supposed to.  But after hitting <Enter>, the program just hangs there.
:I have to hit <Ctrl> + Z to get back to my command prompt.
:
:How come it isn't reversing my string like it's supposed to?  What am I
:not adding to the code that it's supposed to have?  TIA for any help.


You could try ^D on a line by itself.

Let me say that a few more times, since you posted so many....

you
hit
ctrl
D
^D
D
ctrl
you
hit

--
Casey Tweten  HighVision Associates
Web Developer http://www.highvision.com
<joke> This is 100% certified,
       virus and bug free code </joke>


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

Date: Sun, 27 Jun 1999 07:47:34 GMT
From: Mike Dichirico <mdichirico@lamotionpictures.com>
Subject: Apologies for multiple posts
Message-Id: <7l4kum$j1v$1@nnrp1.deja.com>

A fellow poster mentioned to me via e-mail that I had posted several
times on the same topic.  My apologies to all.

I'm using deja.com to post and had been getting error messages during
the posting.  Apparently, each subsequent attempt I made at posting
went through and now I look like an idiot asking to get flamed with
four identical posts.

Not looking to piss anyone off.  Just looking for some help.  Hope you
all can forgive me on my mistake and offer me some help.  TIA.

--Mike


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sun, 27 Jun 1999 02:42:16 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Command line parameters / Wildcard characters / Recursive  directories
Message-Id: <1du19vo.1nl7kin13tn6bkN@p11.tc2.metro.ma.tiac.com>

Eric Anderson <eman@cc.gatech.edu> wrote:

> Other command
> line utilities such as 'rm' can apply a given wildcard string
> recursively down directories (such as rm -rf *.html would delete all
> 'html' files in the current directory and every subdirectory of the
> current directory).

You are obviously grossly misinformed about the meaning of `rm -r`.
Have you ever actually _used_ `rm -rf *.html` to remove html files in
subdirectories?

`man rm`

     ...

     -r   This option causes the recursive removal of any directories
          and subdirectories in the argument list.
          ...

As you can see from the documentation, the -r option recursively removes
entire directories and subdirectories.  It has absolutely nothing to do
with the wildcard pattern.  In fact, it could not have anything to do
with the wildcard pattern; as has already been explained, the wildcard
pattern is expanded by the shell before rm is executed.  rm never sees
the wildcard pattern, only the expanded list of matching filenames.


The correct solution to your problem is to quote the pattern, and expand
it within your program - recursing through subdirectories, if
appropriate.

`whatever -r '*.html'`

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 27 Jun 1999 02:42:21 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: deleting part of a string
Message-Id: <1du1aaa.15wlrgvo8nijiN@p11.tc2.metro.ma.tiac.com>

Abigail <abigail@delanet.com> wrote:

> ** Longer to type, yes....
> ** but beside to mererly show another way, I also
> ** blindly assumed that he wanted to extract string
> ** contains file path (or URL).  And that's what
> ** the module does.  Talking about portable, the
> ** module is platform independent.
> 
> The problem is that the code as given above, does *NOT* remove everything
> from the last slash onwards. What it exactly does depends on the platform.
> And URL separators don't change when moving from platform to platform.
> 
> The module is platform independent if you know what you are doing, it'll
> break your code if used unwisely. Using File::Basename for dealing with
> URLs is unwise.

This is the first mention of URLs in this thread.  How do you know that
the data in question ('computers/hardware/monitors/sony') is a URL?
Note: There's not even a protocol specifier.

Perhaps the data is a local file path, in which case File::Basename *is*
an appropriate solution.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 27 Jun 1999 00:09:00 -0600
From: Tim <bie@connect.ab.ca>
Subject: Explination of a be
Message-Id: <3775BFFC.471E@connect.ab.ca>

Hello,


I was wondering if someone could explain how a banner exchange works
with detail. How does the program know if the banner is seen? How does
it decide which to show? How does it work the click on the banner to go
to the right site?


If you could explain with code snippets, I would aprecaite it greatly


Tim


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

Date: Sun, 27 Jun 1999 02:42:22 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Free New Job/Resume Site!
Message-Id: <1du1afs.155497gd4sua5N@p11.tc2.metro.ma.tiac.com>

Code Development Inc. <jerms@iname.com> wrote:

> Newsgroups: comp.lang.perl.misc,
>             van.jobs,
>             bc.jobs,
>             ab.jobs,
>             alt.jobs,
>             ca.jobs,
>             la.jobs

o/~
One of these things isn't like the others
One of these things doesn't belong
o/~

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 27 Jun 1999 06:15:55 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: grep variants?
Message-Id: <3775bec5.99392499@news.rmi.net>

A came across a situation where I need to split an array into two
arrays according to a regular expression.

This is straightforward using foreach and if/else, of course. I
suspect that grep is more efficent than foreach though.

This made me wonder if anyone has ever made a module with a nice,
efficient (C I suppose) two-output grep function? I mean one sort of
like

dual_grep(/regex/, \@source, \@true, \@false);

which copies elements of @source for which /regex/ is true to @true
and the others to @false ?

---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.


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

Date: Sun, 27 Jun 1999 08:35:56 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: grep variants?
Message-Id: <3778e1a7.2305367@news.skynet.be>

William Herrera wrote:

>This is straightforward using foreach and if/else, of course. I
>suspect that grep is more efficent than foreach though.

Is it? I wouldn't expect much difference. After all, grep() IS a loop.

>This made me wonder if anyone has ever made a module with a nice,
>efficient (C I suppose) two-output grep function? I mean one sort of
>like
>
>dual_grep(/regex/, \@source, \@true, \@false);
>
>which copies elements of @source for which /regex/ is true to @true
>and the others to @false ?

	foreach (1..10) {
	    push @{$_ & 1 ? \@odd : \@even }, $_;
	}
	print "Odd: @odd\n";
	print "Even: @even\n";

	Bart.


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

Date: Sun, 27 Jun 1999 10:43:38 +0100
From: Timo Hummel <thummel@junior-net.de>
Subject: Re: How to store hashes
Message-Id: <3775F24A.D9483E8E@junior-net.de>

I already solved the problem myself. For all those who want to know
(altough it fails when you use newline characters (\n) in the hashes):

Writing hashes:
----snip-----snip------
open (INF,">filename");

 foreach $key (keys %settings)
 {
  print INF $key;
  print INF "\n";
  print INF $settings{$key};
  print INF "\n";
  }
 close(INF);
----snip-----snip------


Writing keys:
----snip-----snip------

 open (INF,"filename");

 @ary = <INF>;

 close (INF);

 $fsel = 1;

 foreach $line (@ary)
 {

  if ($fsel == 1)
  {
   $fsel = 2;
   $templine = $line;
  }
  else
  {
   $fsel = 1;
   chop $line;
   chop $templine;

   $settings{$templine} = $line;
  }
 }
----snip-----snip------

I think there is a more efficient way, but this example is very easy :)

Timo




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

Date: Sun, 27 Jun 1999 02:42:23 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Index of an array-item
Message-Id: <1du1c2m.d7rd481grjmsuN@p11.tc2.metro.ma.tiac.com>

Larry Rosler <lr@hpl.hp.com> wrote:

> In article <37750034@cs.colorado.edu> on 26 Jun 1999 10:30:44 -0700, Tom
> Christiansen <tchrist@mox.perl.com> says...
> > Cursed to torture himself and others with MicroPlanet Gravity v2.11,
> > pjotor@kurir.net (Peter Johansson) writes in comp.lang.perl.misc:
> > 
> > :I've got this array @items which contains a list of, well, items. Now I'd
> > :like to known the index of, say, the item named "foo". Is there a nice
> > :way to do this in Perl? (I'm quite sure there is, I just haven't found it
> > :yet...)
> > 
> > NAME
> >     perlfaq4 - Data Manipulation ($Revision: 1.49 $, $Date:
> >     1999/05/23 20:37:49 $)
> ...
> >   How can I tell whether a list or array contains a certain element?
> 
> Cursed to torture myself and others with MicroPlanet Gravity v2.11, I
> wonder why you think that this FAQ is responsive to the particular 
> question.  Where in the array is not the same as whether in the array.

It doesn't seem to me to be a big jump from one to the other.  All of
the recommended solutions in the FAQ can be easily extended to find not
only whether an element is in the array, but also which index it is at.
Simply create the hash with increasing values for the keys, rather than
a constant value of 1.

> I don't know how to do this besides using a dumb for-loop linear search
> with breakout on match, do you?

There's always more than one way to do it.  Here's one, modified from
the FAQ.

        @blues = qw/azure cerulean teal turquoise lapis-lazuli/;
        undef %is_blue;
        $i = 0;
        for (@blues) { $is_blue{$_} = $i++ }

Now you check whether $some_color exists in %is_blue, and if so, what
the associated value is.  Simple.


Although it does get trickier (but still possible by extending the same
suggested solutions) if you need to deal with duplicates...



-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Sun, 27 Jun 1999 12:30:58 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Learning Perl exercises using reverse
Message-Id: <7l5n7i$9n3@news.cyber.net.pk>

Try this:

print "Enter a string: ";
chomp ( $str = <> );
print reverse $str;

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
AOL: Whiz Swift
ICQ: 4265451
FAX: (815) 846-2877
Mike Dichirico <mdichirico@lamotionpictures.com> wrote in message
news:7l4bcj$f79$1@nnrp1.deja.com...
> I'm reading "Learning Perl" and trying the exercises in them.  I'm
> using my Win98 computer as my platform.
>
> On page 57, exercise #1, it says to wrte a program that reads a list of
> strings on seperate lines and prints out the list in reverse order.
>
> Appendix A of the book gives the following code as one of the possible
> answers to the exercise:
>
> print "Enter the list of strings:\n";
> @list = <STDIN>;
> @reverselist = reverse @list;
> print @reverselist;
>
> When I run the program, it asks for me to enter a string like it's
> supposed to.  But after entering a string and hitting <Enter>, the
> program just hangs there.  I have to hit <Ctrl> + Z to get back to my
> command prompt.
>
> How come it isn't reversing my string like it's supposed to?  What am I
> not adding to the code that it's supposed to have?  TIA for any help.
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.




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

Date: Sun, 27 Jun 1999 07:56:02 GMT
From: asdfasdfwertwert@my-deja.com
Subject: learning perl
Message-Id: <7l4leg$j66$1@nnrp1.deja.com>

what are good books or web sites? I found a few tutorials at
http://devlib.virtualave.net


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Sun, 27 Jun 1999 12:31:48 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: offline testing of Perl/CGI's
Message-Id: <7l5n92$1r83@news.cyber.net.pk>

Get a web server, www.apache.org / www.sambar.com

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
AOL: Whiz Swift
ICQ: 4265451
FAX: (815) 846-2877

Laar <laar@ix.netcom.com> wrote in message
news:3775b811.86772142@nntp.ix.netcom.com...
> Hello all,
>
> I read everything twice looking for an answer to this -- anyone who
> can point me in the direction of the answer will be blessed with my
> eternal gratitude... and stuff...
>
> I'm writing a bunch of CGI scripts (in Perl) for handling a fairly
> complex set of databases. The scripts will be running on my ISP's
> server, and most of the hours of the day I can't be online to write,
> upload, test and debug the scripts on their system. My main problem is
> getting the code right (rookie Perl scripter that I am), and my life
> would become meaningful and filled with pleasure if I could just run
> the scripts on my own machine (W95 laptop, Perl 5.005, Netscape 4) via
> a web browser, interacting with the scripts the same way I would
> online.
>
> --> Problem: I've tried everything, but I can't seem to get the HTML
> doc to call the script properly. First, regardless of whether I
> specify the GET or POST method in the HTML form, the form seems to try
> to pass the data to the script with POST, and it invariably fails.
> Both the HTML pages and the scripts I'm trying to test are in c:\perl\
> and I've tried every possible combination of fixes (that I can think
> of) from both the HTML and script sides, and at best, the browser
> tries to download the script (as if downloading a file from on line)
> instead of execute it.
>
> Any ideas? Somebody? Please?
>
> --
> Laar
> www.netcom.com/~laar/index.html




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

Date: Sun, 27 Jun 1999 08:35:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <3776dcde.1081198@news.skynet.be>

Abigail wrote:

>That's not what I said, was it?

You said "not TomC's posts, but the posts TomC replies to". In the cases
I think you're referring to, TomC replies by quoting whole FAQ and
PerlFunc sections.

	Bart.


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

Date: Sun, 27 Jun 1999 02:42:24 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Unlink == delete files? Why (on earth) is it called unlink?
Message-Id: <1du1d3a.dm04s6p601boN@p11.tc2.metro.ma.tiac.com>

Jonathan Stowe <gellyfish@gellyfish.com> wrote:

> > such
> > as the various GNU application programs, vi, awk, sed, and the Bourne and
> > C shells.
> 
> A) That is artefact
> 
> B) none of vi, awk, sed, and the Bourne and C shells have anything to do
>   with GNU.

I wonder if that clause could have been rephrased:

such as vi, awk, sed, the Bourne and C shells, and the various GNU
application programs.

and still meant what the original author intended...

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 27 Jun 1999 00:18:35 -0700
From: gerg@shell.ncal.verio.com (Greg Andrews)
Subject: Re: weirdness with Netcom
Message-Id: <7l4j8b$5nb$1@shell1.ncal.verio.com>

laar@ix.netcom.com writes:
>
>Any idea why an FTP upload would corrupt a file rather than replace
>it?
>

Aside from the usual use of binary mode between Unix and Windows
or Macintosh, instead of ascii/text mode?

  -Greg


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 6142
**************************************

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