[15659] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3072 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 17 03:05:22 2000

Date: Wed, 17 May 2000 00:05:11 -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: <958547110-v9-i3072@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 17 May 2000     Volume: 9 Number: 3072

Today's topics:
    Re: *Beginner help with HASHES <bmb@dataserv.libs.uga.edu>
    Re: *Please Help.New to Perl and CGI* <evilbeaver.picksoft@NOSPAMzext.net>
    Re: *Please Help.New to Perl and CGI* <me@here.or.there.com>
    Re: Camel T-Shirt <elaine@chaos.wustl.edu>
    Re: Camel T-Shirt (Andrew Johnson)
    Re: catching eval warnings and preventing them <anmcguire@ce.mediaone.net>
        counting leading spaces <mcdonabNO@SPAMyahoo.com>
    Re: counting leading spaces <jeff@vpservices.com>
    Re: counting leading spaces <uackermann@orga.com>
        cpan errors <joe@nall.com>
        determining existence of object method <kenneth.lee@alfacomtech.com>
    Re: determining existence of object method <uri@sysarch.com>
    Re: Getopt::Std 1 == 0 ??? <andkaha@my-deja.com>
    Re: Parsing Data Files & CGI <jeff@vpservices.com>
        printing hash of hash ? tvn007@my-deja.com
        reading from a socket <news**NO_SPAM**@psychogenic.com>
    Re: Reading/searching file problem <anmcguire@ce.mediaone.net>
        regex mind bender (for me) <nomail@nomail.com>
    Re: regex mind bender (for me) <uri@sysarch.com>
        Simple question about parsing HTML <frankieli@hotmail.com>
    Re: Sorting hash of hash by first then second key <abuse@borpin.co.uk>
        upload to server <neumann@m-line-bremen.de>
        Why does STDOUT->fdopen(...) work? <franl-removethis@world.omitthis.std.com>
    Re: Why does the contents of my file dissapear in an FT <anmcguire@ce.mediaone.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 17 May 2000 00:15:56 -0400
From: Brad Baxter <bmb@dataserv.libs.uga.edu>
Subject: Re: *Beginner help with HASHES
Message-Id: <Pine.GSO.4.21.0005170007580.26871-100000@dataserv.libs.uga.edu>

On Wed, 17 May 2000 neysa@nycap.rr.com wrote:
 ...
> Now I need to change the report and replace the heading GROUPS with all
> the unique group names and then below list the operators with X to
> represent the groups they are in
> 
> Example:
> OPRID       NAME          GROUP1   GROUP2   GROUP3   GROUP4
> -----------------------------------------------------------
> 123         TEST123       X                  X
> ABC         DUMMYA                   X
> XYZ         TESTX         X                          X
 ...

Here's one approach:

     1  #!/usr/local/bin/perl -w
     2  use strict;
     3
     4  my %hash = (
     5      123 => {
     6        name   => 'TEST123',
     7        groups => {
     8          GROUP1 => 1,
     9          GROUP3 => 1,
    10          },
    11        },
    12      ABC => {
    13        name   => 'DUMMYA',
    14        groups => {
    15          GROUP2 => 1,
    16          },
    17        },
    18      XYZ => {
    19        name   => 'TESTX',
    20        groups => {
    21          GROUP1 => 1,
    22          GROUP4 => 1,
    23          },
    24        },
    25      );
    26
    27  my $fmt = "%-10s";
    28
    29  printf $fmt x 6, qw( OPRID NAME GROUP1 GROUP2 GROUP3 GROUP4 );
    30  print "\n", '-' x 60, "\n";
    31
    32  foreach my $oprid ( sort keys %hash ) {
    33    my $name = $hash{ $oprid }{name};
    34    printf $fmt x 2, $oprid, $name;
    35
    36    foreach my $group ( qw ( GROUP1 GROUP2 GROUP3 GROUP4 ) ) {
    37      printf $fmt, $hash{ $oprid }{groups}{ $group } ? 'X' : '';
    38    }  # foreach group
    39    print "\n";
    40
    41  }  # foreach oprid

Output:

OPRID     NAME      GROUP1    GROUP2    GROUP3    GROUP4
------------------------------------------------------------
123       TEST123   X                   X
ABC       DUMMYA              X
XYZ       TESTX     X                             X


-- 
Brad



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

Date: Wed, 17 May 2000 04:18:58 GMT
From: "The Evil Beaver" <evilbeaver.picksoft@NOSPAMzext.net>
Subject: Re: *Please Help.New to Perl and CGI*
Message-Id: <S4pU4.55485$Kv2.249770@quark.idirect.com>

I had the same problem. Then I switched to Apache/Win32, and it's been great
ever since. Just remember the #! thingie.


-----
The Evil Beaver <evilbeaver.picksoft@NOSPAMzext.net>
-- Remove NOSPAM to e-mail me.
This message ROT-13 encrypted twice for extra security.

SaintJAVA <saintjava@aol.com> wrote...
> Hello,
>
> I have recently began learning Perl with the purpose of using it to write
CGI
> scripts. I think I can grasp the Perl language, but I've found difficulty
> testing my scripts in a Web environment.
>
> I've installed the Microsoft Personal Web Server that comes with Windows
98
> hoping that its built in CGI bin would work out.  It hasn't. Whenever I
call a
> perl script in my cgi-bin directory I get a HTTP 500 - Internal server
error
> message.
>
> Could anyone tell me:
> How can I configure my Windows server to excecute the perl scripts in my
> cgi-bin when I call them from a web page form?
>
> Is there an online resource that you know for a fact tells how to set up
your
> webserver to process CGI requests?
>
> I've searched www.perl.org, the books "Using Perl 5" by Que and "The CGI
Manual
> of Style" for the answers but I've come up with zilch. Anf after two
afternoons
> at Barnes and Noble looking through their webserver books I've almost
given up.
>
> I am running:
> Windows 98 SE
> ActivePerl 5.6
> Microsoft Personal Web Server (that comes with Windows 98)
>
> An simple test script that I've tried using is:
>
> print "Content-type: text/html\n\n";
> print "<h1>hello world</h1>";
>
>
> Thanks in advance!
> ~e
>




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

Date: Wed, 17 May 2000 06:18:59 +0100
From: "Brian" <me@here.or.there.com>
Subject: Re: *Please Help.New to Perl and CGI*
Message-Id: <958540788.1398.0.nnrp-12.c2de3303@news.demon.co.uk>

Have you set the permissions for your cgi-bin (or where ever your script
currently lives).
Use the Personal Web Server Manager / advanced properties / select the
appropriate directory / select properties... make sure you can 'read' and
run 'scripts'.

Good Luck,

Brian.

> I've installed the Microsoft Personal Web Server that comes with Windows
98
> hoping that its built in CGI bin would work out.  It hasn't. Whenever I
call a
> perl script in my cgi-bin directory I get a HTTP 500 - Internal server
error
> message.
>
> Could anyone tell me:
> How can I configure my Windows server to excecute the perl scripts in my
> cgi-bin when I call them from a web page form?





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

Date: Wed, 17 May 2000 04:13:55 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Camel T-Shirt
Message-Id: <B54794C1.41E2%elaine@chaos.wustl.edu>

in article 3921B4D1.447E83F6@attglobal.net, Drew Simonis at
care227@attglobal.net quoth:

> From Websters:  
> 
> monger \Mon"ger\, v. t. To deal in; to make merchandise of; to
> traffic in; -- used chiefly of discreditable traffic.

Well...Portuguese has a slang term sounding much like monger that means
'retard' ...so it could be worse. :)

Trafficing Perl is about as nerdy as it gets. I don't think someone will
approach me late at night in an alley asking me if I want a deal on some
Perl items. 

Of course, one might notice a large number of exploits these days being
written in Perl. Perhaps we should make the authors of them honorary
'mongers'.

e. 




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

Date: Wed, 17 May 2000 04:41:27 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Camel T-Shirt
Message-Id: <XppU4.13975$95.196524@news1.rdc1.mb.home.com>

In article <brian-1605002256520001@1cust103.tnt3.durham.nc.da.uu.net>,
 brian d foy <brian@smithrenaud.com> wrote:
[snip]
> >monger \Mon"ger\, v. t. To deal in; to make merchandise of; to 
> >traffic in; -- used chiefly of discreditable traffic. 
> 
> hoepfully you don't think trafficking in Perl is discreditable ;)

hmm, what would that be like...

    He knew it was dangerous to be jacked-in to the net carrying so
    many cycles running Perl, but it was a necessary risk. You were
    only allowed so many cycles for personal use, they confiscated
    all the rest to keep the system running -- or so they said, but
    you knew the fat cat officials had their own private caches
    dedicated to all kinds of illicit activities ... porn simulations
    mostly and other such trivial wastage. If he got caught with this
    many cycles running Perl they'd bust him for trafficking for sure
    and then he'd be on the cyberstreet just like those he was trying
    to help, or worse. He ducked into a dark alleyway and they were
    there waiting for him -- some the very architects of this
    misappropriated technology -- strung out and deperate for a fix,
    and he had one for them. He passed around the jack allowing each
    a few seconds of direct linkage into teracycles of nearly pure
    Perl -- but there wasn't much time, even with all his safegaurds,
    a cycle drain like this could be traced in minutes and because of
    its highly subversive nature and the extreme threat it
    represented to the system, trafficking in Perl carried very
    harsh penalties. He took no credits from them, their fix was also
    their contribution. As quickly as he had come he disappeared into
    the night and made his way back to the safehouse. He'd be back
    though, and if he got caught one of the other Perl Mongers would
    come in his place -- but not for much longer, they were ahead of
    schedule...

regards,
andrew (ack! Did I take the wrong pill again?)

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/epwp.html
      The generation of random numbers is too 
      important to be left to chance.
      


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

Date: Wed, 17 May 2000 00:10:59 -0500
From: "Andrew N. McGuire" <anmcguire@ce.mediaone.net>
Subject: Re: catching eval warnings and preventing them
Message-Id: <392229E3.D0A5C770@ce.mediaone.net>

Dan Brown wrote:

[ snip ]

Good gracious man, check your word wrap.  Also it
is considered appropriate in this NG, as with most
of Usenet, to reply at the bottom of a post. :-)

Best Wishes,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| anmcguire@ce.mediaone.net                              |
`-------------------------------------------------------*/


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

Date: Tue, 16 May 2000 23:22:43 -0700
From: "Brian McDonald" <mcdonabNO@SPAMyahoo.com>
Subject: counting leading spaces
Message-Id: <8ftdsj$dcp$1@nntp9.atl.mindspring.net>

Hi.

I know how to strip leading spaces...

s/^\s+//;

But I can't figure out a way to count them before I strip them. I need to
count them in order to encode the formatting information for a series of
lines of text.

For example,

    I am a line of text.
    I am another line of text.
        I am an indented line of text.

A variable called $indent should take the value of 2 (spaces) for the last
line.

Any ideas?

Thanks,
brian





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

Date: Tue, 16 May 2000 23:52:18 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: counting leading spaces
Message-Id: <392241A2.10C885DF@vpservices.com>

Brian McDonald wrote:
> 
> I know how to strip leading spaces...
> 
> s/^\s+//;
> 
> But I can't figure out a way to count them before I strip them. I need to
> count them in order to encode the formatting information for a series of
> lines of text.
> 
> For example,
> 
>     I am a line of text.
>     I am another line of text.
>         I am an indented line of text.
> 
> A variable called $indent should take the value of 2 (spaces) for the last
> line.

Well it looks like four spaces rather than 2 to me :-), but:

while(<DATA>){
    if( /^(\s*)(\S.*)/ ) { 
        $indent = length($1); 
        $line = $2; 
        print "$indent : $line\n";    
    }
}

-- 
Jeff


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

Date: Wed, 17 May 2000 08:51:57 +0200
From: Ulrich Ackermann <uackermann@orga.com>
Subject: Re: counting leading spaces
Message-Id: <3922418D.9663D63@orga.com>

Brian McDonald wrote:
> 
> Hi.
> 
> I know how to strip leading spaces...
> 
> s/^\s+//;
> 
> But I can't figure out a way to count them before I strip them. I need to
> count them in order to encode the formatting information for a series of
> lines of text.
> 
> For example,
> 
>     I am a line of text.
>     I am another line of text.
>         I am an indented line of text.
> 
> A variable called $indent should take the value of 2 (spaces) for the last
> line.
> 
> Any ideas?
> 
> Thanks,
> brian
Maybe there is a modifier that does such things. perldoc perlre should
tell you if so.
But I think this should work too:
my $indent;
$text =~ s/^(\s+)//;
$indent = length($1);

Hope this helps,

Ulrich


-- 
Ulrich Ackermann
ORGA Kartensysteme GmbH (SY-PEAT-STA)
Tel.:+49.5254.991-925 
mailto:uackermann@orga.com


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

Date: Wed, 17 May 2000 04:34:45 +0000
From: Joe Nall <joe@nall.com>
Subject: cpan errors
Message-Id: <39222165.A909456D@nall.com>

 perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.52)
ReadLine support enabled

cpan> r
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  ftp://ftp.cdrom.com/pub/perl/CPAN/authors/01mailrc.txt.gz
Fetching with Net::FTP:
  ftp://ftp.cdrom.com/pub/perl/CPAN/authors/01mailrc.txt.gz
Couldn't cwd pub/perl/CPAN/authors at /usr/libdata/perl5/CPAN.pm line
1869.
Fetching with LWP:
  ftp://mirror.xmission.com/CPAN/authors/01mailrc.txt.gz
Fetching with Net::FTP:
  ftp://mirror.xmission.com/CPAN/authors/01mailrc.txt.gz
Couldn't fetch 01mailrc.txt.gz from mirror.xmission.com
Fetching with LWP:
  ftp://cpan.valueclick.com/CPAN/authors/01mailrc.txt.gz
Fetching with Net::FTP:
  ftp://cpan.valueclick.com/CPAN/authors/01mailrc.txt.gz
Couldn't fetch 01mailrc.txt.gz from cpan.valueclick.com
Fetching with LWP:
  ftp://ftp.duke.edu/pub/perl/authors/01mailrc.txt.gz
Fetching with Net::FTP:
  ftp://ftp.duke.edu/pub/perl/authors/01mailrc.txt.gz

 ...
WTFO?

joe


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

Date: Wed, 17 May 2000 12:47:09 +0800
From: Kenneth Lee <kenneth.lee@alfacomtech.com>
Subject: determining existence of object method
Message-Id: <3922244D.B80A1EF8@alfacomtech.com>

i want to test whether an object can invoke an arbitrary method.
defined() (or exists() in 5.6.0) only works for class methods, but not 
object ones.

i tried eval(), which set $@ if the method doesn't exists, but it sets $@ 
also if that method exists and raises exception when called.

there's no way to identify the error except parsing the value in $@.
Any thought?

kenneth


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

Date: Wed, 17 May 2000 05:04:41 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: determining existence of object method
Message-Id: <x7zopphimx.fsf@home.sysarch.com>

>>>>> "KL" == Kenneth Lee <kenneth.lee@alfacomtech.com> writes:

  KL> i want to test whether an object can invoke an arbitrary method.
  KL> defined() (or exists() in 5.6.0) only works for class methods, but not 
  KL> object ones.

use the can method which every package inherits.

and comp.lang.perl is a dead group. tell your isp to drop it.

uri

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


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

Date: Wed, 17 May 2000 06:52:33 GMT
From: Andreas Kahari <andkaha@my-deja.com>
Subject: Re: Getopt::Std 1 == 0 ???
Message-Id: <8ftfjd$8da$1@nnrp1.deja.com>

In article <8fs5q8$q3s$1@nnrp1.deja.com>,
  gregsptl1962@my-deja.com wrote:
> #!/usr/bin/perl
> #!/usr/bin/perl -dw
>
> use Getopt::Std;
> getopts ('c:');  # set -c to the skip count
>
> $Getopt::Std::opt_c = '1' unless
> $Getopt::Std::opt_c;
>          # Set count by default to 1
>
> print "$Getopt::Std::opt_c\n"; # Debug Why's -c 0
> == 1???
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

You probably meant to say

use Getopt::Std;
getopts('c:');
$opt_c = '1' unless defined($opt_c); # use defined to see if it was
defined or not
print "$opt_c\n";

/A

--
# Andreas Kähäri, <URL:http://hello.to/andkaha/>.
# All junk email is reported to the appropriate authorities.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 16 May 2000 21:18:04 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Parsing Data Files & CGI
Message-Id: <39221D7C.4DED6444@vpservices.com>

Lewis Etheridge wrote:
> 
> I've been provided with a data file that has each "field" on successive
> lines ($state.txt).  Each "record" is six lines longs, and I don't have
> to deal with inappropriate input (this time).   The plan is to load
> this up and provide various ways to sort the data. I'll need to provide
> sorting methods on each field. 

If you don't particularly feel like reinventing the wheel on your sort
routines, you can simply take the whole hashref from your Get_Store_Data
and import it into into a DBD::RAM in-memory table with a single
command, then search, sort, select, modify using SQL commands that would
let you use any combination of fields as your sorting criteria.  You
could either let it automatically create field names (col1,col2,col3,
etc.), or you could feed it a comma-separated list of field names and
let your sort commands be based on those (e.g. ORDER BY
state,city,lastname,firstname would sort on four different fields and if
you wanted reverse sorts, you'd just add in a DESC -descending - after
the field to be in reverse order).

-- 
Jeff


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

Date: Wed, 17 May 2000 06:42:54 GMT
From: tvn007@my-deja.com
Subject: printing hash of hash ?
Message-Id: <8ftf1c$7q8$1@nnrp1.deja.com>

Hi,

Would someone please help me with the script below:

Here what I need help on:

As an example, I would like the output to be print in 5 columns only as
shown below:

order#		A		B		C		D


Pizza		1		2		4		3

Mango		2		3		3		3


Order#		X		Y		Z		F


Pizza		1		2		4		3

Mango		2		3		3		3





  The script below, print the hash in many many columns and It
is very diffcult to import and print the data using Excel.



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

$data_file = 'OUTPUT';


open(DATA,$data_file)or die "cannot open '$data_file':$!";


$output_file = $data_file.".out";
open (OUTFILE,">$output_file")|| die "cannot open\n";


my(%hash, %items);

while (<DATA>) {
chomp;
my($order, $item, $value) = split /:/;
$hash{$order}{$item} = $value;

$items{$item}{cnt}++;
}

print OUTFILE "order #\t";

 for (sort keys %items){

	print OUTFILE  "\t$_" ;

	}

print "\n\n";
print OUTFILE "\n\n";
for my $order (sort keys %hash) {
	print OUTFILE "$order\t";

for my $item (sort keys %items) {
   print OUTFILE "\t", exists($hash{$order}{$item})?
$hash{$order}{$item}: "xxx";
}
print OUTFILE "\n";
}

Thanks in advance for any help,


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 17 May 2000 05:37:37 GMT
From: Pat <news**NO_SPAM**@psychogenic.com>
Subject: reading from a socket
Message-Id: <39222FD6.A7EE53E@psychogenic.com>

Hello all!

I've been playing with sockets and a few of the server examples in "Programming Perl" and I've run into a problem I can't seem to get an answer to...

I have created an interactive server which responds to my input using calls to read, something like:

read(Client, $answer, 20);

This works fine but what if I don't know the lenght of the answer in advance?  The perldoc says that '[...] SCALAR [the length] will be grown or shrunk to the length actually read' but typing in something longer than 20 get choped at 20 chars and I can't get it to stop reading at anything under 20 chars (^D doesn't work - unless I do it 20 times!).

Using read without a third arg causes errors.

Any ideas?

TIA.
Pat.


---
Remove the **NO_SPAM** if replying via email.


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

Date: Wed, 17 May 2000 00:05:17 -0500
From: "Andrew N. McGuire" <anmcguire@ce.mediaone.net>
Subject: Re: Reading/searching file problem
Message-Id: <3922288D.22E58F58@ce.mediaone.net>

[ rearranged and trimmed for legibility ]

scott wrote:
>
> Jimmy Lantz <webmaster@ostas.lu.se> wrote in message
> news:391E844B.509D31DC@ostas.lu.se...
> > Hi, I have the following problem:
> > I need to read a file and search for a match according to the following
> criterias:
> >
> >
> > $match = KIN213:;
> >
> > open(IN, "$file");
> >
> > How do I match the line in the file ???? And set the text to var $titel ?
> >
> > close(IN);
> > }
> >
> > Below are some samples of lines in the file(the jidderish is supposed to
> > be random text and that's the text I need to set to the variabel $titel:
> >
> > OSH435: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
> > KIN213: jfjfdshfjhsd this is a match jdhf
> > JAP346: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
> > THA212: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
> > KAN234: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
> > KIN244: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
> > KIN262: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf

[ snip ]
> 
> $pattern = "$KIN213";

Why the '$'?

>     open (FILE, $input) or die "Couldn't open input $input: $!; aborting";

Assuming $input is assigned, OK.

>     while (<FILE>) {
>         print if /\Q$pattern\E/;
>     }
>     close FILE;
> 
> close($file);

Where was this ever opened, or even assigned?
 
> See also perfaq 6 in the documentation.

Good idea.  Your code compiles, but is incomplete,
and does not do what the OP wanted.
If the pattern must be stored in a variable, I think this
will get you started, if I understand correctly.

#!/usr/bin/perl -w

use strict;
my $pat = '^KIN213:\s+(.*)';
my $titel;
/$pat/ and print $titel = $1 while <DATA>;

__DATA__
OSH435: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
KIN213: jfjfdshfjhsd this is a match jdhf
JAP346: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
THA212: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
KAN234: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
KIN244: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf
KIN262: jfjfdshfjhsdfkjhsdjfhdjhfdjhfjdhf

Regards,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| anmcguire@ce.mediaone.net                              |
`-------------------------------------------------------*/


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

Date: Tue, 16 May 2000 21:01:51 -0400
From: "Jonah" <nomail@nomail.com>
Subject: regex mind bender (for me)
Message-Id: <8ft1dm$137i$1@onlink3.onlink.net>

This seems simple enough but I can't
solve it.

I'm getting a value from a $q->textfield
and I need to check if it contains *only* spaces.

not empty,  but if it has 1 or more spaces and nothing else in it.

my $var = $q->param('mytextfield');
print "yay" if $var =~ /\s+/;

Obviously that matches on any string with one or more spaces in it
even if it has word characters too.

I think I have to do a negation and use .   but that
still screws with my head.

Any ideas?

Thanks.









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

Date: Wed, 17 May 2000 06:27:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: regex mind bender (for me)
Message-Id: <x7vh0dhes8.fsf@home.sysarch.com>

>>>>> "J" == Jonah  <nomail@nomail.com> writes:

  J> I'm getting a value from a $q->textfield
  J> and I need to check if it contains *only* spaces.

  J> not empty,  but if it has 1 or more spaces and nothing else in it.

  J> print "yay" if $var =~ /\s+/;

that only checks if there are ANY spaces in the string. you need to
anchor it to eliminate any other chars:

print "yay" if $var =~ /^\s+$/;

uri

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


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

Date: Wed, 17 May 2000 14:41:53 +0800
From: Frankie <frankieli@hotmail.com>
Subject: Simple question about parsing HTML
Message-Id: <39223F31.5FBF7808@hotmail.com>

Hello, I have the following case: I have the content of a HTML file
stored in a string(whole file in 1 string) , and I just wanted to cut
out the link and the text of it, eg if the string have something like
:"... <a href=abc.html>This is abc</a> ...", then the script will return
"abc.html" and "This is abc" to me. I have implemented the first
part(the link) of it by HTML::LinkExtor, but dunno how to implement the
second part(the text), can anyone tell me how?

Thanks a lot!!!



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

Date: Wed, 17 May 2000 07:25:01 +0100
From: Brian Orpin <abuse@borpin.co.uk>
Subject: Re: Sorting hash of hash by first then second key
Message-Id: <o6e4ison270mrht7bpqh7mged7jjgo8vjh@4ax.com>

On Tue, 16 May 2000 15:30:05 +0100, "Damon Jebb" <damon_jebb@nai.com>
wrote:

>Brian Orpin <abuse@borpin.co.uk> wrote in message
>news:k082iscofpf50df58s7v1sqepbv2vvfql8@4ax.com...
>> I have a hash
>>
>> $hash{key1}{key2} = val
>>
>> I want to sort it on the first key and then on the second key. So that on
>> key value of;
>>
>> 3 - 2
>> 3 - 1
>> 1 - 2
>> 4 - 2
>>
>> would sort to
>> 1 - 2
>> 3 - 1
>> 3 - 2
>> 4 - 2

>In irder for this to work the structure of the hash needs to be ...
>
>%Hash = (
>    key1 => {key1.2 => 'Val1'},
>    key3 => {key3.1=> 'Val3.1', Key3.2=>'Val3.2'},
>    key4 => {key4.2=> 'Val4.2'},
>    );

Hash is constructed like this (which I think is the same).  Data from
Data Dumper looks right;

$versions{$key}{$1} = $2 if m/(match1)(match2)/;

where $key is incremented in a loop.

If this isn't the same the how could I construct the hash in a loop with
$key incremented?

Dumper output.....

$VAR1 = '7';
$VAR2 = {
          '%1' => ' 1.6'
        };
$VAR3 = '8';
$VAR4 = {
          '%1' => ' 1.3',
          '%2' => ' 1.5'
        };

I am not worried about the value just in sorting the (2 levels of) keys
correctly.

>foreach $key1 (sort keys %Hash) {
> print "Found Key1 = $key1\n";
>
>    foreach $key2 (sort keys %{$Hash{$key1}}) {
>        print "Item $key1,$key2 has value ".$key1->{$key2}."\n";
>    }
>}

foreach $key1 (sort keys %versions) {

  foreach $version (sort keys %{$versions{$key1}}) {
	print "$key1$version\n";
   }
}

This doesn't even sort the first key correctly!!

I am missing something obvious here :-((

-- 
Brian Orpin  **Reply to address is valid***
Selfbuilding and It'll be finished one day.
http://www.borpin.co.uk/  *I have exorcised the Demon*


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

Date: Wed, 17 May 2000 08:47:09 +0200
From: "news.btx.dtag.de" <neumann@m-line-bremen.de>
Subject: upload to server
Message-Id: <8ftf2h$oil$13$1@news.t-online.com>

I need help. I want to upload binary files to my www-server.
I wrote a Script, but it isn't able to open the local file. What is wrong
or what have I forgotten :

sub save
{     
 
 my $query=new CGI;
 my $html=param("file");                             #
 my $file =$query->param("Datei");            # Name of the file
                                                                  # c:\...\...\filename.jpg
  
 my ($cb, @data, $data);
 my $max_size = 4096;
    
 open (DATA, "<$file") || die &sorry ("Datei konnte nicht zum lesen geöffnet werden");                               # Unix coulnd't open this file, why ?????
 binmode( DATA );
 binmode( STDOUT );    
 while ( $cb = read( DATA, $data, $max_size ) ) 
       {
        push @data, $data;
       }    
 close (DATA);
   
 $file =~ s/.*\\(.*\....)/$1/go; 
 my $out =&pfad.'mpage/images/'.$file;
 
 open (SAVE, ">$out") || die &sorry ("Datei konnte nicht zum speichern geöffnet werden");
 binmode SAVE;
 print SAVE @data;
 close (SAVE);
 
 &editfile($html);
 exit;
 }

I hope anyone of you could answer my question, so thanks.
If anybody knows where I can get a COMPLETE Script fordoing this
please mail to me DigitalChaos@gmx.de





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

Date: Wed, 17 May 2000 04:44:21 GMT
From: Francis Litterio <franl-removethis@world.omitthis.std.com>
Subject: Why does STDOUT->fdopen(...) work?
Message-Id: <m3ln194wgq.fsf@franl.andover.net>

I came across the following code, which has me confused:

	#!/usr/bin/perl -w

	use strict;
	use IO::File;

	my $file = IO::File->new('xxx', 'w');
	STDOUT->fdopen($file, 'w');      # Why does this work?

	print "this is a test\n";
	exit 0;


Why does the STDOUT->fdopen(...) work?  STDOUT is neither a blessed
reference nor the name of a package, yet it's used to invoke a package
method via the -> operator.  What's going on here?
--
Francis Litterio
franl-removethis@world.std.omit-this.com
PGP public keys available on keyservers.


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

Date: Tue, 16 May 2000 23:06:24 -0500
From: "Andrew N. McGuire" <anmcguire@ce.mediaone.net>
Subject: Re: Why does the contents of my file dissapear in an FTP?
Message-Id: <39221AC0.7591549A@ce.mediaone.net>

Abigail wrote:
> 
> On Wed, 17 May 2000 09:59:14 +1000,
> Amri, Kuross [WOLL:4009-I:EXCH] <kamri@asiapacificm01.nt.com> wrote:
> ++
> ++ I have this file that I've FTP'd across to another computer. Upon arrival,
> ++ it is missing it's contents. Any idea why?
> 
> Bitrot.

Please, stop, I'm not sure I can take anymore. :-)
ROTFLMAO

Regards,

anm
-- 
/*-------------------------------------------------------.
| Andrew N. McGuire                                      |
| anmcguire@ce.mediaone.net                              |
`-------------------------------------------------------*/


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 3072
**************************************


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