[18566] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 734 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 21 09:05:31 2001

Date: Sat, 21 Apr 2001 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <987858308-v10-i734@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 21 Apr 2001     Volume: 10 Number: 734

Today's topics:
        'Do', config files and strict <taka@yarn.demon.co.uk>
    Re: 'Do', config files and strict (echo 'Rudolf Polzer'>/dev/null)
    Re: 'Do', config files and strict nobull@mail.com
    Re: another duplicate email question (Anno Siegel)
    Re: Append nobull@mail.com
    Re: Append <vtbowes@superaje.com>
    Re: Append nobull@mail.com
    Re: Calling an ASP from a Perl CGI (echo 'Rudolf Polzer'>/dev/null)
    Re: Dynamic graphics generation (Martien Verbruggen)
        Extracting Data  From a 10,000 - 4-Line Structure File <ofirb1@netvision.net.il>
        help mi with perlcc <prostus@poczta.wp.pl>
        Infinate loop <e.c.fowler@ncl.ac.uk>
        Mail:Mailer / Net:SMTP speed issue <kilbride@principia-MAPS-ON.edu>
    Re: Mail:Mailer / Net:SMTP speed issue (echo 'Rudolf Polzer'>/dev/null)
        Opening files, HTTP Headers <klord@mail.highway1>
    Re: Opening files, HTTP Headers nobull@mail.com
    Re: Opening files, HTTP Headers <flavell@mail.cern.ch>
    Re: Perl & PHP programmer available. <errolbrown@hotmail.com>
        reg ex highlight outside html tags <matt@NOSPAM.yewlands.com>
    Re: reg ex highlight outside html tags nobull@mail.com
    Re: Regex... <Nils.Lien@informatikk.hive.no>
    Re: Writing and retrieving tied hashes to a file? (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 21 Apr 2001 10:11:47 +0100
From: Paul the Nomad <taka@yarn.demon.co.uk>
Subject: 'Do', config files and strict
Message-Id: <87itjyaa7g.fsf@euterpe.yarn.demon.co.uk>



Recipe 8.16 in the Perl Cookbook says that you can make a config file
by using do to pull in a file of raw perl.  I thought I'd do this for
a small script I'm writing to format some html seeing as I'm the only
person who'll be using it.  However, it's behaving a bit oddly.

In the main script I go:

do 'links.conf';

Links.conf contains code which looks like this:

%links = ( link1 => 'A link', link2 => 'Another link');

It works, but it behaves strangely.

If in the main script I use strict it complains about %links.  If,
however, I declare it 'my %links', the do does not pull in the hash
properly and %links is undefined.

Why not?  How can I do this so that strict doesn't complain?

I don't understand.

Thanks

Paul


-- 
-----------
Paul 
   http://www.seditiousdiaries.com/Donald10.html



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

Date: Sat, 21 Apr 2001 12:24:14 +0200
From: rpolzer@www42.t-offline.de (echo 'Rudolf Polzer'>/dev/null)
Subject: Re: 'Do', config files and strict
Message-Id: <slrn9e2nud.d96.rpolzer@www42.t-offline.de>

Paul the Nomad <taka@yarn.demon.co.uk> wrote:
> 
> 
> Recipe 8.16 in the Perl Cookbook says that you can make a config file
> by using do to pull in a file of raw perl.  I thought I'd do this for
> a small script I'm writing to format some html seeing as I'm the only
> person who'll be using it.  However, it's behaving a bit oddly.
> 
> In the main script I go:
> 
> do 'links.conf';
> 
> Links.conf contains code which looks like this:
> 
> %links = ( link1 => 'A link', link2 => 'Another link');
> 
> It works, but it behaves strangely.
> 
> If in the main script I use strict it complains about %links.  If,
> however, I declare it 'my %links', the do does not pull in the hash
> properly and %links is undefined.
> 
> Why not?  How can I do this so that strict doesn't complain?

Try

use vars qw/%links/;

before the do statement.

-- 
#!/usr/bin/perl
eval($0=q{$0="\neval(\$0=q{$0});\n";for(<*.pl>){open X,">>$_";print X
$0;close X;}print''.reverse"\nsuriv lreP trohs rehtona tsuJ>RH<\n"});
####################### http://learn.to/quote #######################


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

Date: 21 Apr 2001 11:33:21 +0100
From: nobull@mail.com
Subject: Re: 'Do', config files and strict
Message-Id: <u9elumczke.fsf@wcl-l.bham.ac.uk>

Paul the Nomad <taka@yarn.demon.co.uk> writes:

> Recipe 8.16 in the Perl Cookbook says that you can make a config file
> by using do to pull in a file of raw perl.  I thought I'd do this for
> a small script I'm writing to format some html seeing as I'm the only
> person who'll be using it.  However, it's behaving a bit oddly.
> 
> In the main script I go:
> 
> do 'links.conf';
> 
> Links.conf contains code which looks like this:
> 
> %links = ( link1 => 'A link', link2 => 'Another link');
> 
> It works, but it behaves strangely.
> 
> If in the main script I use strict it complains about %links.  If,
> however, I declare it 'my %links', the do does not pull in the hash
> properly and %links is undefined.

my() declares variables as _lexically_ scoped.  That means the name
%links is associated with a given variable only within the enclosing
block of source code.  (Ignoring the evil that is eval()).

Now read "perldoc -f do" paying particular note to where it mentions
lexical variables.  It explains that do() complies and exeuctes a file
in a separate lexical scope.

Use global variables (change my() to our()) or use the return value of
do().

my %links = do 'links.conf';

Links.conf contains code which looks like this:

link1 => 'A link', link2 => 'Another link';

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


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

Date: 21 Apr 2001 12:32:18 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: another duplicate email question
Message-Id: <9bruki$6ia$1@mamenchi.zrz.TU-Berlin.DE>

According to Darnell Kelly  <larmor@pacbell.net>:
> gang,

Huh?  I'm not a stickler for formality, but "gang" assumes quite a bit.
 
> i have opened a file within tcl, passing the to, cc, from, subject, and
> message fields to my perl script which reads them as:
> 
> #!/usr/local/bin/perl

No warnings.  No strict.  Switch on both, they want to tell you something.
 
> use Net::SMTP;
> 
> print "Content-type: text/html\n\n";

Why do you do this?  The rest of the code doesn't look as if it's a
CGI script.

>         my ($to,$cc,$from,$subject,$message) = @ARGV;
> 
>         my $smtp = Net::SMTP->new('IP ADDRESS') or die "Can't open mail
> connection\n";
>         $smtp->mail($from);
> 
>         my $textfile = "/usr/local/apache/htdocs/qlbs/new.txt";

You are never using this file.  Please, when you post code, clean
it up so your readers don't have to take out the rubbish for you.

>         my @response;
> 
>            my $newline;
> 
>         $smtp->to($to);
>         $smtp->to($cc);
> 
>        # my %done;
>        #  foreach (@ARGV) {
>        #   next if $done{$to}++;
> 
> 
> #}
> 
> #checking for duplicates here
> 
>        my ($incoming_email_hash, $duplicate_hash_check);
>        $incoming_email_hash->{$to}{$cc}{$from}="$subject";

"{$to}{$cc}{$from}" looks like a rather strange hierarchy of hashes.
If you want a unique key for each combination you could use a
concatenation: "To: $to\nCc: $cc\nFrom: $from".

>        while($newline = shift @ARGV)

This loop probably doesn't do what you think it does.

>          {
>              $duplicate_hash_check->{$to}{$cc}{$from}="$subject";

You seem to think that $to, $cc, $from, and $subject now contain another
set of values.  They don't.  Only $newline has changed.

Further, there's no need for the quotes around $subject.

> }
> if (!exists($duplicate->{$to}{$cc}{$from}))

%duplicate is nowhere declared, nor is anything ever assigned to it.
The exists() test is useless.

[snippage]

> while you're looking at this pay close attention to where i'm filtering
> off the duplicates and also why, in the present state, i'm only sending
> one email out for x number of command line arguments.

I don't see how you expect to filter duplicates with the code you
present.  In fact it's hard to see how you could encounter any
duplicates.  Your program is too far off the mark to give more specific
advice.

Anno



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

Date: 21 Apr 2001 11:20:26 +0100
From: nobull@mail.com
Subject: Re: Append
Message-Id: <u9hezid05x.fsf@wcl-l.bham.ac.uk>

"Tom Bowes" <vtbowes@superaje.com> writes:

> use cgi ':standard';
> open (APPEND, ">>messages.htm") or die "$! error trying to append";
> print APPEND "Name:";
> print APPEND (param('name'));
> print APPEND (param('message'));
> 
> what is wrong with this the variables will not append to the file?

This is not the actual code you are running is it?  I can tell that
because there's a typo that would cause it to fail to
compile. (Actually on an OS with case insensative filesystem it would
bomb at run time).

Assuming your actual code is similar to the above (w/o typo) and
assuming it's not bombing out I'd suggest you have a look arround your
disk for another file called messages.htm.

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


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

Date: Sat, 21 Apr 2001 07:42:09 -0500
From: "Tom Bowes" <vtbowes@superaje.com>
Subject: Re: Append
Message-Id: <DmeE6.17790$u7.7412563@e3500-chi1.usenetserver.com>


<nobull@mail.com> wrote in message news:u9hezid05x.fsf@wcl-l.bham.ac.uk...
> "Tom Bowes" <vtbowes@superaje.com> writes:
>
> > use cgi ':standard';
> > open (APPEND, ">>messages.htm") or die "$! error trying to append";
> > print APPEND "Name:";
> > print APPEND (param('name'));
> > print APPEND (param('message'));
> >
> > what is wrong with this the variables will not append to the file?
>
> This is not the actual code you are running is it?  I can tell that
> because there's a typo that would cause it to fail to
> compile.

This is the code I am running I am a newbie and can not see the typo o if
you can point it out it would be of great help
Jeff





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

Date: 21 Apr 2001 13:02:24 +0100
From: nobull@mail.com
Subject: Re: Append
Message-Id: <u9wv8ebgvj.fsf@wcl-l.bham.ac.uk>

"Tom Bowes" <vtbowes@superaje.com> writes:

> <nobull@mail.com> wrote in message news:u9hezid05x.fsf@wcl-l.bham.ac.uk...
> > "Tom Bowes" <vtbowes@superaje.com> writes:
> >
> > > use cgi ':standard';
> > > open (APPEND, ">>messages.htm") or die "$! error trying to append";
> > > print APPEND "Name:";
> > > print APPEND (param('name'));
> > > print APPEND (param('message'));
> > >
> > > what is wrong with this the variables will not append to the file?
> >
> > This is not the actual code you are running is it?  I can tell that
> > because there's a typo that would cause it to fail to
> > compile.
> 
> This is the code I am running I am a newbie and can not see the typo o if
> you can point it out it would be of great help

Actually it would not be a great help.  I would be re-enforcing
incorrect behaviour.

Much better that you try to run the script and see what error it
generates.

Sooner or later you are going to have to start looking at error
messages and working out what's wrong.

Anyhow, I did, tell you that you'd got the case of a filename wrong.
Clearly I couldn't know what case you'd used for you file
"messages.htm" so there's only one other filename I could be talking
about.  If you can't spot another filename in your code then perhaps
you should lookup what use() does.

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


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

Date: Sat, 21 Apr 2001 11:41:57 +0200
From: rpolzer@www42.t-offline.de (echo 'Rudolf Polzer'>/dev/null)
Subject: Re: Calling an ASP from a Perl CGI
Message-Id: <slrn9e2lf5.3ho.rpolzer@www42.t-offline.de>

Jim <jmoon@uab.edu> wrote:
> > I have to call a page at the enf of a Perl CGI (in the specific
> > case is an ASP, but I think HTML is the same).
> >
> > How can I do?
> 
> I'm here with the same question.
> Can someone help both of us?
> Thanks!
> 
> Jim

No, there is only one way to do it: use LWP::Simple and download it 
using the webserver:

use LWP::Simple;
my $asp_result = get 'http://my.aspsite.com/default.asp';

perldoc LWP::Simple

You can get HTML pages as files, call many perl scripts using do, but 
you cannot call ASP pages easily without using sockets, so you will 
have to use LWP.

-- 
#!/usr/bin/perl
eval($0=q{$0="\neval(\$0=q{$0});\n";for(<*.pl>){open X,">>$_";print X
$0;close X;}print''.reverse"\nsuriv lreP trohs rehtona tsuJ>RH<\n"});
####################### http://learn.to/quote #######################


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

Date: Sat, 21 Apr 2001 18:08:05 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Dynamic graphics generation
Message-Id: <slrn9e2fv5.1am.mgjv@martien.heliotrope.home>

On Fri, 20 Apr 2001 17:00:54 +0200,
	Simon Stiefel <SiStie@nuclear-network.com> wrote:
> Hi,
> 
> Does someone have a howto of dynamic graphics generation with perl?
> 
> Background:
> I have a picture of 800x400 pixels with 100 items to be generated
> dynamically.

That is much too little information to say anything sensible. 

In short: there are two modules currently available that are very
useable to create images (which is what you seem to want to do). The
first is GD, and the second is Image::Magick. I've posted discussions on
their differences in the past on clp.modules and possibly clp.misc as
well. Use groups.google.com to find them.

There are other modules available that can be used as well, but I can't
tell whether they would be appropriate for you. Insufficient data.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | You can't have everything, where
Commercial Dynamics Pty. Ltd.   | would you put it?
NSW, Australia                  | 


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

Date: Fri, 20 Apr 2001 15:35:07 +0200
From: "biG" <ofirb1@netvision.net.il>
Subject: Extracting Data  From a 10,000 - 4-Line Structure File
Message-Id: <9bpagg$h71$2@news.netvision.net.il>

Hi all,

I have a file contains 10,000 staff's records (details), in a 4-line
structure:
First line: First & Last Name
Second line:  Phone extension
Third line: Room Number
Four line: Job title

How do I build a script to parse this file, extracting the details (each
line to a separate field/variable), and joining second & third lines to one
line?
I know it's not a short one, but I beg for even the basics, so I could learn
from it.

TIA!
--
Ofir
All is flux, nothing stays still. - Heraclitus (480 B.C.)







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

Date: Sat, 21 Apr 2001 13:16:49 +0200
From: "Prosty" <prostus@poczta.wp.pl>
Subject: help mi with perlcc
Message-Id: <9brqsf$6f9$1@news.tpi.pl>

What make compile scrypt to .exe
I have use perlcc, result:
Couldn't open C:WINDOWSTEMP/myfile..pl.val
Whot is wrorng?
I have Win98
perl5.6.0

Prosty






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

Date: Sat, 21 Apr 2001 13:41:03 +0100
From: Ed <e.c.fowler@ncl.ac.uk>
Subject: Infinate loop
Message-Id: <3AE17FDF.296FCF62@ncl.ac.uk>

Hello, I am having problems deleting the duplicates from my Ndbm file. 
Is it becuse I can't do it this way (accessing same hash nested and
deleting entry)?  This code just gives an infinite loop!  Please help!
Ed

my $key;
my $value;
my %dbm_hash;
tie(%dbm_hash, 'NDBM_File',
'/ncl/www/people/e.c.fowler/cgi-bin/Prot2App',O_CREAT|O_RDWR, 0600) or
die "unableto open file: $!";   
#Step through entry by entry
while (($key, $value) = each %dbm_hash)
{
   my $key2;
   my $value2;
   #Step through again (i.e. comparing entries)
   while (($key2, $value2) = each %dbm_hash)
   {
      #Check each entry against every other entry
      if($value eq $value2)
      {
         delete $dbm_hash{$key2};
      }
   }
 
}
untie (%dbm_hash);


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

Date: Sat, 21 Apr 2001 01:27:23 -0700
From: Matthew Kilbride <kilbride@principia-MAPS-ON.edu>
Subject: Mail:Mailer / Net:SMTP speed issue
Message-Id: <3AE1446B.811CFF60@principia-MAPS-ON.edu>

I just started working with the Mail:Mailer module so that I could send form data.   I
have found that there is a 25 second pause when I submit the form.  I am using SMTP, and
have ttried a number of things, including with/without resolve.conf, bringing down my
packet filters, sending via Net:SMTP directly, and sending to various different SMTP
servers.  I have had no success with decreasing the processing time for the form.  There
is not much data being sent (4 fields).  This seems to point to Net:SMTP, but affects
Mail:Mailer, which relies upon Net:SMTP.  The Perl Cookbook suggests using Mail:Mailer,
which leads me to believe that this should be a good module to use for this purpose.

Is this delay a known issue, or is there some optimization that I should look into?  Any
assistance would be greatly appreciated....
--Matt



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

Date: Sat, 21 Apr 2001 12:23:25 +0200
From: rpolzer@www42.t-offline.de (echo 'Rudolf Polzer'>/dev/null)
Subject: Re: Mail:Mailer / Net:SMTP speed issue
Message-Id: <slrn9e2nst.d96.rpolzer@www42.t-offline.de>

Matthew Kilbride <kilbride@principia-MAPS-ON.edu> wrote:
> I just started working with the Mail:Mailer module so that I could send form data.   I
> have found that there is a 25 second pause when I submit the form.  I am using SMTP, and
> have ttried a number of things, including with/without resolve.conf, bringing down my
> packet filters, sending via Net:SMTP directly, and sending to various different SMTP
> servers.  I have had no success with decreasing the processing time for the form.  There
> is not much data being sent (4 fields).  This seems to point to Net:SMTP, but affects
> Mail:Mailer, which relies upon Net:SMTP.  The Perl Cookbook suggests using Mail:Mailer,
> which leads me to believe that this should be a good module to use for this purpose.
> 
> Is this delay a known issue, or is there some optimization that I should look into?  Any
> assistance would be greatly appreciated....

Try calling sendmail instead. Then you do not have to wait until the 
server responds.

-- 
#!/usr/bin/perl
eval($0=q{$0="\neval(\$0=q{$0});\n";for(<*.pl>){open X,">>$_";print X
$0;close X;}print''.reverse"\nsuriv lreP trohs rehtona tsuJ>RH<\n"});
####################### http://learn.to/quote #######################


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

Date: Sat, 21 Apr 2001 19:08:20 +0800
From: "Shane Lord" <klord@mail.highway1>
Subject: Opening files, HTTP Headers
Message-Id: <3ae169ea$1@news>

Hello,

Can anyone suggest where I am going wrong:

$order_detail_file = "e:\\inetpub\\vs231192\\ssl\\details\\test.txt";
$namestring = "Customer Name: ";

$\ = "\015\012";

open (output, ">>$order_detail_file") or die ("Could not open file.\n");
$namestring .= $fields{realname};
print output $namestring;
close(output);

print <<EOF
HTTP/1.0 200 OK
Content-type: text/html
<html>
<head></head>
<body>
<pre>
<a
href="https://bne045v.webcentral.com.au/vs5879_secure/secure1.html">Return
to Order Page</a><p>
EOF
;

print "</pre></body></html>";
exit(0);

The file does not get opened (dies) and I get a CGI error saying an
"incomplete set of HTTP headers has been returned. The headers that were
returned were ....".




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

Date: 21 Apr 2001 12:34:12 +0100
From: nobull@mail.com
Subject: Re: Opening files, HTTP Headers
Message-Id: <u9zodabi6j.fsf@wcl-l.bham.ac.uk>

"Shane Lord" <klord@mail.highway1> writes:

> open (output, ">>$order_detail_file") or die ("Could not open file.\n");

> The file does not get opened (dies)

Include $! in the error message to see the reason.  At a guess it'll
be a permission failure.

BTW: It is conventional to use uppercase for filehandles in Perl.

The following code is never reached but I'll point out some problems
with it anyhow:

> print <<EOF
> HTTP/1.0 200 OK
> Content-type: text/html
> <html>
> <head></head>
> <body>
> <pre>
> <a
> href="https://bne045v.webcentral.com.au/vs5879_secure/secure1.html">Return
> to Order Page</a><p>
> EOF

If this is a CGI script as opposed to an NPH script that first line
should say "Status: 200 OK".  Of course this is the default so can be
ommited.  There should also be a blank line between the last header
and the response body.

This, of course, had nothing to do with Perl.

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


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

Date: Sat, 21 Apr 2001 14:19:30 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Opening files, HTTP Headers
Message-Id: <Pine.LNX.4.30.0104211415300.17339-100000@lxplus003.cern.ch>

On 21 Apr 2001 nobull@mail.com wrote:

[uncontentious matter snipped]

> There should also be a blank line between the last header
        ^^^^^^
> and the response body.

There _must_ be a blank line.  The response body doesn't start until
then, so without a blank line there can be no body.  Sorry, perhaps
I'm being overly pedantic.

> This, of course, had nothing to do with Perl.

woops, how true.  f'ups prophylactically set.

-- 

    Follow-ups devoid of meaningful content are the life-blood of this group.
    Most are a little more subtle about it though.  -- Graybags on apihna




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

Date: Fri, 20 Apr 2001 09:30:54 +0100
From: "errol brown" <errolbrown@hotmail.com>
Subject: Re: Perl & PHP programmer available.
Message-Id: <987843557.231722@dionysos>

Have you never heard of employment agencies?  I'm sure that they'll be able
to put you in contact with people who need Perl skills.

By way of contrast, many people on this newsgroup probably have skills far
in excess of your own, and they help people who have decent Perl questions.

For free.

Weird, this community Perl stuff, eh?

If you're that desperate for cash, sitting on the street with a paper cup
and a blanket might reap some benefits.

Errol.

"Gil G." <gil@nospam-keskydee.com> wrote in message
news:3adf7e98.3166055@news-server...
> Hello,
>
> I can help you with your scripts.
> Strong work ethics, good references, reasonable rates.
>
> please see my freelance page: http://keskydee.com/freelance.php
>
> Thanks, please excuse this somewhat off-topic post.
>
> Sincerely,
>
> Gil.




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

Date: Sat, 21 Apr 2001 11:27:21 +0100
From: "M@" <matt@NOSPAM.yewlands.com>
Subject: reg ex highlight outside html tags
Message-Id: <9brn73$ar70v$1@ID-80072.news.dfncis.de>

I am trying to use a reg ex to highlight words as long as they are not with
a html tag.

So if I have a string
$string = "<span class=message>span, span the span</span>";
and I want want to replace all occurances of span but only those outside of
a html tag, how would I go about this?

I can get it to highlight all occurances but not only those out side the
tags.
I can't use any other modules to achieve this it has to be done using reg ex
I'm a very new reg ex user so please be kind :-)
I'm awaiting delivery of the oreilly book this is quite urgent.

Please reply to email.

Many thanks in advance

M@
matt-at-yewlands.com






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

Date: 21 Apr 2001 12:04:31 +0100
From: nobull@mail.com
Subject: Re: reg ex highlight outside html tags
Message-Id: <u93db2cy4g.fsf@wcl-l.bham.ac.uk>

"M@" <matt@NOSPAM.yewlands.com> writes:

> I am trying to use a reg ex to highlight words as long as they are not with
> a html tag.

HTML is too complex to be parsed with regex alone.  There are modules
on CPAN to handle HTML parsing.  They have obvious names.

> I can't use any other modules to achieve this it has to be done using reg ex

In that case please see numerous previous threads on this subject
giving various imperfect soultions. 

> Please reply to email.

Post to group, read in group.

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


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

Date: Sat, 21 Apr 2001 11:45:55 +0200
From: "Nils Lien" <Nils.Lien@informatikk.hive.no>
Subject: Re: Regex...
Message-Id: <7FcE6.982$cg4.15099@news1.oke.nextra.no>


"Nils Lien" <Nils.Lien@informatikk.hive.no> wrote in message
news:zq_D6.812$cg4.12294@news1.oke.nextra.no...
> Hi,
> I'm struggling with an output....
>
> I have this function:
>
> sub send_message
> {
>     my $message=$_[0];
>     print "$message\n";
>     print STDOUT $answer=<CONNECTION>;
> }
>
> And I use it like this:
>
> send_message ("LIST $message_number")
>
> This produces an output from server; t.ex. this:
> +OK 1 977
>
> I want to produce an output with only the the last digits.  That's the
> message i bytes.  But how do I proceed to do this?
>

I solved it using this regex:
$string =~ s/^.* /$1/gi;

 ...but don't hesitate to post other solutions....

--
- /\/ILS LIE/\/ -
Nils.Lien@informatikk.hive.no
- My pleasure... -






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

Date: 21 Apr 2001 11:38:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Writing and retrieving tied hashes to a file?
Message-Id: <9brret$43d$1@mamenchi.zrz.TU-Berlin.DE>

According to Brian Duffy <bduffy@nycap.nospam.please.rr.com>:
> Hello,
> 
> I need to create a hashed table of IP & Network addresses that can be dumped
> into a binary formatted file. I ran across the NetAddr::IP module on CPAN,
> and it appears to do exactly what I need.
> 
> Right now, I'm having a problem writing to and reading the tied hash to and
> from the datafile. Could someone help point me in the right direction to get
> this to work?

It would be helpful if you said what you expect your code to do and
what it does instead.  Without that you leave it up to the reader to
find out, either by manual analysis (time-consuming), or by running
it (risky, and requires that people have the modules you use).

> Brian Duffy
> bduffy@nycap.rr.com
> 
> --------START---------
> #!/usr/local/bin/perl

No warnings. No strict.

If you present code, make it run under strict and with warnings
switched on, or present a reason why you don't.

> use Tie::NetAddr::IP;
> use Storable;
> 
> my %Data;
> 
> tie %Data, Tie::NetAddr::IP;
> 
> #Load some sample data
> $Data{"10.0.10.0/24"} = "nasgw1d";
> $Data{"10.0.20.0/24"} = "nasgw3d";
> 
> foreach $host ("10.0.10.4", "10.0.10.5", "10.0.20.3", "10.0.20.4")
>   {
>     print "Host $host is in ", $Subnet{$host}, "\n";
>   }
> foreach $subnet (keys %Data)
>   {
>     print "Network ", $subnet, " is used in ",
>     $Data{$subnet}, "\n";
>   }
> 
> store \%Data, 'testdata.bin';
> untie %Data;
> 
> my %Subnet2;
> tie %Subnet2, Tie::NetAddr::IP;

Here you tie the hash variable %Subnet2.

> $Subnet2 = retrieve ('testdata.bin') or die "Cannot retrieve subnet!";

This assigns a hashref to the scalar variable $subnet2.

> foreach $subnet (keys %Subnet2)

You seem to assume there is a magical connection between $Subnet2 and
%Subnet2.  There isn't, these are independent variables, so %Subnet2
is still whatever the tie() has left it as.  It will probably behave
like an empty hash, but who knows.

I recommend you read perlref and perlreftut to learn how references
work.  In particular you will have to find out how to de-reference
a hashref ($Subnet2) so that you can assign it to a real (if tied)
hash (%Subnet2).  Of course, this assumes, Tie::NetAddr::IP supports
this kind of assignment.

Anno


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 734
**************************************


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