我有一个页面,加载后我希望它运行一个perl脚本.这可能与javascript有关吗?我之前从未在网上运行过perl脚本,而且我看到它的唯一方法是链接到它.
<script type="text/javascript">
var places = [];
</script>
<?php
$date = $_POST['orderdate'];
$file = fopen("http://www.spc.noaa.gov/climo/reports/".$date."_rpts_hail.csv", "r");
$content = fgetcsv($file, 1000, ",");
$id = 1;
while (($content = fgetcsv($file, 1000, ",")) !== FALSE) {
/*******************************************************************************************
Values of content
(ignore)****content[0] = Time*******(ignore)
content[1] = Size
(ignore)****content[2] = Location***(ignore)
content[3] = City
content[4] = State
content[5] = Lat
content[6] = Long
content[7] = Comments
*******************************************************************************************/
if ($content !== false) {
?>
<script type="text/javascript">
places.push(new google.maps.LatLng(<?php echo json_encode($content[5]); ?>, <?php echo json_encode($content[6]); ?>));
</script>
<?php …Run Code Online (Sandbox Code Playgroud) 我在perl中有一个数组,其中包含大约200个用于csv文件的索引.它喜欢以下几行:
46.9234784633993,Springwood Drive,Naples,FL
89.7786182217159,W 8th St,Lakeland,FL
Run Code Online (Sandbox Code Playgroud)
我想在第一个逗号之前按那个数字对它们进行排序.我尝试使用只是排序,但有时数字会变成数百和数千,它只是对1中的所有数字进行排序.然后数字排序不喜欢它,因为它们不是数字条目
我试过这个
my @sortedDistances = sort{ $a <=> $b }(@completedDistances);
and
my @sortedDistances = sort(@completedDistances);
Run Code Online (Sandbox Code Playgroud) 我试图用java获取文件的第一行,我不知道为什么它不工作或为什么我得到我得到的错误.这是我第一次在java中尝试过这个.
错误
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 16
at getSum.main(getSum.java:33)
Run Code Online (Sandbox Code Playgroud)
码
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.File;
import java.io.FileNotFoundException;
public class getSum {
public static void main(String[] args) {
File file = new File("path/InputArray.txt");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
String line = null;
try{
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);
while(dis.available() != 0){
line = dis.readLine();
}
}catch (FileNotFoundException e){
e.printStackTrace();
}catch (IOException …Run Code Online (Sandbox Code Playgroud) 我不得不在包含19000个条目的文本文件中读取,重新排列它们,然后将它们放回到csv文件中.问题是某些条目包含逗号,当我输出回csv时,它会在逗号上中断.我输出时有没有办法逃避逗号?