| |
| |
| |
|
Comments:
<0> how can i set the next line as a variable after the line i found ? <1> zeeee, where are you getting the lines? <2> txt file <2> i got 1 line with xxx in it for example <2> and want to set the line after it as var <1> so how are you pulling the text file into your program? <2> open (blah, "$file") <1> are you using a while loop or @text = <FILE>; ? <2> yes <1> which? <2> $infile = <IN>; @lines = $infile->as_string; <1> ok, so $line[$num] is the line you found, the next one is $num + 1 <2> i need the how to set it as separate variable part <1> $newvar = $line[$_+1]
<2> thanks :) <1> $num = $_ + 1; $newvar = $line[$num]; might work better <1> yw <3> I am aware of the format for printing multiple lines to STDOUT, ie. print <<EOF (...) EOF, what would be the printf equivalent? (replacing items within the text ie printf("hello %s", "world"); ). Searching google for "<<" doesn't work and I can't think of its name. Thanks. <4> perl rocks <5> hey guys, what does this mean? http://pastebin.com/538639 <6> you're in strict mode and the variable wasn't declared with 'my' in the local scope <5> mm <5> http://pastebin.com/538671 <5> thats my code <6> line 223 <6> You're using $host as a string, but it's defined as an array <6> They're all the same kind of errors <5> damn <5> damn perl :P <6> you're the using struct :P <6> >one< <5> i didnt write the script. the only part of it i wrote was the Reverse DNS parts <5> i dont get this <5> Global symbol "%host" <5> i dont have %host ANYWHERE in that file <6> $host{$id{$vlan}{$portn{$vlan}{$mac}}}; <5> yeah <5> That doesnt have %host <6> a hash's index is specified with a $ sign <6> %bla = (); $bla{'yadda'} = "something"; <6> same with an array. @bla = (); push(@bla, "hello"); print $bla[0] . "\n"; <5> its complaining about these two lines now <5> my $thehost = $host{$if{$vlan}{$portn{$vlan}{$mac}}}; <5> $thehost = "" if not defined($host); <5> okay now its just bitching about the first one <5> http://pastebin.com/538688 Thats what I have now <6> what's the error message? <5> Global symbol "%host" requires explicit package name at ./cammer.pl line 224. <6> $host{$if{$vlan}{$portn{$vlan}{$mac}}} <6> hence... <5> 224 is 15 on what i pasted <6> heh <6> my $name = $name{$if{$vlan}{$portn{$vlan}{$mac}}}; <6> ya can't be doing stuff like that <5> whys that <6> you shouldn't do that in php either <6> give yourself a specific data hash to work with <6> then, do my $name = $dataHash{'some index'}; <5> the line above it is my $name = $name{$if{$vlan}{$portn{$vlan}{$mac}}}; <5> and it works just fine <6> trust me <6> you'll make your life a lot easier not doing that kind of thing, in perl or php <6> or any other language <5> okay, wanna rewrite it then? <6> I already did <5> okay show me <6> my $name = $dataHash{'some index'};
<6> you figure out the rest <5> nah <5> I dont have a clue what youre doing <6> my $name = $name{$if{$vlan}{$portn{$vlan}{$mac}}}; <6> that should be <6> [something like...] <6> my $name = $dataHash{'some index'}; <6> put in the proper index and you're good to go <6> think it through <5> my $thehost = $host{$if{$vlan}{$portn{$vlan}{$mac}}}; <5> which is the proper index? <6> this is the index for $host --> $if{$vlan}{$portn{$vlan}{$mac}} <5> I just want to fix the error <5> not rewrite the script <5> why does one work but not the other? <5> makes no sense <6> okay paste the error message <6> @host is an array, you're trying to access that array like a hash ie {index} <5> Global symbol "%host" requires explicit package name at ./cammer.pl line 224. <6> yeah <6> exactly <6> dude <5> k <6> grr <5> so how do i fix that? <6> did you write this? <5> just the part that doesnt work <6> heh <5> :) <5> so how do i fix that? <6> $host{$if{$vlan}{$portn{$vlan}{$mac}}}; <6> is that $if defined anywhere? <6> do you mean $IP ? <6> $ip, rather <5> nope <5> the line above it uses if <6> ahh, hash of interfaces <6> bad naming <5> probably <6> @host is an array of hostnames or IPs <6> so <5> right <6> you can't index $host as if it were a hash(ie. ***ociative array) with a string key <5> k <6> you have to rewrite what you did keeping in mind you can only index @host with a numeric key <5> okay, ill just give up <5> i have no idea how to do this <5> i dont even know if i put the code in the right place <5> for each ip address in the ip array, i want to do a reverse dns lookup, and enter it in the database with its corresponding ip <6> okay <6> so after you've done the lookup, do the insert <5> i do <5> but i need to insert something <5> http://pastebin.com/538721 <5> thats what i have <6> why don't you store the hostname when you find it? ie. inside the ip loop <5> hmm <5> thats probably a good ide <5> a <5> http://www.cathartik.com/crap/work/switches.html <5> thats what the script produces <5> i just wanted to add hostnames to it <2> if ($_ =~ /$find/) { <- this will find the bext line in text, what is the symbol to find current line ? <7> how could i make perl do an: exec("crontab /path/of/script/file.txt"); where it puts in the path of the script
Return to
#perl or Go to some related
logs:
deadmanchattin
#unixer #india #india #kl #india invalid write after block
to refresh a pahe in +PHP
#allnitecafe #kl
|
|