[24415] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6603 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 24 18:10:40 2004

Date: Mon, 24 May 2004 15:10:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 24 May 2004     Volume: 10 Number: 6603

Today's topics:
        Map or Regex and Sorting <schaumfestiger@gmx.de>
    Re: Map or Regex and Sorting <schaumfestiger@gmx.de>
    Re: Map or Regex and Sorting <thepoet_nospam@arcor.de>
    Re: Map or Regex and Sorting (Anno Siegel)
    Re: Map or Regex and Sorting <schaumfestiger@gmx.de>
    Re: Map or Regex and Sorting <schaumfestiger@gmx.de>
    Re: Map or Regex and Sorting <perl@my-header.org>
    Re: Map or Regex and Sorting <schaumfestiger@gmx.de>
        NET::IMAP problems mk-2@corena.de
    Re: open file error <tadmc@augustmail.com>
        Pari lib with Math-BigInt (win32) <tlviewer@yahoo.com>
        Perl inplace editing (Sundaram Ramasamy)
    Re: Perl inplace editing <Joe.Smith@inwap.com>
    Re: Perl inplace editing <ittyspam@yahoo.com>
    Re: Perl inplace editing <ittyspam@yahoo.com>
    Re: Perl inplace editing <ittyspam@yahoo.com>
    Re: Perl vs PHP <bart.lateur@pandora.be>
    Re: Sequential analysis in perl? <davcamer@interchange.ubc.ca>
    Re: Sequential analysis in perl? <davcamer@interchange.ubc.ca>
    Re: Sockets: receiving data <jgibson@mail.arc.nasa.gov>
    Re: String search/match question <krahnj@acm.org>
    Re: String search/match question (Anno Siegel)
        Take three form variables and write to an "settings-fil <hanssonrickard@hotmail.com>
    Re: Take three form variables and write to an "settings <ittyspam@yahoo.com>
    Re: Take three form variables and write to an "settings <noreply@gunnar.cc>
    Re: Take three form variables and write to an "settings <hanssonrickard@hotmail.com>
        Using Cookies With Perl <jameskorea2003@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 24 May 2004 18:41:12 +0200
From: Herr Hardy <schaumfestiger@gmx.de>
Subject: Map or Regex and Sorting
Message-Id: <4094b01hbjjlsm5hl580iv2vuvf54ioqcj@4ax.com>

Hi,

I have some working code, but I think, there's more than one better
way to solve the task:

I have some given Data that should be sorted first on appearance of
string OPEN (on top) and second after the values of the first
occurence of digits, here e.g. 31 to 40. 
How can I 'regex' or 'map' this to sort them in one loop already?

Thanks
Hardy

#!/usr/bin/perl

use warnings;
use strict;

my @digitlist;
my @openlist;
my @clsdlist;

while(<DATA>){
    /(\d{1,3})/;
    push (@digitlist,$1.$_);
}

@digitlist = sort @digitlist;

for(@digitlist){
    if (/OPEN/){
        push(@openlist,$_);
    }else{
        push(@clsdlist,$_);
    }
}

for(@openlist){
    print;
}
for(@clsdlist){
    print;
}
1;
# EOF

__DATA__
SBruhrtal32PER09CLSD
SBsorpe31PER19IN18last
RBruhrII33PER11OPEN
RBruhrI34PER14CLSD
RBharkortI40PER09OPEN


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

Date: Mon, 24 May 2004 20:09:29 +0200
From: Herr Hardy <schaumfestiger@gmx.de>
Subject: Re: Map or Regex and Sorting
Message-Id: <oge4b09ncmm9l41lv1uk62g6vslq8797vl@4ax.com>

On Mon, 24 May 2004 18:41:12 +0200, Herr Hardy <schaumfestiger@gmx.de>
wrote:

>I have some given Data that should be sorted first on appearance of
>string OPEN (on top) and second after the values of the first
>occurence of digits, here e.g. 31 to 40. 
>How can I 'regex' or 'map' this to sort them in one loop already?

Shorter sorting of the @digitlist, but howto combine it with the
String search, hm?

#!/usr/bin/perl

use warnings;
use strict;

my($x,$y);
my @digitlist = sort {($x)=($a=~/(\d{1,3})/);($y)=($b=~/(\d{1,3})/);$x
<=> $y} (<DATA>);

for(@digitlist){
    print;
}


1;
# EOF

__DATA__
SBruhrtal32PER09CLSD
SBsorpe31PER19IN18last
RBruhrII33PER11OPEN
RBruhrI34PER14CLSD
RBharkortI40PER09OPEN
RBruhrI34PER14OPEN



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

Date: Mon, 24 May 2004 21:05:57 +0200
From: "Christian Winter" <thepoet_nospam@arcor.de>
Subject: Re: Map or Regex and Sorting
Message-Id: <40b24801$0$26344$9b4e6d93@newsread4.arcor-online.net>

"Herr Hardy" schrieb:
> On Mon, 24 May 2004 18:41:12 +0200, Herr Hardy <schaumfestiger@gmx.de>
> wrote:
> 
> >I have some given Data that should be sorted first on appearance of
> >string OPEN (on top) and second after the values of the first
> >occurence of digits, here e.g. 31 to 40. 

Well, I'd build a HoH (Hash of Hashes) to store
the OPEN-offset and the first digit group, then
use a normal sort (you can combine sort patterns
with ||).

In my example I've assumed that neither the offset
reaches 1000 nor does the digit value. Of course you
should adapt this value to your needs.

HTH & happy rail route calculating
-Christian

#!perl -l

use warnings;
use strict;

my %val;

while(<DATA>){
    chomp;
    $val{$_}->{'OPEN'} = ( /(OPEN)/ and $-[0] or 1000 );
    $val{$_}->{'DIGT'} = ( /(\d{1,3})/ and $1 or 1000 );
}

print $_ for(
  sort { 
         $val{$a}->{'OPEN'} <=> $val{$b}->{'OPEN'}
         || 
         $val{$a}->{'DIGT'} <=> $val{$b}->{'DIGT'} 
       }
       keys %val
     );

1;
# EOF

__DATA__
SBruhrtal32PER09CLSD
SBsorpe31PER19IN18last
RBruhrII33PER11OPEN
RBruhrI34PER14CLSD
RBharkortI40PER09OPEN




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

Date: 24 May 2004 19:25:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Map or Regex and Sorting
Message-Id: <c8ti6k$dm9$3@mamenchi.zrz.TU-Berlin.DE>

Herr Hardy  <schaumfestiger@gmx.de> wrote in comp.lang.perl.misc:
> On Mon, 24 May 2004 18:41:12 +0200, Herr Hardy <schaumfestiger@gmx.de>
> wrote:
> 
> >I have some given Data that should be sorted first on appearance of
> >string OPEN (on top) and second after the values of the first
> >occurence of digits, here e.g. 31 to 40. 
> >How can I 'regex' or 'map' this to sort them in one loop already?
> 
> Shorter sorting of the @digitlist, but howto combine it with the
> String search, hm?
> 
> #!/usr/bin/perl
> 
> use warnings;
> use strict;
> 
> my($x,$y);
> my @digitlist = sort {($x)=($a=~/(\d{1,3})/);($y)=($b=~/(\d{1,3})/);$x
> <=> $y} (<DATA>);
> 
> for(@digitlist){
>     print;
> }
> 
> 
> 1;
> # EOF
> 
> __DATA__
> SBruhrtal32PER09CLSD
> SBsorpe31PER19IN18last
> RBruhrII33PER11OPEN
> RBruhrI34PER14CLSD
> RBharkortI40PER09OPEN
> RBruhrI34PER14OPEN

That can be done using a Schwartz transform.  Assign numeric sort keys
to the lines.  Make the key -1 if the line contains "OPEN", otherwise
use the first group of digits.  Sort according to keys, throw the
keys away.  

    print for                                   # print result
    map $_->[ 0],                               # throw keys away
    sort { $a->[ 1] <=> $b->[ 1] }              # sort by key
    map [ $_ , /OPEN/ ? -1 : ( /(\d+)/ )[ 0] ], # assign keys
    <DATA>;

Anno


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

Date: Mon, 24 May 2004 21:52:33 +0200
From: Herr Hardy <schaumfestiger@gmx.de>
Subject: Re: Map or Regex and Sorting
Message-Id: <s3k4b0d1ce2qrj75tekcu5a6kab3fkvgp0@4ax.com>

On Mon, 24 May 2004 21:05:57 +0200, "Christian Winter"
<thepoet_nospam@arcor.de> wrote:

>
>Well, I'd build a HoH (Hash of Hashes) to store
>the OPEN-offset and the first digit group, then
>use a normal sort (you can combine sort patterns
>with ||).
Aha, pretty good idea (not mine, sniff) and looks very clear.
>
>In my example I've assumed that neither the offset
>reaches 1000 nor does the digit value. Of course you
>should adapt this value to your needs.
OK, YYYYMMDDhhmmss

$val{$_}->{'DIGT'} = ( /(\d{14})/ and $1);

>
>HTH & happy rail route calculating
>-Christian

Thanks a lot... but it's project data from regional water supply, at
least 200 sets of DATA but never more than 321 at once, so I had no
reason to  care for performance and worked well with my loopy-loop
skript... 

Yours tastes better!

Ciao Hardy


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

Date: Mon, 24 May 2004 22:00:36 +0200
From: Herr Hardy <schaumfestiger@gmx.de>
Subject: Re: Map or Regex and Sorting
Message-Id: <glk4b0l30e5jvhi652rovnc521v40850so@4ax.com>

On 24 May 2004 19:25:08 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>
>That can be done using a Schwartz transform.  Assign numeric sort keys
>to the lines.  Make the key -1 if the line contains "OPEN", otherwise
>use the first group of digits.  Sort according to keys, throw the
>keys away.  

ooh great, Anno, I'd already seen the Schwartzian transform while
googling, but I'm pretty unfamiliar with that mighty map function and
wouldn't get that assignment
>    map [ $_ , /OPEN/ ? -1 : ( /(\d+)/ )[ 0] ], # assign keys
to work.

So, thank you



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

Date: Mon, 24 May 2004 22:38:55 +0200
From: Matija Papec <perl@my-header.org>
Subject: Re: Map or Regex and Sorting
Message-Id: <6gm4b0dc8mfqja2rdqltrvqbgk2s2jho1l@4ax.com>

X-Ftn-To: Herr Hardy 

Herr Hardy <schaumfestiger@gmx.de> wrote:
>>to the lines.  Make the key -1 if the line contains "OPEN", otherwise
>>use the first group of digits.  Sort according to keys, throw the
>>keys away.  
>
>ooh great, Anno, I'd already seen the Schwartzian transform while
>googling, but I'm pretty unfamiliar with that mighty map function and
>wouldn't get that assignment
>>    map [ $_ , /OPEN/ ? -1 : ( /(\d+)/ )[ 0] ], # assign keys
>to work.

If you're familiar with references, learning map is very usefull

  use Data::Dumper;
  print Dumper
    # map [ $_ , /OPEN/ ? -1 : ( /(\d+)/ )[ 0] ], # assign keys
    map {
      my ($value_for_sorting) = /(\d+)/;
      $value_for_sorting = -1 if /OPEN/;
      [ $_, $value_for_sorting ];
    }
    <DATA>;


-- 
Secure and instant E-pay for web shops
http://www.ouroboros.hr/?e-placanje


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

Date: Mon, 24 May 2004 23:36:14 +0200
From: Herr Hardy <schaumfestiger@gmx.de>
Subject: Re: Map or Regex and Sorting
Message-Id: <6vp4b09fv86ftfhq3ft1lihcuq4oar72tc@4ax.com>

On 24 May 2004 19:25:08 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:

>> __DATA__
>> SBruhrtal32PER09CLSD
>> SBsorpe31PER19IN18last
>> RBruhrII33PER11OPEN
>> RBruhrI34PER14CLSD
>> RBharkortI40PER09OPEN
>> RBruhrI34PER14OPEN
>
>That can be done using a Schwartz transform.  Assign numeric sort keys
>to the lines.  Make the key -1 if the line contains "OPEN", otherwise
>use the first group of digits.  Sort according to keys, throw the
>keys away.  
>
>    print for                                   # print result
>    map $_->[ 0],                               # throw keys away
>    sort { $a->[ 1] <=> $b->[ 1] }              # sort by key
>    map [ $_ , /OPEN/ ? -1 : ( /(\d+)/ )[ 0] ], # assign keys
>    <DATA>;

 ... buuuuut the result ist

RBruhrII33PER11OPEN
RBharkortI40PER09OPEN
RBruhrI34PER14OPEN
SBsorpe31PER19IN18last
SBruhrtal32PER09CLSD
RBruhrI34PER14CLSD

3 OPEN on top, rest follows, but the OPEN-values should then be
ordered after their (\d{1,3})'s and here's 33 40 34, 
should be 33 34 40

So, is there a way to alter the keys by 2nd mapping? 

map [ $_ , /OPEN/?$_->[0]+=1000:(0) [ 0] ],  # alter keys on 1st level

but that's not referencing, I see.


print for                                # print result
map $_->[ 0],                            # throw keys away
sort { $a->[ 1] <=> $b->[ 1] }           # sort by altered-key
#do something, maybe add 1000 if(/OPEN/) # alter keys on 1st level
map [ $_ , (/(\d{1,3})/) [ 0] ],         # assign 2nd-level ordinate 
 <DATA>;


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

Date: 24 May 2004 09:34:28 -0700
From: mk-2@corena.de
Subject: NET::IMAP problems
Message-Id: <ffa7fa20.0405240834.102dc857@posting.google.com>

Hallo!

I try to use Net::IMAP to access our IMAP servers.

~~~~~~
use Net::IMAP;

# open a connection to the IMAP server
$server = new Net::IMAP( 'localhost',
			 Synchronous => 1, 
			 Debug => 1,	
			 ) 
    || die ("no server");

~~~~~~
The server is 2.1.16 in Debian Linux testing.
Apparently the script connects, but does not return a valid handle.

~~~~~~
mk@orcus:~/tmp> perl -w conn2
Name "main::server" used only once: possible typo at conn2 line 4.
<- Net::IMAP=HASH(0x82c9cac) 18:24:04 [* OK orcus Cyrus IMAP4
v2.1.16-IPv6-Debian-2.1.16-4 server ready]
no server at conn2 line 4.
~~~~~~

Any other operations later on this handle are failing.
Any idea what is wrong?

Thanks
   Michael


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

Date: Mon, 24 May 2004 07:29:10 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: open file error
Message-Id: <slrncb3qkm.ol5.tadmc@magna.augustmail.com>

Brian Gough <bjg@network-theory.co.uk> wrote:

> By default, open will access the file in read-write mode.


No it won't.

Where in the std docs did you see it say that?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 24 May 2004 20:05:02 GMT
From: "gnu valued customer" <tlviewer@yahoo.com>
Subject: Pari lib with Math-BigInt (win32)
Message-Id: <Ozssc.22615$ZQ.19259@nwrddc03.gnilink.net>

hello,

Win2k sp3
Perl 5.8.1 (ActiveState extensions)

using Math-Pari 2.010500

and the latest Math-BigInt i've
tried to install and use
Math-BigInt-Pari.

Everything installs fine, but I get
this warning when I call like so

use Math::BigInt lib =3D> 'Pari';

warning:
Cannot load outdated Math::BigInt::Pari v1.10, please=20
upgrade at ... (points to about 'use')

The script is reverting to the Pure-Perl version of
Math-BigInt (slow).

tia for your help,
Mark Pryor


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

Date: 24 May 2004 12:28:12 -0700
From: sundaram@sfg.homeunix.com (Sundaram Ramasamy)
Subject: Perl inplace editing
Message-Id: <b029225f.0405241128.37a67b32@posting.google.com>

I want to check in file line start with HOSTNAME, then I want to
replcae HOSTNAME value to linux.com, if line is not there I want add
new line HOSTNAME=linux.com

Using inplace editing I was not able to add new line.

Here is my one liner inplace editing script

 perl -i.old -ne '$ne=0; if( /^\s*HOSTNAME\s*=/ ) {
s/=.*$/=linux.com/; $nx++; print $_; }else { print $_; } END { if( $nx
==0 ){ $_="HOSTNAME=linux.com\n"; print $_; } }' network

Requirment:

1) orginal file:
NMAE=myname
IP=234.56.43.23
HOSTNAME=abcde.com

I need out put:
NMAE=myname
IP=234.56.43.23
HOSTNAME=linux.com

2) orginal file:
NMAE=myname
IP=234.56.43.23

I need out put:
NMAE=myname
IP=234.56.43.23
HOSTNAME=linux.com

Any tips for this


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

Date: Mon, 24 May 2004 20:14:59 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Perl inplace editing
Message-Id: <7Jssc.17821$hi6.1747813@attbi_s53>

Sundaram Ramasamy wrote:

>  perl -i.old -ne '$ne=0; if( /^\s*HOSTNAME\s*=/ ) {

You don't want to set $ne to zero everytime through the loop.

    perl -i.old -ne '$ne=0 if not defined $ne; if( /^\s*HOSTNAME\s*=/ ) {

	-Joe


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

Date: Mon, 24 May 2004 16:16:29 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Perl inplace editing
Message-Id: <20040524160629.L338@dishwasher.cs.rpi.edu>

On Mon, 24 May 2004, Sundaram Ramasamy wrote:

> I want to check in file line start with HOSTNAME, then I want to
> replcae HOSTNAME value to linux.com, if line is not there I want add
> new line HOSTNAME=linux.com
>
> Using inplace editing I was not able to add new line.
>
> Here is my one liner inplace editing script
>
>  perl -i.old -ne '$ne=0; if( /^\s*HOSTNAME\s*=/ ) {
> s/=.*$/=linux.com/; $nx++; print $_; }else { print $_; } END { if( $nx
> ==0 ){ $_="HOSTNAME=linux.com\n"; print $_; } }' network
>
Your main problem is that when run via -i, perl selects STDOUT after the
end of the implicit loop.  perldoc perlrun gives the clue on how to do
this correctly.
(Other problems in your code involve using $ne one place and $nx another
and doing more regular expression processing than you need to).

perl -i.old -ne '$n++ if s/^(\s*HOSTNAME\s*)=.*/$1=linux.com/; print $_;
if (eof && $n==0 ){ print "HOSTNAME=linux.com\n" }' network


read perldoc perlrun for -i and perldoc perlfunc for eof

Paul Lalli


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

Date: Mon, 24 May 2004 16:23:01 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Perl inplace editing
Message-Id: <20040524162209.E338@dishwasher.cs.rpi.edu>

On Mon, 24 May 2004, Joe Smith wrote:

> Sundaram Ramasamy wrote:
>
> >  perl -i.old -ne '$ne=0; if( /^\s*HOSTNAME\s*=/ ) {
>
> You don't want to set $ne to zero everytime through the loop.
>
>     perl -i.old -ne '$ne=0 if not defined $ne; if( /^\s*HOSTNAME\s*=/ ) {
>
> 	-Joe
>

Seeing as the OP wasn't using $ne anywhere else in the one-liner, that
wasn't one of his problems at all, actually.

Paul Lalli


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

Date: Mon, 24 May 2004 16:29:57 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Perl inplace editing
Message-Id: <20040524162529.H338@dishwasher.cs.rpi.edu>

On Mon, 24 May 2004, Paul Lalli wrote:

> On Mon, 24 May 2004, Sundaram Ramasamy wrote:
>
> > I want to check in file line start with HOSTNAME, then I want to
> > replcae HOSTNAME value to linux.com, if line is not there I want add
> > new line HOSTNAME=linux.com
> >
> > Using inplace editing I was not able to add new line.
> >
> > Here is my one liner inplace editing script
> >
> >  perl -i.old -ne '$ne=0; if( /^\s*HOSTNAME\s*=/ ) {
> > s/=.*$/=linux.com/; $nx++; print $_; }else { print $_; } END { if( $nx
> > ==0 ){ $_="HOSTNAME=linux.com\n"; print $_; } }' network
>
> Your main problem is that when run via -i, perl selects STDOUT after the
> end of the implicit loop.  perldoc perlrun gives the clue on how to do
> this correctly.
> (Other problems in your code involve using $ne one place and $nx another
> and doing more regular expression processing than you need to).
>
> perl -i.old -ne '$n++ if s/^(\s*HOSTNAME\s*)=.*/$1=linux.com/; print $_;
> if (eof && $n==0 ){ print "HOSTNAME=linux.com\n" }' network

If and only if you're willing to let the HOSTNAME line move in the file,
this might be a slightly less messy way of accomplishing your goal.

[untested]
perl -i.old -ne 'print unless /^\s*HOSTNAME\s*=/; print
"HOSTNAME=linux.com\n" if eof;'

(The caveat is that the modified file will always have the HOSTNAME line
at the end of the file, regardless of where it might have been in the
original)

Paul Lalli


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

Date: Mon, 24 May 2004 17:15:56 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl vs PHP
Message-Id: <aab4b0pujlqk3m8jeqrf0vni8cb3dh0caf@4ax.com>

Ben Morrow wrote:

>> I've got stuff that uses both ... so much of the syntax, etc. is similar. 
>
>*boggle* Beyond a basic similarity to C, and to shell, is it?

No, PHP is actually based upon Perl.

But Perl is more versatile (= "less frustrating"). I actually like
Javascript as a language better than PHP.

-- 
	Bart.


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

Date: Mon, 24 May 2004 10:08:44 -0700
From: D Cameron <davcamer@interchange.ubc.ca>
Subject: Re: Sequential analysis in perl?
Message-Id: <c8ta6l$qoa$1@nntp.itservices.ubc.ca>


Unfortunately I lot of the stuff google came up with are link farms. 
Maybe this is time to bust out Vivissimo. Anyway, I did find out about R 
and the MatLab packages through a similar search, which is what prompted 
me to start questioning perl altogether.

Dave


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

Date: Mon, 24 May 2004 10:10:44 -0700
From: D Cameron <davcamer@interchange.ubc.ca>
Subject: Re: Sequential analysis in perl?
Message-Id: <c8taad$qoa$2@nntp.itservices.ubc.ca>

Thanks for the R suggestion! I'd run across a reference to it in one of 
the readmes for a Statistics:: module and was thinking it might be worth 
looking at. We had been hoping to get the process down to a one step 
batch sort of thing, but even two steps would be better than what they 
had before.

Dave


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

Date: Mon, 24 May 2004 10:17:18 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Sockets: receiving data
Message-Id: <240520041017189411%jgibson@mail.arc.nasa.gov>

In article <39ee9c03a3a99dd4501c8c963726a4be@news.teranews.com>, Bigus
<someone@somewhere.com> wrote:

[socket program snipped]

> >
> > Stick to the object-oriented versions of the socket functions. E.g.,
> > use $lsv->recv(...) instead of recv(...) (although as you have
> > discovered you should be using read instead of recv). You are calling
> > the basic Perl recv function with a reference to an IO::Socket::INET
> > object instead of a file handle as the first argument. That may or may
> > not work.
> 
> OK, I've done that now. What's the advantage of referencing the object when
> calling a function? Is it something to do with error-trapping?

The advantage is explicitness, consistency, and readability. As Ben
Morrow pointed out, an IO::Socket::INET works as a file handle, but
that is something I was not able to discern from the 10 minutes I spent
looking at the documentation for IO::Socket::INET, IO::Socket,
IO::Handle, and IO::File, all of which are involved in interpreting how
to use the IO::Socket::INET object you have created. It is best not to
mix your paradigms. Doing so may lead to confusion on your part and
those who are trying to help you. Other modules you use may not be
implemented in such a transparent way as to allow mixing functional and
object-oriented methods.


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

Date: Mon, 24 May 2004 18:25:39 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: String search/match question
Message-Id: <40B23E05.EF277063@acm.org>

Anno Siegel wrote:
> 
> John W. Krahn <krahnj@acm.org> wrote in comp.lang.perl.misc:
> >
> > perl -le'
> > $_ = "abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz";
> > /x(?=[^]]*\[)/ && print $-[0]
> > '
> > 37
> 
> That fails when no "[" follows the valid "x".

perl -le'
$_ =
"abcdefg[extra]hijklmn[texas]opqrstuvwYZabc[tex]defghijklmnopqrstuvwxyz";
/x(?=[^]]*(?:\[|$))/ && print $-[0]
'
67


John
-- 
use Perl;
program
fulfillment


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

Date: 24 May 2004 18:57:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: String search/match question
Message-Id: <c8tgia$dm9$2@mamenchi.zrz.TU-Berlin.DE>

John W. Krahn <krahnj@acm.org> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > 
> > John W. Krahn <krahnj@acm.org> wrote in comp.lang.perl.misc:
> > >
> > > perl -le'
> > > $_ =
> "abcdefg[extra]hijklmn[texas]opqrstuvwxYZabc[tex]defghijklmnopqrstuvwxyz";
> > > /x(?=[^]]*\[)/ && print $-[0]
> > > '
> > > 37
> > 
> > That fails when no "[" follows the valid "x".
> 
> perl -le'
> $_ =
> "abcdefg[extra]hijklmn[texas]opqrstuvwYZabc[tex]defghijklmnopqrstuvwxyz";
> /x(?=[^]]*(?:\[|$))/ && print $-[0]
> '
> 67

Yup.

Anno


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

Date: 24 May 2004 21:44:01 +0200
From: Rickard <hanssonrickard@hotmail.com>
Subject: Take three form variables and write to an "settings-file"
Message-Id: <40b25081$1@news.wineasy.se>

Hi.

I am so very new to perl that i have to ask for help. :-)

This is what i need help with:


I have an web page, it contains an form with three textfields and one 
Submit button.

What i want it to do is to take those variables from the three 
textfields and put them in an local file on the webserver.

the file should be formatted like this (with tab separated fields)

variable1	content1
variable2	content2
variable3	content3


Where variable 1-3 is then "name of the line" and content 1-3 is the 
"value".


This information is later on used in shell scripts running on the server.

So this should be some kind of admin frontend to the scripts.


Please help me.


//Rickard Hansson


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

Date: Mon, 24 May 2004 15:53:46 -0400
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Take three form variables and write to an "settings-file"
Message-Id: <20040524155126.A338@dishwasher.cs.rpi.edu>

On Mon, 24 May 2004, Rickard wrote:

> Hi.
>
> I am so very new to perl that i have to ask for help. :-)
>
> This is what i need help with:
>
> I have an web page, it contains an form with three textfields and one
> Submit button.
>
> What i want it to do is to take those variables from the three
> textfields and put them in an local file on the webserver.
>
> the file should be formatted like this (with tab separated fields)
>
> variable1	content1
> variable2	content2
> variable3	content3
>
> Where variable 1-3 is then "name of the line" and content 1-3 is the
> "value".
>
> This information is later on used in shell scripts running on the server.
>
> So this should be some kind of admin frontend to the scripts.
>
> Please help me.


What have you tried so far?  What didn't work the way you expected?

Have you ever done any CGI programming with Perl?  If not, please read the
documentation:
perldoc CGI
or
http://www.perldoc.com/perl5.8.4/lib/CGI.html

Once you've learned enough to make an attempt, if it doesn't work, let us
know and we can help you debug.

Paul Lalli


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

Date: Mon, 24 May 2004 21:53:10 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Take three form variables and write to an "settings-file"
Message-Id: <2hf27rFc57m4U1@uni-berlin.de>

Rickard wrote:
> I am so very new to perl that i have to ask for help. :-)

That's not a reason in itself to ask for help in a newsgroup.

> This is what i need help with:

*Why* do you "need help"? Can it possibly be because you haven't tried 
yourself, and simply hope that others will do your work for you? Your 
problem is trivial, so it's well covered by the Perl documentation as 
well as numerous books, tutorials, etc.

Have a look at 
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

and make a serious try to fix it by yourself.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 24 May 2004 21:56:16 +0200
From: Rickard <hanssonrickard@hotmail.com>
Subject: Re: Take three form variables and write to an "settings-file"
Message-Id: <40b25360$1@news.wineasy.se>

Paul Lalli wrote:

> On Mon, 24 May 2004, Rickard wrote:
> 
> 
>>Hi.
>>
>>I am so very new to perl that i have to ask for help. :-)
>>
>>This is what i need help with:
>>
>>I have an web page, it contains an form with three textfields and one
>>Submit button.
>>
>>What i want it to do is to take those variables from the three
>>textfields and put them in an local file on the webserver.
>>
>>the file should be formatted like this (with tab separated fields)
>>
>>variable1	content1
>>variable2	content2
>>variable3	content3
>>
>>Where variable 1-3 is then "name of the line" and content 1-3 is the
>>"value".
>>
>>This information is later on used in shell scripts running on the server.
>>
>>So this should be some kind of admin frontend to the scripts.
>>
>>Please help me.
> 
> 
> 
> What have you tried so far?  What didn't work the way you expected?
> 
> Have you ever done any CGI programming with Perl?  If not, please read the
> documentation:
> perldoc CGI
> or
> http://www.perldoc.com/perl5.8.4/lib/CGI.html
> 
> Once you've learned enough to make an attempt, if it doesn't work, let us
> know and we can help you debug.
> 
> Paul Lalli

Well actually, i have never done PERL CGI scripting.

But thanks for the link, i will start reading directly.

Sorry for taking up your time.

//Rickard H


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

Date: Mon, 24 May 2004 15:35:24 -0600
From: "James Hunt" <jameskorea2003@hotmail.com>
Subject: Using Cookies With Perl
Message-Id: <d6udnXeKBqsK9y_dRVn-hQ@comcast.com>

Does anyone have a good web reference for setting up and accessing cookies
with Perl?

- James Hunt




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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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