[23216] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5437 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 4 09:05:45 2003

Date: Thu, 4 Sep 2003 06:05:13 -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           Thu, 4 Sep 2003     Volume: 10 Number: 5437

Today's topics:
    Re: [newbie] how to get just the first value of a hash? <dave.nospam@ntlworld.com>
    Re: [newbie] how to get just the first value of a hash? (Anno Siegel)
    Re: [newbie] how to get just the first value of a hash? <jurgenex@hotmail.com>
        [newbie] list elements <guest1@deskpro192.internal.sanger.ac.uk>
    Re: [newbie] list elements <nospam@please.com>
    Re: [newbie] list elements <noreply@gunnar.cc>
    Re: [newbie] list elements <guest1@deskpro192.internal.sanger.ac.uk>
    Re: [newbie] list elements <minceme@start.no>
    Re: [newbie] list elements <nobull@mail.com>
    Re: [newbie] list elements <jurgenex@hotmail.com>
    Re: Arbitrarily Complex Data Structure <nobull@mail.com>
    Re: Artificial intelligence (AI) has been solved (Anno Siegel)
        expression specific search and replace (qanda)
    Re: expression specific search and replace <minceme@start.no>
    Re: expression specific search and replace (Anno Siegel)
    Re: expression specific search and replace (Tad McClellan)
        file upload script (boris bass)
    Re: file upload script <someone@somewhere.com>
        Learning Perl (was Re: learning examples) (Tad McClellan)
    Re: Order of evaluation of expressions (Anno Siegel)
    Re: Redirect stdio into a string (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 04 Sep 2003 08:54:55 +0100 (BST)
From: "Dave Saville" <dave.nospam@ntlworld.com>
Subject: Re: [newbie] how to get just the first value of a hash??
Message-Id: <qnirfnivyyragyjbeyqpbz.hkox7j7.pminews@text.news.ntlworld.com>

On Wed, 03 Sep 2003 12:41:13 +0200, Janek Schleicher wrote:

>Guest1 wrote at Wed, 03 Sep 2003 14:52:22 +0100:
>
>You can't.
>Hashs are unsorted, so there is no first key or value.

What I thought the OP meant was something I had wondered myself. If you
have a function/module/whatever that returns a hash and you happen to
*know* that there will only be one value in it, is there an easy way to
get that single value?

Regards

Dave Saville

NB switch saville for nospam in address




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

Date: 4 Sep 2003 08:32:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: [newbie] how to get just the first value of a hash??
Message-Id: <bj6ta7$bm3$1@mamenchi.zrz.TU-Berlin.DE>

Dave Saville <dave.nospam@ntlworld.com> wrote in comp.lang.perl.misc:
> On Wed, 03 Sep 2003 12:41:13 +0200, Janek Schleicher wrote:
> 
> >Guest1 wrote at Wed, 03 Sep 2003 14:52:22 +0100:
> >
> >You can't.
> >Hashs are unsorted, so there is no first key or value.
> 
> What I thought the OP meant was something I had wondered myself. If you
> have a function/module/whatever that returns a hash and you happen to
> *know* that there will only be one value in it, is there an easy way to
> get that single value?

Sure:

    my ( $value) = values %hash;

Anno


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

Date: Thu, 04 Sep 2003 12:01:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: [newbie] how to get just the first value of a hash??
Message-Id: <RQF5b.16677$N95.2615@nwrddc03.gnilink.net>

Tassilo v. Parseval wrote:
> Also sprach Jürgen Exner:
>
>> Guest1 wrote:
>> [see subject]
>>
>> Hashes are mappings and by definition don't have an order, therefore
>> there is no first element or first value.
>> Or how would you select the first value of let's say the cubicroot
>> function?
>
> Well, the first one is probably 0 (at least for real numbers). The
> challenge is to find the second value since it has a non-discrete
> carrier.

You fell for the trap ;-)
For squareroot(x) you are probably right.
But I was talking about cubicroot and I would think that -5 comes before 0.

You could also argue that in case of squareroot i comes before 0. But there
are too many people who don't know complex numbers, therefore it makes a
poor example.

jue




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

Date: Thu, 4 Sep 2003 11:04:28 +0100
From: Guest1 <guest1@deskpro192.internal.sanger.ac.uk>
Subject: [newbie] list elements
Message-Id: <Pine.LNX.4.44.0309041100540.9304-100000@deskpro192.internal.sanger.ac.uk>


If I have an array @a = [ 1 2 3 4 2 3 ];

how I can get just the elements that are not the same?

1, 2, 3 and 4

and what is the best way to store these values?

Thanks
Pedro



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

Date: Thu, 04 Sep 2003 10:22:39 GMT
From: Gunter Schelfhout <nospam@please.com>
Subject: Re: [newbie] list elements
Message-Id: <PnE5b.19042$eE2.792701@phobos.telenet-ops.be>

Guest1 wrote:

> 
> If I have an array @a = [ 1 2 3 4 2 3 ];

Try your array once in real code. ;-)

> how I can get just the elements that are not the same?
> 
> 1, 2, 3 and 4

A solution:
$seen{$_}++ foreach @a;
@unique = sort keys %seen;

> and what is the best way to store these values?

Another array?

Buy the Perl cookbook. It has a lot of codesnippets to solve problems like
this.

-- 
Blood, sweat & tears


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

Date: Thu, 04 Sep 2003 12:30:46 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: [newbie] list elements
Message-Id: <bj7499$fvjgf$1@ID-184292.news.uni-berlin.de>

Guest1 wrote:
> If I have an array @a = [ 1 2 3 4 2 3 ];

Then you get a compilation error.

> how I can get just the elements that are not the same?
> 
> 1, 2, 3 and 4

Assuming that your array is:

     @a = qw/1 2 3 4 2 3/;

you'd better study the FAQ:

     perldoc -q duplicate

> and what is the best way to store these values?

"Best way"? Don't understand the question.

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



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

Date: Thu, 4 Sep 2003 11:44:06 +0100
From: Guest1 <guest1@deskpro192.internal.sanger.ac.uk>
Subject: Re: [newbie] list elements
Message-Id: <Pine.LNX.4.44.0309041143210.9411-100000@deskpro192.internal.sanger.ac.uk>

Thanks guys,

I am learning a lot with your help

I'll buy the cook book too.

P

On Thu, 4 Sep 2003, Gunnar Hjalmarsson wrote:

> Guest1 wrote:
> > If I have an array @a = [ 1 2 3 4 2 3 ];
> 
> Then you get a compilation error.
> 
> > how I can get just the elements that are not the same?
> > 
> > 1, 2, 3 and 4
> 
> Assuming that your array is:
> 
>      @a = qw/1 2 3 4 2 3/;
> 
> you'd better study the FAQ:
> 
>      perldoc -q duplicate
> 
> > and what is the best way to store these values?
> 
> "Best way"? Don't understand the question.
> 
> 



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

Date: Thu, 4 Sep 2003 10:47:30 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: [newbie] list elements
Message-Id: <bj7582$hc8$1@troll.powertech.no>

Guest1 <guest1@deskpro192.internal.sanger.ac.uk> wrote:

> If I have an array @a = [ 1 2 3 4 2 3 ];
> how I can get just the elements that are not the same?

I'll do as Gunnar, and assume you mean 

    @a = qw( 1 2 3 4 2 3 );
>
> and what is the best way to store these values?

You could perhaps use the fact that hashes have unique keys.
Try building a hash with the values from the array:

    map $hash{$_} = 1, @a; # this will be more efficient in later perls..

Then you can print the unique keys by making a call to keys(),

    @unique = keys %hash;

If you want it in sequence, call sort (this is numerical sort):

    @unique = sort { $a <=> $b } keys %hash;

HTH,

-- 
Vlad


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

Date: 04 Sep 2003 12:29:12 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: [newbie] list elements
Message-Id: <u9u17saj1z.fsf@wcl-l.bham.ac.uk>

Guest1 <guest1@deskpro192.internal.sanger.ac.uk> top-posts:

> Thanks guys,
> 
> I am learning a lot with your help

I recommend that you learn to post correctly before your persistant
top-posting (which is considered rudeness) leads people to stop stop
helping you.

Please read posting guidelines to learn how to be a more constuctive
member of the comp.lang.perl.* community.

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


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

Date: Thu, 04 Sep 2003 12:03:03 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: [newbie] list elements
Message-Id: <XRF5b.16681$N95.7702@nwrddc03.gnilink.net>

Guest1 wrote:
> If I have an array @a = [ 1 2 3 4 2 3 ];
>
> how I can get just the elements that are not the same?

Please see
    perldoc -q duplicate

> and what is the best way to store these values?

???
Please be more specific. What do you mean with "store"?

jue




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

Date: 04 Sep 2003 13:00:39 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Arbitrarily Complex Data Structure
Message-Id: <u9iso8ahlk.fsf@wcl-l.bham.ac.uk>

jrolandumuc@yahoo.com (JR) writes:

> ### I came up with and tested the below code on a few dozens complex data 
> ### structures.  As long as the subroutine was passed a reference, and 
> ### the data structures contained either a scalar, code, hash, array, 
> ### or ref, or references to these, the subroutine returned the contents
> ### of the data structure.  This could be factored and improved upon, but
> ### is a decent second attempt, and seems to do the job I need it to do well.
> ### The Data::Dumper module does the same thing, but returns more 
> ### information than I really need---I only need the contents
> ### (there's probably a way to turn off this extra info., I'm guessing).      
> 
> #!/perl -w
> use strict;
> use diagnostics;
> 
> ### Traverse data structures of varying complexity
> 
> my $c = 0;
> sub traverse {
>    my $arg = shift; 
> 
>    ## Initial argument must be a reference.
>    ## If argument is passed a reference data structure,
>    ## but not as a reference, this block will be circumvented,
>    ## and the passed reference may not be completely traversed.
>    if (!$c && ref($arg) ne 'REF'   &&
>               ref($arg) ne 'HASH'  &&
>               ref($arg) ne 'ARRAY' &&
>               ref($arg) ne 'CODE'  &&
>               ref($arg) ne 'SCALAR') {
>       die "Data structure must be passed as a reference.\n";
>    } 

Hmmm... why not just !ref($arg) you need to re-check for un-handled
reference types again later so there's no need to enumerate all
handled types here.
 
Actually I think the whole check is probably better removed - I can't
see it does anything usefull.  If you want to ensure that traverse()
is only passed a single argument then a prototype would be simpler.

>    ## Handle references to a reference 
>
>    if (ref($arg) eq 'REF') {
>      ## Try hash
>       eval { %$arg; };
>       traverse(%$arg) if (!$@);

That can never do anyting.  We know ref($arg) is 'REF' so $@ will
always be 'Not a HASH reference' 

You meant

       eval { %$$arg; };
       traverse(\%$$arg) if (!$@);

Or more simply

       traverse($$arg);

Which, like I said is just like treating 'REF' like scalar.

>    elsif (ref($arg) eq 'SCALAR') {
>      if (ref($$arg) eq 'HASH'   ||
>          ref($$arg) eq 'ARRAY'  ||
>          ref($$arg) eq 'SCALAR' ||
>          ref($$arg) eq 'CODE'   ||
>          ref($$arg) eq 'REF' ) {
>          traverse($$arg);
>      }

This can never do anthing since there's no way the conditions in both
ifs can be met.  (If ref($$arg) is HASH then ref($arg) must be 'REF').

Just make it

   elsif (ref($arg) eq 'REF') {
         traverse($$arg);
   }

>    elsif (ref($arg) eq 'CODE') {
>       if (ref(&$arg()) eq 'HASH'  ||
>           ref(&$arg()) eq 'ARRAY' ||
>           ref(&$arg()) eq 'SCALAR'||
>           ref(&$arg()) eq 'CODE'  ||
>           ref(&$arg()) eq 'REF') {
>          traverse(&$arg);
>       }

Eeek! Why are you calling the subroutine 6 times?  Why not call it
once and store the value?  Why are you calling it with an empry
argument list the first 5 times and with @_ pass-though the last time?

&$arg() is more conventionally written as $arg->()

I think you meant:
   elsif (ref($arg) eq 'CODE') {
          traverse(&$arg->());
   } 

All-in-all, removing redundant or unreachable code, your traverse
function() simplifies to:

sub traverse($) {
    my $arg = shift; 
    if ( !ref $arg ) {
	print "$arg\n";
    } elsif (ref($arg) eq 'HASH') {
	for (%$arg) {
	    traverse($_);
	}
    }
    elsif (ref($arg) eq 'ARRAY') {
	for (@$arg) {
	    traverse($_);
	}
    }
    elsif (ref($arg) eq 'SCALAR' || ref($arg) eq 'REF') {
	traverse($$arg);
    }
    elsif (ref($arg) eq 'CODE') {
	traverse($arg->());
    }
    else {
	warn "EXCEPTION: $arg\n";
    }
}

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


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

Date: 4 Sep 2003 11:17:56 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Artificial intelligence (AI) has been solved
Message-Id: <bj7714$gqb$3@mamenchi.zrz.TU-Berlin.DE>
Keywords: A Programming Language, AI, APL, artificial intelligence

Arthur T. Murray <uj797@victoria.tc.ca> wrote in comp.lang.perl.misc:
> > If it has, why isn't it telling us itself ?

Artificial intelligence rests on the hope that eventually the computer
will do something only humans can do.  Software engineering rests on the
hope that eventually the computer will do something, anything, please?

Anno


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

Date: 4 Sep 2003 02:38:32 -0700
From: fumail@freeuk.com (qanda)
Subject: expression specific search and replace
Message-Id: <62b4710f.0309040138.18238c2b@posting.google.com>

Hi all

I've just started with Perl again and would like some help with the following.
I have files that contain records like the following (I've used comma as the
delimiter but in real life it is octal 177)...

field1,ABC/ab12cd ef34,field3,field4,EFC/ab12cd ef56,field6
field1,XBC/ab12cd ef34,field3,field4,EFC/ab13cd ef56,field6
field1,YBC/ab12cd ef34,field3,field4,EFC/ab13ce ef56,field6

I want to find a pattern such as /C\/w+/ (I belive?) and then replace it
with string_patternNumber.  Each different pattern that is found would be
assigned an incremental number and each pattern would then be replaced by
a text string plus the pattern number.  The pattern can appear any number
of times in a record.

So we could end up with something like ...

field1,ABC/string_1 ef34,field3,field4,EFC/string_1 ef56,field6
field1,XBC/string_1 ef34,field3,field4,EFC/string_2 ef56,field6
field1,YBC/string_1 ef34,field3,field4,EFC/string_3 ef56,field6


My other problem is with modifying ARGV after doing a readdir with grep.
I want to match a subset of several similar file patterns.

aa_b_aba_kdkgh.ext
aa_b_bcb_kdkgh.ext
aab_b_def_kdkgh_ueyd.ext
aa_b_abc_kdkgh.ext
aab_b_abc_kdkgh_kdkdk.ext
aab_b_gag_kdkgh.ext
aab_b_abc_kdkgh.ext
aab_b_abc_kdkgh.ext

so the aa.?_ part is common at the beginning and the _.+\.ext is common at the
end, but I only want aba, def and gag in the middle.

Any help is greatly appreciated.

Thanks.


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

Date: Thu, 4 Sep 2003 10:29:46 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: expression specific search and replace
Message-Id: <bj746q$h4k$1@troll.powertech.no>

qanda <fumail@freeuk.com> wrote:

> Hi all
>
> I've just started with Perl again and would like some help with the
> following. I have files that contain records like the following (I've
> used comma as the delimiter but in real life it is octal 177)...
>
> field1,ABC/ab12cd ef34,field3,field4,EFC/ab12cd ef56,field6
> field1,XBC/ab12cd ef34,field3,field4,EFC/ab13cd ef56,field6
> field1,YBC/ab12cd ef34,field3,field4,EFC/ab13ce ef56,field6
>
> I want to find a pattern such as /C\/w+/ (I belive?) and then replace
> it with string_patternNumber.  Each different pattern that is found
> would be assigned an incremental number and each pattern would then be
> replaced by a text string plus the pattern number.  The pattern can
> appear any number of times in a record.
>
> So we could end up with something like ...
>
> field1,ABC/string_1 ef34,field3,field4,EFC/string_1 ef56,field6
> field1,XBC/string_1 ef34,field3,field4,EFC/string_2 ef56,field6
> field1,YBC/string_1 ef34,field3,field4,EFC/string_3 ef56,field6

                   ^^^
                      I'll assume these are to be incremented also

How about:

    #!/usr/bin/perl

    my $count = 0;
    while ( <DATA> ) {
        $count++;
        s#(?<=C/)\w+#string_$count#g;
        print;
    }

    __DATA__
    field1,ABC/ab12cd ef34,field3,field4,EFC/ab12cd ef56,field6
    field1,XBC/ab12cd ef34,field3,field4,EFC/ab13cd ef56,field6
    field1,YBC/ab12cd ef34,field3,field4,EFC/ab13ce ef56,field6

( Output: 

    field1,ABC/string_1 ef34,field3,field4,EFC/string_1 ef56,field6
    field1,XBC/string_2 ef34,field3,field4,EFC/string_2 ef56,field6
    field1,YBC/string_3 ef34,field3,field4,EFC/string_3 ef56,field6
)


> My other problem is with modifying ARGV after doing a readdir with grep.
> I want to match a subset of several similar file patterns.
>
> aa_b_aba_kdkgh.ext
> aa_b_bcb_kdkgh.ext
> aab_b_def_kdkgh_ueyd.ext
> aa_b_abc_kdkgh.ext
> aab_b_abc_kdkgh_kdkdk.ext
> aab_b_gag_kdkgh.ext
> aab_b_abc_kdkgh.ext
> aab_b_abc_kdkgh.ext
>
> so the aa.?_ part is common at the beginning and the _.+\.ext is
> common at the end, but I only want aba, def and gag in the middle.
>
> Any help is greatly appreciated.
>
> Thanks.

This loops over filenames with suffix '.ext' in current directory: 

    foreach ( <*.ext> ) {
        next unless /^aa.?_/;       # skip unless wanted beginning
        ## next unless /_.+\.ext$/; #          ..        end (unneeded)
        print if /_(aba|def|gag)_/; # print if it contains _aba_, ...
    }



Hope this helps,
-- 
Vlad


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

Date: 4 Sep 2003 10:45:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: expression specific search and replace
Message-Id: <bj753j$gqb$1@mamenchi.zrz.TU-Berlin.DE>

qanda <fumail@freeuk.com> wrote in comp.lang.perl.misc:
> Hi all
> 
> I've just started with Perl again and would like some help with the following.
> I have files that contain records like the following (I've used comma as the
> delimiter but in real life it is octal 177)...
> 
> field1,ABC/ab12cd ef34,field3,field4,EFC/ab12cd ef56,field6
> field1,XBC/ab12cd ef34,field3,field4,EFC/ab13cd ef56,field6
> field1,YBC/ab12cd ef34,field3,field4,EFC/ab13ce ef56,field6
> 
> I want to find a pattern such as /C\/w+/ (I belive?) and then replace it
                                                                        ^^
It?  Your example data show the pattern unchanged.  You seem to be
replacing what is between "/" and the following blank.

> with string_patternNumber.  Each different pattern that is found would be
> assigned an incremental number and each pattern would then be replaced by
> a text string plus the pattern number.  The pattern can appear any number
> of times in a record.

Since both the patterns you want to match and the strings you want to
replace vary in your data, it is hard to determine when the count for
what should go up.  I am ignoring your imprecise description and going
with the example.

> So we could end up with something like ...
> 
> field1,ABC/string_1 ef34,field3,field4,EFC/string_1 ef56,field6
> field1,XBC/string_1 ef34,field3,field4,EFC/string_2 ef56,field6
> field1,YBC/string_1 ef34,field3,field4,EFC/string_3 ef56,field6

    my %count;
    while ( <DATA> ) {
        s{(..C/)\w+}{ $count{ $1}++; "$1string_$count{ $1}"}eg;
        print;
    }


> My other problem is with modifying ARGV after doing a readdir with grep.

If you have two independent problems, it's better to start two independent
threads.

[snip]

Anno


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

Date: Thu, 4 Sep 2003 07:26:39 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: expression specific search and replace
Message-Id: <slrnblebrv.611.tadmc@magna.augustmail.com>

qanda <fumail@freeuk.com> wrote:

> I want to find a pattern such as /C\/w+/ (I belive?) and then replace it
> with string_patternNumber.  Each different pattern that is found would be
> assigned an incremental number and each pattern would then be replaced by
> a text string plus the pattern number.  The pattern can appear any number
> of times in a record.


----------------------------------
#!/usr/bin/perl
use strict;
use warnings;

my %seen;
while ( <DATA> ) {
   s#([^,]*C/)\S+# $1 . 'string_' . ++$seen{$1} #ge;
   print;
}


__DATA__
field1,ABC/ab12cd ef34,field3,field4,EFC/ab12cd ef56,field6
field1,XBC/ab12cd ef34,field3,field4,EFC/ab13cd ef56,field6
field1,YBC/ab12cd ef34,field3,field4,EFC/ab13ce ef56,field6
----------------------------------


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


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

Date: 4 Sep 2003 00:37:48 -0700
From: bbass@hotmail.com (boris bass)
Subject: file upload script
Message-Id: <65fcb898.0309032337.27d3a45f@posting.google.com>

the following script

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

#!/usr/local/bin/perl

######use lib $0 =~ m#(.+)[/\\]#;
use CGI qw(:standard);
######use CGI::Carp qw/fatalsToBrowser/;

print header();
print start_html("File Upload Example");
print strong("Version "),$CGI::VERSION,p;

print h1("File Upload Example"),
    '',
    strong(""),
    p,
    '',cite(''),'';

@types = ('count lines','count words','count characters');

# Start a multipart form.
print start_multipart_form(),
    "Enter the file to process:",
    filefield('filename','',45),
    br,
    checkbox_group('count',\@types,\@types),
    p,
    reset,submit('submit','Process File'),
    endform;

# Process the form if there is a file name entered
if ($file = param('filename')) 
  {
    $filename = "Cabbage.gif";
    $UPLOAD_PATH = "";
    $UPLOAD_FILE = $UPLOAD_PATH.$filename;

    print "FILE NAME: $UPLOAD_PATH$filename<br>";
    open (OUTFILE,">$UPLOAD_FILE") or die "Could not open $UPLOAD_FILE
- $!\n";
    binmode(OUTFILE);

    while(read($file,$buffer,1024))
      {
        print OUTFILE $buffer;
      }
   print "Finished - Filname: $filename, Buffer: $buffer<BR><BR>";
   close OUTFILE;

}

print end_html;
                        
---------------------------------

is not working for me; the form is printed ok, but param() does not
return a filename.

what could possibly be wrong?

if somebody could post a script that works for them, it would be
greatly appreciated


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

Date: Thu, 4 Sep 2003 09:51:16 +0100
From: "Bigus" <someone@somewhere.com>
Subject: Re: file upload script
Message-Id: <bj6ue6$spc@newton.cc.rl.ac.uk>


"boris bass" <bbass@hotmail.com> wrote in message
news:65fcb898.0309032337.27d3a45f@posting.google.com...
> the following script
>
> --------------------------
>
> #!/usr/local/bin/perl
>
> ######use lib $0 =~ m#(.+)[/\\]#;
> use CGI qw(:standard);

[..]

> # Process the form if there is a file name entered
> if ($file = param('filename'))

I always thought that you had to use CGI standard to get submitted form
values like this:

use CGI qw(:standard);
$query = new CGI;
if($file = $query->param("filename"));

Bigus




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

Date: Thu, 4 Sep 2003 07:30:30 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Learning Perl (was Re: learning examples)
Message-Id: <slrnblec36.611.tadmc@magna.augustmail.com>

David Oswald <printsplit/!/> wrote:

> a copy of Learning
> Perl, published by O'Rilley & Assoc, written by Tom Christiansen and Randal
> Schwartz. 


Don't get that old 2nd edition, get the newer 3rd edition
by Randal and Tom Phoenix.


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


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

Date: 4 Sep 2003 12:15:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Order of evaluation of expressions
Message-Id: <bj7ace$kha$1@mamenchi.zrz.TU-Berlin.DE>

Mark Jason Dominus <mjd@plover.com> wrote in comp.lang.perl.misc:
> In article <slrnbk10md.srs.abigail@alexandra.abigail.nl>,
> Abigail  <abigail@abigail.nl> wrote:
> >Where is its order of evaluation documented? Where in the documentation
> >does it say that:
> 
> Yes, that's what I would like to know.
> Or, if it doesn't say that, I would like to know that it doesn't.
> 
> Does anyone have any actual facts?
> 
> I wasn't able to find anything about it in the manuals, but the
> manuals are pretty badly organized on basic matters like this, so I'm
> not sure I was looking in the right places.

Like you, I was never able to find a general commitment in the docs.
While Perl documentation is huge, and a moving target, I think it's
safe to say that it is silent about the point.  I mean, *someone*
would have found it by now :)

Only some (few) operators are described individually as having left-right
evaluation order.  Some that come to mind are the short-circuiting boolean
operators, the list- and comma operators (both ","), and (I think)
assignment ("="), though I'm not entirely sure of the latter.

The most consequential conclusion can probably be drawn from the
list operator: it guarantees that function arguments are evaluated
in order.

I know I'm following up late, but I thought I'd add my two cents.

Anno


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

Date: 4 Sep 2003 07:29:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Redirect stdio into a string
Message-Id: <bj6pld$984$1@mamenchi.zrz.TU-Berlin.DE>

Initial-N <neruson_newsletter@yahoo.ca> wrote in comp.lang.perl.misc:
> Hi all,
> 
> How to catch all stdio output into a string?
> I am using system() to call a external tool (exe), with some
> arguments. Just doing so, it will print out all lot of data (which I
> need to process it within the script). I wonder how I can catch all
> the stdio ouput and redirect them into a string so that I can parse
> it.

Read the system() documentation again.

> Thanks everyone!! I would like much appreciate if you can email at
> neruson_newsletter@yahoo.ca

Post here, read here.

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


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