[11710] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5310 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 6 13:06:46 1999

Date: Tue, 6 Apr 99 10:00:18 -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           Tue, 6 Apr 1999     Volume: 8 Number: 5310

Today's topics:
        Anyone help with reading from data file?  Read here. <D@nt.Email.Me>
    Re: constructing a list of hashes <jglascoe@giss.nasa.gov>
    Re: Cookies <cassell@mail.cor.epa.gov>
    Re: devide a formular into two html-pages <vvb@xibm.net>
    Re: Elegant parsing of HTML title and metatags? <vvb@xibm.net>
    Re: Elegant parsing of HTML title and metatags? <jglascoe@giss.nasa.gov>
    Re: flocking question - worried (Jonathan Stowe)
    Re: I can't use alarm :( <cosmas.lang@uni-mainz.de>
    Re: I can't use alarm :( (Jonathan Stowe)
    Re: Installed Perl 5.005_02, what are the paths? (Jonathan Stowe)
        Installing CPAN modules <donny@impulsesoftware.com>
    Re: is there any ceiling function in perl? <jdf@pobox.com>
        leap year? du_bing@my-dejanews.com
    Re: leap year? (Larry Rosler)
    Re: perl and y2k (was Re: The millennium cometh -- even <cassell@mail.cor.epa.gov>
    Re: Premature end of script headers <upsetter@ziplink.net>
    Re: Premature end of script headers <cassell@mail.cor.epa.gov>
        Problems connecting to Oracle 8 from Perl using DBI (Bill Morgan)
    Re: Sorting lines. <cassell@mail.cor.epa.gov>
        switch statement? du_bing@my-dejanews.com
    Re: switch statement? (Greg Bacon)
    Re: switch statement? (Larry Rosler)
    Re: switch statement? (Sean McAfee)
    Re: Urgent: Document contains no data <sjenifer@geo.census.gov>
        variable trace for C code <prochak@my-dejanews.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 6 Apr 1999 08:42:30 -0700
From: "Freaky" <D@nt.Email.Me>
Subject: Anyone help with reading from data file?  Read here.
Message-Id: <370a2bfe@news.greatbasin.net>

Does anyone know how to read a data file in reverse order? I use the format
open (HEADERREAD, "$file3") or die "Unable to open...
and it will only read in normal order.  Im just curious if theres a way to
reverse it.  Thanks.

--
+++++++++++++++++++++++++++++++++++++++++++++++
     Freaky - warfreak@nospam.psynet.net
     Sharing My Opinion To Better Humanity
     Remove NoSpam In My E-Mail Address To E-Mail Me.
+++++++++++++++++++++++++++++++++++++++++++++++




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

Date: Tue, 06 Apr 1999 11:51:05 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
Subject: Re: constructing a list of hashes
Message-Id: <370A2D69.8BE6591E@giss.nasa.gov>

Uri Guttman wrote:
> 
> that is an unstable version of perl. maybe it will work in 5.003 when it
> comes out.

no, unfortunately these shennanigans don't work for 5.005_03

	Jay Glascoe


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

Date: Tue, 06 Apr 1999 09:44:03 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Cookies
Message-Id: <370A39D3.F62F0660@mail.cor.epa.gov>

 . . wrote:
> 
> Does anyone have any cookie libraries or an example on how to
> set/retrieve cookies? I tried MSA's cookie.lib but it generated the
> error:
> Premature end of script headers
> when I added the cookie functions.. ?
> Email me if youcan..

Well, . . [if I may use your first name :-], I strongly suggest
that you check out the CGI.pm module written by Lincoln Stein.
It's available on CPAN (and if you don't know what that is, go 
to www.perl.org and look there - you'll get multiplexed to a
CPAN repository near you).  And there's a book on CGI.pm by
the author that will help too, although the module comes with
lots of docs and examples, which may be all you need.

In future, you might first try to isolate whether your problem
really is Perl-related or cgi-related.  Then if the problem
is really more cgi-related, post to 
comp.infosystems.www.authoring.cgi where they can give you more
web-related help.  And where they won't rag on you for posting
a cgi question to a language newsgroup.  :-)

HTH, 
David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 6 Apr 1999 18:13:22 +0200
From: "Vincent Vanbiervliet" <vvb@xibm.net>
Subject: Re: devide a formular into two html-pages
Message-Id: <370a3239@news.uk.ibm.net>


Maik Wiege <101.48179@germanynet.de> wrote in message
news:7ed116$3tq$1@newshost.germany.net...
> I want to devide my long form into two small forms on two html-pages.
> On the second page the CGI-Perl-program needs to recognise, from whom the
second data was sended and the program must concat the new data with the
data sended on the first page.

Use your first script to re-enter the data of the first form in the second
form. But use <input type="hidden" ...> kinda things...
Of course you would have to generate the second form with Perl...

> My idea is to do this using cookies to save the data of the first page on
the host and than send the stored data and the data of the seond data to the
program. But I do not want to use JavaScript and Cookies. Is there any other
way to do this. Is ist possible to get the IP-Adress of the Host, to
identify his computer?

$ENV{REMOTE_ADDR} will give the IP address
$ENV{REMOTE_HOST} gives the host name (I think only if your webserver
translates ip addresses by default)
Of course if they identified themselves in the first form, you wouldn't need
this data anymore.

Vincent Vanbiervliet
Learning Technologies, IBM
http://learn.ibm.be

>
> Thank you very much
>
>  Maik
>
>
>
> Maik Wiege
> Berlin
> MSWiege@gmx.de
> http://members.aol.com/langeness
> http://www.spsberlin.de
>
>
>
>




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

Date: Tue, 6 Apr 1999 18:03:44 +0200
From: "Vincent Vanbiervliet" <vvb@xibm.net>
Subject: Re: Elegant parsing of HTML title and metatags?
Message-Id: <370a2ff7@news.uk.ibm.net>

This is a script that works. I've numbered the lines, and under the script
I've commented the lines that need clarification.

1 $filename = "test1.html";
2 open FILE, $filename or die "Can't open file $filename: $!\n";
3 undef $/;
4 $pagetext=<FILE>;
5 $/="\n";
6 close FILE;

7 ($title=$pagetext)=~s/.*<TITLE>(.*)<\/TITLE>.*/$1/is;
8 chomp $title;
9 $title=($title)?$title:"No title found.";

10 $lcpagetext=lc $pagetext;
11 $pos=-1;
12 while ( ( $pos=index($lcpagetext, '<meta', $pos) ) > -1) {
13 $meta=substr $pagetext, $pos, index($pagetext,'>',$pos)+1-$pos;
14 ($name=$meta)=~s/.*?\"(.*?)\".*/$1/is;
15 ($val=$meta)=~s/.*\"(.*?)\".*/$1/is;
16 $meta{$name}=$val;
17 $pos++;
18 }

19 foreach $metakey (sort keys %meta) {
20  print "Title: $title\n";
21 print "$metakey:\t $meta{$metakey}\n";
22 }

Comments:
2: You may want to use errortracking, in case the file isn't found... $! is
the errormessage.
3: $/ is the input separator, and defaults to \n. By undef'ing it, the whole
file will be read using the <> operator.
7: I'm using s/// instead of m//.
   If you do $a=~s/.../.../;, $a is searched AND modified.
   By using ($b=$a)=~s///;, $a is searched, $b gets the value of the
substitution
8: chomp: see camel book
9: if no title is found, make $title equal to string "No title found."
10: make it lowercase to search
11-18: looks complicated, but isn't
       $meta equals every '<meta ...>' string
14: I'm parsing on the first '"' ... '"', by making the search minimal
(using the '?')
    So, $name will be <meta identifier="$name"...>, because identifier can
also be 'http-equiv', 'id' or 'content', not only 'name'.
15: Not using the '?', and since perl will try to match as greedy as
possible, it will take the last '"' ... '"'

16: Store your values, and ...
19-22: ... print them.

Et voila!

> - it may be memory inefficient and slow for large files - do I have to
> read the whole file into memory, or is there a cute way of doing this
> reading line by line?
> - I have heard that using $1 and $2 has an overhead and ideally I'd like
> to avoid that
>

PS:
1. The only way to read the file partially, would be to read line by line,
and stop after '<head>'. Of course assuming
   that your html files follow the regular syntax.
2. I don't know about $1 and $2. I use them.





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

Date: Tue, 06 Apr 1999 12:37:23 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Neale Morison <nmorison@ozemail.com.au>
Subject: Re: Elegant parsing of HTML title and metatags?
Message-Id: <370A3843.ED64A39B@giss.nasa.gov>

Neale Morison wrote:
> 
> I'd appreciate any help. I'm new to regexs and I'm looking for the most
> elegant and efficient syntax.

use strict;

my $s = do {
    local $/, *FH;
    open FH, "< index.html" or die $!;
    <FH>;
};

my @metas = ($s =~ m#<META>(.*?)</META>#gis);
my ($title) = ($s =~ m#<TITLE>(.*?)</TITLE>#is);

print "title: $title\n";
print "metas: @metas\n";

	Jay Glascoe


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

Date: Tue, 06 Apr 1999 15:06:25 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: flocking question - worried
Message-Id: <370a229e.26005165@news.dircon.co.uk>

On 06 Apr 1999 08:50:53 -0400, Jonathan Feinberg <jdf@pobox.com>
wrote:

>"Chris Denman" <c-denman@dircon.co.uk> writes:
>
>> The flocking side of things is not a problem, I am just worried what
>> happens when a file is locked and the server crashes before the file
>> is unlocked.
>
>If your web server crashes often enough that this is an issue, you
>have *much* bigger problems than your hit counter.
>

Must be ICL DRS/NX ;-}

/J\


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

Date: Tue, 06 Apr 1999 17:48:37 +0200
From: Cosmas Lang <cosmas.lang@uni-mainz.de>
Subject: Re: I can't use alarm :(
Message-Id: <370A2CD5.7BD3D70F@uni-mainz.de>

Fernando Ariel Gont wrote:
> 
> Hola All , llego la alegria!! :D
> 
> I wanted to use alarm to timeout a function. I tried to make a little
> script to "test" it, but I got an error message... :(
> 
> And here's the error message I got:
> 
> The Unsupported function alarm function is unimplemented at alarm.pl line 6.
> 
> What's wrong?

alarm must be supported by your OS. For example, in perl on windows
there is no
alarm function as far as I know.

Where are you running on?
---------
Cosmas Lang  (Cosmas.Lang@Uni-Mainz.DE)

***************************************************************
*  Homepage: http://www.Uni-Mainz.DE/~langc/my_homepage.html  *
***************************************************************


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

Date: Tue, 06 Apr 1999 15:49:06 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: I can't use alarm :(
Message-Id: <370a2cb5.28587874@news.dircon.co.uk>

On Tue, 06 Apr 99 04:24:31 -0700, Fernando Ariel Gont
<Fernando.Ariel.Gont@p10.f3.gonzo.circuit.com> wrote:

>
>
>Hola All , llego la alegria!! :D
>
>I wanted to use alarm to timeout a function. I tried to make a little
>script to "test" it, but I got an error message... :(
>
>Here's the script:
>
>/* (ALARM.PL)
>#! /local/bin/perl
>
>use strict;
>
>$SIG{'ALRM'}= \&mi_alarma;
>alarm(10);
>
>sub mi_alarma{
>        print "Recibm una se1al de alarma!\n";
>}
>        */
>
>
>And here's the error message I got:
>
>The Unsupported function alarm function is unimplemented at alarm.pl line 6.
>
>
>What's wrong?
>

What does it say in the perldiag document about that message?

/J\


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

Date: Tue, 06 Apr 1999 15:01:35 GMT
From: gellyfish@gellyfish.com (Jonathan Stowe)
Subject: Re: Installed Perl 5.005_02, what are the paths?
Message-Id: <370a2184.25722704@news.dircon.co.uk>

On Sun, 04 Apr 1999 18:32:44 +0000, "WebMaster of WebKnights.com"
<webmaster@webknights.com> wrote:

>Hello! I installed Perl 5.005 and I don't have any clue what the paths
>are. I installed Perl into C:\Perl if that helps. I need to know all of
>the most commonly used paths, pleeeease. 

C:\> PATH

>                                         Also, when I run a Perl script
>using my webserver (MS WebServer, which is running on my local hard
>drive, not on the web), but the browser doesnt seem to want to run it.
>It wants to download it! Please help!
>

This is a web server configuration problem.

/J\


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

Date: Tue, 06 Apr 1999 15:33:46 GMT
From: Donny Widjaja <donny@impulsesoftware.com>
Subject: Installing CPAN modules
Message-Id: <370A29EC.E47E3B8@impulsesoftware.com>

Hi,

I have a question about installing CPAN modules.
I try to install a CPAN module on my virtual server (I am not a root and
I can't be a root).
I do it in the following step "perl Makefile.pl", "make" and 'make
install PREFIX="usr/local"'.

The problem occurs in the 'make install PREFIX="usr/local"', and these
are the output that I got.

Installing usr/local/lib/perl5/site_perl/./IO/stty.pl
Installing usr/local/lib/perl5/site_perl/./IO/Stty.pm
Writing usr/local/lib/perl5/site_perl/i386-bsdos/auto/IO/Stty/.packlist
/bin/sh: cannot create
usr/local/lib/perl5/i386-bsdos/5.00404/perllocal.pod: dir
ectory nonexistent
*** Error code 2

When I checked, the
"usr/local/lib/perl5/i386-bsdos/5.00404/perllocal.pod" is exist and in
the right directory.

Please help me !!! 
Thanks


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

Date: 05 Apr 1999 23:06:18 -0400
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: is there any ceiling function in perl?
Message-Id: <m3wvzqla6t.fsf@joshua.panix.com>

Don Roby <droby@copyright.com> writes:

> sub myceil { ($_[0] != int $_[0]) - ($_[0] < 0) + int $_[0] }
> sub myfloor { int $_[0] - ($_[0]<0) }
> 
> which is certainly more fun.  ;-)

But, sadly, just as wrong.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 06 Apr 1999 15:45:47 GMT
From: du_bing@my-dejanews.com
Subject: leap year?
Message-Id: <7eda79$2vg$1@nnrp1.dejanews.com>

Hi there,

How to judge if the current year is a leap year or not in Perl?  There should
be a formula.  Unfortunately I forgot.

Thanks in advance for your help,
Bing

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 6 Apr 1999 09:29:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: leap year?
Message-Id: <MPG.1173d63f2ff16446989848@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7eda79$2vg$1@nnrp1.dejanews.com> on Tue, 06 Apr 1999 
15:45:47 GMT, du_bing@my-dejanews.com <du_bing@my-dejanews.com >says...
> How to judge if the current year is a leap year or not in Perl?  There should
> be a formula.  Unfortunately I forgot.

A search in DejaNews (you know about DejaNews? -- that's where you 
posted from) of this newsgroup for 'leap year' yields about 200 entries.  
Surely one of them will be what you want.

(Yes, I could write it out off the top of my head, and yes, someone else 
surely will, but why not figure out how to find things for yourself?)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 06 Apr 1999 09:34:49 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: perl and y2k (was Re: The millennium cometh -- eventually)
Message-Id: <370A37A9.752414F9@mail.cor.epa.gov>

Sam Holden wrote:
> David L. Cassell <cassell@mail.cor.epa.gov> wrote:
> >George wrote:
> >>
> >> $is_2000 = 0;
> >> if ($year>=100) { $is_2000 = 1;
> >>                $year = $year - 100; }
> >> if ($year<10) { $year = "0" . "$year"; }
> >> if ($is_2000) { $year = "20" . "$year"; }
> >> if ($year<100) { $year = "19" . "$year"; }
> >>
> >> That gives a nicely formatted date.. like 1999 or 2003..
> >
> >George, I don't want to be difficult, but wouldn't it be easier
> >just to say:
> >    $year += 1900;
> >
> 
> Also what happens if through some strange twist not only are people
> still alive, and the calender hasn't been changed, but perl is still
> being used in 2100?
> 
> Of course we won't be using 32 bit time_t's then. As if. That'd be
> like still using two digit dates in the year 1999...
> 
> --
> Sam
> 
> There's no such thing as a simple cache bug.
>         --Rob Pike

If you really want a thorough discussion of this problem, check 
comp.risks digest 20.27 [I think - this is strictly from memory]
released on April Fool's day, for a post covering the Y10K and
Y100K problems.  A very far-seeing document.  :-)
 
David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 06 Apr 1999 15:51:50 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Premature end of script headers
Message-Id: <q4qO2.34$i06.5296@news.shore.net>

Uri Guttman <uri@home.sysarch.com> wrote:

: aren't those "retronyms" or acronyms made up after the word existed.

: my favorite (or really most hated) is ping which got its name from the
: ping used by submarine sonar which would echo back from submerged
: objects. it was never an acronym, but i have seen in print (it must be
: true! :-) the acronym 'packet internet groper', about as absurd a
: definition as one could hope for.

Speaking of 'ping', this is quite humorous:

http://www.amazon.com/exec/obidos/ASIN/0140502416/o/qid=923413794/sr=2-1/002-3644015-3553857

(Sorry if the url gets wrapped). Be sure to scroll down to the book
reviews.

--Art
-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Tue, 06 Apr 1999 09:22:37 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Premature end of script headers
Message-Id: <370A34CD.1B91F026@mail.cor.epa.gov>

Larry Rosler wrote:
> [Posted and a courtesy copy mailed.]
> In article <m1zp4mad7k.fsf@halfdome.holdit.com> on 05 Apr 1999 15:56:31
> -0700, Randal L. Schwartz <merlyn@stonehenge.com> says...
> > >>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
> >
> > Larry> Can you point to a use of P[eE][rR][lL] as an acronym in any of the
> > Larry> official Perl docs?  I know it isn't in perlfaq1.
> >
> > You're gonna scream when you see how easy it is to answer you!
> >
> >     perldoc perl =>
> >
> >     NAME
> >          perl - Practical Extraction and Report Language
> >     [...]
> >          Perl actually stands for Pathologically Eclectic Rubbish
> >          Lister, but don't tell anyone I said that.
> 
> SCREEEEAM!!!!!   (But sssh -- it's a secret :-)
> 
> Now I'm frantically searching the Web and my bookshelf for anyplace
> where The Real Larry disavows that.  Help, anyone???
> 
> (The Blue Camel, p. 555, implies that it is a retro-acronym from
> 'Pearl', which is quite believable.  Basic is obviously such a beast,
> while Cobol and Fortran obviously are not.  And then there is C.  :-)

Hmm, when I read this I interpreted this as evidence that Perl is
an acronym, albeit not the first acronym chosen for the language.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 06 Apr 1999 16:19:56 GMT
From: wmorgan@nswc.navy.mil (Bill Morgan)
Subject: Problems connecting to Oracle 8 from Perl using DBI
Message-Id: <7edbpe$3ks$1@oanews.nswc.navy.mil>

I am running the latest version of Active State Perl under NT 4.0 and trying 
to connect to 
an Oracle 8 database with DBI.  Here is the code I am using:

use DBI;

$ENV{'ORACLE_HOME'}  = "E:\ORANT";
$ENV{'ORACLE_SID'} = "ORCL";

$dbh = DBI->connect("dbi:Oracle:my_db", "username", "password");

if ( !defined $dbh) {
  die "Cannot connect to Oracle database: $DBI::errstr\n";
}

exit;

I get the following error message:

Cannot connect to Oracle database: ORA-03121: no interface driver connected - 
function not performed (DBD: login failed)

I can connect via ODBC using these statements:

use Win32::ODBC;
$database = "DRIVER={Oracle ODBC Driver};DBQ=my_db;UID=username;PWD=password";
$db = new Win32::ODBC($database)

so I know my database connectivity is there,
but I can't figure out what I am doing wrong with DBI.  Any help you can 
provide would be greatly appreciated!  Please email any replies as well as 
posting to this group.
Thanks.

---------------------------------------------------------------------------
William E. Morgan       NAVAL SURFACE WARFARE CENTER
Code N84                     email: wmorgan@nswc.navy.mil
17320 Dahlgren Rd.     phone: (540)653-6088
Dahlgren, VA  22448   fax: (540)653-1810



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

Date: Tue, 06 Apr 1999 09:56:10 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Sorting lines.
Message-Id: <370A3CAA.78EBB519@mail.cor.epa.gov>

Todd LaWall wrote:
> jambutter@my-dejanews.com wrote:
> >
> > I want to sort the lines of a file, is there anyway to do this
> > without using an array?

Why not an array?  It's a lot cheaper [unless your file is *huge*]
to read the lines into an array [usually one named more mnemonically
than 'array' BTW] and do the sort there, than to spend all your
time reading lines and swapping to disk and writing your own sort
code in order to avoid using an array.
 
> Probably.  But since it's the end of the day, and I'm a little fried,
> I'm not going to try to think about it.  I'll just answer you're
> question below instead...
> 
> > I've assumed so and am trying to use an array. Each element of the
> > array will be something like "abc.def". I want to sort on everything
> > after the '.' (if equal, ideally, I'd like to then search on
> > everything before the '.').
> >
> > This is what I've tried so far:
> >
> > @array = sort by_afterdot @array.
> >
> > sub by_afterdot
> > {
> >         $a =~ /\./;
> >         $a = $';
> >         $aa = $`;
> >
> >         $b =~ /\./;
> >         $b = $';
> >         $bb = $`;
> >
> >         ($a cmp $b) || ($aa cmp $bb);
> > }
> >
> > Unfortunately, I do not seem to get anywhere near the result I want
> > when I do a print.
> >
> > What am I doing wrong?

Todd has answer #1 below.  $a and $b are special variables.  Don't
use them except in blocks and subroutines for sort(), and don't 
modify them even in that sort() subroutine.

Answer #2: what you're really doing wrong is not using the Perl
docs to their fullest.  Type 'perldoc -q sort' and get some fast
guidance on sorting.. plus a URL to tchrist's guide to Far More 
Than Everything You Ever Wanted To Know about sorting anything
on anything.
 
> Well, for starters, I'm going to take a stab at saying that you've done
> something to sabotage your sort: you've modified the actual data you're
> trying to sort.  The book states that $a and $b should not be modified
> because they are passed in by reference, so I'm going to suggest that
> you change the temp variables you use to avoid problems.  If I were to
> rewrite your code, I might do something like (and yes, I tested it):
> 
> sub by_afterdot {
>         $a =~ /\./;
>         $temp_a = $';
>         $temp_aa = $`;
> 
>         $b =~ /\./;
>         $temp_b = $';
>         $temp_bb = $`;
> 
>         ($temp_a cmp $temp_b) || ($temp_aa cmp $temp_bb);
> }
> 
> > Also, if I am trying to get everything after the . of a string, is
> > the method I've used best?  Or should I use split?
> 
> It works, so change it only if you wish.  I suspect it might increase
> your run time, due to an extra function call, but that's only
> speculation.
> 
> HTH,
> Todd
> --
> use Disclaimer qw(This is my own opinion not my employers);

Umm, maybe I'll pass and let Larry or Sam or Tad comment on this code.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 06 Apr 1999 15:22:30 GMT
From: du_bing@my-dejanews.com
Subject: switch statement?
Message-Id: <7ed8rf$1kn$1@nnrp1.dejanews.com>

Hi there,

Does Perl support switch/case statement?  For example:

switch $month of
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: {print "there are 31 days in this month"; break;}
}

If not, do I have to use if/else?

Any idea would be welcomed.

Bing

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 6 Apr 1999 15:55:22 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: switch statement?
Message-Id: <7edapa$2k9$1@info2.uah.edu>

In article <7ed8rf$1kn$1@nnrp1.dejanews.com>,
	du_bing@my-dejanews.com writes:
: Does Perl support switch/case statement?

RTFFAQ.

Greg
-- 
Bluto: My advice to you is to start drinking heavily.
Otter: Better listen to him, Flounder. He's pre-med.


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

Date: Tue, 6 Apr 1999 09:00:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: switch statement?
Message-Id: <MPG.1173cf7f85850c62989847@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <7ed8rf$1kn$1@nnrp1.dejanews.com> on Tue, 06 Apr 1999 
15:22:30 GMT, du_bing@my-dejanews.com <du_bing@my-dejanews.com >says...
> Does Perl support switch/case statement?
 ...
> If not, do I have to use if/else?

perlfaq7:  "How do I create a switch or case statement?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 06 Apr 1999 16:27:28 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: switch statement?
Message-Id: <QBqO2.1489$9Y5.7390177@news.itd.umich.edu>

In article <7ed8rf$1kn$1@nnrp1.dejanews.com>,  <du_bing@my-dejanews.com> wrote:
>Does Perl support switch/case statement?

No.  See perlfaq7.

>For example:

>switch $month of
>{
>case 1:
>case 3:
>case 5:
>case 7:
>case 8:
>case 10:
>case 12: {print "there are 31 days in this month"; break;}
>}

>If not, do I have to use if/else?

No, it's much easier than that.

@thirty_one{ 1, 3, 5, 7, 8, 10, 12 } = ();

print "there are 31 days in this month" if exists $thirty_one{$month};

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Tue, 06 Apr 1999 11:20:37 -0400
From: "Shade L. Jenifer" <sjenifer@geo.census.gov>
Subject: Re: Urgent: Document contains no data
Message-Id: <370A2645.98689908@geo.census.gov>

Thanks to everyone who responded.

It turns out that the perl code was attempting
to divide by 0....ouch.

Shade L. Jenifer wrote:

> Hello developers,
>
> I have a problem that needs immediate attention and
> our resources here (ie books) are scarce.  I have
> a CGI perl script that causes my browser (Netscape
> 4.0 running on an SGI/IRIX OS) to pop up an
> alert window saying:
>
> Document contains no data.
>
> Normally, this tells me that I have a syntax error in
> my script.  However, when I run the script from the
> command line, I get no errors.  Are there any other
> reasons why such an alert is generated?
>
> Quick response is greatly appreciated.
>
> -shade l. jenifer
> --

--
Shade L. Jenifer
Systems Engineer
NWS Consulting, Inc.

Census Bureau: GEO/MSB
sjenifer@geo.census.gov
(301) 457-1073




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

Date: Tue, 06 Apr 1999 16:21:43 GMT
From: Ed Prochak <prochak@my-dejanews.com>
Subject: variable trace for C code
Message-Id: <7edcaf$4mo$1@nnrp1.dejanews.com>



I need some code to parse C code for uses of a particular structure. I cannot
just look for the original variable, I need to find all the uses of each field
in the structure. Something like cflow, but it follows the data assignments
instead of the call tree. Any ideas?

It will need to be able to understand C syntax somewhat in order to follow
the assignments. Somebody must have done something similar for Y2K
conversions. Now you can use that code for other things.

The specific problem is: the data structure in question comes in to the
program, some of the fields are used/modified/whatever but others are never
touched, finally the structure is stored in a database.

The desired goal is to store in the database only the fields that are used.

It is expected that only part of the structure, maybe a third, is used, so
the space savings could be (substancial/substansial/substantial drat!)
significant. Finding something even close that I could modify would make my
client very happy. He really doesn't want to do it manually, which may be the
only alternative.

Thanks to all in advance!!!
   ed


Ed Prochak
Magic Interface, Ltd.
ORACLE services
440-498-3702

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

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 5310
**************************************

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