[11929] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5529 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 30 16:07:15 1999

Date: Fri, 30 Apr 99 13:00:27 -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           Fri, 30 Apr 1999     Volume: 8 Number: 5529

Today's topics:
    Re: a better way??? <aqumsieh@matrox.com>
        Concatenating files with PERL <psychout@pacbell.net>
    Re: Concatenating files with PERL (Sean McAfee)
    Re: Concatenating files with PERL <tchrist@mox.perl.com>
    Re: Concatenating files with PERL (Larry Rosler)
        DB_File (Floridashe)
        Dynamic loading perl modules <vpatricio@abrantina.pt>
    Re: Dynamic loading perl modules <t-armbruster@ti.com>
        Fill a listbox or Pull_down <l463520@lmtas.lmco.com>
        Help: Accessing Telnet via Perl (Nelson Kulz)
        How does return work in END block? <tbc@col.hp.com>
    Re: JavaScript/PERL for dynamic form generation <t-armbruster@ti.com>
    Re: Moving the Perl distribution - global @INC problem (Tad McClellan)
    Re: Newsfeed and Local Weather (I R A Aggie)
    Re: Newsfeed and Local Weather <tchrist@mox.perl.com>
        NT Perl vs UNIX Perl <jim.ray@west.boeing.com>
        ODBC PROBLEMS ! Please help. Is it Microsoft?? rich@greedo.partnersweb.com
        ODBC PROBLEMS ! Please help. Is it Microsoft?? rich@greedo.partnersweb.com
        RegExp for escape characters swistow@my-dejanews.com
    Re: Regexp or subst (Tad McClellan)
    Re: Regexp or subst (Larry Rosler)
    Re: Simple Checksum "Confidence Level"?? <emschwar@rmi.net>
        SSub-routine names sithlar@my-dejanews.com
    Re: SSub-routine names <tchrist@mox.perl.com>
    Re: Sybase::DBlib and Two Phase commit <mpeppler@peppler.org>
    Re: using perl to manage passwords? (Michel Dalle)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 30 Apr 1999 11:17:48 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
To: mudin@expert.cc.purdue.edu (Meling Mudin)
Subject: Re: a better way???
Message-Id: <x3y3e1i6sth.fsf@tigre.matrox.com>


mudin@expert.cc.purdue.edu (Meling Mudin) writes:

> Can anyone suggests a better way of doing this .... I am losing
> my head and errrghhh!!!! 

Calm down .. it's only a program :)

> When the program runs, it's suppose to look for user(s) that is/are
> connected from different hosts. I have initialization error
> pointing to the line:
>   if (exists ($hash{$user}{$from}))

This usually means that $user and/or $from are undefined.

> Anyone have any idea how to fix it?
> 
> -mel
> 
> ---- code ---
> # check if a user is remotely logged in from
> # two different host
> 
> use strict;
> 
> my $cmd = "/bin/who";
> my $line = "";
> my $user;
> my $from;
> my @myline = ();
> my %hash = ();
> my $count = 0;
> my $from_here ="";
> 
> open (WHO, "$cmd |") or die "can't execute who: $!\n";
> 
> while (<WHO>) {
> 	
> 	# split the lines
> 	@myline = split /[((\t)+)((\s)+)]+/; 

You want to split on one or more tabs or one or more white space
characters. Well, tabs ARE whitespaces :)
But, the best way to do what you want is simply:

	@myline = split;

This is exactly identical to:

	@myline = split ' ', $_;

Check out the split() documenation for info on the ' ' pattern for
split() .. it's magical.

> 	$user = $myline[0];
> 	$from = $myline[5];

You can save some key strokes by:

	($user, $from) = (split)[0, 5];

and you don't need @myline anymore.
Note that the fifth field might not actually exist. (Do a 'who' and
see for yourself). So the value of $from might be undef. I suggest you
set it to something like "UNKNOWN" if so.

	$from = 'UNKNOWN' unless defined $from;

This will solve it for you.

> 	# store the stuff into a hash 
> 	
> 	if (exists ($hash{$user}{$from})) {
> 		$hash{$user}{$from}++;
> 	}
> 	else {
> 		$hash{$user}{$from} = 0;

Shouldn't that be:

		$hash{$user}{$from} = 1;

??

> 	}
> }
> 
> foreach $user (sort keys %hash) {
> 	$count = 0;
> 	$from_here = "";
>     foreach $from (sort keys %{$hash{$user}}) {
> 		$count++;
> 		$from_here.="$from ";
> 	 	# print "$user==>$from \n";
> 	}
> 	# print $count."\n";
> 	if ($count > 1) {
> 		print "$user : $from_here\n";
> 	}
> }

HTH,
Ala



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

Date: Fri, 30 Apr 1999 18:36:17 GMT
From: "psychout" <psychout@pacbell.net>
Subject: Concatenating files with PERL
Message-Id: <01be9336$7635b1a0$0201010a@psychout>

I'm new to PERL and trying to figure out how to use PERL to concatenate 3
files together into one file on an NT system. Can anyone help me?
Thanks.


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

Date: Fri, 30 Apr 1999 18:48:02 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Concatenating files with PERL
Message-Id: <CVmW2.231$OZ6.8602@news.itd.umich.edu>

In article <01be9336$7635b1a0$0201010a@psychout>,
psychout <psychout@pacbell.net> wrote:
>I'm new to PERL and trying to figure out how to use PERL to concatenate 3
>files together into one file on an NT system. Can anyone help me?

It's easy; you just have to ask the interpreter nicely.  Be sure to use
the Magic Word!

perl -please_concatenate_these_files file1 file2 file3 > bigfile

-- 
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: 30 Apr 1999 12:54:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Concatenating files with PERL
Message-Id: <3729fc56@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "psychout" <psychout@pacbell.net> writes:
:I'm new to PERL and trying to figure out how to use PERL to concatenate 3
:files together into one file on an NT system. Can anyone help me?

Man, it sure sucks to be screwed out of proper tools, doesn't it?

    % cat f1 f2 f3 > f4

Go to http://language.perl.com/ppt/ to get a set of Perlian replacement tools
for those poor unfortunates such as yourself. :-)

--tom "you'll get my tools when you pry 'em outta my dead hands" christiansen
-- 
    It's documented in The Book, somewhere...
            --Larry Wall in <10502@jpl-devvax.JPL.NASA.GOV>


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

Date: Fri, 30 Apr 1999 12:07:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Concatenating files with PERL
Message-Id: <MPG.11939f3cb4b3607d989985@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <01be9336$7635b1a0$0201010a@psychout> on Fri, 30 Apr 1999 
18:36:17 GMT, psychout <psychout@pacbell.net> says...
> I'm new to PERL and trying to figure out how to use PERL to concatenate 3
> files together into one file on an NT system. Can anyone help me?
> Thanks.

Same as anywhere.

  perl -pe1 file1 file2 file3 >one_file

If you want filename wild-card expansion, the standard so-called command 
processor, cmd.exe, won't do it.  But Perl can do it just fine.

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


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

Date: 30 Apr 1999 19:22:19 GMT
From: floridashe@aol.com (Floridashe)
Subject: DB_File
Message-Id: <19990430152219.17263.00000334@ng153.aol.com>

I a trying to create a database for a site I am building....I have purchased a
Perl 5 "How-To" and it gives code and examples for creating a database with
Perl, using the dbmopen() and dbmclose().  I am getting a error message that
follows:

auto/DB_File/autosplit.ix in @INC at c:\Perl\lib/AutoLoader.pm line 153.  at
DB_File.pm line 161 can't find loadable objectfor module DB_File in @INC at
convert.pl line 5  Begin failed-- compilation aborted at convert.pl line 5

I don't know what library I need to make this work...any suggestions would be
greatly appreciated



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

Date: 30 Apr 1999 17:17:35 GMT
From: "Vasco Patrmcio" <vpatricio@abrantina.pt>
Subject: Dynamic loading perl modules
Message-Id: <01be932d$5534fd20$3f0a0a0a@vpatricio>

To anyone who is kind enough to answer:

I'm building a web application that has a main service that provides access
to several distinct services. Each service is coded in a separate perl
module (a .pm file). Right now, I had to include all the modules in the
main service (via "use").

I think there must be a way of loading only the module that the user asks
for. I searched the Camel book and only found documentation about
DynaLoader, which, if I understood correctly, only loads previously
compiled libraries.

My question is:

How do I load a perl module dynamically? Do I have to compile it first?

Thanks,
Vasco


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

Date: Fri, 30 Apr 1999 14:48:25 -0500
From: "Tim Armbruster" <t-armbruster@ti.com>
Subject: Re: Dynamic loading perl modules
Message-Id: <4SnW2.1$Zd2.53@dfw-service1.ext.raytheon.com>


Vasco Patrmcio wrote in message <01be932d$5534fd20$3f0a0a0a@vpatricio>...
>My question is:
>
>How do I load a perl module dynamically? Do I have to compile it first?
>


You might try reading the README document that came with the module,
assuming there is one.  If not, comp.lang.perl.modules is more suited to
this type of question.




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

Date: Fri, 30 Apr 1999 12:34:55 -0500
From: Michael Hill <l463520@lmtas.lmco.com>
Subject: Fill a listbox or Pull_down
Message-Id: <3729E9BF.105DF259@lmtas.lmco.com>

All,

I have this code that retrieves data from Oracle and I want to populate
a web listbox or pull_down. It is not working, the output is:

parta partb partc

The HTML equavalent is:

<select name="parts">
<option value="parta"> Parta
<option value="partb"> Partb
<option value="partc"> Partc
</select>

print "Content-type:text/html\n\n";
print <<EndOfHTML1;
<HTML>
<HEAD>
<TITLE>test</TITLE>
<BODY>
<SELECT NAME="ROWS">
EndOfHTML1
;

use DBI;

$drh = DBI->connect( "<connect string>");
$sth = $drh->prepare( "<sql statemaent>);

#execute the statement at the database level
$rc = $sth->execute;

while ( @row = $sth->fetchrow() )
 {
 print "<OPTION value>$row[0]\n";
 }
print <<EndOfHTML2
</SELECT> >
</BODY>
</HTML>
EndOfHTML2
;



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

Date: Fri, 30 Apr 1999 12:14:39 -0700 (PDT)
From: RedXI@webtv.net (Nelson Kulz)
Subject: Help: Accessing Telnet via Perl
Message-Id: <6619-372A011F-43@newsd-113.bryant.webtv.net>

I know this may be a bit much to ask, but does anyone have source for a
program in Perl that can access telnet (that only uses CGI.pm, CPAN.pm,
and POSIX)? If so, please post it in a text format. I specifically want
to be able to enter a server, port, and be able to telnet to it.
Unfortunately, I use Webtv so it can't be in tar, zip, or tar.gz format
and it can't use Java or XML incorported. I REALLY appreciate any help
that anyone has. Thank you for your time.



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

Date: Fri, 30 Apr 1999 11:08:30 -0600
From: "Tim Chambers" <tbc@col.hp.com>
Subject: How does return work in END block?
Message-Id: <7gco71$scl$1@nonews.col.hp.com>

I'm looking at Tom Christiansen's example of File::LockDir in the PERL
COOKBOOK, pp. 264-266. It looks like he is trying to clean up stale locks
when perl exits, but doesn't the return statement prematurely exit from the
loop? Or does return work differently somehow in the END block?

package File::LockDir;

# <snip - tbc>

# anything forgotten?
END {
    for my $pathname (keys %Locked_Files) {
        my $lockname = name2lock($pathname);
        my $whosegot = "$lockname/owner";
        carp "releasing forgotten $lockname";
        unlink($whosegot);
        return rmdir($lockname);
    }
}

1;






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

Date: Fri, 30 Apr 1999 14:45:18 -0500
From: "Tim Armbruster" <t-armbruster@ti.com>
Subject: Re: JavaScript/PERL for dynamic form generation
Message-Id: <bPnW2.1$nd2.99@dfw-service1.ext.raytheon.com>


David Marshall wrote in message <3729D701.C5F8FD1@cwe2.com>...
>I am using a PERL script to generate a form.  This makes calls to a SQL
>database to generate a dynamic SELECTion list (L1) and executes a
>JavaScript "onChange=" event if the user wishes to add an additional
>option to that list.  This part is working fine.


>I hope I have presented this dilemma clearly.  Any assistance would be
>greatly appreciated.
>


First make sure your problem is directly related to Perl.  If it is a
problem related to HTML, JavaScript, CGI, or anything else, then you have
the wrong newsgroup.  You did explain your problem well, but if it *is*
related to Perl, which I doubt, you would need to post 40 or less lines of
code to assist the experts in finding what the problem is.  But first, make
SURE it is a Perl problem.




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

Date: Fri, 30 Apr 1999 07:42:57 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Moving the Perl distribution - global @INC problem
Message-Id: <105cg7.ip3.ln@magna.metronet.com>

srmorgan@my-dejanews.com wrote:
: We have multiple installations of perl at my workplace and I need to create
: another one which will be owned by my group. Due to 'regression testing'
: requirements I am not allowed to install a new one from source to the new
: location, and we tried copying the perl executable and library directory to
: the new location so that the relative paths (unix) are the same.

: However, this does not work, 


   Meaning you get some sort of message from perl?

   All of the messages that perl might issue are documented in
   perldiag.pod.

   Since you are withholding the waring/error message text (not
   a Good Idea), I'll guess that it is this one:


 ------------------------------
=item Can't locate %s in @INC

(F) You said to do (or require, or use) a file that couldn't be found
in any of the libraries mentioned in @INC.  Perhaps you need to set the
PERL5LIB or PERL5OPT environment variable to say where the extra library
is, or maybe the script needs to add the library name to @INC.  Or maybe
you just misspelled the name of the file.  See L<perlfunc/require>.
 ------------------------------


: perl still looks for the modules in the old
: library location. Could anyone tell me if the main @INC locations are
: compiled into perl when it is built, 


   Yes.


: or if there is any way of changing this
: globally without using -I in all programs? 


   Yes.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 30 Apr 1999 17:59:30 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Newsfeed and Local Weather
Message-Id: <slrn7ijs0v.io8.fl_aggie@stat.fsu.edu>

On Fri, 30 Apr 1999 15:03:26 GMT, Rick K
<rkoehler@osmre.gov>, in <FB0CGx.H3F@igsrsparc2.er.usgs.gov> wrote:

+ Skyward Internet Technology wrote:
+ >Does anybody know of any Perl scripts available that go out to the Weather
+ >Channel and grab their local forecast?  I've seen this done with a Cold
+ >Fusion application and just wondered if anybody had a Perl script to do the
+ >same.

+ Just for funsies, you might want to check out "Daily Update" at this link:
+ http://www.cs.virginia.edu/~dwc3q/code/DailyUpdate/index.html
+ since part of it includes "fetch some weather info" functionality.

This jogs a memory. I have a shell script (sh) that does this sort of
thing. For example, I live in Tallahassee, FL (TLH). I would then say:

% weather TLH

Weather Conditions at 12 PM EST on 30 APR 99 for Tallahassee, FL.
Temp(F)    Humidity(%)    Wind(mph)    Pressure(in)    Weather
========================================================================
   54          71%        NORTH at 14       29.96      Overcast
 
[followed by the zone forecast, the state extended forecast, and any
 other notices - severe weather outlook, watches, warnings, etc]

It makes a telnet connection to a WeatherUndergound site at port 3000,
and queries the server. You can do it interactively, too. I've
occasionally thought about doing a perl version, but it never got high
enough on my "fun list" to warrant work.

Maybe if I decide to do a Net::Telnet toy...if anyone wants a copy, I'll
slap it on a web site somewhere...

James


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

Date: 30 Apr 1999 12:15:25 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Newsfeed and Local Weather
Message-Id: <3729f33d@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    fl_aggie@thepentagon.com writes:
:It makes a telnet connection to a WeatherUndergound site at port 3000,
:and queries the server. You can do it interactively, too. I've
:occasionally thought about doing a perl version, but it never got high
:enough on my "fun list" to warrant work.

#!/usr/local/bin/perl
'di';
'ig00';
#
# $Header$
#
# $Log$
#
# A perl script to connect to the 'weather server' at
# Michigan and get the forcast for whatever city
# you want (3 letter code -- columbus 'cmh' by default).
#
# Alternatively, you can get the current information for
# a state if you enter a 2 letter code.
#
# Thanks to J Greely for the original network code, and
# Tom Fine for assistance and harassment.
#
# Copyright 1991 Frank Adelstein.  All Rights Reserved.
#
# Permission to use, copy, modify, and distribute this
# software is hereby granted without fee, provided that
# the copyright notice and permission notice are not removed.
#
# --FNA 6/28/91
#
# Hacked by George Ferguson (ferguson@cs.rochester.edu) to include
# Canadian forecasts by zone number.
#
# From the README (which you should have read already):
#  While I (gf) welcome reports of bugs in the program, I have neither the
#  time nor the desire to constantly maintain this program. The script
#  can get confused when the weather server's menu change, and I'd prefer
#  to not be flooded with messages about the script being broken every
#  time this happens. If something like that happens, and if I fix the
#  script to handle it, you can be sure I will post the changes. However,
#  please do not mail me requesting new versions. The Perl script is
#  simple enough for you to have a go at fixing it yourself and posting
#  the changes. Both the Net and I will love you for it.
#
# ferguson@cs.rochester.edu, 26 Jun 1992: Mods for new weather service menus.
#   I ripped lots of stuff out of this version, some of it may have to be
#   put back, but it works fine for me.
#   It's much easier to navigate the system now (for US forecasts, anyway),
#   so the interaction loop is considerably simplified. The Canadian stuff
#   is relatively straightforward also.
# kenr@storage.tandem.com 29 Jun 1992: Handle severe weather statements.
# gf 29 Jun 1992: More severe weather stuff for Canadian forecasts.
# gf 30 Jun 1992: Use <<...>> stuff in weatherT.pl then generate weather.pl.
# 8 Jul 1992:
#	gf: Started version numbering at 2.1.
#	frank@cis.ohio-state.edu: Show message if connection refused.
# 16 Sep 1992: Version 2.2
#	bruce@cs.ualberta.ca: Some continue patterns changed
#

$VERSION = "2.2";
$SERVER  = "madlab.sprl.umich.edu";
$PORT    = "3000";

$| = 1;  # so "connecting...." gets out

#
# Parse argument, if any
#
$CITY = $ARGV[0] || "DEN"; # No arg -> use default city

#
# Allow 4-char symbolic names for Canadian reports.
#
%canNames = ("salt","1",  "SALT","1",
	     "calt","2",  "CALT","2",
	     "nalt","3",  "NALT","3", "nebc","3", "NEBC","3",
	     "cobc","4",  "COBC","4",
	     "inbc","5",  "INBC","5",
	     "sman","6",  "SMAN","6",
	     "nman","7",  "NMAN","7",
	     "nova","8",  "NOVA","8",
	     "pedi","9",  "PEDI","9",
	     "newb","10", "NEWB","10",
	     "labr","11", "LABR","11",
	     "nfld","12", "NFLD","12",
	     "sont","13", "SONT","13",
	     "nont","14", "NONT","14",
	     "nwon","15", "NWON","15",
	     "ssas","16", "SSAS","16",
	     "nsas","17", "NSAS","17",
	     "yukn","18", "YUKN","18",
	     "sque","19", "SQUE","19", "ottw","19", "OTTW","19",
	     "nque","20", "NQUE","20");              
#
# If we're given one of these names, use the number instead.
#
if ($t=$canNames{$CITY}) {
    $CITY = $t;
}

#
# Check argument
#
if ($CITY =~ /[0-9]+/) {
    $ISCAN = 1;
} elsif (length ($CITY) == 3 ) {
    $ISCAN = 0;
} elsif (length ($CITY) == 2 ) {
    $ISCAN = 0;
} else {
    print "Must be either a 2 letter state code or 3 letter city code.\n";
    print "Can also be a numeric Canadian zone number or symbolic name.\n";
    exit (1);
}

#
# Connect to the server
#
print "\nWeather retrieval script, version $VERSION\n";
local($sockaddr,$here,$there,$response,$tries) = ("Snc4x8");
$here  = pack($sockaddr,2,0,&getaddress("localhost"));
$there = pack($sockaddr,2,$PORT,&getaddress($SERVER));
print "Connecting to $SERVER..";
die "socket: $!\n" if (!socket(SOCK,2,1,6));
print ".";
die "connect: $!\n" if (!connect(SOCK,$there));
print "connected\n";
select(SOCK); $| = 1;
select(STDOUT); $| = 1;       # make unbuffered

#
# Initialize
#
$SHOWIT = 0;			# Should we print?
$MAINMENU = 0;			# Seen main menu once already?
$CANMENU = 0;			# See Canadian menu once already?

sub PLUMBER { exit; } 
$SIG{'PIPE'} = 'PLUMBER';

#
# Interact...
#
while (read(SOCK,$c,1)) {	# Get a character
    if ($c eq "\n") {		# Newline -> maybe print, start new line
	if ($SHOWIT == 1) {
	    $curline =~ s/^[\cC\s]+$//;
	    $curline =~ tr/A-Z/a-z/;
	    print $curline, "\n" unless $curline =~ /^$/ && $was_blank;
	    $was_blank = $curline =~ /^$/;
	}
	$curline = "";
	next; 
    }
    if ($c eq "\r") { next; }	# Return -> ignore
    $curline .= $c;		# Else add char to current line
	
    #
    # Now test the current line so far to see what action to take, if any.
    #
    if ($curline =~ /Press Return for menu, or enter 3 letter forecast city code:/) { # At first prompt...
	if ($ISCAN) {
	    printf SOCK "\n";	# For Canadian forecast, go via main menu
	} else {
	    printf SOCK "%s\n", $CITY; # For US, bypass menu
	    $curline = "";
	    &showiton("us city/state");
	}
    } elsif ($curline =~ / Selection:/) { # In main menu...
	if ($ISCAN) {		# Canadian forecast...
	    if (!$MAINMENU) {	    # At main menu, select Canadian forecasts
		$MAINMENU = 1;
		printf SOCK "2\n";  # Canadian forecast is item 2!!
		$curline = "";
	    } elsif (!$CANMENU) {   # At Canadian menu, select region
		$CANMENU = 1;
		printf SOCK "%s\n", $CITY;
		&showiton("canadian region");
		$curline = "";
	    } else {
		printf SOCK "X\n";  # Otherwise exit
	    }
	} else {
	    printf SOCK "X\n";	# Otherwise exit
	}
    } elsif ($curline =~ / Invalid 3-letter city code./) {
	printf SOCK "X\n";
	printf "%s is an invalid 3 letter city code.\n", $CITY;
	&showitoff("3-letter");
    } elsif ($curline =~ / Invalid city or state code./) {
	printf SOCK "X\n";
	printf "%s is an invalid city or state code.\n", $CITY;
	&showitoff("invalid");
    } elsif ($curline =~ / CITY FORECAST MENU/) {
	&showitoff("city forecast");
    } elsif ($curline =~ / CURRENT WEATHER MENU/) {
	&showitoff("city forecast");
    } elsif ($curline =~ / CANADIAN FORECASTS/) {
	&showitoff("canadian forecasts");
    } elsif ($curline =~ / Press Return for menu: /) {
	printf SOCK "\n";
	$curline = "";
	&showiton("Return for menu");
    } elsif ($curline =~ / Press Return to continue, M to return to menu, X to exit: /) {
	printf SOCK "\n";
	$curline = "";
	&showiton("Return to continue printing");
    } elsif ($curline =~ / Press Return to display statement, M for menu: /) {
	# kenr@storage.tandem.com: Handle severe weather statement in city
        printf SOCK "\n";
        $curline = "";
        &showiton("Return to display statment (city)");
    } elsif ($curline =~ / Press [rR]eturn to display statement, M to display main menu: /) {
	# gf: Similarly for severe Michigan weather and Canadian forecasts
	if ($ISCAN) {
	    printf SOCK "M\n";
	    &showitoff("Return to display statement (main)");
	} else {
	    printf SOCK "\n";
	    &showiton("Return to display statement (main)");
	}
        $curline = "";
    } elsif ($curline =~ /The Weather Underground is fully loaded. Try again later./) {
	# frank@cis.ohio-state.edu: Show message if connection refused
	print "Weather server fully loaded, try again later.\n";
    }
}

#
# Clean up and done
#
close(SOCK);
exit(0);

#####################################################

sub getaddress {
    local($host) = @_;
    local(@ary);
    @ary = gethostbyname($host);
    return(unpack("C4",$ary[4]));
}

sub showitoff {
    local($txt) = @_;
    &maybeprint ("showit off ($txt)\n");
    $SHOWIT = 0;
}

sub showiton {
    local($txt) = @_;
    &maybeprint ("showit on ($txt)\n");
    $SHOWIT = 1;
}

sub maybeprint {
#    print @_;
}
###############################################################

    # These next few lines are legal in both Perl and nroff.

 .00;                       # finish .ig
 
'di           \" finish diversion--previous line must be blank
 .nr nl 0-1    \" fake up transition to first page again
 .nr % 0         \" start at page 1
'; __END__ ##### From here on it's a standard manual page #####
 .TH WEATHER 1 "30 Jun 1992"
 .SH NAME
weather - display current weather for a city or state
 .SH SYNOPSIS
 .B "weather"
[city, state, or canadian zone code]
 .SH DESCRIPTION
 .PP
 .I Weather
is program that will print the current weather conditions for an area.
 .I Weather
is a Perl(1) script that connects to the Weather Underground weather 
server from The University of Michigan, sends the appropriate request,
ignores the inappropriate text, and prints out the weather data.
 .PP
If no code is given on the command-line, then the forecast for the
default city (DEN ) is retrieved.
 .SH OPTIONS
 .TP
 .B city code
The 3 letter airport style city code will cause
 .I weather
to display the weather for that specified city. The weather server
can display the city codes for a given state using the interactive
interface described below.
 .TP
 .B state code
The 2 letter state abbreviation will cause
 .I weather
to display (a brief version of) the current weather 
for that specified state.
 .TP
 .B Canadian zone code
The following list of codes are understood for Canadian weather reports:

 .nf
 .na
  1.  SALT (Southern Alberta)      11 LABR (Labrador)
  2.  CALT (Central Alberta)       12 NFLD (Newfoundland)
  3.  NALT|NEBC (N. Alta - NE BC)  13 SONT (Southern Ontario)
  4.  COBC (Coastal BC)            14 NONT (Northern Ontario)
  5.  INBC (Interior BC)           15 NWON (Northwest Ontario)
  6.  SMAN (Southern Manitoba)     16 SSAS (Southern Saskatchewan)
  7.  NMAN (Northern Manitoba)     17 NSAS (Northern Saskatchewan)
  8.  NOVA (Nova Scotia)           18 YUKN (Yukon)
  9.  PEDI (Prince Edward Island)  19 SQUE|OTTW (S. Quebec - Ottawa)
  10. NEWB (New Brunswick)         20 NQUE (Northern Quebec)

 .ad
 .fi
A vertical bar (`|') denotes alternate names for the region.  Either
the four-character symbolic name (in upper- or lowercase) or the zone
number can be given to
 .IR weather .
 .SH "WEATHER SERVER"
The Weather Underground provides more detailed information using an
interactive interface than can be extracted automatically by this
script. Use the command

 .ce
% telnet downwind.sprl.umich.edu 3000

to connect interactively. Please limit your connection time to help
lower server load.
 .SH BUGS
Every time the menus on the server changes, 
 .I weather 
will usually wind up hanging, or printing the same
text infinitely.
 .PP
Please *don't* send me mail if this happens. If I update the script
you can be sure I will post the changes. However, please do not mail
me requesting new versions. The Perl script is simple enough for you
to have a go at fixing it yourself and posting the changes. Both the
Net and I will love you for it.
 .SH SEE ALSO
xforecast(1),
Perl(1)
 .SH AUTHOR
 .na
Frank Adelstein, frank@cis.ohio-state.edu.
 .PP
Canadian support added by George Ferguson, ferguson@cs.rochester.edu.
 .PP
Updated for new weather server menus by George Ferguson, 26 Jun 1992.
 .SH COPYRIGHT
Copyright 1991, Frank Adelstein.
-- 
    I won't mention any names, because I don't want to get sun4's into
    trouble...  :-)     --Larry Wall in <11333@jpl-devvax.JPL.NASA.GOV>


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

Date: Fri, 30 Apr 1999 16:27:10 GMT
From: "news.boeing.com" <jim.ray@west.boeing.com>
Subject: NT Perl vs UNIX Perl
Message-Id: <FB0GCJ.8pv@news.boeing.com>

I am getting better with converting my UNIX perl to NT, but still some
problems exist.  It's not as easy some would say.

Is there some documentations that describe what calls different from NY and
UNIX?

Such commands like CHDIR in UNIX does not work with NT.  Well at least it
does not work with my code.

Thank you.
--
Jim Ray
Delta Program NT Administrator
The Boeing Company
714-896-2038
jim.ray@west.boeing.com




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

Date: Fri, 30 Apr 1999 18:50:50 GMT
From: rich@greedo.partnersweb.com
Subject: ODBC PROBLEMS ! Please help. Is it Microsoft??
Message-Id: <7gcu28$87t$1@nnrp1.dejanews.com>

I have the following problem. I am connecting to the database through
DBI::ODBC: The parameters I receive from the from are going to be sent to be
added to the database using the following syntax:
  $sth=$dbh->prepare("insert into TABLE(PARAMETERS) VALUES(?,?....)
   Then the update to the database is made using:
   $sth->execute($scalar1, ...$scalarN)
The data is not always updated its flaky!

It could be a Microsoft problem?
?

Please email directly thanks!

rw

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


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

Date: Fri, 30 Apr 1999 18:51:29 GMT
From: rich@greedo.partnersweb.com
Subject: ODBC PROBLEMS ! Please help. Is it Microsoft??
Message-Id: <7gcu3f$888$1@nnrp1.dejanews.com>

I have the following problem. I am connecting to the database through
DBI::ODBC: The parameters I receive from the from are going to be sent to be
added to the database using the following syntax:
  $sth=$dbh->prepare("insert into TABLE(PARAMETERS) VALUES(?,?....)
   Then the update to the database is made using:
   $sth->execute($scalar1, ...$scalarN)
The data is not always updated its flaky!

It could be a Microsoft problem?
?

Please email directly thanks!

rw

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


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

Date: Fri, 30 Apr 1999 19:39:10 GMT
From: swistow@my-dejanews.com
Subject: RegExp for escape characters
Message-Id: <7gd0su$aq2$1@nnrp1.dejanews.com>

At the moment I'm writing a script which is a file line by ine.

Each line can contain a sequence along the lines of

${foo}

where 'foo' is a variable name, the value of which is obtained by the function

get_value('foo');

If get_value does return a result, say 'bar', then the whole sequence is to be
replaced by it

${foo} => 'bar'

however if get_value('foo') does not return a result then

${'foo'} => ${'foo'}

these sequences can occur any number of times on a line.

Implementing this wasn't too much of a problem using this (ugly) bit of code
 ...

  # let's check to see if there are any variables
  while ($value =~ m/\${([\w\d%]+)}/gi)
  {
	# there are! let's get it's real value
	my $replacer = get_value($1);
	# if it has one, then substitute it and carry on
	if ($replacer){
        	$value =~ s/\${$1}/$replacer/g;}
  }



However I want to increase functionality by allowing escape characters such
that

${foo}    => bar
\${foo}   => ${foo}
\\${foo}  => \bar
\\\${foo} => \${foo}

and any arbitary '\'s not followed by ${foo} will remain the same

\\\ some stuff ${foo} => \\\ some stuff bar

I've been trying for a couple of days to get this right and haven't come up
with anything that works properly (sometimes I get it correctly replacing the
slashes sometimes the variable but never both at the same time or if it does
it goes into an infinite loop even using \G).

Please help, this is driving me insane! And I've just ordered 'Mastering
Regexps' from Amazon so hopefully this should be the last time.

Simon Wistow

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


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

Date: Fri, 30 Apr 1999 07:49:55 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Regexp or subst
Message-Id: <3d5cg7.ip3.ln@magna.metronet.com>

Richard H (rhardicr@hotmail.com) wrote:

: I think i should be using s but not sure how for the following:


   you need s///e


: I have a line $msg (from a Mainframe - i didnt choose the $)
: and i have an array of variables (@errors) and desired result
: is  'fies foes and fum repeats ble at ';
: How do i substitute 'respectively' occurrence 1 of $$$ with $errors[0]
: occ 2 of $$$ with $errors[1] and so on, 

: my $msg = '$$$$ $$$$$$ and $$$ repeats $$$$ $$$$ $$ $$$$';             
: my @errors = ("fies", "foes", "fum", "ble", "at", "", "", "");          
: I can do them all with:

: How can i index  $errors in the subst or do this better???


   my $i=0;   # index into @errors
   $msg =~ s/\$+/ $errors[++$i] /ge;


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 30 Apr 1999 11:26:57 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regexp or subst
Message-Id: <MPG.119395ca3890eaa989984@nntp.hpl.hp.com>

In article <3d5cg7.ip3.ln@magna.metronet.com> on Fri, 30 Apr 1999 
07:49:55 -0400, Tad McClellan <tadmc@metronet.com> says...
> Richard H (rhardicr@hotmail.com) wrote:
> : I think i should be using s but not sure how for the following:
> 
>    you need s///e

No, you don't.  See below.

> : I have a line $msg (from a Mainframe - i didnt choose the $)
> : and i have an array of variables (@errors) and desired result
> : is  'fies foes and fum repeats ble at ';
> : How do i substitute 'respectively' occurrence 1 of $$$ with $errors[0]
> : occ 2 of $$$ with $errors[1] and so on, 
> 
> : my $msg = '$$$$ $$$$$$ and $$$ repeats $$$$ $$$$ $$ $$$$';             
> : my @errors = ("fies", "foes", "fum", "ble", "at", "", "", "");          
> : I can do them all with:
> 
> : How can i index  $errors in the subst or do this better???
> 
>    my $i=0;   # index into @errors
>    $msg =~ s/\$+/ $errors[++$i] /ge;

The /e isn't needed.  The subscript is evaluated during the normal 
interpolation into the substitution part of the expression.  If present, 
the /e evaluates the element from the array, which is a string; its 
value is the characters in the string, so there is no apparent effect.  
Of course, without the /e, the spaces on each side become part of the 
result, which isn't what was wanted.

Also, you should post-increment the index, or you miss the first element 
of @errors.

     my $i=0;   # index into @errors
     $msg =~ s/\$+/$errors[$i++]/g;

Another way (in addition to Bart's neat use of sprintf), if you don't 
mind destroying @errors, is:

     $msg =~ s/\$+/ shift @errors /eg;

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


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

Date: 30 Apr 1999 13:37:22 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Simple Checksum "Confidence Level"??
Message-Id: <xkfbtg5nbm5.fsf@valdemar.col.hp.com>

jabarone@my-dejanews.com writes:
> I was wondering if anyone may have any ideas concerning some research I need
> to do about a simple checksum routine to verify the programming of an 8 Meg
> FLASH memory on a CPU module I'm working on.

Probably.  But you should ask your question in a more appropriate venue.
I would suggest alt.gaping.chest.wounds; they surely would know at least
as much (if not more) about checksum confidence levels than a newsgroup
about Perl, the programming language.

> I was asked to come up with a "confidence level", in so many percent, that a
> simple 32-bit checksum (i.e., the addition of all the words in a FLASH memory
> (firmware)) would verify the image was correct.

My personal scientific opinion is "pretty pathetically poor", but I
have made no effort to check the literature.  Apparently you haven't
either.

-=Eric


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

Date: Fri, 30 Apr 1999 17:27:16 GMT
From: sithlar@my-dejanews.com
Subject: SSub-routine names
Message-Id: <7gcp5e$3ra$1@nnrp1.dejanews.com>

Is there any way to get the name of the subroutine I'm currently executing
in perl ?  I have in mind something like this:

****
sub test {
  my $name = get_cur_sub();
  print "Executing sub '$name'\n";
}
test();
***

And the output would be: "Executing sub 'test'".

-hal

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


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

Date: 30 Apr 1999 12:04:14 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: SSub-routine names
Message-Id: <3729f09e@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, sithlar@my-dejanews.com writes:
:Is there any way to get the name of the subroutine I'm currently executing
:in perl ?  

Yes. Caller should do it.

    $this_function = (caller(0))[3];

or 

    $me  = whoami();
    $him = whowasi();

    sub whoami  { (caller(1))[3] }
    sub whowasi { (caller(2))[3] }

--tom
-- 
    You can't set a breakpoint on a subroutine that hasn't been
    defined yet (yet).  This is a topic for ongoing research...  :-)
	--Larry Wall in <1994Feb25.192042.17196@netlabs.com>


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

Date: Fri, 30 Apr 1999 17:59:49 +0000
From: Michael Peppler <mpeppler@peppler.org>
Subject: Re: Sybase::DBlib and Two Phase commit
Message-Id: <3729EF95.6F805EBF@peppler.org>

nekoboh@my-dejanews.com wrote:
> 
> Hello,
> 
> Where might I find some documentation on doing Two-phase commit using
> Sybase::DBlib?
> 
> Michael Peppler's site
> http://www.mbay.net/~mpeppler/Sybperl/sybperl.html#Sybase_DBlib
> lists Sybase::DBlib's Two Phase commit routines.
> 
> But there's not enough explanation.
> I'd like to find some examples if possible.

You need to read up on this in the Sybase manuals on http://sybooks.sybase.com.
Look in the middleware section for the OpenCLient manuals.

Michael
--
Michael Peppler         -||-  Data Migrations Inc.
mpeppler@peppler.org    -||-  http://www.mbay.net/~mpeppler
Int. Sybase User Group  -||-  http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com


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

Date: Fri, 30 Apr 1999 19:08:12 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: using perl to manage passwords?
Message-Id: <7gcnpt$4it$2@news.mch.sbs.de>

In article <3729C427.F3E8EFF0@bus-prod.com>, Dan Baker <dtbaker@bus-prod.com> wrote:
>I need to implement some password protected areas of a website... can
>anyone suggest some online tutorials on the subject? I am looking for
>information on what is possible, how secure it will be, whether robots
>would be able to "get in" to subdirectories. etc.
>
>If you have experience in this area, and can explain the basic options
>and pros/cons of each, I'm sure the group would all learn a lot! Just a
>basic overview would help.
>
>If anyone can post links, examples, or suggest good reading....
>
>thanx,

Have a look at the Apache manuals...(or whatever webserver you'll
be using),

Michel.


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

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

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