who can help me figure out some PERL script? - GM Forum - Buick, Cadillac, Chev, Olds, GMC & Pontiac chat


Lounge For casual talk about things unrelated to General Motors. In other words, off-topic stuff. And anything else that does not fit Section Description.

Reply
 
 
 
Thread Tools Search this Thread
Old 11-07-2007, 10:50 PM   #1
Darrel
Guest
 
Posts: n/a
Default who can help me figure out some PERL script?

I have to run this code and print out the results for class but i can't figure out what the heck it does! when i run it i do'ntn know what to do with it to make it "show" anything. anyonne have any ideas?

Quote:
#! /usr/bin/perl -w

$in = "";
print "Enter a key/value pair separated by a colon
(quit to finish)\t";
$in = <STDIN>;
chomp $in;

while($in ne "quit") {
($key, $val) = split(/:/, $in);
$myhash{$key} = $val;
print "Enter a key/value pair separated by a colon
(quit to finish)\t";
$in = <STDIN>;
chomp $in;
}

$cnt = 0;
foreach $temp (sort keys %myhash) {
$keyarray[$cnt] = $temp;
$valarray[$cnt++] = $myhash{$temp};
}

while($cnt > 0) {
$t = pop(@keyarray);
$tt = pop(@valarray);
print("Key: $t Value: $tt\n");
$cnt--;
}

exit(0);
  Reply With Quote
Old 11-07-2007, 11:11 PM   #2
Senior Member
True Car Nut
 
Join Date: Sep 2006
Location: Somewhere south of Ottawa with your girlfriend driving faster then you.
Posts: 3,277
Thanks: 0
Thanked 0 Times in 0 Posts
ReallyAGXP is on a distinguished road
Default

remove the -w.
ReallyAGXP is offline   Reply With Quote
Old 11-07-2007, 11:12 PM   #3
Darrel
Guest
 
Posts: n/a
Default

what does the -w do?

i'm really a rookie here... I know about as much as a half arse web programing book can teach in about 20 pages...
  Reply With Quote
Old 11-07-2007, 11:15 PM   #4
Senior Member
True Car Nut
 
Join Date: Sep 2006
Location: Somewhere south of Ottawa with your girlfriend driving faster then you.
Posts: 3,277
Thanks: 0
Thanked 0 Times in 0 Posts
ReallyAGXP is on a distinguished road
Default

what line are you getting an error on or are you getting an error
ReallyAGXP is offline   Reply With Quote
Old 11-07-2007, 11:16 PM   #5
Darrel
Guest
 
Posts: n/a
Default

no error really, i just am not getting a printout of anything. It should be working code because its directly from the book. im just not sure if i'm running it correctly
  Reply With Quote
Old 11-07-2007, 11:17 PM   #6
Senior Member
True Car Nut
 
Join Date: Sep 2006
Location: Somewhere south of Ottawa with your girlfriend driving faster then you.
Posts: 3,277
Thanks: 0
Thanked 0 Times in 0 Posts
ReallyAGXP is on a distinguished road
Default

what are you running it in ?
ReallyAGXP is offline   Reply With Quote
Old 11-07-2007, 11:20 PM   #7
Darrel
Guest
 
Posts: n/a
Default



I was running it though notepad++ and when i would give the "quit" command so i could see my printout it would just close the screen.

i went into the cmd prompt and ran it that way and what do ya know... it does work.


I have a bit to learn here...

on another note, can you print what you see in the command prompt window? i'm just looking for the best way to turn in the printout of what the code displays. all i can think of is a good ole screen shot.
  Reply With Quote
Old 11-07-2007, 11:24 PM   #8
Senior Member
True Car Nut
 
Join Date: Sep 2006
Location: Somewhere south of Ottawa with your girlfriend driving faster then you.
Posts: 3,277
Thanks: 0
Thanked 0 Times in 0 Posts
ReallyAGXP is on a distinguished road
Default

yup that would work.
ReallyAGXP is offline   Reply With Quote
Old 11-07-2007, 11:25 PM   #9
Darrel
Guest
 
Posts: n/a
Default

cool. thanks fer your help
  Reply With Quote
Old 11-07-2007, 11:55 PM   #10
Senior Member
Posts like a Camaro
 
Join Date: Nov 2002
Posts: 1,109
Thanks: 0
Thanked 0 Times in 0 Posts
1995BvSSE is on a distinguished road
Default

Quote:
Originally Posted by Darrel


on another note, can you print what you see in the command prompt window? i'm just looking for the best way to turn in the printout of what the code displays. all i can think of is a good ole screen shot.
I'm late to the party as usual. I'm not a Perl guru, but I fight a good fight (Software Engineer).

In any event, as far as printing out what you see in the command window, you can do an "edit, select all" by clicking on the top left corner icon. You can also highlight what you want with the mouse and press enter. After executing one of these actions, you can paste the results into an editor

You can also redirect output from pretty much any program by using the ">" character, and then print the file. For example:

perl myscript.pl >output.txt

Hope that helps.
1995BvSSE is offline   Reply With Quote
 
 
Reply

Related Topics
Thread Thread Starter Forum Replies Last Post
Please help me figure out where to hook up line out converter.... DADillac Audio (and aftermarket electronics) 8 09-25-2008 06:28 PM
java script off? Drifty Lounge 1 08-04-2007 03:59 AM
Can you figure this one out??? SSE14U24ME Lounge 7 04-18-2004 06:10 AM
I HOPE SOMEONE CAN FIGURE THIS OUT bonnie94ssei Everything Electrical & Electronic 9 02-20-2004 05:48 PM
uhhh can someone figure this out? FiReDeViL Lounge 9 08-24-2003 12:39 AM


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -4. The time now is 11:15 PM.


We are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for us to earn fees by linking to Amazon.com and affiliated sites.