[17871] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 31 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 10 14:06:38 2001

Date: Wed, 10 Jan 2001 11:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <979153515-v10-i31@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 10 Jan 2001     Volume: 10 Number: 31

Today's topics:
        (Beginner) Can't open file on Win98 <garry@heaton6.freeserve.co.uk>
    Re: (Beginner) Can't open file on Win98 <garry@heaton6.freeserve.co.uk>
    Re: (Beginner) Can't open file on Win98 (Garry Williams)
    Re: (Beginner) Can't open file on Win98 (Richard Zilavec)
    Re: (Beginner) Can't open file on Win98 <juex@deja.com>
    Re: ASCII to integer conversion <uri@sysarch.com>
    Re: ASCII to integer conversion (Brandon Metcalf)
    Re: ASCII to integer conversion gls@byu.edu
    Re: ASCII to integer conversion gungeek@my-deja.com
    Re: building all together (Andy Dougherty)
        CORBA::ORBit problem <mmertel@ix.netcom.com>
    Re: counting lines in a file lpj91100@my-deja.com
    Re: counting lines in a file nobull@mail.com
    Re: counting lines in a file lpj91100@my-deja.com
        csv revisited <news@#nospam#althepal.com>
    Re: data problems <tony_curtis32@yahoo.com>
        data structure syntax robr@sitera.com
        File <mp@softex.com.pl>
        Finding ranges in a list of integers (Rafael Garcia-Suarez)
    Re: Finding ranges in a list of integers <aqumsieh@hyperchip.com>
    Re: Frames <nickco3@yahoo.co.uk>
    Re: Help this newbie learn please :) <aqumsieh@hyperchip.com>
    Re: Help this newbie learn please :) <peb@bms.umist.ac.uk>
    Re: Help this newbie learn please :) (Richard Zilavec)
    Re: HTML stripper (James Kufrovich)
        Mac Databases and MacPerl <markp@mail1.jpl.nasa.gov>
    Re: Net::Telnet and --More-- bmurphee@my-deja.com
        Net::Telnet question <neil@alaweb.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 10 Jan 2001 14:55:01 -0000
From: "Garry Heaton" <garry@heaton6.freeserve.co.uk>
Subject: (Beginner) Can't open file on Win98
Message-Id: <93ht2d$5m2$1@news6.svr.pol.co.uk>

I'm exercising opening a file and can't get anything to work. Here's the
mini-script:

#!c:\perl\bin\perl.exe

open EXAMPLE, "c:\cgi\ex.txt" or die "Can't open file: $!";
while ($words = <EXAMPLE>) {
 print $words;
}

Each time I get a "no such file or directory" error. For the exercise I put
the script and a text file called "ex.txt" in a "\cgi\" directory on my c:\
drive. I have used "ex" and "ex.txt" in addition to the full-path version
but none seem to work. My PATH is set correctly.

Garry Heaton





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

Date: Wed, 10 Jan 2001 14:58:16 -0000
From: "Garry Heaton" <garry@heaton6.freeserve.co.uk>
Subject: Re: (Beginner) Can't open file on Win98
Message-Id: <93ht8e$5pv$1@news6.svr.pol.co.uk>

Sorry. Cracked it. I hadn't used "ex.txt" it seems, as that now works.

Garry

"Garry Heaton" <garry@heaton6.freeserve.co.uk> wrote in message
news:93ht2d$5m2$1@news6.svr.pol.co.uk...
> I'm exercising opening a file and can't get anything to work. Here's the
> mini-script:
>
> #!c:\perl\bin\perl.exe
>
> open EXAMPLE, "c:\cgi\ex.txt" or die "Can't open file: $!";
> while ($words = <EXAMPLE>) {
>  print $words;
> }
>
> Each time I get a "no such file or directory" error. For the exercise I
put
> the script and a text file called "ex.txt" in a "\cgi\" directory on my
c:\
> drive. I have used "ex" and "ex.txt" in addition to the full-path version
> but none seem to work. My PATH is set correctly.
>
> Garry Heaton
>
>
>




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

Date: Wed, 10 Jan 2001 15:49:11 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: (Beginner) Can't open file on Win98
Message-Id: <Xv%66.556$qi1.10897@eagle.america.net>

On Wed, 10 Jan 2001 14:55:01 -0000, Garry Heaton
<garry@heaton6.freeserve.co.uk> wrote:

>I'm exercising opening a file and can't get anything to work. Here's
>the mini-script:
>
>#!c:\perl\bin\perl.exe

 #!c:/perl/bin/perl.exe -w
 use strict;

>open EXAMPLE, "c:\cgi\ex.txt" or die "Can't open file: $!";
>while ($words = <EXAMPLE>) {

 while (my $words = <EXAMPLE>) {

> print $words;
>}
>
>Each time I get a "no such file or directory" error. For the exercise
>I put the script and a text file called "ex.txt" in a "\cgi\"
>directory on my c:\ drive. I have used "ex" and "ex.txt" in addition
>to the full-path version but none seem to work. My PATH is set
>correctly.

If you print the name of the file in your error message, you will see
what the problem is.  

The PATH variable will not affect the opening of a file; it's used to
locate programs you execute.  

-- 
Garry Williams


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

Date: Wed, 10 Jan 2001 15:54:20 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: (Beginner) Can't open file on Win98
Message-Id: <3a5c84bb.177764896@news.tcn.net>

On Wed, 10 Jan 2001 14:55:01 -0000, "Garry Heaton"
<garry@heaton6.freeserve.co.uk> wrote:

>I'm exercising opening a file and can't get anything to work. Here's the
>mini-script:
>
>#!c:\perl\bin\perl.exe
>
>open EXAMPLE, "c:\cgi\ex.txt" or die "Can't open file: $!";
                          ^^^^^^^^^^^^^^^^^^
You are escaping \c \e, try this

print "c:\cgi\ex.txt";
print 'c:\cgi\ex.txt';

open(EX, "c:\\cgi\\ex.txt") or die "Can't open file: $!\n";
while(<EX>) { print; }


--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Wed, 10 Jan 2001 09:08:31 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: (Beginner) Can't open file on Win98
Message-Id: <3a5c9710@news.microsoft.com>

"Garry Heaton" <garry@heaton6.freeserve.co.uk> wrote in message
news:93ht2d$5m2$1@news6.svr.pol.co.uk...
> I'm exercising opening a file and can't get anything to work. Here's the
> mini-script:
>
> #!c:\perl\bin\perl.exe
>
> open EXAMPLE, "c:\cgi\ex.txt" or die "Can't open file: $!";
[...]
> Each time I get a "no such file or directory" error. For the exercise I
put

Try c:/cgi/ex.txt instead (currently you are escaping c and e which makes
Perl searching for the file c:cgiex.txt)

jue




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

Date: Wed, 10 Jan 2001 16:21:06 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: ASCII to integer conversion
Message-Id: <x7ae8z5qfh.fsf@home.sysarch.com>

>>>>> "CP" == Clifford Pennock <cliff@*MYLASTNAMEHERE*.nl> writes:

  CP> Uri Guttman wrote:
  >> 
  >> >>>>> "CP" == Clifford Pennock <cliff@*MYLASTNAMEHERE*.nl> writes:
  >> 
  CP> Oh jump of your soapbox, Uri. The quotes were not included to
  CP> indicate "strings" or whatever. Or do I now need to write my
  CP> english in Perl syntax also?
  >> 
  >> this is a perl newsgroup, not an english one. if you are refering to
  >> values, typing the proper value is important.

  CP> Then what is the proper way to refer to the value of scalars in plain
  CP> English?

use Data::Dumper. it show the proper way to display perl data.

  >> you were concerned with converting strings to integers.

  CP> No, I am concerned about converting scalars that contain something like
  CP> 1234m/s is the speed of the object (I wanted to use quotes here so
  CP> people won't get confused about what is part of the scalar and what
  CP> isn't, but that would be wrong in your opinion) to a scalar that
  CP> contains 1234 only.

speed? huh? you are being as unclear as you have typically been in this
thread. 

  >> you type what should be an integer value
  >> as a string with quotes.

  CP> No, since I wasn't typing a piece of code here.

you were showing perl data. if it is quoted it is assumed to be a
string. if it is bare number it is a number. all else is not clear.


  CP> Given the thread, there is no such thing as wrong data format.

if i plonked people, you would be there.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 10 Jan 2001 16:10:04 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: ASCII to integer conversion
Message-Id: <93i1gs$elm$1@bcarh8ab.ca.nortel.com>

wyzelli@yahoo.com writes:

 > >
 > > You can do it both ways.  You have to provide the digits in the base
 > > and request a conversion.  Decimal conversion looks like
 > >
 > >     $num =~ tr|0-9||dc;  # dc == decimal conversion
 > 
 > For the benefit of the uninitiated that simply deletes all non-digits
 > from the string (c being the complement of the search which is all
 > digits, and d being delete)
 > 
 > > To convert a decimal number to a string, use
 > >
 > >     $str =~ tr|0-9||cs;  # cs == convert to string
 > 
 > This simply takes any non digit in the string and converts it to a
 > single instance of itself (c being the complement of the all digit
 > search and s being squash)
 > 
 > So the first example will convert any string to only have digits but I
 > fail to see the value in the second since if the string is already only
 > digits, then it will remain 'as is' and if the string contains
 > 'aaaa12345' then it becomes 'a12345'.
 > 
 > Am I missing something here?  (humour perhaps?)

I think it was meant as a joke.

Brandon


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

Date: 10 Jan 2001 09:34:01 -0700
From: gls@byu.edu
Subject: Re: ASCII to integer conversion
Message-Id: <ulmsjz7ra.fsf@SNOW.i-did-not-set--mail-host-address--so-shoot-me>

Clifford Pennock <cliff@*MYLASTNAMEHERE*.nl> writes:

> Abigail wrote:
> > 
> > If you would know the very basics of Perl, you'd know how silly the
> > question is.
> 
> An why is this silly? I've just started programming in Perl and I have
> encountered the exact same "problem" numerous times.
> 
> For instance, suppose we have a string that contains an important value
> we need for some other stuff. The only thing we know and can be certain
> of, is that this value can be found directly *after* a fixed delimiter
> (in this case a ","). Now everything directly following this number can
> be literally anything, except numbers:
> 
>     $a_string = "Random string with a value from somewhere,1234m/s";
>     $a_number = substr( $a_string, index( $a_string, "," ) );
> 
> Now we need to pass this number to another program:
> 
>     `a_program $a_string`;

I am assuming that the above should be:  `a_program $a_number`;

I think that the problem here is that you are asking the wrong
question.  Do you ever use $a_number as a number, or do you only pass
it to the back quotes?  The back quotes will convert a number back to
a string.  Converting something to an integer just to convert it back
to a string is kind of like finding the absolute value of a number by
squaring it, then taking the positive square root, it works for the
test case of -4, but does more work than is needed and may not work
for different data.

I believe the question that you would like answered is:

< I have a line of data that contains a comma (,) followed by one or
< more digits (plus other characters that I don't care about at this
< point), how do I extract just the digits from the string?  e.g. if
< $a_string contains 
< "Random string 4321 somewhere,1234m/s", then how do I get just the
< digits 1234 into $a_number?

If that is your real question, then there are a couple of answers that
suggest themselves:

( $a_number ) = $a_string =~ /,(\d+)/;

( $a_number ) = $a_string =~ /,\s*(\d+)/;

( $a_number ) = $a_string =~ /,(\d*)/;

if( $a_string =~ /,(\d+)/ ){
	$a_number = $1 
} else {
	die "wrong format";
}

$a_string =~ s/,(\d*)/$1/ and $a_number = $a_string or 
            die "wrong format";

are just a few.

You probably would have received this answer sooner, but you kept
insisting that you need to use the middle step of converting to an
integer and many people are trying to point out that you don't need to
do this.  Also several of the docs that they have pointed you to
should have started you down this path also.

hope this helps,

--
---------------------------------------------------------------------
 Dr. Gregory L. Snow         |  Inertia makes the world go round,
     (Greg)                  |   Love makes the trip worth taking.
   gls@byu.edu               |
---------------------------------------------------------------------


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

Date: Wed, 10 Jan 2001 18:03:42 GMT
From: gungeek@my-deja.com
Subject: Re: ASCII to integer conversion
Message-Id: <93i85l$5u0$1@nnrp1.deja.com>

In article <93epse$54e$1@news.news-service.com>,
  Clifford Pennock <cliff@*MYLASTNAMEHERE*.nl> wrote:
>
>     $a_string = "Random string with a value from somewhere,1234m/s";
>     $a_number = substr( $a_string, index( $a_string, "," ) );

You should use a regular expression here to extract the number, instead
of substrings.  This is what's causing your problems.  If you use a
regular expression, you can rely on $a_number always being a number.

You're trying to force C programming styles into Perl.  Learn Perl.
It's much nicer for the tasks you've mentioned.


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 14:44:00 -0000
From: doughera@maxwell.phys.lafayette.edu (Andy Dougherty)
Subject: Re: building all together
Message-Id: <slrn95otbo.oar.doughera@maxwell.phys.lafayette.edu>

In article <93fjbt$pml$1@bmerhc5e.ca.nortel.com>, Michael P. Soulier wrote:
>    Now, extension modules placed in the ext subdirectory seem to get picked
>up, for the most part. I'm having problems with some however, and I think it
>might be due to prerequisities on other modules. Is there a way to make sure
>that these extension modules are built in the correct order, and that all
>include and @INC paths are correct?

Extensions are built according to the order given in the config.sh
variable dynamic_ext (and static_ext and nonxs_ext for static and
non-XS extensions respectively).  You can supply a 'config.over' file that
contains the lines

	# Re-order dynamic_ext so they get built in the right order
	dynamic_ext='IO File whatever ...'

to re-order the extensions.  This 'config.over' file will get loaded
up after Configure runs but before the final config.sh is written.

This might do what you need to do.

Hope this helps,

-- 
    Andy Dougherty		doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042


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

Date: Wed, 10 Jan 2001 10:55:03 -0800
From: Mark Mertel <mmertel@ix.netcom.com>
Subject: CORBA::ORBit problem
Message-Id: <3A5CB006.C8108C14@ix.netcom.com>

is anyone using this module - i'm having trouble compiling it on HP
10-20.

mmertel@ix.netcom.com





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

Date: Wed, 10 Jan 2001 17:33:26 GMT
From: lpj91100@my-deja.com
Subject: Re: counting lines in a file
Message-Id: <93i6d6$422$1@nnrp1.deja.com>

Thanks for the idea.

Since I'm new to perl, what is the command to read a line?  Also how do
I check whether the line is a comment or blank?  What is the pattern
matching syntax for blank line or comment?

Thanks,
-LPJ

In article <grkn5t0sqhtrc0oaka7lulhmdjcn43sfl5@4ax.com>,
  Jeff Helman <jhelman@wsb.com> wrote:
> On Tue, 09 Jan 2001 23:54:15 GMT, lpj91100@my-deja.com wrote:
>
> >Hi,
> >
> >Does anybody have a perl script that counts the
> >numbers of lines of a file, excluding blank lines
> >and commented lines?
>
> No, not on me, sorry.  But here's some ideas...
>
> 1. Open the file
> 2. Initialize our counter to 0
> 3. Read a line
> 4. If the line is blank or a comment, skip it.
> 5. Otherwise, increment the counter
> 6. Close file, read counter.
>
> Or...
>
> 1. Open the file
> 2. Read a line
> 3. If the line is blank or a comment, skip it.
> 4. Otherwise, push the line into a storage array.
> 5. Close file when done.
> 5. Count the number of entries into the array.
>
> Or...
>
> 1. Read the file into memory in one slurp
> 2. Use a regular expression to extract blank or comment lines
> 3. Count the lines (either using a regex or a split())
>
> Pretty much your choice, but I'd suggest the first option.
>
> JH
>
>


Sent via Deja.com
http://www.deja.com/


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

Date: 10 Jan 2001 18:15:08 +0000
From: nobull@mail.com
Subject: Re: counting lines in a file
Message-Id: <u9d7dvl1eb.fsf@wcl-l.bham.ac.uk>

lpj91100@my-deja.com writes:

> Since I'm new to perl...

What you actually mean is you have not even started to learn Perl.
The questions you ask would be answered in even the most basic Perl
tutorial.  Leaning anything from scratch by asking "how do I do x?",
"how do I do y?" is not efficient.  You have to reach a certain
baseline level of knowledge by following a tutorial (or, if you
already posess related skills, a reference manual) before it makes
sense to ask suvh questions.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 10 Jan 2001 18:21:28 GMT
From: lpj91100@my-deja.com
Subject: Re: counting lines in a file
Message-Id: <93i96r$73o$1@nnrp1.deja.com>

Our comments start with either # or // or are enclosed with /* some
comment */.  They are mainly java files.

I took a look at the FAQ for counting line numbers, I'm not sure what
the $buffer variable is coming from. As you can tell, I am very new to
Perl.

Thanks.

In article <slrn95ofm5.4bc.tadmc@tadmc26.august.net>,
  tadmc@augustmail.com wrote:
> lpj91100@my-deja.com <lpj91100@my-deja.com> wrote:
> >
> >Does anybody have a perl script that counts the
> >numbers of lines of a file,
>
> You are expected to check the Perl FAQ *before* posting to
> the Perl newsgroup:
>
>    perldoc -q count
>
>       "How do I count the number of lines in a file?"
>
> >excluding blank lines
> >and commented lines?
>
> That would depend entirely on what the syntax for a
> "commented line" is. You haven't told us what kind
> of data file you are processing, so we cannot know
> what comments look like.
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas
>


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 19:01:05 GMT
From: Alex Hart <news@#nospam#althepal.com>
Subject: csv revisited
Message-Id: <Rj276.3043$CN6.471319@typhoon2.ba-dsg.net>

I do not think this is in the faq. The faq deals with comma separated
values when the entire entry is enclosed in quotes (,"One
Entry","Another Entry",)  . But in email addresses, often only part of
the entry is enclosed in quotes(,"The Name"<email@domain>,"Num
2"<second@domain>). The regex in the faq would split up the previous
examples into 2 entries each.

I wrote a regex to deal with this, but I'd like some validation.

Can anyone find data that will break this regular expression. I'm
willing to assume that there will be only one set of quotes in the email

("first""name"<first@name.com> is invalid).

$recips is a string with a series of email addresses separated by commas

@to should contain one email address per entry when done

$recips = qq( test@test.com,"Dan"<dan@rob.com>,"Someone
,else",Joe<joe@pete.com>    );
while ($recips =~ m{([^,\"]*(?:".*?")?[^,]*),?}gx) {
    push(@to, $+) if $+;
}


--

- Alex Hart





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

Date: 10 Jan 2001 08:10:28 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: data problems
Message-Id: <87y9wj33cb.fsf@limey.hpcc.uh.edu>

>> On Wed, 10 Jan 2001 02:39:57 -0000,
>> "Ben Graves" <ben.graves@virgin.net> said:

> My web server reports the time incorrectly for the area
> I live, could someone tell me how to get the date and
> time and add six hours to this time.

> I thought I had it working but if the time is changed it
> doesn't update the date if the time goes past midnight.

comp.infosystems.www.servers.<your web server platform here>

how on earth does this have anything to do with perl?

t
-- 
Eih bennek, eih blavek.


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

Date: Wed, 10 Jan 2001 18:26:27 GMT
From: robr@sitera.com
Subject: data structure syntax
Message-Id: <93i9g4$7a2$1@nnrp1.deja.com>

HI Folks,

If I have:

my $ref = {
             "foo"    =>  [ "0", "1" ]
          };

what would be the syntax to push "2" onto the anonymous array?

Thanks,


Rob Root


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 15:17:01 +0100
From: "Marcin Pytlik" <mp@softex.com.pl>
Subject: File
Message-Id: <93hqp5$aad$1@news.polbox.pl>

Hi !
I want to create script to move files
I want one disk (d:\) on this disk I have directories and files. I wan to
choose automiatically files with date (e.g. 2001.01.05). These files I have
to move to disk E:
please help me
MArcin




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

Date: Wed, 10 Jan 2001 17:01:09 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Finding ranges in a list of integers
Message-Id: <slrn95p5b0.pcm.rgarciasuarez@rafael.kazibao.net>


Here's a small problem.

I've a list of integers, sorted in ascending numerical order, like this:
  qw/1 3 4 5 6 7 9 11 12 13 15 16 18 19 20 21 23 24/
and I want to turn it into a string representation : a list of integers
separated by commas, but where ranges of three or more consecutive
integers are written like '1-3'. E.g. the solution for the above list
would be :
  1,3-7,9,11-13,15,16,18-21,23,24
or, alternatively :
  1,3-7,9,11-13,15-16,18-21,23-24
if we allow two consecutive integers to be considered as a range.

I'm looking for smart, short, efficient or funny solutions.

I came up with this one :

  #!/usr/local/bin/perl -w
  use strict;
  my @list = qw/1 3 4 5 6 7 9 11 12 13 15 16 18 19 20 21 23 24/;
  my @r = @list;
  for my $i (2..$#list) {
    $r[$i-1] = ($list[$i-2] == $list[$i]-2) ? '-' : $list[$i-1];
  }
  my $result = join ',', @r;
  $result =~ s/,-(,-)*,/-/g;
  print "@list\n$result\n";

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Wed, 10 Jan 2001 19:04:25 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Finding ranges in a list of integers
Message-Id: <7aitnni5z7.fsf@merlin.hyperchip.com>


rgarciasuarez@free.fr (Rafael Garcia-Suarez) writes:

> Here's a small problem.
> 
> I've a list of integers, sorted in ascending numerical order, like this:
>   qw/1 3 4 5 6 7 9 11 12 13 15 16 18 19 20 21 23 24/
> and I want to turn it into a string representation : a list of integers
> separated by commas, but where ranges of three or more consecutive
> integers are written like '1-3'. E.g. the solution for the above list
> would be :
>   1,3-7,9,11-13,15,16,18-21,23,24
> or, alternatively :
>   1,3-7,9,11-13,15-16,18-21,23-24
> if we allow two consecutive integers to be considered as a range.
> 
> I'm looking for smart, short, efficient or funny solutions.
> 
> I came up with this one :
> 
>   #!/usr/local/bin/perl -w
>   use strict;
>   my @list = qw/1 3 4 5 6 7 9 11 12 13 15 16 18 19 20 21 23 24/;
>   my @r = @list;
>   for my $i (2..$#list) {
>     $r[$i-1] = ($list[$i-2] == $list[$i]-2) ? '-' : $list[$i-1];
>   }
>   my $result = join ',', @r;
>   $result =~ s/,-(,-)*,/-/g;
>   print "@list\n$result\n";

Hmmm, what about:

	use strict;

	my @list = qw/1 3 4 5 6 7 9 11 12 13 15 16 18 19 20 21 23 24/;
	my %hash;

	$hash{$_} = exists $hash{$_ - 1} ? 
		delete $hash{$_ - 1} : $_ for @list;

	print join ',' => map { $_ == $hash{$_} ? $_ : "$hash{$_}-$_" } 
		sort {$a <=> $b} keys %hash;


Without any benchmarking, I would assume it's rather fast.

--Ala


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

Date: Wed, 10 Jan 2001 14:15:27 +0000
From: Nick Condon <nickco3@yahoo.co.uk>
Subject: Re: Frames
Message-Id: <3A5C6E7F.9030701@yahoo.co.uk>

Steve D. wrote:

> Hi,
> I'm new at developing web pages. I just configured and installed
> some perl scripts for a message board I'm working on. I want to know
> if it's ok to use FrontPage 2000 (not FrontPage's Discussion Web Wizard)
> to develop this board using Frames even though I won't be using
> FrontPage's extensions on the hosting server. If it's possible, please
> let me know how. Thanks,

Not really what we do here. Try one of the groups under the 
comp.infosystems.www.* heirachy.



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

Date: Wed, 10 Jan 2001 14:49:54 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Help this newbie learn please :)
Message-Id: <7almsjihrh.fsf@merlin.hyperchip.com>


Paul Boardman <peb@bms.umist.ac.uk> writes:

> Wyzelli wrote:
> 
> > if (@ARGV){
> >     $what = (shift @ARGV);
> > }
> > else {
> >     die "\nUsage ASCII or CHAR: $!\n";
> > }
> 
> sorry to be one of those nit pickers, but I think perl's natural
> language syntax reads much better.
> 
> $what = (shift @ARGV) or die "\nUsage ASCII or CHAR: $!\n";

But this is different from the first snippet. Consider the case when
@ARGV contains a single element: zero. The first snippet will set $what
to zero and continue, but the second one will die().

--Ala


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

Date: Wed, 10 Jan 2001 17:05:15 +0000
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Help this newbie learn please :)
Message-Id: <3A5C964B.55182CD2@bms.umist.ac.uk>

Ala Qumsieh wrote:
> 
> Paul Boardman <peb@bms.umist.ac.uk> writes:
> 
> > Wyzelli wrote:
> >
> > > if (@ARGV){
> > >     $what = (shift @ARGV);
> > > }
> > > else {
> > >     die "\nUsage ASCII or CHAR: $!\n";
> > > }
> >
> > sorry to be one of those nit pickers, but I think perl's natural
> > language syntax reads much better.
> >
> > $what = (shift @ARGV) or die "\nUsage ASCII or CHAR: $!\n";
> 
> But this is different from the first snippet. Consider the case when
> @ARGV contains a single element: zero. The first snippet will set $what
> to zero and continue, but the second one will die().
> 

Fair point, but in this case @ARGV should not contain a zero as only the
strings 'ASCII' or 'CHAR' are valid.

Paul


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

Date: Wed, 10 Jan 2001 18:39:57 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: Help this newbie learn please :)
Message-Id: <3a63abb8.187747950@news.tcn.net>

On Wed, 10 Jan 2001 17:05:15 +0000, Paul Boardman
<peb@bms.umist.ac.uk> wrote:


>> > sorry to be one of those nit pickers, but I think perl's natural
>> > language syntax reads much better.
>> >
>> > $what = (shift @ARGV) or die "\nUsage ASCII or CHAR: $!\n";
>> 
>> But this is different from the first snippet. Consider the case when
>> @ARGV contains a single element: zero. The first snippet will set $what
>> to zero and continue, but the second one will die().
>> 
>
>Fair point, but in this case @ARGV should not contain a zero as only the
>strings 'ASCII' or 'CHAR' are valid.

You could just test $what, make sure its defined:

defined($what = (shift @ARGV)) or die "\nUsage ASCII or CHAR: $!\n";

die "\nUsage ASCII or CHAR: $!\n" unless(defined($what = shift
@ARGV));

Just a thought, but it does seem to solve the zero issue.

--
 Richard Zilavec
 rzilavec@tcn.net


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

Date: Wed, 10 Jan 2001 17:29:24 GMT
From: eggie@REMOVE_TO_REPLYsunlink.net (James Kufrovich)
Subject: Re: HTML stripper
Message-Id: <slrn95p75k.7t4.eggie@melody.mephit.com>

On Wed, 10 Jan 2001 05:31:53 GMT, I <eggie@REMOVE_TO_REPLYsunlink.net>
wrote:
>	if ($message =~ m!<(.*?)>\s*(.*?)\s*</\1>!i) {
>		#error!  contains html.  
>	}
>

	Following up my own post, the following regex will work better,
matching a newline anywhere between the HTML tags:

 m!<(.*?)>(?s:.*?)</\1>!i)

	Basically, the (?s:...) modifier uses single-line mode within that
cluster only, allowing '.' to match any character, including the newline,
which '.' doesn't normally match.  Hrmm, maybe sticking the /s outside of
the entire regex would be better in this case?  Maybe
m!<(\w+)>(.*?)</\1>!si would work?  Are there any valid HTML tags that
don't match (\w+)?

HTH, Jamie

-- 
Egg, eggie@REMOVE_TO_REPLYsunlink.net
FMSp3a/MS3a A- C D H+ M+ P+++ R+ T W Z+ 
Sp++/p# RLCT a+ cl++ d? e++ f h* i+ j p+ sm+


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

Date: Wed, 10 Jan 2001 06:45:12 -0800
From: Marc Pestana <markp@mail1.jpl.nasa.gov>
Subject: Mac Databases and MacPerl
Message-Id: <3A5C73E3.B4C99336@mail1.jpl.nasa.gov>

Hello Group,

I want to create a CGI script in MacPerl that accesses a database. I've
thought of using the DB_File.pm but it requires the Berkeley database
which I don't have loaded on my Mac. Where can I obtain a version of the
BD for a G3? Does anyone know of a MacPerl Newsgroup I could query? Is
there an SQL database for the Mac that I could use instead of the BD?

Thanks, Marc P



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

Date: Wed, 10 Jan 2001 17:04:25 GMT
From: bmurphee@my-deja.com
Subject: Re: Net::Telnet and --More--
Message-Id: <93i4mh$29b$1@nnrp1.deja.com>

so in your script you can end by putting it back to
default which I believe is

term len 24


This thread solved the same problem I was having getting an
expect script to work.  --More-- was causing it to choke.

Now it makes me wonder which is best Net::Telnet or
Expect from the Tcl/Tk toolkit.

Anyone want to debate?

In article <6zm66.22034$Ip3.728952@typhoon.mn.mediaone.net>,
  Paul Thompson <thompson_nospam@athenet.net> wrote:
> I use the Cisco "term len 0" command to get rid of the more for that
session.
>
> Paul
>
> Neil <neil@alaweb.com> wrote:
> : Hi Folks,
>
> : I am having a problem using Net::Telnet when accesing a Cisco
router....
> : When I  run this code... which is a sub in a larger program ... so
please
> : note that all the variables are defined earlier....
>


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 10 Jan 2001 09:50:36 -0600
From: "Neil" <neil@alaweb.com>
Subject: Net::Telnet question
Message-Id: <t5p161lsqstea4@corp.supernews.com>

Hi folks !

I am using Net::Telnet to login to a remote host. I also keep debugging
logs, error logs and check all my returns. This code snippet below is
throwing me off ...

Here is the code snippet....

# initialize the core session
$core_session =
Net::Telnet->new(Host=>$core_ip,Errmode=>'return',Prompt=>$box_prompt);

# initialize the debugging logs for the core or write an error message
$core_log_fh = $core_session->input_log("$debug_file");
if (!$core_log_fh)
   {
   my $error_msg = "unable to open debugging log $debug_file";
   write_error_log("$error_msg  : $core_log_fh");
   }

This last bit actually creates and uses the input_log BUT it also spits out
the error message to my error log.
I assumed, after reading the Net::Telnet docs, that $core_log_fh would
return the filehandle and be non-zero, and therefore no error - and no error
log entry.

Your input is appreciated,
Thanks, Neil





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

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


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