Re: Is there a better way to get current tty name

2008-10-27 Thread Yue Chen
Sorry, I've got the answer. It should be $mytty = POSIX::ttyname(1); 2008/10/28 Yue Chen <[EMAIL PROTECTED]>: > Hi > > I am writing a perl script which need send current tty to another program. > > Now i am using external cmd 'tty' and redirect the result to my > variable, such as: > > $mytty =

Is there a better way to get current tty name

2008-10-27 Thread Yue Chen
Hi I am writing a perl script which need send current tty to another program. Now i am using external cmd 'tty' and redirect the result to my variable, such as: $mytty = `tty`; Since sometimes 'tty' is not in my PATH, my script is not always successful. So is there a better perl internal mecha

RE: Can any one tell me a better way to upload a file from the HTML form to a location in my home directorrt.

2006-04-07 Thread Moon, John
, April 06, 2006 5:45 AM To: beginners@perl.org Subject: Can any one tell me a better way to upload a file from the HTML form to a location in my home directorrt. I tried many ways, Though I am seeing the file. the SIZE IS 0. I tried out these ways First One = my $upload_file= $q

Re: Can any one tell me a better way to upload a file from the HTML form to a location in my home directorrt.

2006-04-06 Thread JupiterHost.Net
Anish Kumar K. wrote: I tried many ways, Though I am seeing the file. the SIZE IS 0. I tried out these ways use the upload() info in CGI.pm's POD, be sure to do it befpre any headers are output :) -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTEC

Re: Can any one tell me a better way to upload a file from the HTML form to a location in my home directorrt.

2006-04-06 Thread Dr.Ruud
Anish Kumar K. schreef: > I tried many ways, Though I am seeing the file. the SIZE IS 0. Maybe this helps: http://perlmeme.org/tutorials/cgi_upload.html -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Can any one tell me a better way to upload a file from the HTML form to a location in my home directorrt.

2006-04-06 Thread Anish Kumar K.
I tried many ways, Though I am seeing the file. the SIZE IS 0. I tried out these ways First One = my $upload_file= $q->param('upload_file'); # This is the description file which is being uploaded if ($upload_file) { my $outfile="/home/anish/testing.doc"; open(OUTFILE,">$outf

Re: A better way.

2005-08-02 Thread Dan Klose
Hi, I have gone for the following code: my %avs_dev = map{ $_ => [mean($hoa{$_}), dev($hoa{$_})] } keys %hoa; for (sort {$avs_dev{$a}[0] <=> $avs_dev{$b}[0]} keys %avs_dev) { print "$_, $avs_dev{$_}[0], $avs_dev{$_}[1]\n"; } I have never used MAP before... it looks handy! Works a treat. Th

Re: A better way.

2005-08-02 Thread Jeff 'japhy' Pinyan
On Aug 2, Dan Klose said: my %hash_of_arrays2; for (keys %hash_of_arrays) { my @array_of_data = exists($hash_of_arrays{$_}) [EMAIL PROTECTED] :(); Given that you're iterating over the list of keys in %hash_of_arrays, there's NO reason to be using exists() here. my @array_of_data

Re: A better way.

2005-08-02 Thread Wiggins d'Anconia
Dan Klose wrote: > Hello Everyone. > > I have the following code: > > > ### CODE BLOCK ### > > my %hash_of_arrays2; > Have you considered a hash of hashes? For me, given the sample below, I would prefer it, but obviously I haven't seen your whole script. > for (keys %hash_of_arrays) { > my

A better way.

2005-08-02 Thread Dan Klose
Hello Everyone. I have the following code: ### CODE BLOCK ### my %hash_of_arrays2; for (keys %hash_of_arrays) { my @array_of_data = exists($hash_of_arrays{$_}) [EMAIL PROTECTED] :(); my $mean = mean([EMAIL PROTECTED]); #GET MEAN my $std_dev = dev([EMAIL PROTECTED]); #GET STAND

Re: HoH is there a better way?

2004-11-10 Thread Richard Kofler
Miguel Santinho wrote: > > On Wed, 10 Nov 2004 00:04:12 -0600 > "Charles K. Clarkson" <[EMAIL PROTECTED]> wrote: > > > my @headers = split ' ', ; > > This way, if tomorrow you have some data like: > > extents nptot > 51671035 > 2223412520365 > > you'll be in troubles, right

RE: HoH is there a better way?

2004-11-10 Thread Charles K. Clarkson
Miguel Santinho (Simplicidade.com) <> wrote: : On Wed, 10 Nov 2004 00:04:12 -0600 : "Charles K. Clarkson" <[EMAIL PROTECTED]> wrote: : : : my @headers = split ' ', ; : : This way, if tomorrow you have some data like: : : extents nptot : 51671035 : 2223412520365 : : you'll b

Re: HoH is there a better way?

2004-11-10 Thread Miguel Santinho (Simplicidade.com)
On Wed, 10 Nov 2004 00:04:12 -0600 "Charles K. Clarkson" <[EMAIL PROTECTED]> wrote: > my @headers = split ' ', ; This way, if tomorrow you have some data like: extents nptot 51671035 2223412520365 you'll be in troubles, right? > my @tables; > while () { > my %table;

Re: HoH is there a better way?

2004-11-10 Thread Richard Kofler
Gunnar Hjalmarsson wrote: > > Gunnar Hjalmarsson wrote: > > You may want to remove the field names from the database, to avoid the > > need to test for them at each iteration. > > Optionally you can extract the field names from the first line of the > database rather than hardcode them: > >

Re: HoH is there a better way?

2004-11-10 Thread Richard Kofler
"Simplicidade.com" wrote: > > Probably this is not better and it's not what you want. > Take it as an alternative ;-) I *need* the table name as key. I am pretty sure, that any handcoded technique of search for the respective table will be considerably slower than picking out an element from a h

RE: HoH is there a better way?

2004-11-09 Thread Charles K. Clarkson
Simplicidade.com <[EMAIL PROTECTED]> wrote: : Probably this is not better and it's not what you want. : Take it as an alternative ;-) : : It's an Array of Hashes. : It gets the column headers from the first row of __DATA__. : When you have fixed length columns 'unpack' is a good choice. : For thi

Re: HoH is there a better way?

2004-11-09 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote: You may want to remove the field names from the database, to avoid the need to test for them at each iteration. Optionally you can extract the field names from the first line of the database rather than hardcode them: sub tabinfo_hash { my @elems = ( split '

Re: HoH is there a better way?

2004-11-09 Thread Gunnar Hjalmarsson
while () { ( my $table, my @vals) = split or next; @{ $tih{$table} }{ @elems } = @vals; last if $. > 10; } \%tih; } And there is one main question left: Is HoH appropriate for what I do, or is HoA a better way to go. A HoH allows for clearer

Re: HoH is there a better way?

2004-11-09 Thread Simplicidade.com
Probably this is not better and it's not what you want. Take it as an alternative ;-) It's an Array of Hashes. It gets the column headers from the first row of __DATA__. When you have fixed length columns 'unpack' is a good choice. For this example I'm not using __END__ at the end of __DATA__ :-)

HoH is there a better way?

2004-11-09 Thread Richard Kofler
c.l.p.m :) I'd apreciate it very much, if someone could hint me into better ways to do it. And there is one main question left: Is HoH appropriate for what I do, or is HoA a better way to go. After all I use this sub very much like a lookup table, much like in the main:: of the code further

Re: Is there a better way to?

2003-10-14 Thread Rob Dixon
Christopher Lyon wrote: > > From: simran [mailto:[EMAIL PROTECTED] > > > > On Tue, 2003-10-14 at 13:59, Christopher Lyon wrote: > > > > > I have a line of text that I want to pull an e-mail address > > > out from. Is this the best way to pull that information from > > > that line? > > > > > > > >

RE: Is there a better way to?

2003-10-13 Thread Christopher Lyon
Cc: [EMAIL PROTECTED] > Subject: Re: Is there a better way to? > > the cpan module: > > http://search.cpan.org/~miyagawa/Email-Find-0.09/lib/Email/Find.pm > > might come in handy... > > > On Tue, 2003-10-14 at 13:59, Christopher Lyon wrote: > > I have a line of

Re: Is there a better way to?

2003-10-13 Thread simran
the cpan module: http://search.cpan.org/~miyagawa/Email-Find-0.09/lib/Email/Find.pm might come in handy... On Tue, 2003-10-14 at 13:59, Christopher Lyon wrote: > I have a line of text that I want to pull an e-mail address out from. Is > this the best way to pull that information from that line

Is there a better way to?

2003-10-13 Thread Christopher Lyon
I have a line of text that I want to pull an e-mail address out from. Is this the best way to pull that information from that line? $user = 'From: "First Last Name" <[EMAIL PROTECTED]>'; @addy = split(/ Also, how do you handle if the email is in brackets like so? $user = 'From: "First Last Na

Re: looking for a better way...

2003-08-14 Thread Pinku Bhatnagar
Hey Jerry, I have a one quick solution for you. str = "\"q4171\",\"(08/11/03 23:30:48)\",\"\""; @array = split(/,/,$str); foreach (@array) { s/\"//g ; } HTH Pinku Jerry Preston wrote: Hi!, I am trying to breakdown this line: "q4171","(08/11/03 23:30:48)","" with ( @data ) = split /[,|\"]/

looking for a better way...

2003-08-14 Thread Jerry Preston
Hi!, I am trying to breakdown this line: "q4171","(08/11/03 23:30:48)","" with ( @data ) = split /[,|\"]/;#" but I get many parts of the array that are empty. All I want is in between the "'s. Thanks, Jerry -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EM

Re: looking for a better way...

2003-08-14 Thread Pinku Bhatnagar
hi Jerry, On second thought, I have a better solution for you. $str = "\"q4171\",\"(08/11/03 23:30:48)\",\"\""; @array = $str =~ /"([^"]*)"/g; HTH Pinku Jerry Preston wrote: Hi!, I am trying to breakdown this line: "q4171","(08/11/03 23:30:48)","" with ( @data ) = split /[,|\"]/;#" but I ge

RE: looking for a better way...

2003-08-14 Thread NYIMI Jose (BMB)
t: Tuesday, August 12, 2003 10:38 AM To: [EMAIL PROTECTED] Subject: looking for a better way... Hi!, I am trying to breakdown this line: "q4171","(08/11/03 23:30:48)","" with ( @data ) = split /[,|\"]/;#" but I get many parts of the ar

Re: looking for a better way...

2003-08-14 Thread Jeff 'japhy' Pinyan
On Aug 12, Jerry Preston said: >I am trying to breakdown this line: > >"q4171","(08/11/03 23:30:48)","" > >with ( @data ) = split /[,|\"]/;#" Either use the Text::CSV module from CPAN (or perhaps Text::CSV_XS), or else use a regex like the following: @fields = $str =~ m{ " [^"]* " | [^,]+ }xg

Re: Is there a better way?

2003-07-23 Thread denis
On Tue, 22 Jul 2003, Rob Dixon wrote: > [EMAIL PROTECTED] wrote: > > I know I'm missing something here, but this code just looks to me > > like I shloud be doing it a better way.. > > > > Any ideas? > > > > > > # -N > > print "N

Re: Is there a better way?

2003-07-22 Thread Rob Dixon
[EMAIL PROTECTED] wrote: > I know I'm missing something here, but this code just looks to me > like I shloud be doing it a better way.. > > Any ideas? > > > # -N > print "Number of Hosts? "; > # get user input and strip off "CR-LF" > chomp($

Re: Is there a better way?

2003-07-22 Thread Jeff 'japhy' Pinyan
On Jul 22, Kevin Pfeiffer said: >In article <[EMAIL PROTECTED]>, >[EMAIL PROTECTED] wrote: > >> >> I know I'm missing something here, but this code just looks to me like I >> shloud be doing it a better way.. >> >> Any ideas? > >my $int

Re: Is there a better way?

2003-07-22 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, Kevin Pfeiffer wrote: [...] > unless ($input =~ /^[^\D]+/ or $input eq '') { While messing around with the valid '' input problem I see I obfuscated the regex. I think this will do just fine: unless ($input =~ /^\d+/ or $input eq '') { -- Kevin Pfeiffer I

Re: Is there a better way?

2003-07-21 Thread Kevin Pfeiffer
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > > I know I'm missing something here, but this code just looks to me like I > shloud be doing it a better way.. > > Any ideas? > > > # -N > print "Number of Hosts? "; >

Is there a better way?

2003-07-21 Thread denis
I know I'm missing something here, but this code just looks to me like I shloud be doing it a better way.. Any ideas? # -N print "Number of Hosts? "; # get user input and strip off "CR-LF" chomp($n=<>); $intel_num_hosts = join (" ", "-N",$n)

Re: A better way

2003-04-03 Thread R. Joseph Newton
Rob Dixon wrote: > > Unless the $target variable was meant simply to decide on a return, it makes more > > sense to assign its value--one task, one line, and check it for validity--another > > task > > entirely, on a line of its own. > > So presumably you're against > > while ( my $line = )

Re: A better way

2003-04-03 Thread Rob Dixon
R. Joseph Newton wrote: > Paul Johnson wrote: > > To my mind, > > return if $target eq "MAIN"; > > at the top of a sub is a lot more helpful than making me search all the > > way down to the botttom to see if there is anything after the conditional. > > > > And it's probably a lot less likely tha

Re: A better way

2003-04-03 Thread R. Joseph Newton
Paul Johnson wrote: > R. Joseph Newton said: > > >The only thing it > > lacked was a meaningful return value. Since the getTarget function > > provided enough information to decide in favor of an early exit, this > > information should proba

Re: A better way

2003-04-03 Thread Paul Johnson
R. Joseph Newton said: >The only thing it > lacked was a meaningful return value. Since the getTarget function > provided enough information to decide in favor of an early exit, this > information should probably be passed on more explicitly

Re: A better way

2003-04-03 Thread R. Joseph Newton
Paul Johnson wrote: > To my mind, > return if $target eq "MAIN"; > at the top of a sub is a lot more helpful than making me search all the > way down to the botttom to see if there is anything after the conditional. > > And it's probably a lot less likely that the next person to edit that sub >

Re: A better way

2003-04-03 Thread R. Joseph Newton
Rob Richardson wrote: > Stefan, > > Personally, I'd prefer: > > if (target ne "MAIN") > { >#do lots of other stuff > } > > I think general programming practice discourages multiple return points > in subroutines. > > RobR I disagree. While one should certainly exercise care when making an ea

Re: A better way

2003-04-03 Thread Rob Dixon
Paul Johnson wrote: > Rob Dixon said: > > "Rob Richardson" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > Stefan, > > > > > > Personally, I'd prefer: > > > > > > if (target ne "MAIN") > > > { > > >#do lots of other stuff > > > } > > > > > > I think general programming pra

Re: A better way

2003-04-03 Thread Paul Johnson
Rob Dixon said: > > "Rob Richardson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Stefan, >> >> Personally, I'd prefer: >> >> if (target ne "MAIN") >> { >>#do lots of other stuff >> } >> >> I think general programming practice discourages multiple return points >> in subro

Re: A better way

2003-04-03 Thread Rob Dixon
Brian Ling wrote: > Thanks for that, I had not released you could effectively use the > getTarget() return value twice :-) > > > well this works: > > return if 'MAIN' eq (my $target = getTarget()); > > > /Stefan Personally, I prefer: ( my $target = getTarget() ) eq 'MAIN' and return; as I b

Re: A better way

2003-04-03 Thread Rob Dixon
"Rob Richardson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Stefan, > > Personally, I'd prefer: > > if (target ne "MAIN") > { >#do lots of other stuff > } > > I think general programming practice discourages multiple return points > in subroutines. Yes, and it's no more dan

RE: A better way

2003-04-03 Thread Brian Ling
Thanks for that, I had not released you could effectively use the getTarget() return value twice :-) >well this works: >return if 'MAIN' eq (my $target = getTarget()); >/Stefan BBCi at http://www.bbc.co.uk/ This e-mail (and any attachments) is confidential and may contain personal views wh

Re: A better way

2003-04-03 Thread Rob Richardson
Stefan, Personally, I'd prefer: if (target ne "MAIN") { #do lots of other stuff } I think general programming practice discourages multiple return points in subroutines. RobR __ Do you Yahoo!? Yahoo! Tax Center - File online, calculators, fo

Re: A better way

2003-04-03 Thread Stefan Lidman
Brian Ling wrote: > > Hi List, > > I have the following bit of code, that works but doesn't feel like the > best way, can anyone think of a better neater answer maybe a one liner? > > my $target = getTarget(); > If ( target eq "MAIN" ) { return } > #do lots of other stuff with value of target w

A better way

2003-04-03 Thread Brian Ling
Hi List, I have the following bit of code, that works but doesn't feel like the best way, can anyone think of a better neater answer maybe a one liner? my $target = getTarget(); If ( target eq "MAIN" ) { return } #do lots of other stuff with value of target Thanks Brian BBCi at http://ww

Re: looking for a better way, a perl way

2003-03-06 Thread John W. Krahn
Jerry Preston wrote: > > Hi! Hello, > I am looking for way to reduce the following code, a better way, a perl > way. Any ideas? > > while ( my ( $Site, $Description, $Part_Number, $Part_Serial_Number, $Qty, > $RMA_Number, $Customer_Contac, $RMA_Date, $Part_R

RE: looking for a better way, a perl way

2003-03-06 Thread Bakken, Luke
Look at the sprintf function. Please! > # while ( $data ) = $sth->fetchrow()) { > $l = length( $Site ); > if( $l != 5 ) { > $s = substr( "", 0, 5 - $l ); > $Site .= $s; > } Does this do what you want? $Site = sprintf '%-5s', $Site; One liner: C:\>perl -e"$S

Re: looking for a better way, a perl way

2003-03-06 Thread Rob Dixon
Hi Jerry. "Jerry Preston" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi! > > I am looking for way to reduce the following code, a better way, a perl > way. Any ideas? I think you've been overlooked a little because your post looks very much

looking for a better way, a perl way

2003-03-05 Thread Jerry Preston
Hi! I am looking for way to reduce the following code, a better way, a perl way. Any ideas? while ( my ( $Site, $Description, $Part_Number, $Part_Serial_Number, $Qty, $RMA_Number, $Customer_Contac, $RMA_Date, $Part_Rec ) = $sth->fetchrow()) { # while ( $data ) = $sth->fetchrow()) {

Re: A better way, a perl way?

2003-01-23 Thread Jeff 'japhy' Pinyan
On Jan 22, david said: >> @data_ = map { (my $copy = $_) =~ s/^ //; $copy } @data; > >s/^ // for(@data_ = @data); Sigh. I usually do that. I was a little slow on the idiom-uptake. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http:

Re: A better way, a perl way?

2003-01-22 Thread david
Jeff 'Japhy' Pinyan wrote: > > If you DON'T want that, you'd have to do: > > for (@data) { > (my $copy = $_) =~ s/^ //; > push @data_, $copy; > } > > Or something to that effect. Here's a one-liner: > > @data_ = map { (my $copy = $_) =~ s/^ //; $copy } @data; > a bit shorter:

RE: A better way, a perl way?

2003-01-22 Thread Bob Showalter
Frank Wiles wrote: > .--[ Jerry Preston wrote (2003/01/22 at 11:59:14) ]-- | > | I am looking for a better way, a perl way for the following: | > | foreach ( @data ) ) { > |s/^ //; > |

Re: A better way, a perl way?

2003-01-22 Thread Frank Wiles
.--[ Jerry Preston wrote (2003/01/22 at 11:59:14) ]-- | | I am looking for a better way, a perl way for the following: | | foreach ( @data ) ) { |s/^ //; |$data_[ $jp++ ] = $_; | } | `- I&#

Re: A better way, a perl way?

2003-01-22 Thread Jeff 'japhy' Pinyan
On Jan 22, Jerry Preston said: >I am looking for a better way, a perl way for the following: > >foreach ( @data ) ) { > s/^ //; > $data_[ $jp++ ] = $_; >} You do realize that you're modifying the elements in @data as well, right? So that, unless $jp sta

A better way, a perl way?

2003-01-22 Thread Jerry Preston
I am looking for a better way, a perl way for the following: foreach ( @data ) ) { s/^ //; $data_[ $jp++ ] = $_; } I have seen a one liner using while, but I do not remember. Thanks, Jerry

Re: A better way to handle array index?

2002-10-21 Thread Jenda Krynicky
From: chris <[EMAIL PROTECTED]> > I am looking for a less cryptic way to handle array index. > > most cryptic > $array[0] > > better > use constant NAME => 0; > $array[NAME] This all depends on what do you want to do with the data structure. But most probably you do want to use a hash.

RE: A better way to handle array index?

2002-10-21 Thread Jenda Krynicky
From: "Johnstone, Colin" <[EMAIL PROTECTED]> > for example I read my form variables into a hash for processing. > > I then reference them by the form fieldname. > > #read STDIN, $PostData, $ENV{'CONTENT_LENGTH'}; > > #print "post data =$PostData"; > > #postdata will look like this > #[EMAIL P

RE: A better way to handle array index?

2002-10-20 Thread Timothy Johnson
And if you're really stuck with using arrays, you can always: my @bases = (); my $first = 0; $bases[$first] = 'who'; -Original Message- From: Johnstone, Colin To: 'chris' Cc: '[EMAIL PROTECTED]' Sent: 10/19/02 5:47 PM Subject: RE: A better way to h

RE: A better way to handle array index?

2002-10-19 Thread Johnstone, Colin
ot;; -----Original Message- From: chris [mailto:chris@;home.com] Sent: Sunday, October 20, 2002 10:40 To: [EMAIL PROTECTED] Subject: A better way to handle array index? I am looking for a less cryptic way to handle array index. most cryptic $array[0] better use constant NAME => 0; $array[NA

A better way to handle array index?

2002-10-19 Thread chris
I am looking for a less cryptic way to handle array index. most cryptic $array[0] better use constant NAME => 0; $array[NAME] Any ideas? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: a better way?

2002-09-26 Thread Jeff 'japhy' Pinyan
On Sep 26, Jerry Preston said: >I guess it an old 'c' habit. I do this to check each line for the item I am >looking for. > >I there a better way and why? my $found = 0;# have we found 'jeff'? while () { # reads ONE LINE at a time, and stores it in $_

RE: a better way?

2002-09-26 Thread Nikola Janceski
From: Jerry Preston [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 26, 2002 11:51 AM > To: [EMAIL PROTECTED] > Cc: Beginners Perl > Subject: RE: a better way? > > > Jeff, > > I guess it an old 'c' habit. I do this to check each line > for the ite

RE: a better way?

2002-09-26 Thread Jerry Preston
Jeff, I guess it an old 'c' habit. I do this to check each line for the item I am looking for. I there a better way and why? Thanks, Jerry -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Thursday, September 26, 2002 10:36 AM

RE: a better way?

2002-09-26 Thread Nikola Janceski
:[EMAIL PROTECTED]] > Sent: Thursday, September 26, 2002 11:36 AM > To: Jerry Preston > Cc: Beginners Perl > Subject: Re: a better way? > > > but why do you need the file in an array? > ---

Re: a better way?

2002-09-26 Thread Jeff 'japhy' Pinyan
On Sep 26, Jerry Preston said: >Is there a better way? A Perl way? > > $j = 0; > while( ) { >chomp; >( $lots[ $j++ ] ) = $_; That's usually written as push @lots, $_; > } Well, you could do: chomp(@lines = ); but why do you need the file in

RE: a better way?

2002-09-26 Thread Nikola Janceski
open(FILE, "yourfile") or die "$!"; chomp(my(@lots) = ); close FILE; > -Original Message- > From: Jerry Preston [mailto:[EMAIL PROTECTED]] > Sent: Thursday, September 26, 2002 11:30 AM > To: Beginners Perl > Subject: a better way? > > >

a better way?

2002-09-26 Thread Jerry Preston
Hi! Is there a better way? A Perl way? $j = 0; while( ) { chomp; ( $lots[ $j++ ] ) = $_; } ? @lots = ; Thanks, Jerry

Re: A better way to list variable names in report format?

2002-09-12 Thread chris
Thank you. Now I can quit the horizontal scrolling. On Wed, 11 Sep 2002 20:52:59 -0400, [EMAIL PROTECTED] (Bob Showalter) wrote: > >I know beans about formats, but perldoc perlform contains this statement: > >"The expressions may be spread out to more than one line if enclosed in >braces. If so,

Re: A better way to list variable names in report format?

2002-09-11 Thread chris
Oops. $$ @$myStuff{qw/column1 column2 column3/}; is definitely an improvement but my list is very long. I think I will have to assign new variables just to make the listing in multiple lines. Horizontal scrolling to read off-page code is not nice. On Wed, 11 Sep 2002 16:42:10 -0700, [EM

Re: A better way for seeding an annoymous hash

2002-08-08 Thread Peter Scott
At 11:44 AM 8/8/02 -0700, drieux wrote: >On Thursday, August 8, 2002, at 11:04 , Peter Scott wrote: > >>At 10:38 AM 8/8/02 -0700, drieux wrote: >>>I'm not sure the average normal person would feel at home with say: >>> >>> %{$by_os{$os_key}}->{$_}++ for(@$found); >> >>Especially since it'

Re: Gotta be a better way: File Compares

2001-10-24 Thread Jeff 'japhy' Pinyan
On Oct 24, Kingsbury, Michael said: >compiling xyz >"a: warning" >"b: warning" >compiling more stuff. >"a: warning" > >I want to get one instance of each warning & output it to a file. I can do >that by backticking it through sort, and loading lines that start with a " & >don't match the previou

Gotta be a better way: File Compares

2001-10-24 Thread Kingsbury, Michael
I'm trying to avoid loading this data into arrays & foreaching each one, so I want to see if anyone has an idea for a better way to do this. Part 1. Given the output from compiling xyz, I end up with a log with warnings as such compiling xyz "a: warning" &qu

RE: Is there a better way to do this

2001-09-14 Thread Bradshaw, Brian
TED] Subject: Re: Is there a better way to do this --- MPM <[EMAIL PROTECTED]> wrote: > Look into using the map function. It should leave you with the following > code: > > map {push @arr_DBanswers, $results{$_}} keys %results; > > Scott Scott, Actually, it's usually b

Re: Is there a better way to do this

2001-09-14 Thread Curtis Poe
--- MPM <[EMAIL PROTECTED]> wrote: > Look into using the map function. It should leave you with the following > code: > > map {push @arr_DBanswers, $results{$_}} keys %results; > > Scott Scott, Actually, it's usually bad to use map in void context as returns a lot data, merely to throw it awa

RE: Is there a better way to do this

2001-09-14 Thread Sean Pfister
aw, Brian > Cc: [EMAIL PROTECTED] > Subject: Re: Is there a better way to do this > > > Look into using the map function. It should leave you with the following > code: > > map {push @arr_DBanswers, $results{$_}} keys %results; > > Scott > > > On Wed, 12 Sep 2

Re: Is there a better way to do this

2001-09-14 Thread MPM
rr_DBanswers[$z] = $result{$_}; >$z=$z+1; > } > > Is there a better way to break out the values in a hash list to a single > array? > > I'd be curious to know. Thanks. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Is there a better way to do this

2001-09-13 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 13, Bradshaw, Brian said: >while (%result = $finalSet->fetchhash()) >{ > push @arr_DBanswers, values %result; >} That code looks fine. You might want to use 'my' on the %result hash, since you don't need it existing later. while (my %result = $finalSet->fetchhash()) { push @arr_

RE: Is there a better way to do this

2001-09-13 Thread Bradshaw, Brian
esn;t help much with the array stuff. brian -Original Message- From: Jason Tiller [mailto:[EMAIL PROTECTED]] Sent: Wednesday, September 12, 2001 9:04 PM To: [EMAIL PROTECTED] Subject: Re: Is there a better way to do this Hi, Again, Brian, :) On Wed, 12 Sep 2001, Bradshaw, Brian wrote:

Re: Is there a better way to do this

2001-09-12 Thread Jason Tiller
Hi, Again, Brian, :) On Wed, 12 Sep 2001, Bradshaw, Brian wrote: > I have the code: > $z = 0; > foreach(@key = keys(%result)) > { >$arr_DBanswers[$z] = $result{$_}; >$z=$z+1; > } > Is there a better way to break out the values in a hash list to a &g

Is there a better way to do this

2001-09-12 Thread Bradshaw, Brian
Another question for the list, I have the code: $z = 0; foreach(@key = keys(%result)) { $arr_DBanswers[$z] = $result{$_}; $z=$z+1; } Is there a better way to break out the values in a hash list to a single array? I'd be curious to know. Thanks. -- To unsubscribe, e

RE: Re[2]: A better way?

2001-06-26 Thread Stephen Nelson
utput: empty list BUT IT ISN'T. You get: Output: ab Output: empty list I find this a good reason to avoid the & syntax, or to at least always use parens. > -Original Message- > From: Jos I. Boumans [mailto:[EMAIL PROTECTED]] > Sent: Saturday, June 23, 2001 2:33 AM &

Re: Re[2]: A better way?

2001-06-23 Thread Jos I. Boumans
Ehm, you cant *just* use & and expect all to stay the same... concider the following: if you use a & you dont need to predeclare a sub if you want to leave of the parenthesis for an argument list: ie: &foo#calls sub foo with no arguments foo #calls sub foo with no arguments IF y

Re[2]: A better way?

2001-06-22 Thread iansmith
On Fri, 22 Jun 2001, Tim Musson wrote: > I am using the most recent from ActiveState, but I tend to stick the & > out there so I can tell at a glance that I am calling a sub. Does it > cause problems or is it just not needed? It doesn't cause any problems that I am aware of. Go ahead and use it

Re[2]: A better way?

2001-06-22 Thread Tim Musson
Hey Paul, Friday, June 22, 2001, 10:14:28 PM, you wrote: >> if ($Var eq "String") { &Sub($Var1); } elsif ($Var2 =~ >> /$STRING/) { &Sub($Var1); } >> >> Is this a better way? >> >> if (($Var eq "String") || ($Var2 =

Re[2]: A better way?

2001-06-22 Thread Tim Musson
Hey iansmith, Friday, June 22, 2001, 10:15:49 PM, you wrote: >> &Sub($Var1); } snip i> You can also leave off the & if you are using Perl 5. I am using the most recent from ActiveState, but I tend to stick the & out there so I can tell at a glance that I am calling a sub. Does it cause p

Re: A better way?

2001-06-22 Thread iansmith
On Fri, 22 Jun 2001, Tim Musson wrote: > Is this a better way? > > if (($Var eq "String") || ($Var2 =~ /$STRING/)) { > &Sub($Var1); > } I usually write... if ($Var eq "String" or $Var2 =~ /$STRING/) { ...as I like the diffrent precidence of the &#x

Re: A better way?

2001-06-22 Thread Paul
--- Tim Musson <[EMAIL PROTECTED]> wrote: > Hey all, > > I have this code fragment. > > if ($Var eq "String") { > &Sub($Var1); > } elsif ($Var2 =~ /$STRING/) { > &Sub($Var1); > } > > Is this a better way? > > if

A better way?

2001-06-22 Thread Tim Musson
Hey all, I have this code fragment. if ($Var eq "String") { &Sub($Var1); } elsif ($Var2 =~ /$STRING/) { &Sub($Var1); } Is this a better way? if (($Var eq "String") || ($Var2 =~ /$STRING/)) { &Sub($Var1); } -- [EMAIL PROTECTED] Using The Bat!