Perl脚本语法问题

[复制链接]
查看11 | 回复2 | 2010-7-20 20:36:06 | 显示全部楼层 |阅读模式

  1. ------------------------------------------------
  2. if (`ps -C audacious2` =~ /audacious2/)
  3. {

  4. # Get current playing song information.

  5. $song_info = `audtool2 --current-song `;

  6. chop $song_info;

  7. $album_info = `audtool2 --current-song-tuple-data album `;

  8. chop $album_info;

  9. $artist_info = `audtool2 --current-song-tuple-data artist `;

  10. chop $artist_info;

  11. $year_info = `audtool2 --current-song-tuple-data year `;

  12. chop $year_info;

  13. $len = `audtool current-song-length`;

  14. $out = `audtool current-song-output-length`;

  15. IRC::command("/me 我现在正在听【".$song_info. "】歌曲,【".$album_info. "】专辑【".$artist_info."】,艺术家,年份【".$year_info."】-[".$out."\x1f/\x1f".$len."]");

  16. }
  17. else {
  18. -----------------------------------
复制代码

上面的IRC的脚本,输出怎么格式上有点出入呢?(我是一个刚开始接触Perl语言的学习者...)
输出
-----------
我现在正在听【友情岁月】歌曲,【伊健 十三】专辑【郑伊健】,艺术家,年份【1997】-[0:02
/3:34
]
----------------
后面那个时间$out和$len 中间那个 “/” 这个符号要怎么打,才能顺利的输出,不会自己空格呢?
感觉是我这个语法肯定不对了!
希望能指点迷津..:))
Thx!
Note:这是Linux下Xchat的脚本,音乐播放器:Audacious!
附图,是输出效果
------------------------------
1楼说的

  1. [".$out."\/".$len."]");
  2. -----------------
复制代码

我用了,怎么输出还是:
---------------
* [--JiaBaoYu 我现在正在听【chance for you】歌曲,【Fuse Of Love】专辑【仓木麻衣】,艺术家,年份【】-[1:40
V3:31
]
--------------------
这个了呢?郁闷了
另外'\'这个叶不管用,是不是这个Xchat 特殊呢?

回复

使用道具 举报

千问 | 2010-7-20 20:36:06 | 显示全部楼层
好好看一下正则就明白了,特殊的字符都可以用\ (转义字符)
回复

使用道具 举报

千问 | 2010-7-20 20:36:06 | 显示全部楼层
[".$out."\x1f/\x1f".$len."]");改成 :[".$out."\/".$len."]");
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行